<jupyter_start><jupyter_text>Biolink Lookup  IntroductionThe Biolink Model defines a set of common concepts for use in Translator.  These include semantic types for entities, as well as the relations between them.  These concepts are organized into an inheritance hierarchy capturing different granularities of description. Furthermore, each concept contains metadata relating the concept to ontologies.The Biolink Model is formally maintained in Github [here](http://github.com/biolink/biolink-model/).  The Biolink Lookup [service](https://bl-lookup-sri.renci.org/apidocs/) provides a computational interface to the model, including access to previous versions.   When the service is deployed, it queries the Biolink Github repository, and updates itself to access the latest version.  VersionsBecause the service allows access to multiple versions of Biolink, this function returns the list of versions that can passed as a parameter to subsequent calls.  In principle there may be versions such as: * **latest** which always points to the current master branch.* **1.3.9** a previous version* **custom** which is a special tag pointing at a branch of the model.<jupyter_code>import requests
import json
response = requests.get('https://bl-lookup-sri.renci.org/versions/')
print(json.dumps(response.json(),indent=2))<jupyter_output>[
  "1.3.9",
  "1.4.0",
  "1.5.0",
  "1.6.0",
  "1.7.0",
  "1.8.0",
  "latest"
]<jupyter_text>Concept LookupBiolink concepts can be retrieved to inspect their properties:<jupyter_code>response = requests.get('https://bl-lookup-sri.renci.org/bl/chemical_substance')
print( json.dumps(response.json (),indent = 2 ))<jupyter_output>{
  "name": "chemical substance",
  "id_prefixes": [
    "PUBCHEM.COMPOUND",
    "CHEMBL.COMPOUND",
    "UNII",
    "CHEBI",
    "DRUGBANK",
    "MESH",
    "CAS",
    "DrugCentral",
    "GTOPDB",
    "HMDB",
    "KEGG.COMPOUND",
    "ChemBank",
    "Aeolus",
    "PUBCHEM.SUBSTANCE",
    "SIDER.DRUG",
    "INCHI",
    "INCHIKEY",
    "KEGG.GLYCAN",
    "KEGG.DRUG",
    "KEGG.DGROUP",
    "KEGG.ENVIRON"
  ],
  "definition_uri": "https://w3id.org/biolink/vocab/ChemicalSubstance",
  "aliases": [],
  "mappings": [],
  "description": "May be a chemical entity or a formulation with a chemical entity as active ingredient, or a complex material with multiple chemical entities as part",
  "alt_descriptions": {},
  "deprecated": null,
  "todos": [],
  "notes": [],
  "comments": [],
  "examples": [],
  "in_subset": [
    "model_organism_database"
  ],
  "from_schema": "https://w3id.org/biolink/biolink-model",
  "imported_from": null,
  "see_also": [],
  "exact_mappings": [
    "SIO:010004",
    "[...]<jupyter_text>We can look up semantic types, as above, but we can also look up predicates (slot names):<jupyter_code>response = requests.get('https://bl-lookup-sri.renci.org/bl/causes')
print( json.dumps(response.json (),indent = 2 ))<jupyter_output>{
  "name": "causes",
  "id_prefixes": [],
  "definition_uri": "https://w3id.org/biolink/vocab/causes",
  "aliases": [],
  "mappings": [],
  "description": "holds between two entities where the occurrence, existence, or activity of one causes the occurrence or generation of the other",
  "alt_descriptions": {},
  "deprecated": null,
  "todos": [],
  "notes": [],
  "comments": [],
  "examples": [],
  "in_subset": [
    "translator_minimal"
  ],
  "from_schema": "https://w3id.org/biolink/biolink-model",
  "imported_from": null,
  "see_also": [],
  "exact_mappings": [
    "RO:0002506",
    "SEMMEDDB:CAUSES",
    "SEMMEDDB:causes",
    "WIKIDATA_PROPERTY:P1542",
    "SNOMED:cause_of"
  ],
  "close_mappings": [],
  "related_mappings": [],
  "narrow_mappings": [
    "MONDO:disease_triggers",
    "GOREL:0000040",
    "MONDO:disease_causes_feature",
    "MONDO:disease_triggers",
    "NCIT:allele_has_abnormality",
    "NCIT:biological_process_has_result_biological_process",
    "NCIT:chemical_o[...]<jupyter_text>The query terms are relatively flexible.  Snake case (such as "process_negatively_regulates_process") will work, as will the unfixed names ("process negatively regulates process")<jupyter_code>response = requests.get('https://bl-lookup-sri.renci.org/bl/process negatively regulates process')
print( json.dumps(response.json (),indent = 2 ))
response = requests.get('https://bl-lookup-sri.renci.org/bl/process_negatively_regulates_process')
print( json.dumps(response.json (),indent = 2 ))<jupyter_output>{
  "name": "process negatively regulates process",
  "id_prefixes": [],
  "definition_uri": "https://w3id.org/biolink/vocab/process_negatively_regulates_process",
  "aliases": [],
  "mappings": [],
  "description": null,
  "alt_descriptions": {},
  "deprecated": null,
  "todos": [],
  "notes": [],
  "comments": [],
  "examples": [],
  "in_subset": [],
  "from_schema": "https://w3id.org/biolink/biolink-model",
  "imported_from": null,
  "see_also": [],
  "exact_mappings": [
    "RO:0002212"
  ],
  "close_mappings": [],
  "related_mappings": [],
  "narrow_mappings": [],
  "broad_mappings": [],
  "deprecated_element_has_exact_replacement": null,
  "deprecated_element_has_possible_replacement": null,
  "extensions": [],
  "annotations": [],
  "is_a": "process regulates process",
  "abstract": null,
  "mixin": null,
  "mixins": [
    "negatively regulates"
  ],
  "apply_to": [],
  "values_from": [],
  "created_by": null,
  "created_on": null,
  "last_updated_on": null,
  "modified_by": nul[...]<jupyter_text>Slot LookupSlots can be identified in Biolink by the `slot_uri` property, but also by `mappings` (for versions before 1.4) or `exact_mappings` for versions >= 1.4.0.  The following function takes an IRI and checks both properties to find a match.<jupyter_code>response = requests.get('https://bl-lookup-sri.renci.org/uri_lookup/RO:0002449')
print( json.dumps(response.json (),indent = 2 ))<jupyter_output>[
  {
    "mapping_type": "exact",
    "mapping": "biolink:entity_negatively_regulates_entity"
  }
]<jupyter_text>Ancestors and DescendantsConcepts (types and properties) can have superclasses (ancestors) and subclasses (descendants), which can be queried for by entity name.  In addition, the `lineage` function will return both ancestors and descendants.  The returns are the URIs for the entities.<jupyter_code>response = requests.get('https://bl-lookup-sri.renci.org/bl/genomic_entity/ancestors')
print( json.dumps(response.json (),indent = 2 ))
response = requests.get('https://bl-lookup-sri.renci.org/bl/genomic_entity/descendants')
print( json.dumps(response.json (),indent = 2 ))
response = requests.get('https://bl-lookup-sri.renci.org/bl/genomic_entity/lineage')
print( json.dumps(response.json (),indent = 2 ))<jupyter_output>[
  "biolink:MolecularEntity",
  "biolink:BiologicalEntity",
  "biolink:NamedThing",
  "biolink:Entity",
  "biolink:GenomicEntity",
  "biolink:Gene",
  "biolink:SequenceVariant",
  "biolink:Snv",
  "biolink:Genotype",
  "biolink:Transcript",
  "biolink:RNAProduct",
  "biolink:RNAProductIsoform",
  "biolink:NoncodingRNAProduct",
  "biolink:GenomicBackgroundExposure",
  "biolink:ReagentTargetedGene",
  "biolink:Protein",
  "biolink:ProteinIsoform",
  "biolink:Haplotype",
  "biolink:Exon",
  "biolink:Genome",
  "biolink:CodingSequence"
]<jupyter_text>Any of these calls can be parameterized by version, with `latest` being used by default.  This example shows how to use a different version, in this case `1.3.9`.  Note that in the response, the `biolink:Entity` category is not returned, because this category was added in version 1.4.0.<jupyter_code>response = requests.get('https://bl-lookup-sri.renci.org/bl/chemical_substance/ancestors?version=1.3.9')
print( json.dumps(response.json (),indent = 2 ))<jupyter_output>[
  "biolink:MolecularEntity",
  "biolink:BiologicalEntity",
  "biolink:NamedThing"
]
{'fraction_non_alphanumeric': 0.14887352790578598, 'fraction_numerical': 0.011392729134664619, 'mean_word_length': 4.945966514459665, 'pattern_counts': {'":': 74, '<': 22, '<?xml version=': 0, '>': 23, 'https://': 17, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '7', 'dir': 'jupyter-structured-clean-dedup', 'id': '344618', 'license': 'MIT', 'n_tokens_mistral': 2799, 'n_tokens_neox': 2683, 'n_words': 611, 'path': 'documentation/BiolinkLookup.ipynb', 'repo_name': 'patrickkwang/bl_lookup', 'size': '7812'}