view cpt_rem_annotes/remove_annotations.py @ 2:49f50c55a9f8 draft default tip

Uploaded
author cpt
date Fri, 20 May 2022 09:00:53 +0000
parents 03d27abd1dfd
children
line wrap: on
line source

#!/usr/bin/env python
import sys
import argparse
from CPT_GFFParser import gffParse, gffWrite

if __name__ == "__main__":
    parser = argparse.ArgumentParser()
    parser.add_argument("gff3", type=argparse.FileType("r"), help="GFF3 annotations")
    parser.add_argument("--remark", action="store_true", help="Remove remark features")
    parser.add_argument("--region", action="store_true", help="Remove region features")
    args = parser.parse_args()

    for rec in gffParse(args.gff3):
        rec.annotations = {}
        if args.remark:
            rec.features = [x for x in rec.features if x.type != "remark"]
        if args.region:
            rec.features = [x for x in rec.features if x.type != "region"]
        gffWrite([rec], sys.stdout)