### Construct TRAPI Query Graph with Qualifier Constraints in JSON Source: https://github.com/biolink/biolink-model/blob/master/src/docs/TRAPI-examples.md This snippet demonstrates how to construct a TRAPI 1.3 query graph in JSON format that includes qualifier constraints. The example queries for chemical entities that decrease the degradation of the ESR1 protein. The query graph includes nodes for the chemical entity and the gene/gene product, and an edge with predicates and qualifier constraints specifying the aspect and direction of the effect. Inputs are node categories and IDs, and outputs are the structured query graph. Requires TRAPI 1.3-compliant tools. ```JSON { "query_graph": { "nodes": { "n0": { "categories": ["biolink:ChemicalEntity"] }, "n1": { "categories": ["biolink:GeneOrGeneProduct"], "ids": ["HGNC:3467"] } }, "edges": { "e01": { "subject": "n0", "object": "n1", "predicates": [ "biolink:affects" ], "qualifier_constraints": [ { "qualifier_set": [ { "qualifier_type_id": "biolink:object_aspect_qualifier", "qualifier_value": "degradation" }, { "qualifier_type_id": "biolink:object_direction_qualifier", "qualifier_value": "decreased" } ] } ] } } } } ``` -------------------------------- ### Represent TRAPI Knowledge Graph Result with Qualifiers in JSON Source: https://github.com/biolink/biolink-model/blob/master/src/docs/TRAPI-examples.md This snippet shows how to represent a TRAPI 1.3 knowledge graph result in JSON, including qualifiers on edges. The example demonstrates a result where Bisphenol A (PUBCHEM.COMPOUND:6623) affects the degradation of ESR1 (HGNC:3467) in a decreased manner. The knowledge graph includes nodes, edges with qualifiers, and result bindings. Inputs are the entities and relationships, and outputs are the structured result. Requires TRAPI 1.3-compliant consumers. ```JSON { "knowledge_graph": { "nodes": { "n0": { "categories": ["biolink:ChemicalEntity"], "name": "Bisphenol A" }, "n1": { "categories": ["biolink:Gene"], "name": "ESR1" } }, "edges": { "x17770": { "predicate": "biolink:affects", "subject": "PUBCHEM.COMPOUND:6623", "object": "HGNC:3467", "qualifiers": [ { "qualifier_type_id": "biolink:object_aspect_qualifier", "qualifier_value": "degradation" }, { "qualifier_type_id": "biolink:object_direction_qualifier", "qualifier_value": "decreased" } ] } } }, "results": [ { "node_bindings": { "n0": [ { "id": "PUBCHEM.COMPOUND:6623" } ], "n1": [ { "id": "HGNC:3467" } ] }, "edge_bindings": { "e01": [ { "id": "x17770" } ] } } ] } ``` -------------------------------- ### Define Exact Mappings in YAML Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Illustrates how to use the `exact_mappings` slot to define external concepts that are considered exact matches to a Biolink Model predicate. The example shows the 'same as' predicate and its equivalent external concepts. ```YAML same as: is_a: exact match description: >- holds between two entities that are considered equivalent to each other in_subset: - translator_minimal exact_mappings: - owl:sameAs - skos:exactMatch - WIKIDATA_PROPERTY:P2888 - CHEMBL.MECHANISM:equivalent_to - MONDO:equivalentTo ``` -------------------------------- ### Define Narrow Mappings in YAML Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Shows how to use the `narrow_mappings` slot to define external concepts that are narrower in scope than a Biolink Model predicate. The example continues with the 'same as' predicate. ```YAML same as: is_a: exact match description: >- holds between two entities that are considered equivalent to each other in_subset: - translator_minimal close_mappings: - owl:equivalentClass exact_mappings: - owl:sameAs - skos:exactMatch - WIKIDATA_PROPERTY:P2888 - CHEMBL.MECHANISM:equivalent_to - MONDO:equivalentTo narrow_mappings: - DRUGBANK:external-identifier ``` -------------------------------- ### Define Inverse Predicate in YAML Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Shows how to define the inverse of a predicate using the `inverse` slot. The example illustrates the relationship between 'affects' and 'affected by'. ```YAML affects: is_a: related to description: >- describes an entity that has a direct affect on the state or quality of another existing entity. Use of the 'affects' predicate implies that the affected entity already exists, unlike predicates such as 'affects risk for' and 'prevents, where the outcome is something that may or may not come to be. inverse: affected by in_subset: - translator_minimal ``` -------------------------------- ### Provenance Chain Example for Gene-Chemical Edge (APIDOC) Source: https://github.com/biolink/biolink-model/blob/master/src/docs/knowledge-source-retrieval.md Illustrates a typical provenance chain for a Gene-Chemical edge in a Translator message. Each resource in the chain is annotated with its InfoRes identifier, showing the sequence of retrieval from the original source through aggregators to the final provider. This example demonstrates how to represent linear provenance in Biolink-compliant data. ```APIDOC ProvenanceChainExample: ARAGORN (infores:aragorn) --retrieved_from--> MolePro (infores:molepro) --retrieved_from--> ChEMBL (infores:chembl) --retrieved_from--> ClinicalTrials.gov (infores:clinicaltrials_gov) ``` -------------------------------- ### Define Close Mappings in YAML Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Demonstrates the use of the `close_mappings` slot to define external concepts that are considered close matches to a Biolink Model predicate. The example builds on the 'same as' predicate. ```YAML same as: is_a: exact match description: >- holds between two entities that are considered equivalent to each other in_subset: - translator_minimal exact_mappings: - owl:sameAs - skos:exactMatch - WIKIDATA_PROPERTY:P2888 - CHEMBL.MECHANISM:equivalent_to - MONDO:equivalentTo close_mappings: - owl:equivalentClass ``` -------------------------------- ### Hierarchical Mixin Example (YAML) Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Defines a hierarchical mixin, `frequency qualifier mixin`, to hold the parent slot `frequency qualifier`. This demonstrates how mixins can be used in a hierarchical manner to promote consistency. ```YAML frequency qualifier mixin: mixin: true description: >- Qualifier for frequency type associations slots: - frequency qualifier ``` -------------------------------- ### Build and Upload Python Package to PyPI using Shell Commands Source: https://github.com/biolink/biolink-model/blob/master/release-instructions.md This snippet demonstrates the shell commands required to build the Biolink Model Python package and upload it to PyPI. It assumes that twine and wheel are installed and that the user has the necessary permissions for the biolink-model package on PyPI. The commands remove any previous build artifacts, create new distribution files, and upload them to PyPI using a token-based authentication. Ensure that setup.py is updated with the correct version before running these commands. ```shell rm -rf dist/ python setup.py sdist bdist_wheel twine upload --repository-url https://upload.pypi.org/legacy/ --username __token__ dist/* ``` -------------------------------- ### Chemical Analog Affects Gene (Complex Qualifiers) Source: https://github.com/biolink/biolink-model/blob/master/src/docs/association-examples-with-qualifiers.md Another complex example where an analog of a chemical affects a gene, with multiple qualifiers. ```JSON { "id": "e0", "category": "biolink:ChemicalAffectsGeneAssociation", "subject": "CHEBI:16811", "subject_form_or_variant_qualifier": "analog", "predicate": "biolink:affects", "qualified_predicate": "biolink:causes", "object": "NCBIGene:1029", "object_aspect_qualifier": "methylation", "object_direction_qualifier": "increased", "object_part_qualifier": "enhancer", "object_form_or_variant_qualifier": "modified" } ``` -------------------------------- ### Compose Qualifier-Based Association Statement in Biolink Model Source: https://github.com/biolink/biolink-model/blob/master/src/docs/reading-a-qualifier-based-statement.md This snippet shows an example of an Association Statement using subject, predicate, object, and various qualifier slots to represent a complex biological assertion. It demonstrates how qualifiers add semantic detail to the core triple. The code is a structured key-value representation of the statement components. ```plaintext subject: CHEBI:5692 # Hexachlorobenzene subject_derivative: metabolite predicate: biolink:affects qualified_predicate: biolink:causes object: NCBIGene:1029 # CDKN2A object_part: promoter object_form_or_variant: mutant_form object_aspect: methylation object_direction: increased object_context: "UBERON:0001013" # nucleus, experimental_context_qualifier: HeLa cells ``` -------------------------------- ### Define Symmetric Predicate in YAML Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Demonstrates how to use the `symmetric` slot to specify that a predicate is symmetric. This means the relationship holds in both directions. The example shows the 'interacts with' predicate. ```YAML interacts with: domain: named thing range: named thing description: >- holds between any two entities that directly or indirectly interact with each other is_a: related to in_subset: - translator_minimal symmetric: true ``` -------------------------------- ### Chemical Affects Gene (Complex Qualifiers) Source: https://github.com/biolink/biolink-model/blob/master/src/docs/association-examples-with-qualifiers.md A more complex example where a metabolite of a chemical affects a gene, with multiple qualifiers. ```JSON { "id": "e0", "category": "biolink:ChemicalAffectsGeneAssociation", "subject": "CHEBI:17026", "predicate": "biolink:affects", "qualified_predicate": "biolink:causes", "object": "NCBIGene:351", "object_aspect_qualifier": "methylation", "object_direction_qualifier": "decreased", "object_part_qualifier": "promoter", "object_form_or_variant_qualifier": "mutant" } ``` -------------------------------- ### Define Broad Mappings in YAML Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Illustrates the use of the `broad_mappings` slot to define external concepts that are broader in scope than a Biolink Model predicate. The example uses the 'in complex with' predicate. ```YAML in complex with: description: >- holds between two genes or gene products that are part of (or code for products that are part of) in the same macromolecular complex is_a: coexists with domain: gene or gene product range: gene or gene product in_subset: - translator_minimal broad_mappings: - SIO:010285 ``` -------------------------------- ### Specify Domain and Range Constraints for a Slot in Biolink Model (YAML) Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Shows how to define both 'domain' and 'range' for a slot, constraining both the subject and object types. This example ensures that both ends of the 'genetically interacts with' predicate are instances of 'gene'. Dependencies: Biolink Model schema. Inputs: slot definitions; outputs: type-constrained associations. Limitation: Only supports types defined in the schema. ```YAML genetically interacts with: is_a: interacts with domain: gene range: gene ``` -------------------------------- ### Anchor Biolink Class Semantics to External Ontology Using subclass_of Slot in YAML Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md This snippet shows how to use the subclass_of slot to link a Biolink class to an external ontology term, anchoring its semantics. The example anchors the 'named thing' class to the Basic Formal Ontology term 'BFO:0000001', implying all subclasses inherit this external classification. ```YAML named thing: description: "a databased entity or concept/class" slots: - id - name - category subclass_of: BFO:0000001 ``` -------------------------------- ### Define an abstract class with inheritance constraints in LinkML YAML Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md This snippet shows how to mark a class as abstract using the abstract slot set to true in LinkML YAML. The example defines 'cell line to thing association' as an abstract subclass of 'association' with a constrained subject slot range. Abstract classes cannot be instantiated directly but can be used in inheritance hierarchies. ```yaml cell line to thing association: is_a: association defining_slots: - subject abstract: true description: >- A relationship between a cell line and another entity slot_usage: subject: range: cell line ``` -------------------------------- ### Represent Biolink Edge with Properties Using RDF* and RDF Reification Source: https://github.com/biolink/biolink-model/blob/master/src/docs/mapping-rdf.md This snippet demonstrates how to represent an edge between two Biolink nodes with an additional edge property using RDF* syntax and traditional RDF reification. The RDF* syntax provides a concise way to annotate triples, while the reification approach uses rdf:Statement resources to capture edge properties. The example also notes that some RDF* implementations require explicit assertion of the triple. ```turtle <<:x :p :y>> bl:publication . ``` ```turtle :x :p :y . [a rdf:Statement ; rdf:subject :x ; rdf:predicate :p ; rdf:object :y ; bl:publication ]. ``` ```turtle :x :p :y. <<:x :p :y>> bl:publication . ``` -------------------------------- ### Serialize Biolink Node as RDF Turtle Source: https://github.com/biolink/biolink-model/blob/master/src/docs/mapping-rdf.md This snippet shows how a Biolink node with a CURIE identifier and name is serialized into RDF turtle syntax. It uses standard RDF prefixes and maps the biolink:name to rdfs:label. The CURIE is expanded to a full IRI in the second example. This serialization is suitable for RDF triplestores and graph databases supporting RDF. ```turtle PREFIX MONDO: PREFIX rdfs: MONDO:0001083 rdfs:label "Fanconi syndrome" ``` ```turtle "Fanconi syndrome" . ``` -------------------------------- ### Define subclass hierarchy using is_a slot in LinkML YAML Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md This snippet demonstrates how to use the is_a slot in LinkML YAML to define a subclass relationship between two classes or slots. The example defines 'gene' as a subclass of 'gene or gene product'. The is_a slot should only connect two mixins, two classes, or two slots. ```yaml gene: is_a: gene or gene product ``` -------------------------------- ### Define Defining Slots for a Class in Biolink Model (YAML) Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Demonstrates how to specify which slots are necessary to define an instance of a class using the 'defining_slots' property. This example shows that a 'gene to gene association' is determined by the presence of 'subject' and 'object' slots. Dependencies include the Biolink Model schema. Inputs are class definitions; outputs are class instances with required slots. Limitations: Only applies to explicitly listed slots. ```YAML gene to gene association: is_a: association defining_slots: - subject - object ``` -------------------------------- ### Document Slot Usage for a Class in Biolink Model (YAML) Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Shows how to use the 'slot_usage' property to document the meaning and constraints of slots within a class. This example provides detailed descriptions and range constraints for the 'subject' and 'object' slots in a 'gene to gene association'. Dependencies: Biolink Model schema. Inputs: slot definitions; outputs: enhanced documentation and validation. Limitations: Descriptions must be manually maintained. ```YAML gene to gene association: aliases: ['molecular or genetic interaction'] is_a: association defining_slots: - subject - object description: >- abstract parent class for different kinds of gene-gene or gene product to gene product relationships. Includes homology and interaction. slot_usage: subject: range: gene or gene product description: >- the subject gene in the association. If the relation is symmetric, subject vs object is arbitrary. We allow a gene product to stand as proxy for the gene or vice versa object: range: gene or gene product description: >- the object gene in the association. If the relation is symmetric, subject vs object is arbitrary. We allow a gene product to stand as proxy for the gene or vice versa ``` -------------------------------- ### Declare Symmetric Predicate Slot in Biolink Model (YAML) Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Illustrates how to specify that a predicate slot is symmetric using the 'symmetric' property. This example marks 'genetically interacts with' as symmetric, allowing inference in both directions. Dependencies: Biolink Model schema. Inputs: slot definitions; outputs: bidirectional semantic relationships. Limitation: Symmetry is not inherited by descendants. ```YAML genetically interacts with: is_a: interacts with domain: gene range: gene in_subset: - translator_minimal symmetric: true ``` -------------------------------- ### Specify Domain Constraint for a Slot in Biolink Model (YAML) Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Demonstrates how to use the 'domain' property to restrict which classes a slot can be part of. This example sets the domain of the 'genetically interacts with' slot to 'gene', meaning only gene instances can use this slot. Dependencies: Biolink Model schema. Inputs: slot definitions; outputs: constrained slot usage. Limitation: Only restricts subject (source node) type. ```YAML genetically interacts with: is_a: interacts with domain: gene ``` -------------------------------- ### Define Required Slot for a Class in Biolink Model (YAML) Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Illustrates how to declare a slot as required using the 'required' property. This example marks the 'id' slot as mandatory for all instances of the 'named thing' class. Dependencies: Biolink Model schema. Inputs: slot and class definitions; outputs: enforced presence of required fields. Limitation: All subclasses must comply with this requirement. ```YAML id: is_a: node property required: true domain: named thing mappings: - alliancegenome:primaryId - gff3:ID - gpi:DB_Object_ID ``` -------------------------------- ### Define related_mappings Slot in Biolink Model Using YAML Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md This snippet demonstrates how to use the related_mappings slot to specify external concepts related to a Biolink predicate slot. It shows a YAML example defining a predicate 'in complex with' and associating it with an external related mapping 'SIO:010497'. This helps relate the predicate to external ontology terms without implying further granularity. ```YAML in complex with: description: >- holds between two genes or gene products that are part of (or code for products that are part of) in the same macromolecular complex is_a: coexists with domain: gene or gene product range: gene or gene product in_subset: - translator_minimal broad_mappings: - SIO:010285 related_mappings: - SIO:010497 ``` -------------------------------- ### Define ID Prefixes in YAML Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Illustrates how to define a list of valid ID prefixes for a class using YAML. The order of the list indicates priority. ```YAML gene: is_a: gene or gene product aliases: ['locus'] slots: - id - name - symbol - description - synonym - xref mappings: - SO:0000704 - SIO:010035 - WIKIDATA:Q7187 id_prefixes: - NCBIGene - ENSEMBL - HGNC - UniProtKB - MGI - ZFIN - dictyBase - WB - WormBase - FlyBase - FB - RGD - SGD - PomBase ``` -------------------------------- ### Initialize and Render Treats Predicates Graph Using Cytoscape.js Source: https://github.com/biolink/biolink-model/blob/master/src/docs/treats_dag.html This JavaScript snippet loads graph data from a JSON file and renders it using Cytoscape.js with a dagre layout. Nodes and edges are styled for clarity, including special styling for nodes with a 'mixin' attribute. Nodes are interactive, redirecting to a markdown file if specified in node data. The snippet handles fetch errors gracefully. ```JavaScript document.addEventListener('DOMContentLoaded', function () { fetch('treats_dagre.json') .then(response => response.json()) .then(elements => { var cy = cytoscape({ container: document.getElementById('cy'), elements: elements, layout: { name: 'dagre', nodeSep: 50, edgeSep: 10, rankSep: 1000, rankDir: 'TB' }, style: [ { selector: 'node', style: { 'label': 'data(label)', 'text-valign': 'center', 'text-halign': 'center', 'color': '#fff', 'background-color': '#666', 'text-wrap': 'wrap', 'text-max-width': 160, 'font-size': 110, 'width': 1000, 'height': 1000 } }, { selector: 'node[mixin="true"]', style: { 'background-color': 'purple' } }, { selector: 'edge', style: { 'width': 50, 'line-color': '#ccc', 'target-arrow-color': '#ccc', 'target-arrow-shape': 'triangle', 'curve-style': 'bezier' } } ] }); cy.on('tap', 'node', function (event) { var nodeData = event.target.data(); if (nodeData.mdFile) { window.location.href = nodeData.mdFile; } }); }) .catch(error => console.error('Error loading the elements:', error)); }); ``` -------------------------------- ### Encoding Biolink Associations in KGX Flat File (TSV Format) Source: https://github.com/biolink/biolink-model/blob/master/src/docs/association-examples-with-qualifiers.md This snippet demonstrates how to represent a qualified Biolink association as a row in a KGX-compatible TSV file. Each column corresponds to a core triple component or qualifier, enabling interoperability with knowledge graph tools that use the KGX format. ```TSV subject, predicate, object, qualified_predicate, subject_aspect_qualifier, subject_direction_qualifier, object_aspect_qualifier, object_direction_qualifier, anatomical_context_qualifier CHEBI:16811, biolink:affects, NCBIGene:154, biolink:causes, abundance, decreased, expression, increased, UBERON:0001013 ``` -------------------------------- ### Define Description for a Class in YAML Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Illustrates how to provide a human-readable description of a class or slot using YAML. This enhances understanding of the class's purpose. ```YAML genetically interacts with: is_a: interacts with description: >- holds between two genes whose phenotypic effects are dependent on each other in some way - such that their combined phenotypic effects are the result of some interaction between the activity of their gene products. Examples include epistasis and synthetic lethality. domain: gene range: gene ``` -------------------------------- ### Define Subset Membership in YAML Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Shows how to tag a class or slot to belong to a pre-defined subset using YAML. This helps in categorizing and organizing classes. ```YAML genetically interacts with: is_a: interacts with domain: gene range: gene in_subset: - translator_minimal ``` -------------------------------- ### Use subproperty_of Slot to Constrain Predicate Values in Biolink Model YAML Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md This snippet illustrates the use of the subproperty_of slot under slot_usage to restrict the predicate values of an association to a specific predicate subtree other than the top-level 'related_to'. The example shows constraining the predicate of a gene-to-gene homology association to 'homologous to' or its subclasses. ```YAML gene to gene homology association: is_a: gene to gene association slot_usage: predicate: subproperty_of: homologous to ``` -------------------------------- ### Define Slot URI in YAML Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Demonstrates how to define a canonical URI for a slot using YAML. This ensures a standard representation of the slot when serializing to RDF. ```YAML name: is_a: node property aliases: ['label', 'display name'] domain: named thing range: label type slot_uri: rdfs:label ``` -------------------------------- ### Chemical Associated with Gene (Aspect, Direction) Source: https://github.com/biolink/biolink-model/blob/master/src/docs/association-examples-with-qualifiers.md Demonstrates a chemical associated with a gene, including aspect and direction qualifiers. ```JSON { "id": "e0", "category": "biolink:ChemicalAffectsGeneAssociation", "subject": "CHEBI:16811", "predicate": "biolink:associated_with", "object": "NCBIGene:2099", "object_aspect_qualifier": "degradation", "object_direction_qualifier": "decreased" } ``` -------------------------------- ### Representing Qualified Statements in TRAPI Knowledge Graph JSON Source: https://github.com/biolink/biolink-model/blob/master/src/docs/association-examples-with-qualifiers.md This snippet illustrates how to encode a knowledge graph with qualified statements using the TRAPI (Translator Reasoner API) specification. Nodes and edges are annotated with categories, names, predicates, and a list of qualifiers, supporting rich semantic representation and interoperability with TRAPI-compliant tools. ```JSON { "knowledge_graph": { "nodes": { "PUBCHEM.COMPOUND:6137": { "categories": [ "biolink:ChemicalEntity" ], "name": "Methionine" }, "HGNC:286": { "categories": [ "biolink:GeneOrGeneProduct" ], "name": "ADRB2" } }, "edges": { "x17770": { "predicate": "biolink:affects", "subject": "PUBCHEM.COMPOUND:6137", "object": "HGNC:286", "qualifiers": [ { "qualifier_type_id": "biolink:subject_aspect_qualifier", "qualifier_value": "abundance" }, { "qualifier_type_id": "biolink:subject_direction_qualifier", "qualifier_value": "decreased" }, { "qualifier_type_id": "biolink:qualified_predicate", "qualifier_value": "biolink:causes" }, { "qualifier_type_id": "biolink:object_aspect_qualifier", "qualifier_value": "expression" }, { "qualifier_type_id": "biolink:object_direction_qualifier", "qualifier_value": "increased" }, { "qualifier_type_id": "biolink:anatomical_context_qualifier", "qualifier_value": "UBERON:0001013" } ] } } } } ``` -------------------------------- ### Define Aliases for a Class in YAML Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Shows how to define aliases for a Biolink Model class using YAML. Aliases provide synonymous names for a class or slot. ```YAML gene: is_a: gene or gene product aliases: - locus ``` -------------------------------- ### Define Mixin Class with Slots (YAML) Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Defines a mixin class, `thing with taxon`, with the `mixin: true` setting and a slot `in taxon`. Mixins allow extending properties without altering the class hierarchy. ```YAML thing with taxon: mixin: true description: >- A mixin that can be used on any entity with a taxon slots: - in taxon ``` -------------------------------- ### Define 'treats' Relationship (YAML) Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Defines the 'treats' relationship between an intervention and a medical condition. It includes details on usage, domain, range, annotations, and mappings. ```YAML treats: is_a: treats or applied or studied to treat mixin: true aliases: ['is substance that treats', 'indicated for', 'ameliorates or prevents condition'] description: >- Holds between an intervention (substance, procedure, or activity) and a medical condition (disease or phenotypic feature), and states that the intervention is able to ameliorate, stabilize, or cure the condition or delay, prevent, or reduce the risk of it manifesting in the first place. ‘Treats’ edges should be asserted (knowledge_level: assertion) only in cases where there is strong supporting evidence - i.e. the intervention is approved for the condition, passed phase 3 or in phase 4 trials for the condition, or is an otherwise established treatment in the medical community (e.g. a widely-accepted or formally recommended off-label use). In the absence of such evidence, weaker predicates should be used in asserted edges (e.g. ‘in clinical trials for’ or ‘beneficial in models of’). ‘Treats’ edges based on weaker or indirect forms of evidence can however be created as predictions (knowledge_level: prediction) and should point to the more foundational asserted edges that support them. domain: chemical or drug or treatment range: disease or phenotypic feature annotations: canonical_predicate: true in_subset: - translator_minimal related_mappings: - MONDO:disease_responds_to exact_mappings: - DRUGBANK:treats - WIKIDATA_PROPERTY:P2175 narrow_mappings: # "is substance that treats" constrains statements to # a subset of the universe of all possible treatments - RO:0002606 - NCIT:regimen_has_accepted_use_for_disease # RTX mapped REPODB terms - REPODB:clinically_tested_approved_unknown_phase - REPODB:clinically_tested_suspended_phase_0 - REPODB:clinically_tested_suspended_phase_1 - REPODB:clinically_tested_suspended_phase_1_or_phase_2 - REPODB:clinically_tested_suspended_phase_2 - REPODB:clinically_tested_suspended_phase_2_or_phase_3 - REPODB:clinically_tested_suspended_phase_3 - REPODB:clinically_tested_terminated_phase_0 ``` -------------------------------- ### Apply Mixin to a Class (YAML) Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Demonstrates how to apply the `thing with taxon` mixin to the `molecular entity` class. This adds the `in taxon` attribute to the class without direct inheritance. ```YAML molecular entity: is_a: biological entity mixins: - thing with taxon - physical essence - ontology class aliases: ['bioentity'] ``` -------------------------------- ### Annotate Nodes with Biolink Model in KGX TSV Format Source: https://github.com/biolink/biolink-model/blob/master/src/docs/working-with-the-model.md This snippet shows how to represent protein and gene entities as nodes in a knowledge graph using the Biolink Model. Each node is annotated with its category (protein or gene), identifier, and other relevant metadata. The KGX TSV format is used for serialization. Dependencies include the Biolink Model and KGX conventions. Inputs are entity identifiers and metadata; outputs are properly formatted node records. Ensure all class references use CURIE form with the 'biolink' prefix. ```TSV id name category provided_by xref type in_taxon UniProtKB:P84085 ARF5 biolink:Protein STRING ENSEMBL:ENSP00000000233 NCBITaxon:9606 UniProtKB:P0DP24 CALM2 biolink:Protein STRING ENSEMBL:ENSP00000272298 NCBITaxon:9606 UniProtKB:O43307 ARHGEF9 biolink:Protein STRING ENSEMBL:ENSP00000253401 NCBITaxon:9606 UniProtKB:O75460 ERN1 biolink:Protein STRING ENSEMBL:ENSP00000401445 NCBITaxon:9606 NCBIGene:381 ARF5 biolink:Gene STRING ENSEMBL:ENSG00000004059 SO:0001217 NCBITaxon:9606 NCBIGene:805 CALM2 biolink:Gene STRING ENSEMBL:ENSG00000143933 SO:0001217 NCBITaxon:9606 NCBIGene:23229 ARHGEF9 biolink:Gene STRING ENSEMBL:ENSG00000131089 SO:0001217 NCBITaxon:9606 NCBIGene:2081 ERN1 biolink:Gene STRING ENSEMBL:ENSG00000178607 SO:0001217 NCBITaxon:9606 ``` -------------------------------- ### Annotate Edges with Biolink Model in KGX TSV Format Source: https://github.com/biolink/biolink-model/blob/master/src/docs/working-with-the-model.md This snippet demonstrates how to represent interactions and associations between genes and proteins as edges in a knowledge graph using the Biolink Model. Each edge specifies the subject, predicate, object, and category, following KGX TSV serialization. The Biolink predicate slots and association classes are referenced in CURIE form. Dependencies include the Biolink Model and KGX conventions. Inputs are gene/protein identifiers and relationship metadata; outputs are properly formatted edge records. ```TSV id subject predicate object provided_by category 985eb9e6-e0bf-4cef-be0a-3d8ea12d228b NCBIGene:381 biolink:interacts_with NCBIGene:805 STRING biolink:GeneToGeneAssociation 5550b653-69ff-48cc-a1ef-638ecdc50ea3 NCBIGene:381 biolink:interacts_with NCBIGene:23229 STRING biolink:GeneToGeneAssociation 8bff8da0-6da2-4154-b507-a8e9f75c55f8 NCBIGene:381 biolink:interacts_with NCBIGene:2081 STRING biolink:GeneToGeneAssociation 36e2edf0-d490-4417-9407-7070f4320083 NCBIGene:381 biolink:has_gene_product UniProtKB:P84085 STRING 0dd21d53-4985-467c-8e6d-0a79c0410016 NCBIGene:805 biolink:has_gene_product UniProtKB:P0DP24 STRING fe5f9383-c5f6-4eba-9dc4-185e6d331459 NCBIGene:23229 biolink:has_gene_product UniProtKB:O43307 STRING 8c60c2b2-ff6c-45d5-a18f-e927ab1dec35 NCBIGene:2081 biolink:has_gene_product UniProtKB:O75460 STRING ``` -------------------------------- ### Chemical Affects Gene Activity (Agonist) Source: https://github.com/biolink/biolink-model/blob/master/src/docs/association-examples-with-qualifiers.md Illustrates a chemical affecting gene activity via a specific control mechanism (agonist). ```JSON { "id": "e0", "category": "biolink:ChemicalAffectsGeneAssociation", "subject": "CHEBI:5001", "predicate": "biolink:affects", "qualified_predicate": "biolink:causes", "object": "NCBIGene:5465", "object_aspect_qualifier": "activity", "object_direction_qualifier": "increased", "causal_mechanism_qualifier": "agonism" } ``` -------------------------------- ### Chemical Interacts with Gene Source: https://github.com/biolink/biolink-model/blob/master/src/docs/association-examples-with-qualifiers.md Represents a simple interaction between a chemical and a gene, without additional qualifiers. ```JSON { "id": "e0", "category": "biolink:ChemicalAffectsGeneAssociation", "subject": "CHEBI:5001", "predicate": "biolink:physically_interacts_with", "object": "NCBIGene:5465" } ``` -------------------------------- ### Representing a Fully Qualified Biolink Association in JSON Source: https://github.com/biolink/biolink-model/blob/master/src/docs/association-examples-with-qualifiers.md This snippet shows how to encode a fully qualified biological association using the Biolink Model in JSON format. It includes subject and object identifiers, aspect and direction qualifiers, anatomical context, provenance, and publication evidence. The structure supports extensibility for additional metadata fields. ```JSON { "id": "e0", "category": "biolink:ChemicalAffectsGeneAssociation", "subject": "CHEBI:16811", "subject_aspect_qualifier": "abundance", "subject_direction_qualifier": "decreased", "predicate": "biolink:affects", "qualified_predicate": "biolink:causes", "object": "NCBIGene:154", "object_aspect_qualifier": "expression", "object_direction_qualifier": "increased", "anatomical_context_qualifier": "UBERON:0001013", "publications": ["PMID:123456"], "original_knowledge_source": "infores:molepro" } ``` -------------------------------- ### Chemical Affects Gene (Aspect) Source: https://github.com/biolink/biolink-model/blob/master/src/docs/association-examples-with-qualifiers.md Illustrates a chemical affecting a gene, with an aspect qualifier to specify the type of effect. ```JSON { "id": "e0", "category": "biolink:ChemicalAffectsGeneAssociation", "subject": "CHEBI:16811", "predicate": "biolink:affects", "object": "NCBIGene:154", "object_aspect_qualifier": "hydroxylation" } ``` -------------------------------- ### Define Mixin Class in YAML Source: https://github.com/biolink/biolink-model/blob/master/src/docs/using-the-modeling-language.md Demonstrates how to define a mixin class in YAML to store metadata about a predicate or relationship between two entities. Mixins add semantics without contributing to the inheritance hierarchy. ```YAML individual organism: is_a: organismal entity mixins: - thing with taxon ``` -------------------------------- ### Biolink Model Specification and Mappings Source: https://github.com/biolink/biolink-model/blob/master/README.md Defines the Biolink Model as a YAML specification using LinkML. The model includes class definitions for biological entities and slot definitions for their properties and relationships. It is mapped to multiple formats such as JSON Schema, Python dataclasses, ProtoBuf, GraphQL, OWL, RDF Shape Expressions, JSON-LD context, SHACL, and ShEx for diverse usage scenarios. ```APIDOC Biolink Model Specification: - Format: YAML (linkml) - Core Elements: - Class Definitions: Represent biological entities (e.g., genes, diseases, phenotypes) - Slot Definitions: Properties and relationships (predicates, node and edge properties) Mappings Derived from YAML Source: - JSON Schema: project/jsonschema/biolink_model.schema.json - Python Dataclasses: src/biolink_model/datamodel/model.py - ProtoBuf Definitions: project/protobuf/biolink_model.proto - GraphQL Schema: project/graphql/biolink_model.graphql - OWL Ontology: project/owl/biolink_model.owl.ttl - RDF Shape Expressions: project/shex/biolink_model.shex - JSON-LD Context: project/jsonld/biolink_model.context.jsonld - SHACL Shapes: project/shacl/biolink_model.shacl.ttl - ShEx Shapes: project/shex/biolink_model.shex Usage: - Independent of storage technology (Solr, Neo4j, RDF/OWL, JSON, CSV) - Supports interoperability and integration in biomedical knowledge graphs - Adopted by projects like NCATS Biomedical Data Translator, Monarch Initiative, KG-COVID-19, KG Microbe, Illuminating the Druggable Genome ```