comparison 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
comparison
equal deleted inserted replaced
20:04e57f9ef873 21:211c9b3a5c15
1 1 import argparse
2 import sys
3 import fileinput
2 from Group import Group 4 from Group import Group
3 5
4 class Convertor: 6 def main():
7 parser = argparse.ArgumentParser(description='Get a gff file and the output gff3 file')
8 parser.add_argument('--input', help='input gff file')
9 parser.add_argument('--output', help='output gff3 file', required=True)
10 args = parser.parse_args()
11 input = args.input
12 output = args.output
13 if not sys.stdin.isatty():
14 c = Convertor(sys.stdin, output)
15 else:
16 c = Convertor(input, output)
17 c.convert()
18
19 class Convertor:
5 def __init__(self, input, output): 20 def __init__(self, input, output):
6 with open(input) as self.f: 21 if type(input) is str:
7 self.li = [line.rstrip().split("\t") for line in self.f] 22 with open(input) as self.f:
23 self.li = [line.rstrip().split("\t") for line in self.f]
24 else:
25 self.li = [line.rstrip().split("\t") for line in input]
8 self.gff3 = open(output, "w") 26 self.gff3 = open(output, "w")
9 self.gff3.write("##gff-version 3\n") 27 self.gff3.write("##gff-version 3\n")
10 28
11 def convert(self): 29 def convert(self):
12 index = 0 30 index = 0
33 51
34 52
35 53
36 54
37 if __name__ == "__main__": 55 if __name__ == "__main__":
38 file = Convertor("dbia3.gff", "test.txt") 56 main()
39 file.convert()
40 57
41 58
42 59