Skip to content
Open
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
2 changes: 1 addition & 1 deletion gen3/external/nih/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
# For more details about this regex, see the function that uses it
DBGAP_ACCESSION_REGEX = (
"(?P<phsid>phs(?P<phsid_number>[0-9]+))"
"(.(?P<participant_set>p(?P<participant_set_number>[0-9]+))){0,1}"
"(.(?P<version>v(?P<version_number>[0-9]+))){0,1}"
"(.(?P<participant_set>p(?P<participant_set_number>[0-9]+))){0,1}"
Comment thread
WilsonnnTan marked this conversation as resolved.
"(.(?P<consent>c(?P<consent_number>[0-9]+)+)){0,1}"
)

Expand Down
66 changes: 66 additions & 0 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import pytest

from gen3.external.nih.utils import get_dbgap_accession_as_parts


@pytest.mark.parametrize("test_input, expected", [
(
'phs000123',
{
'phsid': 'phs000123',
'phsid_number': '000123',
'version': '',
'version_number': '',
'participant_set': '',
'participant_set_number': '',
'consent': '',
'consent_number': ''
}
),
(
'phs000123.p1.c3',
{
'phsid': 'phs000123',
'phsid_number': '000123',
'version': '',
'version_number': '',
'participant_set': 'p1',
'participant_set_number': '1',
'consent': 'c3',
'consent_number': '3'
}
),
(
'phs000123.v3.c3',
{
'phsid': 'phs000123',
'phsid_number': '000123',
'version': 'v3',
'version_number': '3',
'participant_set': '',
'participant_set_number': '',
'consent': 'c3',
'consent_number': '3'
}
),
(
'phs000123.v3.p1.c3',
{
'phsid': 'phs000123',
'phsid_number': '000123',
'version': 'v3',
'version_number': '3',
'participant_set': 'p1',
'participant_set_number': '1',
'consent': 'c3',
'consent_number': '3'
}
),

])
def test_get_dbgap_accession_as_parts(test_input, expected):
"""
Test dbgap accession parsing works and outputs expected fields and values.
"""

assert get_dbgap_accession_as_parts(test_input) == expected