comparison gff3_splitgff.py @ 3:8bd03ba8510a draft

planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
author cpt
date Fri, 28 Apr 2023 01:35:25 +0000
parents
children
comparison
equal deleted inserted replaced
2:e7762a585e3d 3:8bd03ba8510a
1 #!/usr/bin/env python
2 import sys
3 import argparse
4 from Bio import SeqIO
5 from Bio.Seq import Seq
6 from CPT_GFFParser import gffParse, gffWrite
7
8 if __name__ == "__main__":
9 parser = argparse.ArgumentParser(
10 description="Sample script to add an attribute to a feature via web services"
11 )
12 parser.add_argument("data", type=argparse.FileType("r"), help="GFF3 File")
13 parser.add_argument(
14 "--gff",
15 type=argparse.FileType("w"),
16 help="Output Annotations",
17 default="data.gff3",
18 )
19 parser.add_argument(
20 "--fasta",
21 type=argparse.FileType("w"),
22 help="Output Sequence",
23 default="data.fa",
24 )
25 args = parser.parse_args()
26
27 for record in gffParse(args.data):
28 gffWrite([record], args.gff)
29 record.description = ""
30
31 if isinstance(record.seq, str):
32 record.seq = Seq(record.seq)
33
34 SeqIO.write([record], args.fasta, "fasta")
35 sys.exit()