### Clone Repository and Install Dependencies with UV Source: https://ontoweaver.readthedocs.io/en/latest/sections/install.html Clone the OntoWeaver repository and install its dependencies using the UV environment manager. This is an alternative installation method if pip installation fails. ```bash git clone https://github.com/oncodash/ontoweaver.git cd ontoweaver uv sync ``` -------------------------------- ### Start Neo4j Server Source: https://ontoweaver.readthedocs.io/en/latest/sections/install.html Start the Neo4j server (version 5+) after importing results. Ensure your results are in the specified directory. ```bash neo4j-admin server start ``` -------------------------------- ### SimpleLabelMaker Mapping Example Source: https://ontoweaver.readthedocs.io/en/latest/sections/user_made_transformers.html Example of a mapping configuration for the SimpleLabelMaker, defining columns and object mapping. ```yaml transformers: - map: columns: - patient to_object: patient via_relation: patient_has_variant ``` -------------------------------- ### Example Turtle Section Source: https://ontoweaver.readthedocs.io/en/latest/sections/intro_SKG.html An example illustrating the Turtle syntax for defining a node with its type ('a' meaning 'is a') and a label. ```Turtle my_node a my_disease ; label "My Node" . ``` -------------------------------- ### CSV Data Example Source: https://ontoweaver.readthedocs.io/en/latest/sections/mapping_api.html Example of a simple CSV table with phenotype and patient data. ```text phenotype,patient 0,A 1,B ``` -------------------------------- ### Typical Use Case: Multiple Sources, Auto Schema, and Import Source: https://ontoweaver.readthedocs.io/en/latest/sections/usage.html A comprehensive example weaving multiple data sources, automatically generating the schema, and running the import script in one command. ```bash ontoweave things.csv:map_things.yaml stuff-part*.parquet:map_stuff.yaml --auto-schema autoschema.yaml --import-script-run ``` -------------------------------- ### BioCypher Publication Example Source: https://ontoweaver.readthedocs.io/en/latest/sections/tutorials.html Example of a BioCypher publication entity with its properties. ```turtle :Pubmed%3A9876 a owl:NamedIndividual, biocypher:Publication ; rdfs:label "Pubmed:9876" ; biocypher:id "Pubmed:9876" ; biocypher:preferred_id "id" . ``` -------------------------------- ### Schema Configuration Example Source: https://ontoweaver.readthedocs.io/en/latest/sections/mapping_api.html Example of a schema configuration file defining node and edge types for Biolink ontology. ```yaml phenotypic feature: represented_as: node label_in_input: phenotype case: represented_as: node label_in_input: case case to phenotypic feature association: represented_as: edge label_in_input: case_to_phenotype source: phenotypic feature target: case ``` -------------------------------- ### Run Ontoweave Command with UV Source: https://ontoweaver.readthedocs.io/en/latest/sections/install.html Execute the ontoweave command-line tool using the UV environment manager after installing dependencies. ```bash uv run ontoweave ``` -------------------------------- ### Install OntoWeaver with pip Source: https://ontoweaver.readthedocs.io/en/latest/sections/install.html Install the OntoWeaver Python module from the Python Package Index using pip. For Debian-derived Linux systems, you might need to use sudo. ```bash pip install ontoweaver ``` ```bash sudo apt install python3-ontoweaver ``` -------------------------------- ### SimpleLabelMaker Multi-Type Dictionary Example Source: https://ontoweaver.readthedocs.io/en/latest/sections/user_made_transformers.html Illustrates the structure of the multi_type_dictionary processed by SimpleLabelMaker when no branching is involved. ```python multi_type_dictionary= { "None" : { 'to_object': patient, # The node class. Is normally a class object from ontoweaver.types. 'via_relation': patient_has_variant, # The edge class. Is normally a class object from ontoweaver.types. 'final_type': None # The final type of the node. In this case, None, because not defined in mapping above. 'reverse_relation': None # The reverse edge class. In this case, None, because not defined in mapping above. } } ``` -------------------------------- ### Example Mapping for MultiTypeLabelMaker Source: https://ontoweaver.readthedocs.io/en/latest/sections/user_made_transformers.html This YAML snippet demonstrates a mapping configuration that utilizes branching logic, which is handled by the MultiTypeLabelMaker. ```yaml transformers: - map: column: patient match: - B: to_object: patient via_relation: patient_has_variant - A: final_type: sickness to_object: disease via_relation: variant_to_disease - C: to_object: oncogenicity via_relation: variant_to_oncogenicity ``` -------------------------------- ### Detailed Node Fusion Step Example Source: https://ontoweaver.readthedocs.io/en/latest/sections/information_fusion.html Shows a detailed breakdown of a single fusion step, applying merge strategies (UseFirst, EnsureIdentical, Append) to combine properties from multiple nodes into one. ```text fuse.Members.merge \ ( ┌node1───────┐ ┌node2─────────┐ ) ┌node────────────┐ ( │ ID: BRCA2│ │ ID: BRCA2 │ ) ──────UseFirst─────▶│ ID: BRCA2 │ (┌key──────┐ │Label: gene │ │Label: gene │ ) ──EnsureIdenticals─▶│Label: gene │ (│BRCA2gene│,│Props: │,│Props: │ ) ───────Append──────▶│Props: │ (└─────────┘ │⎧ source: A⎫│ │⎧ source: B ⎫│ ) ┄┄┄┄{A}+{B}┄┄┄┄▷ │⎧ source: A,B ⎫│ ( │⎨version: 1⎬│ │⎨version: 2,3⎬│ ) ┄┄┄┄{1}+{2,3}┄┄▷ │⎨version: 1,2,3⎬│ ( │⎩ level: I⎭│ │⎩ level: I ⎭│ ) ┄┄┄┄{I}+{I}┄┄┄┄▷ │⎩ level: I ⎭│ ⎝ └────────────┘ └──────────────┘ ) └────────────────┘ ``` -------------------------------- ### Example OWL Ontology (Turtle Syntax) Source: https://ontoweaver.readthedocs.io/en/latest/sections/iterable_data.html A sample OWL ontology in Turtle syntax demonstrating classes, object properties, and data properties, along with named individuals. ```turtle @prefix : . @prefix owl: . @prefix rdf: . @prefix rdfs: . :thing a owl:Class ; rdfs:label "thing" . :source a owl:Class ; rdfs:subClassOf :thing ; rdfs:label "source" . :target a owl:Class ; rdfs:subClassOf :thing ; rdfs:label "target" . owl:ObjectProperty rdfs:subClassOf owl:thing . :link a owl:ObjectProperty ; rdfs:subClassOf :thing ; rdfs:label "link" . :prop a owl:DataProperty ; rdfs:subClassOf :thing ; rdfs:label "prop" . :S0 a :source ; a owl:NamedIndividual ; rdfs:label "S0" ; :link :T0 . :T0 a :target ; a owl:NamedIndividual ; rdfs:label "T0" ; :prop "data property" . ``` -------------------------------- ### Example of Node Merging Process Source: https://ontoweaver.readthedocs.io/en/latest/sections/information_fusion.html Illustrates the conceptual steps of merging three duplicated nodes into a single node using the defined fusion strategies. ```text congregate.duplicates() == ⎧ ⎡ ┌node1───────┐ ┌node2───────┐ ┌node4───────┐ ⎤ ⎫ ⎪ ⎢ │ ID: BRCA2│ │ ID: BRCA2│ │ ID: BRCA2│ ⎥ ⎪ ⎪ ⎢ │Label: gene │ │Label: gene │ │Label: gene │ ⎥ ⎪ ⎨"BRCA2gene": ⎢ │Props: │,│Props: │,│Props: │ ⎥ ⎬ ⎪ ⎢ │⎧ source: A⎫│ │⎧ source: B⎫│ │⎧ source: B⎫│ ⎥ ⎪ ⎪ ⎢ │⎨version: 1⎬│ │⎨version: 2⎬│ │⎨version: 3⎬│ ⎥ ⎪ ⎪ ⎢ │⎩ level: I⎭│ │⎩ level: I⎭│ │⎩ level: I⎭│ ⎥ ⎪ ⎩ ⎣ └────────────┘ └────────────┘ └────────────┘ ⎦ ⎭ ▲ ▲ │ │ └──────────────┘ │ FIRST Reduce step: │ merge node2 and node3 into node2. │ │ └──────────────┘ SECOND Reduce step: merge node1 and node2, one now have a single node. ``` -------------------------------- ### Full YAML Example with Input and Output Validation Source: https://ontoweaver.readthedocs.io/en/latest/sections/data_validation.html A comprehensive YAML configuration including data mapping, input data validation, and output data validation rules for 'variant_id' and 'patient' columns. ```yaml row: rowIndex: to_subject: variant validate_output: checks: isin: value: - '0' - '1' - '2' - '3' transformers: - map: columns: - patient to_object: patient via_relation: patient_has_variant validate_output: checks: isin: value: - A - B - C validate: columns: variant_id: dtype: int64 checks: in_range: min_value: 0 max_value: 3 include_min: true include_max: true patient: dtype: str checks: isin: value: - A - B - C ``` -------------------------------- ### Sample Data in CSV Format Source: https://ontoweaver.readthedocs.io/en/latest/sections/tutorials.html Example of a CSV file containing patient and sample information, including gene alterations and metadata. Ensure correct formatting for all fields. ```csv Patient,Sample_location,Sample_ID,Gene,Type,Location,Impact,Metadata,Sources Albert,Liver,1,brca1,SNP,Chr1_23_A>G,Oncogenic,"{\"ref\":\"A\", \"date\":\"2026-02-15\"}","Pubmed:12345,DOI:abc_123" Albert,Liver,2,brca2,SNP,Chr2_34_G>C,Likely oncogenic,"{\"ref\":\"B\", \"date\":\"2026-02-15\"}", Albert,Liver,3,CLOCK,SNP,Chr4_56_A>C,Not oncogenic,"{\"ref\":\"A\", \"date\":\"2026-02-15\"}",Pubmed:9876 Josette,Prostate,1,brca2,CNV,Chr2,Likely oncogenic,"{\"ref\":\"C\", \"date\":\"2026-02-15\"}",DOI:azr_987 Josette,Prostate,2,brca2,SNP,Chr2_34_G>C,Likely oncogenic,"{\"ref\":\"C\", \"date\":\"2026-02-15\"}","DOI:abc_123,Pubmed:9876" ``` -------------------------------- ### HTML Table Structure Source: https://ontoweaver.readthedocs.io/en/latest/sections/iterable_data.html Example of an HTML page containing a table with a caption, header, and body rows. ```html
Friends
variant_idpatientage
1B12
0A23
2C34
``` -------------------------------- ### JSON Data Structure Example Source: https://ontoweaver.readthedocs.io/en/latest/sections/iterable_data.html A sample JSON document containing an array of objects, each representing a record with variant, patient, and age information. ```json { "data": [ {"variant": 0, "patient": "A", "age": 12 }, {"variant": 1, "patient": "B", "age": 23 }, {"variant": 2, "patient": "C", "age": 34 } ] } ``` -------------------------------- ### Add Multiple Properties to Multiple Node Types Source: https://ontoweaver.readthedocs.io/en/latest/sections/how_to.html This example demonstrates adding the same property values to several property fields across different node types. ```yaml - map: column: age to_properties: - patient_age - age_patient for_object: - case - phenotype ``` -------------------------------- ### Custom Transformer with On-the-Fly Property Declaration Source: https://ontoweaver.readthedocs.io/en/latest/sections/how_to.html This example demonstrates how to declare node, edge, and property types within a custom transformer. It shows how to initialize the transformer and process rows to dynamically set node properties. ```python from ontoweaver import transformer, validate from ontoweaver import types as owtypes from ontoweaver import base class MyTransformer(base.Transformer): """Custom end-user transformer.""" def __init__(self, properties_of, value_maker = None, label_maker = None, branching_properties = None, columns=None, output_validator: validate.OutputValidator = None, multi_type_dict = None, raise_errors = True, **kwargs): super().__init__(properties_of, value_maker, label_maker, branching_properties, columns, output_validator, multi_type_dict, raise_errors=raise_errors, **kwargs) # First declare all node and edge classes needed for your mapping. The declaration is done by using the # `declare_types` member variable, which is an instance of the ``ontoweaver.base.Declare`` class. Node classes are # declared by using the `` self.declare_types.make_node_class`` function. We first declare the name of the # possible source and target node classes (``my_source_node_class``, ``my_target_node_class``, ``another_node_class"``). # Then we extract the properties of those node classes from the `branching_properties` member variable, which is a dictionary # containing all the properties defined in the mapping file for each node and edge class (``self.branching_properties.get("my_source_node_class", {}) # ``). self.declare_types.make_node_class("my_source_node_class", self.branching_properties.get("my_source_node_class", {})) self.declare_types.make_node_class("my_target_node_class", self.branching_properties.get("my_target_node_class", {})) self.declare_types.make_node_class("another_node_class", self.branching_properties.get("another_node_class", {})) # Edge classes are declared by using the `` self.declare_types.make_edge_class`` function. Again, we declare the # name of the edge class (``my_edge_class``) and the source and target node classes it connects. These are # retrieved by using the ``getattr`` function on the ``types`` module, which contains all the declared types in the ontology, as # well as the node classes we just declared above (``getattr(owtypes, "my_source_node_class")``) . # Finally, we extract the properties of the edge class from the ``branching_properties`` member variable # (``self.branching_properties.get("my_edge_class", {}) # ``) self.declare_types.make_edge_class("my_edge_class", getattr(owtypes, "my_source_node_class"), getattr(owtypes, "my_target_node_class"), self.branching_properties.get("my_edge_class", {})) def __call__(self, row, i): # Initialize final type and properties_of member variables to ``None`` for each row processed. This is beacuase # the final type and properties may change depending on the values extracted from the current row. self.final_type = None self.properties_of = None # Extract branching information from the current row, as well as node ID. We branch based on the values of the # ``type`` and ``entity_type_target`` columns. node_id = row["target"] relationship_type = row["type"] entity = row["entity_type_target"] # Here we extract the value of the property key column. property_key = row["property_key"] # Create branching logic and return correct elements. Elements are returned by using the ``yield`` statement, # which yields a tuple containing the node ID, edge type, target node type, and reverse edge type (if any). # At each step we can additionally set the ``final_type`` (See ``How to`` section for more details on ``final_type``) and # ``properties_of`` member variables, which will be used to extract properties for the current node. if relationship_type == "my_relationship_type": if entity == "my_entity_type": self.final_type = # Possible to set final type if feature is needed. # We then declare a property transformer on-the-fly within the ``properties_of`` member variable. # setting ``property_key`` as the property name, and the ``property_value`` column as the property value # to be extracted. self.properties_of = { property_key: "property_value" } ``` -------------------------------- ### Ambiguous Mapping Example in OntoWeaver Source: https://ontoweaver.readthedocs.io/en/latest/sections/mapping_api.html This example demonstrates an ambiguous mapping scenario where multiple items could potentially be mapped to the 'drug' type, leading to uncertainty about property attachment. ```yaml row: map: column: id to_subject: drug transformers: - map: column: parentId to_object: drug # Ambiguous! via_relation: subclass_of - split: column: childChemblIds # A numpy array of drugs. to_object: drug # Ambiguous! via_relation: superclass_of - map: column: name to_property: drugName for_object: drug # Ambiguous: which one of the (more than) 3 created items? ``` -------------------------------- ### PandasAdapter Row Iteration Source: https://ontoweaver.readthedocs.io/en/latest/sections/processing.html Example implementation of an adapter for Pandas DataFrames, utilizing the DataFrame's `iterrows` method for iteration. ```python class PandasAdapter(ontoweaver.iterative.IterativeAdapter): def __init__(self, df): self.df = df def iterate(self); # Pandas provides this function that is a generator consuming rows: return self.df.iterrows() ``` -------------------------------- ### Mapping CSV to Knowledge Graph (Beginner) Source: https://ontoweaver.readthedocs.io/en/latest/sections/introductions.html Defines how to map columns from a CSV file to nodes and edges in a knowledge graph using a YAML mapping file. This example shows a simple mapping for disease-drug relationships. ```yaml row: # The meaning of a row in the input CSV file. map: column: DISEASE # The name of a a column in your table. to_subject: disease # The type used in the ontology. transformers: # How to map cells to nodes and edges. - map: # Map a column to a node. column: DRUG to_object: drug via_relation: treatable_by # The type of link between diseases and drugs in the ontology. ``` -------------------------------- ### Example of Node Reconciliation Source: https://ontoweaver.readthedocs.io/en/latest/sections/information_fusion.html Demonstrates how `fusion.reconciliate` merges nodes with the same identifier and type. Conflicting properties are aggregated into a single value, separated by a delimiter. ```python # From source A: # ("id_1", "type_A", {"prop_1": "x"}), # ("id_1", "type_A", {"prop_2": "y"}), # From source B: # ("id_1", "type_A", {"prop_1": "z"}) # Result of reconciliation: # Note how "x" and "z" are separated by reconciliate_sep=";". # ("id_1", "type_A", {"prop_1": "x;z", "prop_2": "y"}) ``` -------------------------------- ### Detecting Duplicate Nodes with IDLabel Serializer Source: https://ontoweaver.readthedocs.io/en/latest/sections/information_fusion.html Demonstrates how to use the IDLabel serializer and Nodes congregater to find duplicate nodes. The example shows the process of generating keys from nodes and then identifying duplicates based on these keys. ```python nodes == ⎡ ┌node1───────┐ ┌node2───────┐ ┌node3───────┐ ┌node4───────┐ ⎤ ⎢ │ ID: BRCA2┼┐ │ ID: BRCA2┼┐ │ ID: BRCA2┼┐ │ ID: BRCA2┼┐ ⎥ ⎢ │Label: gene ┼┤ │Label: gene ┼┤ │Label: prot ┼┤ │Label: gene ┼┤ ⎥ ⎢ │Props: ││,│Props: ││,│Props: ││,│Props: ││ ⎥ ⎢ │⎧ source: A⎫││ │⎧ source: B⎫││ │⎧ source: B⎫││ │⎧ source: B⎫││ ⎥ ⎢ │⎨version: 1⎬││ │⎨version: 2⎬││ │⎨version: 2⎬││ │⎨version: 3⎬││ ⎥ ⎢ │⎩ level: I⎭││ │⎩ level: I⎭││ │⎩ level:II⎭││ │⎩ level: I⎭││ ⎥ ⎣ └────────────┘│ └────────────┘│ └────────────┘│ └────────────┘│ ⎦ │ │ │ │ >>> on_IDLabel = ontoweaver.serialize.IDLabel() │ >>> for n in nodes: │ │ │ >>> on_IDLabel(n) │ │ │ │ │ │ │ ▼ ▼ ▼ ▼ keys = ["BRCA2gene" , "BRCA2gene" , "BRCA2prot" , "BRCA2gene"] └───┬────────────────────────────────────────────────────────────────┘ │ │ >>> congregate = ontoweaver.congregate.Nodes(on_IDlabel) │ >>> congregate(nodes) │ ▼ congregate.duplicates() == ⎧ ⎡ ┌node1───────┐ ┌node2───────┐ ┌node4───────┐ ⎤ ⎫ ⎪ ⎢ │ ID: BRCA2│ │ ID: BRCA2│ │ ID: BRCA2│ ⎥ ⎪ ⎪ ⎢ │Label: gene │ │Label: gene │ │Label: gene │ ⎥ ⎪ ⎪"BRCA2gene": ⎢ │Props: │,│Props: │,│Props: │ ⎥ ⎪ ⎪ ⎢ │⎧ source: A⎫│ │⎧ source: B⎫│ │⎧ source: B⎫│ ⎥ ⎪ ⎪ ⎢ │⎨version: 1⎬│ │⎨version: 2⎬│ │⎨version: 3⎬│ ⎥ ⎪ ⎪ ⎢ │⎩ level: I⎭│ │⎩ level: I⎭│ │⎩ level: I⎭│ ⎥ ⎪ ⎪ ⎣ └────────────┘ └────────────┘ └────────────┘ ⎦ ⎪ ⎨ , ⎬ ⎪ ⎡ ┌node3───────┐ ⎤ ⎪ ⎪ ⎢ │ ID: BRCA2│ ⎥ ⎪ ⎪ ⎢ │Label: prot │ ⎥ ⎪ ⎪"BRCA2prot": ⎢ │Props: │ ⎥ ⎪ ⎪ ⎢ │⎧ source: B⎫│ ⎥ ⎪ ⎪ ⎢ │⎨version: 2⎬│ ⎥ ⎪ ⎪ ⎢ │⎩ level:II⎭│ ⎥ ⎪ ⎩ ⎣ └────────────┘ ⎦ ⎭ ``` -------------------------------- ### Ontology Definition in TTL Format Source: https://ontoweaver.readthedocs.io/en/latest/sections/tutorials.html Example of a TTL file defining namespaces, classes, and properties for a biological ontology. Ensure all types have labels and appropriate subclass relationships. ```turtle # Namespaces: @prefix : @prefix owl: @prefix rdfs: @prefix biocypher: ####################################################### # The "taxonomy" part of the ontology # (sometimes called the "vocabulary") ####################################################### # We need a base root to which to attach all types. # Because we allow to assemble type hierarchy trees. biocypher:BioCypherRoot a rdfs:Class ; # `a` means the same than `rdf:type`. rdfs:label "BioCypherRoot" . # Classical types, serving ase bases. owl:thing a rdfs:Class ; # Type for nodes. rdfs:label "thing" ; # Note how labels are lowercased. rdfs:subClassOf biocypher:BioCypherRoot . :association a owl:ObjectProperty ; # Type for edges. rdfs:label "association" ; rdfs:subPropertyOf biocypher:BioCypherRoot . # Our own node types, inheriting from the others: :patient a rdfs:Class ; # a Class = is a typed node. rdfs:label "patient" ; rdfs:subClassOf owl:thing . :sample a rdfs:Class ; rdfs:label "sample" ; rdfs:subClassOf owl:thing . :gene a rdfs:Class ; rdfs:label "gene" ; rdfs:subClassOf owl:thing . :alteration a rdfs:Class ; rdfs:label "alteration" ; rdfs:subClassOf owl:thing . :publication a rdfs:Class ; rdfs:label "publication" ; rdfs:subClassOf owl:thing . :effect a rdfs:Class ; rdfs:label "effect" ; rdfs:subClassOf owl:thing . # Our own edge types: :insample a owl:ObjectProperty ; rdfs:label "insample" ; rdfs:subPropertyOf :association . :hasalteration a owl:ObjectProperty ; rdfs:label "hasalteration" ; rdfs:subPropertyOf :association . :ongene a owl:ObjectProperty ; rdfs:label "ongene" ; rdfs:subPropertyOf :association . :knownhas a owl:ObjectProperty ; rdfs:label "knownhas" ; rdfs:subPropertyOf :association . :publishedin a owl:ObjectProperty ; rdfs:label "publishedin" ; rdfs:subPropertyOf :association . :knownas a owl:ObjectProperty ; rdfs:label "knownas" ; rdfs:subPropertyOf :association . ``` -------------------------------- ### SQL Counterpart for Drug Sensitivity Query Source: https://ontoweaver.readthedocs.io/en/latest/sections/intro_SKG.html This SQL query achieves the same result as the GQL example, showing the contrast between SKG and relational database querying. It assumes a specific database schema where parent types are aggregated in a string. ```SQL SELECT d.label FROM Drug d JOIN Disease s ON s.sensitive_to = d.id WHERE s.type LIKE "%Sleep disorder%" -- Assuming that the "type" columns aggregates all parent types in a string. ``` -------------------------------- ### BioCypher TTL Output Example Source: https://ontoweaver.readthedocs.io/en/latest/sections/tutorials.html This snippet shows the Turtle (TTL) representation of various biological entities including publications, samples, and mutations. It defines classes, properties, and individual instances with their relationships. ```turtle @prefix : . @prefix biocypher: . @prefix owl: . @prefix rdfs: . @prefix xsd: . :publication a rdfs:Class ; rdfs:label "publication" ; rdfs:subClassOf owl:thing . :sample a rdfs:Class ; rdfs:label "sample" ; rdfs:subClassOf owl:thing . :CLOCK_SNP_Chr4_56_A%3EC a owl:NamedIndividual, biocypher:Mutation ; rdfs:label "CLOCK_SNP_Chr4_56_A>C" ; biocypher:id "CLOCK_SNP_Chr4_56_A>C" ; biocypher:preferred_id "id" ; :hasalteration :Albert ; :insample :Liver3 ; :ongene :clock ; :publishedin :Pubmed%3A9876 . :brca1_SNP_Chr1_23_A%3EG a owl:NamedIndividual, biocypher:Mutation ; rdfs:label "brca1_SNP_Chr1_23_A>G" ; biocypher:id "brca1_SNP_Chr1_23_A>G" ; biocypher:preferred_id "id" ; :hasalteration :Albert ; :insample :Liver1 ; :ongene :brca1 ; :publishedin :Pubmed%3A12345%2CDOI%3Aabc_123 . :brca2_CNV_Chr2 a owl:NamedIndividual, biocypher:CopyNumberVariation ; rdfs:label "brca2_CNV_Chr2" ; biocypher:id "brca2_CNV_Chr2" ; biocypher:preferred_id "id" ; :hasalteration :Josette ; :insample :Prostate1 ; :ongene :brca2 ; :publishedin :DOI%3Aazr_987 . :brca2_SNP_Chr2_34_G%3EC a owl:NamedIndividual, biocypher:Mutation ; rdfs:label "brca2_SNP_Chr2_34_G>C" ; biocypher:id "brca2_SNP_Chr2_34_G>C" ; biocypher:preferred_id "id" ; :hasalteration :Albert, :Josette ; :insample :Liver2, :Prostate2 ; :ongene :brca2 ; :publishedin :DOI%3Aabc_123%2CPubmed%3A9876 . :hasalteration a owl:ObjectProperty ; rdfs:label "hasalteration" ; rdfs:sub@prefix : . owl:thing a rdfs:Class ; rdfs:label "thing" ; rdfs:subClassOf biocypher:BioCypherRoot . biocypher:BioCypherRoot a rdfs:Class ; rdfs:label "BioCypherRoot" . :alteration a rdfs:Class ; rdfs:label "alteration" ; rdfs:subClassOf owl:thing . :effect a rdfs:Class ; rdfs:label "effect" ; rdfs:subClassOf owl:thing . :gene a rdfs:Class ; rdfs:label "gene" ; rdfs:subClassOf owl:thing . :patient a rdfs:Class ; rdfs:label "patient" ; rdfs:subClassOf owl:thing . PropertyOf :association . :insample a owl:ObjectProperty ; rdfs:label "insample" ; rdfs:subPropertyOf :association . :knownas a owl:ObjectProperty ; rdfs:label "knownas" ; rdfs:subPropertyOf :association . :knownhas a owl:ObjectProperty ; rdfs:label "knownhas" ; rdfs:subPropertyOf :association . :ongene a owl:ObjectProperty ; rdfs:label "ongene" ; rdfs:subPropertyOf :association . :publishedin a owl:ObjectProperty ; rdfs:label "publishedin" ; rdfs:subPropertyOf :association . biocypher:CopyNumberVariation a biocypher:Alteration . :DOI%3Aabc_123%2CPubmed%3A9876 a owl:NamedIndividual, biocypher:Publication ; rdfs:label "DOI:abc_123,Pubmed:9876" ; biocypher:id "DOI:abc_123,Pubmed:9876" ; biocypher:preferred_id "id" . :DOI%3Aazr_987 a owl:NamedIndividual, biocypher:Publication ; rdfs:label "DOI:azr_987" ; biocypher:id "DOI:azr_987" ; biocypher:preferred_id "id" . a owl:NamedIndividual, biocypher:Effect ; rdfs:label "Likely oncogenic" ; biocypher:id "Likely oncogenic" ; biocypher:preferred_id "id" . :Liver1 a owl:NamedIndividual, biocypher:Sample ; rdfs:label "Liver1" ; xsd:date "2026-02-15" ; biocypher:id "Liver1" ; biocypher:preferred_id "id" . :Liver2 a owl:NamedIndividual, biocypher:Sample ; rdfs:label "Liver2" ; xsd:date "2026-02-15" ; biocypher:id "Liver2" ; biocypher:preferred_id "id" . :Liver3 a owl:NamedIndividual, biocypher:Sample ; rdfs:label "Liver3" ; xsd:date "2026-02-15" ; biocypher:id "Liver3" ; biocypher:preferred_id "id" . a owl:NamedIndividual, biocypher:Effect ; rdfs:label "Not oncogenic" ; biocypher:id "Not oncogenic" ; biocypher:preferred_id "id" . :Oncogenic a owl:NamedIndividual, biocypher:Effect ; rdfs:label "Oncogenic" ; biocypher:id "Oncogenic" ; biocypher:preferred_id "id" . :Prostate1 a owl:NamedIndividual, biocypher:Sample ; rdfs:label "Prostate1" ; xsd:date "2026-02-15" ; biocypher:id "Prostate1" ; biocypher:preferred_id "id" . :Prostate2 a owl:NamedIndividual, biocypher:Sample ; rdfs:label "Prostate2" ; xsd:date "2026-02-15" ; biocypher:id "Prostate2" ; biocypher:preferred_id "id" . :Pubmed%3A12345%2CDOI%3Aabc_123 a owl:NamedIndividual, biocypher:Publication ; rdfs:label "Pubmed:12345,DOI:abc_123" ; biocypher:id "Pubmed:12345,DOI:abc_123" ; biocypher:preferred_id "id" . ``` -------------------------------- ### Ontoweaver Transformer 'from_subject' Clause Examples Source: https://ontoweaver.readthedocs.io/en/latest/sections/FAQ.html Illustrates various use cases of the 'from_subject' clause in Ontoweaver transformers, including linking to objects defined in 'to_object' clauses, matching specific subject types, and linking to nodes created by preceding transformers. ```yaml row: map: id_from_column: source match_type_from_column: entity_type match: - protein: to_subject: protein - complex: to_subject: complex transformers: - map: column: role to_object: role via_relation: has_role - map: column: effect from_subject: role # From the transformer just above. to_object: effect via_relation: has_effect - path_directed # Outputs a `target_protein`. MUST BE BEFORE THE NEXT ONE. - map: column: target_genesymbol from_subject: target_protein # Links toward path_directed's target_protein. to_object: target_gene via_relation: transcript_to_gene_relationship - map: column: complex_involved_in from_subject: complex # Only create nodes if the current row outputs this subject. to_object: complex_involved_in via_relation: has_involvement ``` -------------------------------- ### Schema Extension in YAML Source: https://ontoweaver.readthedocs.io/en/latest/sections/tutorials.html Example of a YAML file used to extend an existing ontology schema. This allows defining new types or modifying existing ones without altering the main ontology file. ```yaml # This "schema*"file mainly serves to define what types you are using. # In the simplest case (like here), it allows to *extend* the ontology. # We want to manually extend the taxonomy, # without touching to the ontology file # (which may be maintained by some other expert). mutation: # Add this class... is_a: alteration # ... as a subClassOf this one. copyNumberVariation: is_a: alteration # We could have defined a lot more things here (see BioCyoher's documentation), # but we will let OntoWeaver automatically extend this schema to a complete one. ``` -------------------------------- ### BioCypher Patient Example Source: https://ontoweaver.readthedocs.io/en/latest/sections/tutorials.html Example of a BioCypher patient entity. ```turtle :Josette a owl:NamedIndividual, biocypher:Patient ; rdfs:label "Josette" ; biocypher:id "Josette" ; biocypher:preferred_id "id" . ``` -------------------------------- ### Display OntoWeaver Help Source: https://ontoweaver.readthedocs.io/en/latest/sections/usage.html Run this command to see all available options and commands for OntoWeaver. ```bash ontoweave --help ``` -------------------------------- ### Running OntoWeaver with Multiple Files and Import Source: https://ontoweaver.readthedocs.io/en/latest/sections/introductions.html Command to process multiple data files with their respective mappings and import the generated SKG into a graph database. ```bash ontoweave my_data.csv:my_mapping.yaml other_data.tsv:my_mapping.yaml --run-import-file ``` -------------------------------- ### BioCypher Patient Example (Albert) Source: https://ontoweaver.readthedocs.io/en/latest/sections/tutorials.html Another example of a BioCypher patient entity. ```turtle :Albert a owl:NamedIndividual, biocypher:Patient ; rdfs:label "Albert" ; biocypher:id "Albert" ; biocypher:preferred_id "id" . ``` -------------------------------- ### BioCypher Gene Example (Not Oncogenic) Source: https://ontoweaver.readthedocs.io/en/latest/sections/tutorials.html Example of a BioCypher gene entity marked as Not oncogenic. ```turtle :clock a owl:NamedIndividual, biocypher:Gene ; rdfs:label "clock" ; biocypher:id "clock" ; biocypher:locations "Chr4:56:A>C" ; biocypher:oncogenicity "Not oncogenic" ; biocypher:preferred_id "id" ; :knownas . ``` -------------------------------- ### Manual OntoWeaver Workflow Source: https://ontoweaver.readthedocs.io/en/latest/sections/processing.html Demonstrates a manual workflow for loading data, parsing a YAML mapping, and running an adapter. Requires registering transformers and opening files. ```python import ontoweaver import yaml # Register all the transformers in your dedicated module: ontoweaver.transformer.register_all( my_module_path ) datafile = "path/to/my/file.csv" mappingfile = "path/to/my/mapping.yaml" # Load the data. loader = ontoweaver.loader.LoadPandasFile() # For CSVs. data = loader([filename]) # Load the YAML mapping. with open(mappingfile, 'r') as fd: config = yaml.full_load(fd) # Instantiate the parser. parser = ontoweaver.mapping.YamlParser(config) # Run the parser. mapper = parser() # Instantiate the related adapter ``` -------------------------------- ### BioCypher Gene Example (Oncogenic) Source: https://ontoweaver.readthedocs.io/en/latest/sections/tutorials.html Example of a BioCypher gene entity marked as Oncogenic. ```turtle :brca1 a owl:NamedIndividual, biocypher:Gene ; rdfs:label "brca1" ; biocypher:id "brca1" ; biocypher:locations "Chr1:23:A>G" ; biocypher:oncogenicity "Oncogenic" ; biocypher:preferred_id "id" ; :knownas :Oncogenic . ``` -------------------------------- ### Running OntoWeaver Command (Beginner) Source: https://ontoweaver.readthedocs.io/en/latest/sections/introductions.html Command to execute OntoWeaver for transforming data using a specified CSV file and its corresponding mapping file. ```bash ontoweave my_data.csv:my_mapping.yaml ``` -------------------------------- ### BioCypher Gene Example (Likely Oncogenic) Source: https://ontoweaver.readthedocs.io/en/latest/sections/tutorials.html Example of a BioCypher gene entity marked as Likely oncogenic. ```turtle :brca2 a owl:NamedIndividual, biocypher:Gene ; rdfs:label "brca2" ; biocypher:id "brca2" ; biocypher:locations "Chr2;Chr2:34:G>C" ; biocypher:oncogenicity "Likely oncogenic" ; biocypher:preferred_id "id" ; :knownas . ``` -------------------------------- ### Run OntoWeaver with a Mapping File Source: https://ontoweaver.readthedocs.io/en/latest/sections/iterable_data.html Execute OntoWeaver to process an OWL ontology using a specified mapping file. Ensure the mapping file is correctly referenced. ```bash ontoweave my_ontology.ttl:my_mapping.yaml ``` -------------------------------- ### Instantiate and Configure Node Merging Strategies Source: https://ontoweaver.readthedocs.io/en/latest/sections/information_fusion.html Instantiates merge strategies for node properties like ID, label, and properties. UseUseFirst for IDs, EnsureIdentical for labels, and Append for property dictionaries. ```python use_first = merge.string.UseFirst() # Instantiation. identicals = merge.string.EnsureIdentical() in_lists = merge.dictry.Append(reconciliate_sep) ``` -------------------------------- ### Map Transformer for Node Mapping Source: https://ontoweaver.readthedocs.io/en/latest/sections/mapping_api.html Example of the 'map' transformer to extract a column's value and map it to a specific object type. ```yaml - map: column: patient to_object: case ``` -------------------------------- ### Map Transformer for Property Mapping Source: https://ontoweaver.readthedocs.io/en/latest/sections/mapping_api.html Example of the 'map' transformer used to map a column's value to a property of specified node or edge types. ```yaml - map: column: version to_property: version for_objects: - patient # Node type. - variant - patient_has_variant # Edge type. ``` -------------------------------- ### Instantiating Serializers and Congregaters Source: https://ontoweaver.readthedocs.io/en/latest/sections/information_fusion.html Shows how to instantiate serializer objects (like ID) and congregater objects (like Nodes) for processing nodes. This is a prerequisite for detecting duplicates. ```python on_ID = serialize.ID() # Instantiation. congregater = congregate.Nodes(on_ID) # Instantiation. congregater(my_nodes) # Actual processing call. # congregarter now holds a dictionary of duplicated nodes. ``` -------------------------------- ### Instantiate and Apply Node Fusioner Source: https://ontoweaver.readthedocs.io/en/latest/sections/information_fusion.html Instantiates a Reduce object with the configured node fusioner and applies it to a collection of duplicate nodes. ```python fusioner = Reduce(fuser) # Instantiation. fusioned_nodes = fusioner(congregater) # Call on the previously found duplicates. ``` -------------------------------- ### Resolving Ambiguity with final_type in OntoWeaver Source: https://ontoweaver.readthedocs.io/en/latest/sections/mapping_api.html This example shows how to use the `final_type` keyword to resolve mapping ambiguity by defining temporary types and a final, definitive type for objects. ```yaml row: map: column: id to_subject: row_drug final_type: drug transformers: - map: column: parentId to_object: parent_drug final_type: drug via_relation: subclass_of - split: column: childChemblIds to_object: child_drug final_type: drug via_relation: superclass_of - map: column: name to_property: drugName # Here we need row_drug, or else we wouldn't know # to which drug to map this property: for_object: row_drug ```