Skip to content

Commit

Permalink
Merge pull request #21 from mboudet/master
Browse files Browse the repository at this point in the history
Decode feature_id when searching in cache.
  • Loading branch information
abretaud authored May 10, 2022
2 parents 9982cb7 + c83db9e commit 3a254e9
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ $ chakin feature load_fasta \
## History
- 2.3.9
- URL decode GFF ids when loading blast/interpro/others
- 2.3.8
- Fix connection closed error when loading big interproscan files
Expand Down
18 changes: 13 additions & 5 deletions chado/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from __future__ import unicode_literals

import re
from urllib.parse import unquote

from chado.exceptions import RecordNotFoundError

Expand Down Expand Up @@ -116,15 +117,22 @@ def _match_feature(self, feature_id, re_name, query_type, organism_id, skip_miss
re_res = re.search(re_name, feature_id)
if re_res:
feature_id = re_res.group(1)
else:
re_res = re.search(re_name, unquote(feature_id))
if re_res:
feature_id = re_res.group(1)

cache_id = (feature_id, organism_id, seqterm)

if cache_id not in self._feature_cache:
if skip_missing:
warn('Could not find feature with name "%s", skipping it', feature_id)
return None
else:
raise RecordNotFoundError('Could not find feature with name "%s"' % feature_id)
# Check after decoding
cache_id = (unquote(feature_id), organism_id, seqterm)
if cache_id not in self._feature_cache:
if skip_missing:
warn('Could not find feature with name "%s", skipping it', feature_id)
return None
else:
raise RecordNotFoundError('Could not find feature with name "%s"' % feature_id)

return self._feature_cache[cache_id]['feature_id']

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name="chado",
version='2.3.8',
version='2.3.9',
description="Chado library",
author="Anthony Bretaudeau",
author_email="[email protected]",
Expand Down

0 comments on commit 3a254e9

Please sign in to comment.