Skip to content

Commit

Permalink
Fix #75, avoid to crash when CDS does not have the phase set properly…
Browse files Browse the repository at this point in the history
…. Set it to 0 by default
  • Loading branch information
Juke34 committed Oct 8, 2022
1 parent b69f8ee commit 975eb31
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions EMBLmyGFF3/modules/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,17 @@ def __init__(self, feature = None, seq = None, accessions = [], transl_table = 1
self.translate = translate
self.transl_table = transl_table
self.uncompressed_log = uncompressed_log

self.type = self._from_gff_feature(feature.type)

# Check phase is not missing for CDS otherwise fix it to avoid crash.
if level == 3 and self.type == "CDS":
if not "phase" in self.feature.qualifiers.keys():
ID=""
if "ID" in self.feature.qualifiers.keys():
ID = "%s" % " ".join(self.feature.qualifiers["ID"])
logging.error('CDS %s does not have any phase! Please check your gff file. EMBLmyGFF3 set it to 0 by default' % ID)
self.feature.qualifiers["phase"]=0

logging.info("-------+------------------------------------------")
logging.info("FEATURE| Name: %s" % self.type)
logging.info("-"*50)
Expand Down Expand Up @@ -316,7 +325,7 @@ def _load_definition(self):
mandatory = True if (qualifier in self.dict_features[self.type]["mandatory"]) else False
self.qualifiers[qualifier] = Qualifier(qualifier, self.dict_qualifiers[qualifier], mandatory = mandatory, legal_dbxref=self.dict_qualifiers["legal_dbxref"]["legal_dbxref"])
else:
msg = ">>%s<< is not a valid EMBL feature type. You can ignore this message if you don't need the feature.\nOtherwise tell me which EMBL feature it corresponds to by adding the information within the json mapping file." % (self.type)
msg = ">>%s<< is not a valid EMBL feature type. You can ignore this message if you don't need the feature.\n Otherwise tell me which EMBL feature it corresponds to by adding the information within the json mapping file." % (self.type)
self.handle_message("error", msg, msg, 1)
self.skip_feature=True
for qualifier in self.dict_qualifiers:
Expand Down

0 comments on commit 975eb31

Please sign in to comment.