Skip to content
Snippets Groups Projects
Verified Commit 7a115a1a authored by Laurent Modolo's avatar Laurent Modolo
Browse files

kb: t2g tools work and gz and plain file

parent 6ddf33f5
No related merge requests found
#!/usr/local/bin/python
import os
import re
import gzip
import argparse
......@@ -30,7 +31,7 @@ def get_t2g_line(line, t2g_re):
def write_t2g_line(t2g, line, t2g_re):
results = t2g_line(line, t2g_re)
results = get_t2g_line(line, t2g_re)
if results['transcript_id']:
t2g.write(
t2g_line(
......@@ -51,7 +52,13 @@ if __name__ == "__main__":
args = parser.parse_args()
t2g_re = build_t2g_re()
with open(args.t2g, "r") as gtf:
with open("fix_t2g.txt", "w") as t2g:
for line in gtf:
write_t2g_line(t2g, str(line), t2g_re)
try:
with gzip.open(args.t2g, "rb") as gtf:
with open("fix_t2g.txt", "w") as t2g:
for line in gtf:
write_t2g_line(t2g, str(line), t2g_re)
except gzip.BadGzipFile:
with open(args.t2g, "r") as gtf:
with open("fix_t2g.txt", "w") as t2g:
for line in gtf:
write_t2g_line(t2g, str(line), t2g_re)
......@@ -62,7 +62,14 @@ if __name__ == "__main__":
gene_re = build_gene_re()
transcript_re = build_transcript_re()
with gzip.open(args.gtf, "rb") as gtf:
with open("t2g_dup.txt", "w") as t2g:
for line in gtf:
write_t2g_line(t2g, str(line), transcript_re, gene_re)
\ No newline at end of file
try:
with gzip.open(args.gtf, "rb") as gtf:
with open("t2g_dup.txt", "w") as t2g:
for line in gtf:
write_t2g_line(t2g, str(line), transcript_re, gene_re)
except gzip.BadGzipFile:
with open(args.gtf, "r") as gtf:
with open("t2g_dup.txt", "w") as t2g:
for line in gtf:
write_t2g_line(t2g, str(line), transcript_re, gene_re)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment