-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into annotator-dataproxy-interface
- Loading branch information
Showing
5 changed files
with
120 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import os | ||
import re | ||
|
||
import pytest | ||
|
||
from ga4gh.vrs.dataproxy import create_dataproxy | ||
|
||
|
||
@pytest.mark.parametrize("dp", ["rest_dataproxy", "dataproxy"]) | ||
@pytest.mark.vcr | ||
def test_data_proxies(dp, request): | ||
dataproxy = request.getfixturevalue(dp) | ||
r = dataproxy.get_metadata("NM_000551.3") | ||
assert r["length"] == 4560 | ||
assert "ga4gh:SQ.v_QTc1p-MUYdgrRv4LMT6ByXIOsdw3C_" in r["aliases"] | ||
|
||
r = dataproxy.get_metadata("NC_000013.11") | ||
assert r["length"] == 114364328 | ||
assert "ga4gh:SQ._0wi-qoDrvram155UmcSC-zA5ZK4fpLT" in r["aliases"] | ||
|
||
seq = dataproxy.get_sequence("ga4gh:SQ.v_QTc1p-MUYdgrRv4LMT6ByXIOsdw3C_") | ||
assert seq.startswith("CCTCGCCTCCGTTACAACGGCCTACGGTGCTGGAGGATCCTTCTGCGCAC") | ||
|
||
seq = dataproxy.get_sequence( | ||
"ga4gh:SQ.v_QTc1p-MUYdgrRv4LMT6ByXIOsdw3C_", start=0, end=50 | ||
) | ||
assert seq == "CCTCGCCTCCGTTACAACGGCCTACGGTGCTGGAGGATCCTTCTGCGCAC" | ||
|
||
|
||
def test_data_proxy_configs(): | ||
with pytest.raises( | ||
ValueError, | ||
match=re.escape( | ||
"create_dataproxy scheme must include provider (e.g., `seqrepo+http:...`)" | ||
), | ||
): | ||
create_dataproxy("file:///path/to/seqrepo/root") | ||
|
||
with pytest.raises( | ||
ValueError, | ||
match=re.escape("SeqRepo URI scheme seqrepo+fake-scheme not implemented"), | ||
): | ||
create_dataproxy("seqrepo+fake-scheme://localhost:5000") | ||
|
||
with pytest.raises( | ||
ValueError, match="DataProxy provider fake-dataprovider not implemented" | ||
): | ||
create_dataproxy("fake-dataprovider+http://localhost:5000") | ||
|
||
with pytest.raises( | ||
ValueError, | ||
match="No data proxy URI provided or found in GA4GH_VRS_DATAPROXY_URI", | ||
): | ||
create_dataproxy(None) | ||
|
||
# check that fallback on env var works | ||
os.environ["GA4GH_VRS_DATAPROXY_URI"] = "seqrepo+:tests/data/seqrepo/latest" | ||
create_dataproxy(None) | ||
|
||
# check that method arg takes precedence by passing an invalid arg | ||
with pytest.raises( | ||
ValueError, | ||
match=re.escape( | ||
"create_dataproxy scheme must include provider (e.g., `seqrepo+http:...`)" | ||
), | ||
): | ||
create_dataproxy("file:///path/to/seqrepo/root") |