Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
korikuzma committed Jan 21, 2025
1 parent 42b4e6c commit e1948ed
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 47 deletions.
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ dependencies = [
"ga4gh.vrs==2.0.0a13",
#"ga4gh.cat_vrs~=0.1.0",
#"ga4gh.va_spec~=0.1.0",
"gene-normalizer[etl]~=0.6.0",
"gene-normalizer[etl]==0.6.0",
"variation-normalizer~=0.12.0",
"disease-normalizer[etl]~=0.7.0",
"thera-py[etl]~=0.7.1",
"disease-normalizer[etl]==0.7.0",
"thera-py[etl]==0.7.1",
"civicpy~=3.1",
"requests",
"pydantic==2.*",
Expand Down
26 changes: 7 additions & 19 deletions src/metakb/transformers/civic.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,12 +248,12 @@ async def transform(self, harvested_data: CivicHarvestedData) -> None:

# Get all variant IDs from supported molecular profiles
vids = {
mp_id_to_v_id_mapping[e["molecular_profile_id"]]
mp_id_to_v_id_mapping.get(e["molecular_profile_id"])
for e in evidence_items
if e["molecular_profile_id"]
}
vids |= {
mp_id_to_v_id_mapping[assertion["molecular_profile_id"]]
mp_id_to_v_id_mapping.get(assertion["molecular_profile_id"])
for assertion in assertions
if assertion["molecular_profile_id"]
}
Expand Down Expand Up @@ -336,6 +336,8 @@ def _add_variant_study_stmt(

if record["amp_level"]:
classification = self._get_classification(record["amp_level"])
if not classification:
return

evidence_lines = []
evidence_ids = []
Expand All @@ -347,14 +349,10 @@ def _add_variant_study_stmt(
evidence_lines.append(
EvidenceLine(
hasEvidenceItems=[evidence_item],
directionOfEvidenceProvided=Direction.SUPPORTS, # TODO: Is this always supports?
directionOfEvidenceProvided=Direction.SUPPORTS,
)
)

# TODO: Figure out how to handle cases where CIViC evidence items can't be processed. Is this what we want?
if evidence_ids:
extensions.append(Extension(name="evidence_ids", value=evidence_ids))

record_type = record[f"{record_prefix}_type"]

# Get predicate
Expand Down Expand Up @@ -472,20 +470,10 @@ def _get_classification(amp_level: str) -> MappableConcept | None:
else:
pattern = re.compile(r"TIER_(?P<tier>[IV]+)(?:_LEVEL_(?P<level>[A-D]))?")
match = pattern.match(amp_level).groupdict()
primary_code = f"{match['tier']}{match['level'] or ''}"
primary_code = f"Tier {match['tier']}"
classification = MappableConcept(
conceptType="Guideline",
primaryCode=primary_code,
mappings=[
ConceptMapping(
relation=Relation.EXACT_MATCH,
coding=Coding(
system="AMP/ASCO/CAP",
systemVersion="2017",
code=code(primary_code),
),
)
],
extensions=[Extension(name="civic_amp_level", value=amp_level)],
)
return classification

Expand Down
27 changes: 2 additions & 25 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -1104,19 +1104,6 @@ def civic_aid6_statement(
"id": "civic.aid:6",
"description": "L858R is among the most common sensitizing EGFR mutations in NSCLC, and is assessed via DNA mutational analysis, including Sanger sequencing and next generation sequencing methods. Tyrosine kinase inhibitor afatinib is FDA approved as a first line systemic therapy in NSCLC with sensitizing EGFR mutation (civic.EID:2997).",
"type": "Statement",
"extensions": [
{
"name": "evidence_ids",
"value": [
"civic.eid:2997",
"civic.eid:2629",
"civic.eid:982",
"civic.eid:968",
"civic.eid:883",
"civic.eid:879",
],
}
],
"specifiedBy": civic_method,
"proposition": {
"type": "VariantTherapeuticResponseProposition",
Expand All @@ -1129,18 +1116,8 @@ def civic_aid6_statement(
},
"direction": "supports",
"classification": {
"conceptType": "Guideline",
"primaryCode": "IA",
"mappings": [
{
"coding": {
"system": "AMP/ASCO/CAP",
"systemVersion": "2017",
"code": "IA",
},
"relation": "exactMatch",
}
],
"primaryCode": "Tier I",
"extensions": [{"name": "civic_amp_level", "value": "TIER_I_LEVEL_A"}],
},
"hasEvidenceLines": [
{
Expand Down

0 comments on commit e1948ed

Please sign in to comment.