metakb.repository.neo4j_models#

Define data structures for loading objects into DB.

A few basic motifs are important here –

  • Node classes MUST define a from_gks classmethod, which accepts the corresponding GKS class, and creates an instance of Self, as well as a to_gks instance method, which returns the same GKS class

  • In general, class property names for properties consisting of other nodes should reflect the relationship name used on the graph. This gets tricky in the context of array-like relationships, since the property name should be plural but the graph relationship name is usually singular. Not sure what the best solution is there.

  • The cypher queries employ ON CREATE SET to assign properties, which doesn’t allow for null values. That’s why a lot of values default to empty arrays or strings. These should be returned as None in the to_gks() method.

  • In general, nodes should have some deterministic ID based on their values, if an ID isn’t already given. This is to ensure that repeat nodes aren’t inadvertently added. Note that some nodes, like assertions and evidence lines, might need to be updated in-place as evidence is aggregated together – DO NOT generate IDs based on those values which are subject to change

class metakb.repository.neo4j_models.AlleleNode(**data)[source]#

Node model for VRS allele

expressions: str[source]#
classmethod from_gks(allele)[source]#

Create Node instance from GKS class.

Return type:

Self

has_location: SequenceLocationNode[source]#
has_state: LiteralSequenceExpressionNode | ReferenceLengthExpressionNode[source]#
id: str[source]#
name: str[source]#
to_gks()[source]#

Return VRS-Python Allele instance

Return type:

Allele

class metakb.repository.neo4j_models.BaseNode(**data)[source]#

Abstract base node.

abstract classmethod from_gks(*args, **kwargs)[source]#

Create node instance from GKS class.

Return type:

Self

abstract to_gks()[source]#

Return corresponding GKS class.

Return type:

Any

class metakb.repository.neo4j_models.CategoricalVariantNode(**data)[source]#

Node model for Categorical Variant.

aliases: list[str][source]#
description: str[source]#
extensions: str[source]#
classmethod from_gks(catvar)[source]#

Create Node instance from GKS class.

Return type:

Self

has_constraint: DefiningAlleleConstraintNode | FeatureContextConstraintNode | None[source]#
has_members: list[AlleleNode][source]#
id: str[source]#
mappings: str[source]#
name: str[source]#
to_gks()[source]#

Construct cat-vrs-python CategoricalVariant instance

Return type:

CategoricalVariant

class metakb.repository.neo4j_models.ClassificationNode(**data)[source]#

Node model for a classification.

classmethod from_gks(classification)[source]#

Construct node representation of classification coding object.

Return type:

Self

id: str[source]#
primary_coding: str[source]#
to_gks()[source]#

Return VA-Spec MappableConcept containing variant classification.

Return type:

MappableConcept

class metakb.repository.neo4j_models.ConditionSetNode(**data)[source]#

Node model for ConditionSet.

conditions: list[DiseaseNode | PhenotypeNode | ConditionSetNode][source]#
extensions: str[source]#
classmethod from_gks(condition_set)[source]#

Create Node instance from GKS class.

Return type:

Self

id: str[source]#
membership_operator: MembershipOperator[source]#
to_gks()[source]#

Create ConditionSet GKS class from Node instance.

Return type:

ConditionSet

class metakb.repository.neo4j_models.DefiningAlleleConstraintNode(**data)[source]#

Node model for Cat-VRS DefiningAlleleConstraint

classmethod from_gks(constraint, constraint_id)[source]#

Create new node instance from a Cat-VRS DefiningAlleleConstraint.

Parameters:
  • constraint (DefiningAlleleConstraint) – original constraint object

  • constraint_id (str) – database identifier. Our working convention is to incorporate the container categorical variant’s ID as part of this, which means we need to get this arg separately

Return type:

Self

Returns:

node instance

has_defining_allele: AlleleNode[source]#
id: str[source]#
relations: str[source]#
to_gks()[source]#

Create cat-vrs-python defining allele constraint class instance

Return type:

DefiningAlleleConstraint

class metakb.repository.neo4j_models.DiagnosticStatementNode(**data)[source]#

Node model for an evidence statement about a diagnostic proposition

classmethod from_gks(statement)[source]#

Create Node instance from GKS class.

Return type:

Self

predicate: DiagnosticPredicate[source]#
to_gks()[source]#

Create a Statement containing a diagnostic proposition

Return type:

Statement

class metakb.repository.neo4j_models.DiseaseNode(**data)[source]#

Node model for an individual Disease.

classmethod from_gks(disease)[source]#

Create Node instance from GKS class.

Return type:

Self

id: str[source]#
mappings: str[source]#
name: str[source]#
to_gks()[source]#

Create GKS class for Disease from node.

Return type:

MappableConcept

class metakb.repository.neo4j_models.DocumentNode(**data)[source]#

Node model for Document.

aliases: list[str][source]#
doi: str[source]#
extensions: str[source]#
classmethod from_gks(document)[source]#

Create Node instance from GKS class. :rtype: Self

  • Here, we define a policy about how to make document IDs in cases where the CDM doesn’t provide them (i.e. documents supporting source methods).

Raises:

ValueError – if unable to employ existing ID construction scheme to fill in ID

id: str[source]#
name: str[source]#
pmid: str[source]#
source_type: str[source]#
title: str[source]#
to_gks()[source]#

Create va-spec-python Document instance

Return type:

Document

urls: list[str][source]#
class metakb.repository.neo4j_models.DrugNode(**data)[source]#

Node model for Drug.

extensions: str[source]#
classmethod from_gks(therapy)[source]#

Create Node instance from GKS class.

Return type:

Self

id: str[source]#
mappings: str[source]#
name: str[source]#
to_gks()[source]#

Create GKS MappableConcept (drug) from node.

Return type:

MappableConcept

class metakb.repository.neo4j_models.EvidenceLineNode(**data)[source]#

Node model for an Evidence Line object.

direction: Direction[source]#
evidence_outcome: str[source]#
extensions: str[source]#
classmethod from_gks(evidence_line)[source]#

Construct node representation of Evidence Line object

Return type:

Self

has_evidence_items: list[TherapeuticResponseStatementNode | DiagnosticStatementNode | PrognosticStatementNode | EvidenceLineNode][source]#
has_strength: StrengthNode[source]#
id: str[source]#
to_gks()[source]#

Create EvidenceLine instance.

Return type:

EvidenceLine

class metakb.repository.neo4j_models.FeatureContextConstraintNode(**data)[source]#

Node model for Cat-VRS FeatureContextConstraint

classmethod from_gks(constraint, constraint_id)[source]#

Create new node instance from a Cat-VRS FeatureContextConstraint

Parameters:
  • constraint (FeatureContextConstraint) – original constraint object

  • constraint_id (str) – database identifier. Our working convention is to incorporate the container categorical variant’s ID as part of this, which means we need to get this arg separately

Return type:

Self

Returns:

node instance

has_feature_context: GeneNode[source]#
id: str[source]#
to_gks()[source]#

Create cat-vrs-python feature context constraint class instance

Return type:

FeatureContextConstraint

class metakb.repository.neo4j_models.GeneNode(**data)[source]#

Node model for Gene.

description: str[source]#
extensions: str[source]#
classmethod from_gks(gene)[source]#

Create Node instance from GKS class.

Return type:

Self

id: str[source]#
mappings: str[source]#
name: str[source]#
to_gks()[source]#

Create GKS class for Gene from node.

Return type:

MappableConcept

class metakb.repository.neo4j_models.LiteralSequenceExpressionNode(**data)[source]#

Node model for LiteralSequenceExpression

classmethod from_gks(lse)[source]#

Create Node instance from GKS class.

Return type:

Self

sequence: str[source]#
to_gks()[source]#

Return VRS-Python LiteralSequenceExpression

Return type:

LiteralSequenceExpression

type: Literal['LiteralSequenceExpression'][source]#
class metakb.repository.neo4j_models.MethodNode(**data)[source]#

Node model for Method.

classmethod from_gks(method)[source]#

Create Node instance from GKS class.

Return type:

Self

has_document: DocumentNode[source]#
id: str[source]#
method_type: str[source]#
name: str[source]#
to_gks()[source]#

Create VA-Spec Method instance.

Return type:

Method

class metakb.repository.neo4j_models.PhenotypeNode(**data)[source]#

Node model for Phenotype.

classmethod from_gks(phenotype)[source]#

Create Node instance from GKS class.

Return type:

Self

id: str[source]#
mappings: str[source]#
name: str[source]#
to_gks()[source]#

Create GKS class for Phenotype from node.

Return type:

MappableConcept

class metakb.repository.neo4j_models.PrognosticStatementNode(**data)[source]#

Node model for an evidence statement about a prognostic proposition

classmethod from_gks(statement)[source]#

Create Node instance from GKS class.

Return type:

Self

predicate: PrognosticPredicate[source]#
to_gks()[source]#

Create a Statement containing a prognostic proposition

Return type:

Statement

class metakb.repository.neo4j_models.ReferenceLengthExpressionNode(**data)[source]#

Node model for ReferenceLengthExpression

classmethod from_gks(rle)[source]#

Create Node instance from GKS class.

Return type:

Self

length: int[source]#
repeat_subunit_length: int[source]#
sequence: str[source]#
to_gks()[source]#

Return VRS-Python ReferenceLengthExpression

Return type:

ReferenceLengthExpression

type: Literal['ReferenceLengthExpression'][source]#
class metakb.repository.neo4j_models.SequenceLocationNode(**data)[source]#

Node model for SequenceLocation

end: int[source]#
classmethod from_gks(sequence_location)[source]#

Create Node instance from GKS class.

Return type:

Self

has_sequence_reference: SequenceReferenceNode[source]#
id: str[source]#
sequence: str[source]#
start: int[source]#
to_gks()[source]#

Return VRS-Python SequenceLocation

Return type:

SequenceLocation

class metakb.repository.neo4j_models.SequenceReferenceNode(**data)[source]#

Node model for a sequence reference

classmethod from_gks(sequence_reference)[source]#

Create Node instance from GKS class.

Return type:

Self

refget_accession: str[source]#
to_gks()[source]#

Return VRS SequenceReference

Return type:

SequenceReference

class metakb.repository.neo4j_models.StatementNodeBase(**data)[source]#

Base properties for a Statement node.

Use as a mixin for a flattened statement/proposition node.

Should be able to support both meta-level assertions about other statements, or individual statements themselves

allele_origin_qualifier: str[source]#
description: str[source]#
direction: Direction[source]#
extensions: str[source]#
has_classification: ClassificationNode | None[source]#
has_condition: DiseaseNode | PhenotypeNode | ConditionSetNode[source]#
has_documents: list[DocumentNode][source]#
has_evidence_lines: list[EvidenceLineNode][source]#
has_gene: GeneNode[source]#
has_method: MethodNode[source]#
has_strength: StrengthNode[source]#
has_variant: CategoricalVariantNode[source]#
id: str[source]#
proposition_type: Literal['VariantTherapeuticResponseProposition'] | Literal['VariantDiagnosticProposition'] | Literal['VariantPrognosticProposition'][source]#
url: str[source]#
class metakb.repository.neo4j_models.StrengthNode(**data)[source]#

Node model of a Strength object.

extensions: str[source]#
classmethod from_gks(strength)[source]#

Create Node instance from GKS class.

Return type:

Self

id: str[source]#
mappings: str[source]#
name: str[source]#
primary_coding: str[source]#
to_gks()[source]#

Create VA-Spec Strength instance

Return type:

MappableConcept

class metakb.repository.neo4j_models.TherapeuticResponseStatementNode(**data)[source]#

Node model for an evidence statement about a therapeutic response proposition

classmethod from_gks(statement)[source]#

Create Node instance from GKS class.

Return type:

Self

has_therapeutic: TherapyGroupNode | DrugNode[source]#
predicate: TherapeuticResponsePredicate[source]#
to_gks()[source]#

Create a Statement containing a TR proposition

Return type:

Statement

class metakb.repository.neo4j_models.TherapyGroupNode(**data)[source]#

Node model for TherapyGroup.

extensions: str[source]#
classmethod from_gks(therapy_group)[source]#

Create Node instance from GKS class.

Return type:

Self

has_therapies: list[DrugNode][source]#
id: str[source]#
membership_operator: MembershipOperator[source]#
to_gks()[source]#

Create TherapyGroup GKS class from Node instance.

Return type:

TherapyGroup