Created
April 5, 2018 14:39
-
-
Save SJShaw/d2a7ae2a1ddad2034032b9d2e8ca6782 to your computer and use it in GitHub Desktop.
Strip AS4 annotations from a genbank file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from __future__ import print_function, division | |
import sys | |
from helperlibs.bio import seqio | |
def strip_record(seq_record): | |
new_features = [] | |
for feature in seq_record.features: | |
# Discard features added by antiSMASH | |
if feature.type in ('cluster', 'cluster_border', 'CDS_motif', 'aSDomain', 'PFAM_domain', 'promoter'): | |
continue | |
# clean up antiSMASH annotations in CDS features | |
if feature.type == 'CDS': | |
if 'sec_met' in feature.qualifiers: | |
del feature.qualifiers['sec_met'] | |
if "note" in feature.qualifiers: | |
feature.qualifiers["note"] = [note for note in feature.qualifiers["note"] if not note.startswith("smCOG")] | |
if not feature.qualifiers["note"]: | |
del feature.qualifiers["note"] | |
new_features.append(feature) | |
seq_record.features = new_features | |
def strip_all(filename): | |
record = seqio.read(filename) | |
strip_record(record) | |
seqio.write(record, filename, 'genbank') | |
if __name__ == "__main__": | |
strip_all(sys.argv[1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment