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

Bugfix/run accession for assembly #372

Merged
merged 2 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
3 changes: 1 addition & 2 deletions emgapianns/management/lib/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,7 @@ def get_run_accession(path):
match = re.search(pattern, path)
if match:
if len(match.groups()) > 0:
end_pos = match.end()
return path[0:end_pos]
return match.groups()[0]
else:
raise Exception("Could not identify run accession from {}".format(path))
else:
Expand Down
9 changes: 9 additions & 0 deletions tests/webuploader/test_import_assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@

from model_bakery import baker

from emgapianns.management.lib.utils import get_run_accession


def bake_models(coverage=None, min_gap_length=None):
"""Build the required models for import_assembly
Expand Down Expand Up @@ -109,3 +111,10 @@ def test_import_assembly_with_cov(self, mock_get_assembly):
assert emg_assembly.is_private == False
assert emg_assembly.wgs_accession == ena_assembly.wgs_accession
assert emg_assembly.legacy_accession == ena_assembly.gc_id

def test_run_accession_getter(self):
assert get_run_accession("ERR1111111") == "ERR1111111"
assert get_run_accession("ERR1111111;ERR1111112") == "ERR1111111" # first only
assert get_run_accession("PREFIX_ERR1111111") == "ERR1111111" # only accession part
assert get_run_accession("ERR1111111_SUFFIX") == "ERR1111111"
assert get_run_accession("NOPE;PREFIX_ERR1111111_SUFFIX;PREFIX_ERR1111112_SUFFIX;ALSONOPE") == "ERR1111111" # complete edge case