Skip to content

Commit d4a3918

Browse files
committed
revert some things
1 parent 94905c8 commit d4a3918

File tree

9 files changed

+96
-31
lines changed

9 files changed

+96
-31
lines changed

src/anyvlm/anyvar/base_client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ def search_by_interval(
3535
"""Get all variation IDs located within the specified range
3636
3737
:param accession: sequence accession
38-
:param start: start position for genomic region
39-
:param end: end position for genomic region
38+
:param start: Inclusive, inter-residue genomic start position of the interval
39+
to search
40+
:param end: Inclusive, inter-residue genomic end position of the interval to
41+
search
4042
:return: list of matching variant objects
4143
:raise AnyVarClientError: if connection is unsuccessful during search query
4244
"""

src/anyvlm/anyvar/http_client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,10 @@ def search_by_interval(
6565
"""Get all variation IDs located within the specified range
6666
6767
:param accession: sequence accession
68-
:param start: start position for genomic region
69-
:param end: end position for genomic region
68+
:param start: Inclusive, inter-residue genomic start position of the interval
69+
to search
70+
:param end: Inclusive, inter-residue genomic end position of the interval to
71+
search
7072
:return: list of matching variant objects
7173
:raise AnyVarClientError: if connection is unsuccessful during search query
7274
"""

src/anyvlm/anyvar/python_client.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,10 @@ def search_by_interval(
4444
"""Get all variation IDs located within the specified range
4545
4646
:param accession: sequence accession
47-
:param start: start position for genomic region
48-
:param end: end position for genomic region
47+
:param start: Inclusive, inter-residue genomic start position of the interval
48+
to search
49+
:param end: Inclusive, inter-residue genomic end position of the interval to
50+
search
4951
:return: list of matching variant objects
5052
"""
5153
try:

src/anyvlm/functions/get_caf.py

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,36 +7,44 @@
77

88
from anyvlm.anyvar.base_client import BaseAnyVarClient
99
from anyvlm.storage.base_storage import Storage
10+
from anyvlm.utils.types import ChromosomeName, GrcAssemblyId, UcscAssemblyBuild
1011

1112

1213
def get_caf(
13-
anyvar: BaseAnyVarClient,
14+
anyvar_client: BaseAnyVarClient,
1415
anyvlm_storage: Storage,
15-
accession_id: str,
16+
assembly_id: GrcAssemblyId | UcscAssemblyBuild,
17+
chromosome_name: ChromosomeName,
1618
start: int,
1719
end: int,
1820
) -> list[CohortAlleleFrequencyStudyResult]:
19-
"""Retrieve Cohort Allele Frequency data for all known variants matching provided search params
21+
"""Retrieve Cohort Allele Frequency data for all known variants matching provided
22+
search params
2023
21-
:param anyvar: AnyVar client (variant lookup)
24+
:param anyvar_client: AnyVar client (variant lookup)
2225
:param anyvlm_storage: AnyVLM Storage (CAF storage and retrieval)
23-
:param accession_id: ID for sequence to search upon
24-
:param start: start of range search
26+
:param assembly_id: The reference assembly to utilize - must be one of: "GRCh37",
27+
"GRCh38", "hg38", "hg19"
28+
:param chromosome_name: The chromosome to search on, with an optional "chr" prefix
29+
- e.g., "1", "chr22", "X", "chrY", etc.
30+
:param start: Inclusive, inter-residue genomic start position of the interval to
31+
search
32+
:param end: Inclusive, inter-residue genomic end position of the interval to search
2533
:param reference_bases: Genomic bases ('T', 'AC', etc.)
2634
:param alternate_bases: Genomic bases ('T', 'AC', etc.)
2735
:return: list of CAFs contained in search interval
2836
"""
29-
vrs_variations: list[VrsVariation] = anyvar.search_by_interval(
30-
accession_id, start, end
37+
vrs_variations: list[VrsVariation] = anyvar_client.search_by_interval(
38+
f"{assembly_id}:{chromosome_name}", start, end
3139
)
3240
vrs_variations_map: dict[str, Allele] = {
3341
vrs_variation.id: vrs_variation
3442
for vrs_variation in vrs_variations
3543
if vrs_variation.id and isinstance(vrs_variation, Allele)
3644
}
3745

38-
cafs: list[CohortAlleleFrequencyStudyResult] = anyvlm_storage.get_caf_by_vrs_ids(
39-
list(vrs_variations_map)
46+
cafs: list[CohortAlleleFrequencyStudyResult] = (
47+
anyvlm_storage.get_caf_by_vrs_allele_ids(list(vrs_variations_map))
4048
)
4149

4250
for caf in cafs:

src/anyvlm/storage/base_storage.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@ def add_allele_frequencies(self, caf: CohortAlleleFrequencyStudyResult) -> None:
3232
"""
3333

3434
@abstractmethod
35-
def get_caf_by_vrs_ids(
36-
self, vrs_ids: list[str]
35+
def get_caf_by_vrs_allele_ids(
36+
self, vrs_allele_ids: list[str]
3737
) -> list[CohortAlleleFrequencyStudyResult]:
38-
"""Retrieve cohort allele frequency study results by VRS IDs
38+
"""Retrieve cohort allele frequency study results by VRS Allele IDs
3939
40-
:param vrs_ids: List of VRS variation IDs
40+
:param vrs_allele_ids: List of VRS Allele IDs
4141
:return: List of cohort allele frequency study results matching given VRS
42-
variation IDs. Will use iriReference for focusAllele
42+
Allele IDs. Will use iriReference for focusAllele
4343
"""

src/anyvlm/storage/postgres.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ def add_allele_frequencies(self, caf: CohortAlleleFrequencyStudyResult) -> None:
4747
with self.session_factory() as session, session.begin():
4848
session.execute(stmt, db_entity.to_dict())
4949

50-
def get_caf_by_vrs_ids(
50+
def get_caf_by_vrs_allele_ids(
5151
self, vrs_ids: list[str]
5252
) -> list[CohortAlleleFrequencyStudyResult]:
53-
"""Retrieve cohort allele frequency study results by VRS IDs
53+
"""Retrieve cohort allele frequency study results by VRS Allele IDs
5454
55-
:param vrs_ids: List of VRS variation IDs
55+
:param vrs_allele_ids: List of VRS Allele IDs
5656
:return: List of cohort allele frequency study results matching given VRS
57-
variation IDs. Will use iriReference for focusAllele
57+
Allele IDs. Will use iriReference for focusAllele
5858
"""
5959
cafs: list[CohortAlleleFrequencyStudyResult] = []
6060
with self.session_factory() as session:

tests/integration/functions/cassettes/test_get_caf/test_get_caf_no_results.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,25 @@ interactions:
1111
status:
1212
code: 404
1313
message: NOT FOUND
14+
- request:
15+
body: null
16+
headers: {}
17+
method: GET
18+
uri: http://localhost:5000/seqrepo/1/metadata/GRCh37:Y
19+
response:
20+
body:
21+
string: "{\n \"added\": \"2016-08-24T09:46:03Z\",\n \"aliases\": [\n \"GRCh37:Y\",\n
22+
\ \"GRCh37:chrY\",\n \"GRCh37.p10:Y\",\n \"GRCh37.p10:chrY\",\n \"GRCh37.p11:Y\",\n
23+
\ \"GRCh37.p11:chrY\",\n \"GRCh37.p12:Y\",\n \"GRCh37.p12:chrY\",\n
24+
\ \"GRCh37.p13:Y\",\n \"GRCh37.p13:chrY\",\n \"GRCh37.p2:Y\",\n \"GRCh37.p2:chrY\",\n
25+
\ \"GRCh37.p5:Y\",\n \"GRCh37.p5:chrY\",\n \"GRCh37.p9:Y\",\n \"GRCh37.p9:chrY\",\n
26+
\ \"MD5:1e86411d73e6f00a10590f976be01623\",\n \"NCBI:NC_000024.9\",\n
27+
\ \"refseq:NC_000024.9\",\n \"SEGUID:HRECPk8NXaTlO3q9aTwyJC10bpw\",\n
28+
\ \"SHA1:1d11023e4f0d5da4e53b7abd693c32242d746e9c\",\n \"VMC:GS_BT7QyW5iXaX_1PSX-msSGYsqRdMKqkj-\",\n
29+
\ \"sha512t24u:BT7QyW5iXaX_1PSX-msSGYsqRdMKqkj-\",\n \"ga4gh:SQ.BT7QyW5iXaX_1PSX-msSGYsqRdMKqkj-\"\n
30+
\ ],\n \"alphabet\": \"ACGNT\",\n \"length\": 59373566\n}\n"
31+
headers: {}
32+
status:
33+
code: 200
34+
message: OK
1435
version: 1
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
interactions:
2+
- request:
3+
body: null
4+
headers: {}
5+
method: GET
6+
uri: http://localhost:5000/seqrepo/1/metadata/GRCh38:chrY
7+
response:
8+
body:
9+
string: "{\n \"added\": \"2016-08-27T23:57:42Z\",\n \"aliases\": [\n \"GRCh38:Y\",\n
10+
\ \"GRCh38:chrY\",\n \"GRCh38.p1:Y\",\n \"GRCh38.p1:chrY\",\n \"GRCh38.p10:Y\",\n
11+
\ \"GRCh38.p10:chrY\",\n \"GRCh38.p11:Y\",\n \"GRCh38.p11:chrY\",\n
12+
\ \"GRCh38.p12:Y\",\n \"GRCh38.p12:chrY\",\n \"GRCh38.p2:Y\",\n \"GRCh38.p2:chrY\",\n
13+
\ \"GRCh38.p3:Y\",\n \"GRCh38.p3:chrY\",\n \"GRCh38.p4:Y\",\n \"GRCh38.p4:chrY\",\n
14+
\ \"GRCh38.p5:Y\",\n \"GRCh38.p5:chrY\",\n \"GRCh38.p6:Y\",\n \"GRCh38.p6:chrY\",\n
15+
\ \"GRCh38.p7:Y\",\n \"GRCh38.p7:chrY\",\n \"GRCh38.p8:Y\",\n \"GRCh38.p8:chrY\",\n
16+
\ \"GRCh38.p9:Y\",\n \"GRCh38.p9:chrY\",\n \"MD5:447f54a94ef525e42ce58d3e0c48b3f8\",\n
17+
\ \"NCBI:NC_000024.10\",\n \"refseq:NC_000024.10\",\n \"SEGUID:Aa5HItLyfT0VRdz6r0SjqaidoCQ\",\n
18+
\ \"SHA1:01ae4722d2f27d3d1545dcfaaf44a3a9a89da024\",\n \"VMC:GS_8_liLu1aycC0tPQPFmUaGXJLDs5SbPZ5\",\n
19+
\ \"sha512t24u:8_liLu1aycC0tPQPFmUaGXJLDs5SbPZ5\",\n \"ga4gh:SQ.8_liLu1aycC0tPQPFmUaGXJLDs5SbPZ5\"\n
20+
\ ],\n \"alphabet\": \"ACGNRSTWY\",\n \"length\": 57227415\n}\n"
21+
headers: {}
22+
status:
23+
code: 200
24+
message: OK
25+
version: 1

tests/integration/functions/test_get_caf.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,23 @@
88
from anyvlm.anyvar.python_client import PythonAnyVarClient
99
from anyvlm.functions.get_caf import get_caf
1010
from anyvlm.storage.postgres import PostgresObjectStore
11+
from anyvlm.utils.types import GrcAssemblyId
1112

1213
POSITION = 2781760
13-
REFGET_AC = "SQ.8_liLu1aycC0tPQPFmUaGXJLDs5SbPZ5"
14-
GA4GH_SEQ_ID = f"ga4gh:{REFGET_AC}"
14+
ASSEMBLY = GrcAssemblyId.GRCH38
15+
CHROMOSOME = "chrY"
16+
CHROMOSOME_IDENTIFIER = f"{ASSEMBLY}:{CHROMOSOME}"
17+
GA4GH_SEQ_ID = f"ga4gh:{CHROMOSOME_IDENTIFIER}"
1518

1619

1720
@pytest.fixture
1821
def alleles_to_add(alleles: dict):
19-
"""Create test fixture for alleles whose sequence reference matches REFGET_AC"""
22+
"""Create test fixture for alleles whose sequence reference matches CHROMOSOME_IDENTIFIER"""
2023
return [
2124
value["variation"]
2225
for value in alleles.values()
2326
if value["variation"]["location"]["sequenceReference"]["refgetAccession"]
24-
== REFGET_AC
27+
== CHROMOSOME_IDENTIFIER
2528
]
2629

2730

@@ -70,7 +73,8 @@ def test_get_caf_results_returned(
7073
cafs = get_caf(
7174
anyvar_populated_python_client,
7275
populated_postgres_storage,
73-
GA4GH_SEQ_ID,
76+
ASSEMBLY,
77+
CHROMOSOME,
7478
POSITION,
7579
POSITION,
7680
)
@@ -91,7 +95,8 @@ def test_get_caf_no_results(
9195
cafs = get_caf(
9296
anyvar_populated_python_client,
9397
populated_postgres_storage,
94-
"GRCh45.p1:Y",
98+
GrcAssemblyId.GRCH37,
99+
"Y",
95100
POSITION,
96101
POSITION,
97102
)

0 commit comments

Comments
 (0)