Mercurial > repos > cpt_testbed > functionalworkflow
comparison gff3_splitgff.py @ 0:f678e282b320 draft default tip
"planemo upload"
| author | cpt_testbed |
|---|---|
| date | Fri, 06 May 2022 07:07:23 +0000 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:f678e282b320 |
|---|---|
| 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() |
