From 17a98ceb666178bd645807c21c482540627bb74e Mon Sep 17 00:00:00 2001
From: LauraU123 <laura.urbanska@stud.unibas.ch>
Date: Fri, 28 Oct 2022 10:57:57 +0200
Subject: [PATCH] added script to write gtf output

---
 scripts/writegtf.py | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)
 create mode 100644 scripts/writegtf.py

diff --git a/scripts/writegtf.py b/scripts/writegtf.py
new file mode 100644
index 0000000..426f3f4
--- /dev/null
+++ b/scripts/writegtf.py
@@ -0,0 +1,21 @@
+'''
+This function writes keeps the representative transcripts from the original input file (gtf)
+and writes them to an output.
+(The representative transcripts being listed in a csv file)
+'''
+
+def gtf_representative_transcripts(original_gtf, transcripts):
+    transcript = pd.read_csv(transcripts)
+    representative_transcripts = []
+
+    with open (original_gtf, 'r') as file:
+        for id in transcript['id']:
+            for line in file:
+                if id in line:
+                    representative_transcripts.append(line)
+
+
+    with open ('output.gtf', 'w') as outputfile:
+        outputfile.write(representative_transcripts)
+
+
-- 
GitLab