annotate cpt_rem_annotes/remove_annotations.py @ 1:b46f0c9a4679 draft

Uploaded
author cpt
date Fri, 20 May 2022 07:30:51 +0000
parents 03d27abd1dfd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
03d27abd1dfd Uploaded
cpt
parents:
diff changeset
1 #!/usr/bin/env python
03d27abd1dfd Uploaded
cpt
parents:
diff changeset
2 import sys
03d27abd1dfd Uploaded
cpt
parents:
diff changeset
3 import argparse
03d27abd1dfd Uploaded
cpt
parents:
diff changeset
4 from CPT_GFFParser import gffParse, gffWrite
03d27abd1dfd Uploaded
cpt
parents:
diff changeset
5
03d27abd1dfd Uploaded
cpt
parents:
diff changeset
6 if __name__ == "__main__":
03d27abd1dfd Uploaded
cpt
parents:
diff changeset
7 parser = argparse.ArgumentParser()
03d27abd1dfd Uploaded
cpt
parents:
diff changeset
8 parser.add_argument("gff3", type=argparse.FileType("r"), help="GFF3 annotations")
03d27abd1dfd Uploaded
cpt
parents:
diff changeset
9 parser.add_argument("--remark", action="store_true", help="Remove remark features")
03d27abd1dfd Uploaded
cpt
parents:
diff changeset
10 parser.add_argument("--region", action="store_true", help="Remove region features")
03d27abd1dfd Uploaded
cpt
parents:
diff changeset
11 args = parser.parse_args()
03d27abd1dfd Uploaded
cpt
parents:
diff changeset
12
03d27abd1dfd Uploaded
cpt
parents:
diff changeset
13 for rec in gffParse(args.gff3):
03d27abd1dfd Uploaded
cpt
parents:
diff changeset
14 rec.annotations = {}
03d27abd1dfd Uploaded
cpt
parents:
diff changeset
15 if args.remark:
03d27abd1dfd Uploaded
cpt
parents:
diff changeset
16 rec.features = [x for x in rec.features if x.type != "remark"]
03d27abd1dfd Uploaded
cpt
parents:
diff changeset
17 if args.region:
03d27abd1dfd Uploaded
cpt
parents:
diff changeset
18 rec.features = [x for x in rec.features if x.type != "region"]
03d27abd1dfd Uploaded
cpt
parents:
diff changeset
19 gffWrite([rec], sys.stdout)