Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle weird xrefs during loading #327

Merged
merged 2 commits into from
Jul 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions machado/loaders/feature.py
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ def store_bio_searchio_hit(self, searchio_hit: Hit, target: str) -> None:
)

for aux_dbxref in searchio_hit.dbxrefs:
aux_db, aux_term = aux_dbxref.split(":")
aux_db, aux_term = aux_dbxref.split(":", 1)
if aux_db == "GO":
try:
term_db = Db.objects.get(name=aux_db.upper())
Expand Down Expand Up @@ -469,7 +469,7 @@ def store_feature_dbxref(self, feature: str, soterm: str, dbxref: str) -> None:
feature_id = retrieve_feature_id(accession=feature, soterm=soterm)

try:
db_name, dbxref_accession = dbxref.split(":")
db_name, dbxref_accession = dbxref.split(":", 1)
except ValueError:
raise ImportingError(
"Incorrect DBxRef {}. It should have two colon-separated values (eg. DB:DBxREF).".format(
Expand Down
4 changes: 2 additions & 2 deletions machado/loaders/featureattributes.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def process_attributes(self, feature_id: int, attrs: Dict[str, str]) -> None:
terms = attrs[key].split(",")
for term in terms:
try:
aux_db, aux_term = term.split(":")
aux_db, aux_term = term.split(":", 1)
term_db = Db.objects.get(name=aux_db.upper())
dbxref = Dbxref.objects.get(db=term_db, accession=aux_term)
cvterm = Cvterm.objects.get(dbxref=dbxref)
Expand All @@ -161,7 +161,7 @@ def process_attributes(self, feature_id: int, attrs: Dict[str, str]) -> None:
for dbxref in dbxrefs:
# It expects just one dbxref formated as XX:012345
try:
aux_db, aux_dbxref = dbxref.split(":")
aux_db, aux_dbxref = dbxref.split(":", 1)
except ValueError as e:
raise ImportingError("{}: {}".format(dbxref, e))
db, created = Db.objects.get_or_create(name=aux_db.upper())
Expand Down