diff --git a/src/metakb/load_data.py b/src/metakb/load_data.py index ab47183a..60327b79 100644 --- a/src/metakb/load_data.py +++ b/src/metakb/load_data.py @@ -261,21 +261,21 @@ def _add_variation(tx: ManagedTransaction, variation_in: dict) -> None: tx.run(query, **v) -def _add_categorical_variation( +def _add_categorical_variant( tx: ManagedTransaction, - categorical_variation_in: dict, + categorical_variant_in: dict, ids_in_studies: set[str], ) -> None: - """Add categorical variation objects to DB. + """Add categorical variant objects to DB. :param tx: Transaction object provided to transaction functions - :param categorical_variation_in: Categorical variation CDM object + :param categorical_variant_in: Categorical variant CDM object :param ids_in_studies: IDs found in studies """ - if categorical_variation_in["id"] not in ids_in_studies: + if categorical_variant_in["id"] not in ids_in_studies: return - cv = categorical_variation_in.copy() + cv = categorical_variant_in.copy() mp_nonnull_keys = [ _create_parameterized_query( @@ -476,7 +476,7 @@ def add_transformed_data(driver: Driver, data: dict) -> None: loaded_study_count = 0 for cv in data.get("categorical_variants", []): - session.execute_write(_add_categorical_variation, cv, ids_in_studies) + session.execute_write(_add_categorical_variant, cv, ids_in_studies) for doc in data.get("documents", []): session.execute_write(_add_document, doc, ids_in_studies) diff --git a/src/metakb/query.py b/src/metakb/query.py index 9197c2ec..cb66a2a6 100644 --- a/src/metakb/query.py +++ b/src/metakb/query.py @@ -47,7 +47,7 @@ class PaginationParamError(Exception): class VariationRelation(str, Enum): """Constrain possible values for the relationship between variations and - categorical variations. + categorical variants. """ HAS_MEMBERS = "HAS_MEMBERS" @@ -575,11 +575,11 @@ def _get_disease(self, node: dict) -> Disease: return Disease(**node) def _get_variations(self, cv_id: str, relation: VariationRelation) -> list[dict]: - """Get list of variations associated to categorical variation + """Get list of variations associated to categorical variant - :param cv_id: ID for categorical variation - :param relation: Relation type for categorical variation and variation - :return: List of variations with `relation` to categorical variation. If + :param cv_id: ID for categorical variant + :param relation: Relation type for categorical variant and variation + :return: List of variations with `relation` to categorical variant. If VariationRelation.HAS_MEMBERS, returns at least one variation. Otherwise, returns exactly one variation """ @@ -615,10 +615,10 @@ def _get_variations(self, cv_id: str, relation: VariationRelation) -> list[dict] return variations def _get_cat_var(self, node: dict) -> CategoricalVariant: - """Get categorical variation data from a node with relationship ``HAS_VARIANT`` + """Get categorical variant data from a node with relationship ``HAS_VARIANT`` :param node: Variant node data. This will be mutated. - :return: Categorical Variation data + :return: Categorical Variant data """ node["mappings"] = _deserialize_field(node, "mappings") diff --git a/src/metakb/transformers/civic.py b/src/metakb/transformers/civic.py index 28d6ebbd..d7d25360 100644 --- a/src/metakb/transformers/civic.py +++ b/src/metakb/transformers/civic.py @@ -209,7 +209,7 @@ async def transform(self, harvested_data: CivicHarvestedData) -> None: for mp in molecular_profiles if f"civic.vid:{mp['variant_ids'][0]}" in able_to_normalize_vids ] - self._add_protein_consequences(mps, mp_id_to_v_id_mapping) + self._add_categorical_variants(mps, mp_id_to_v_id_mapping) # Add variant therapeutic response study data. Will update `studies` self._add_variant_therapeutic_response_studies( @@ -366,10 +366,10 @@ def _get_predicate( predicate = TherapeuticResponsePredicate.RESISTANCE return predicate - def _add_protein_consequences( + def _add_categorical_variants( self, molecular_profiles: list[dict], mp_id_to_v_id_mapping: dict ) -> None: - """Create Protein Sequence Consequence objects for all supported MP records. + """Create Categorical Variant objects for all supported MP records. Mutates instance variables ``able_to_normalize['categorical_variants']`` and ``processed_data.categorical_variants``. diff --git a/src/metakb/transformers/moa.py b/src/metakb/transformers/moa.py index 979073ac..ee64b538 100644 --- a/src/metakb/transformers/moa.py +++ b/src/metakb/transformers/moa.py @@ -81,7 +81,7 @@ async def transform(self, harvested_data: MoaHarvestedData) -> None: # Add gene, variant, and source data to ``processed_data`` instance variable # (``genes``, ``variations``, and ``documents``) self._add_genes(harvested_data.genes) - await self._add_protein_consequences(harvested_data.variants) + await self._add_categorical_variants(harvested_data.variants) self._add_documents(harvested_data.sources) # Add variant therapeutic response study data. Will update `studies` @@ -215,8 +215,8 @@ async def _add_variant_therapeutic_response_studies( ) self.processed_data.studies.append(statement) - async def _add_protein_consequences(self, variants: list[dict]) -> None: - """Create Protein Sequence Consequence objects for all MOA variant records. + async def _add_categorical_variants(self, variants: list[dict]) -> None: + """Create Categorical Variant objects for all MOA variant records. Mutates instance variables ``able_to_normalize['variations']`` and ``processed_data.variations``, if the variation-normalizer can successfully normalize the variant diff --git a/tests/unit/database/test_database.py b/tests/unit/database/test_database.py index f2c3b904..85a9c0db 100644 --- a/tests/unit/database/test_database.py +++ b/tests/unit/database/test_database.py @@ -310,14 +310,14 @@ def test_variation_rules( assert v["expression_hgvs_p"] == expected_p -def test_categorical_variation_rules( +def test_categorical_variant_rules( check_unique_property, check_relation_count, check_node_labels, get_node_by_id, civic_mpid12, ): - """Verify property and relationship rules for Categorical Variation nodes.""" + """Verify property and relationship rules for Categorical Variant nodes.""" check_unique_property("CategoricalVariant", "id") check_relation_count( "CategoricalVariant", "Variation", "HAS_DEFINING_CONTEXT", max_rels=1