From d099fc1ff81e14d4a751debcdba4c4f2a1e39fda Mon Sep 17 00:00:00 2001 From: Laura Urbanska <laura.urbanska@stud.unibas.ch> Date: Tue, 10 Jan 2023 09:01:12 +0000 Subject: [PATCH] Updated gtf writer file --- scripts/new_gtf_writer.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 scripts/new_gtf_writer.py diff --git a/scripts/new_gtf_writer.py b/scripts/new_gtf_writer.py new file mode 100644 index 0000000..43e7ca6 --- /dev/null +++ b/scripts/new_gtf_writer.py @@ -0,0 +1,20 @@ + +def gtf_file_writer (original_file, output_file): + output = [] + rep_transcript_dict = get_rep_trans(original_file) + + with open(original_file, 'r') as f: + for entry in f: + if entry[0] != '#': + attributes = attributs_converter(entry) + type_ = attributes[2] + if type_ == 'gene': + gene_id = find_in_attributs(attributes, 'gene_id') + output.append(entry) + if type_ != 'gene': + transcript_id = find_in_attributs(attributes, 'transcript_id') + if rep_transcript_dict[gene_id] == transcript_id: + output.append(entry) + + with open(output_file, 'w') as last_file: + last_file.write(output) \ No newline at end of file -- GitLab