Mercurial > repos > cpt > cpt_gff_split
diff gff3_splitgff.py @ 3:8bd03ba8510a draft
planemo upload commit edc74553919d09dcbe27fcadf144612c1ad3a2a2
author | cpt |
---|---|
date | Fri, 28 Apr 2023 01:35:25 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/gff3_splitgff.py Fri Apr 28 01:35:25 2023 +0000 @@ -0,0 +1,35 @@ +#!/usr/bin/env python +import sys +import argparse +from Bio import SeqIO +from Bio.Seq import Seq +from CPT_GFFParser import gffParse, gffWrite + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + description="Sample script to add an attribute to a feature via web services" + ) + parser.add_argument("data", type=argparse.FileType("r"), help="GFF3 File") + parser.add_argument( + "--gff", + type=argparse.FileType("w"), + help="Output Annotations", + default="data.gff3", + ) + parser.add_argument( + "--fasta", + type=argparse.FileType("w"), + help="Output Sequence", + default="data.fa", + ) + args = parser.parse_args() + + for record in gffParse(args.data): + gffWrite([record], args.gff) + record.description = "" + + if isinstance(record.seq, str): + record.seq = Seq(record.seq) + + SeqIO.write([record], args.fasta, "fasta") + sys.exit()