diff gff2Togff3.py @ 21:211c9b3a5c15 draft

planemo upload commit 6e3286c6569d531846474dcd6959378af0317ce3-dirty
author yating-l
date Fri, 12 Aug 2016 18:26:59 -0400
parents a7f57cf408e8
children
line wrap: on
line diff
--- a/gff2Togff3.py	Fri Aug 12 15:01:58 2016 -0400
+++ b/gff2Togff3.py	Fri Aug 12 18:26:59 2016 -0400
@@ -1,10 +1,28 @@
-
+import argparse
+import sys
+import fileinput
 from Group import Group
 
-class Convertor:
+def main():
+        parser = argparse.ArgumentParser(description='Get a gff file and the output gff3 file')
+        parser.add_argument('--input', help='input gff file')
+        parser.add_argument('--output', help='output gff3 file', required=True)
+        args = parser.parse_args()
+        input = args.input
+        output = args.output
+        if not sys.stdin.isatty():
+            c = Convertor(sys.stdin, output)
+        else: 
+            c = Convertor(input, output)
+        c.convert()
+        
+class Convertor:    
     def __init__(self, input, output):
-        with open(input) as self.f:
-            self.li = [line.rstrip().split("\t") for line in self.f]
+        if type(input) is str:
+            with open(input) as self.f:
+                self.li = [line.rstrip().split("\t") for line in self.f]
+        else:
+            self.li = [line.rstrip().split("\t") for line in input]
         self.gff3 = open(output, "w")
         self.gff3.write("##gff-version 3\n")
 
@@ -35,8 +53,7 @@
         
 
 if __name__ == "__main__":
-    file = Convertor("dbia3.gff", "test.txt")
-    file.convert()
+    main()
 
 
     
\ No newline at end of file