Explore Classes and Properties Defined in Schema

biothings_schema pyton package allows you to explore the classes (e.g. ancestors, descendants, associated properties, etc.) as well as the properties defined within the schema.

List all classes defined in schema

In [1]: from biothings_schema import Schema

In [2]: schema_url = 'https://raw.githubusercontent.com/data2health/schemas/biothings/biothings/biothings_curie_kevin.jsonld'

In [3]: se = Schema(schema=schema_url)

In [4]: se.list_all_classes()

Out [4]: [SchemaClass(name=BiologicalEntity),
          SchemaClass(name=Thing),
          SchemaClass(name=OntologyClass),
          SchemaClass(name=RelationshipType),
          SchemaClass(name=GeneOntologyClass),
          ......
          SchemaClass(name=CellLine),
          SchemaClass(name=GrossAnatomicalStructure),
          SchemaClass(name=ProteinStructure)]

Find all parents of a specific class

In [1]: from biothings_schema import Schema

In [2]: schema_url = 'https://raw.githubusercontent.com/data2health/schemas/biothings/biothings/biothings_curie_kevin.jsonld'

In [3]: se = Schema(schema=schema_url)

In [4]: scls = se.get_class("Gene")

In [5]: scls.parent_classes

Out [5]: [[SchemaClass(name=Thing),
           SchemaClass(name=BiologicalEntity),
           SchemaClass(name=MolecularEntity),
           SchemaClass(name=GenomicEntity),
           SchemaClass(name=MacromolecularMachine),
           SchemaClass(name=GeneOrGeneProduct)]]

Find all children of a specific class

In [1]: from biothings_schema import Schema

In [2]: schema_url = 'https://raw.githubusercontent.com/data2health/schemas/biothings/biothings/biothings_curie_kevin.jsonld'

In [3]: se = Schema(schema=schema_url)

In [4]: scls = se.get_class("MolecularEntity")

In [5]: scls.child_classes

Out [5]: [SchemaClass(name=ChemicalSubstance),
          SchemaClass(name=GenomicEntity),
          SchemaClass(name=GeneFamily)]

Find all descendants of a specific class

In [1]: from biothings_schema import Schema

In [2]: schema_url = 'https://raw.githubusercontent.com/data2health/schemas/biothings/biothings/biothings_curie_kevin.jsonld'

In [3]: se = Schema(schema=schema_url)

In [4]: scls = se.get_class("MolecularEntity")

In [5]: scls.descendant_classes

Out [5]: [SchemaClass(name=Metabolite),
          SchemaClass(name=ProteinIsoform),
          SchemaClass(name=GeneProduct),
          SchemaClass(name=GeneProductIsoform),
          SchemaClass(name=Genome),
          SchemaClass(name=Haplotype),
          SchemaClass(name=Transcript),
          SchemaClass(name=GeneOrGeneProduct),
          SchemaClass(name=RnaProductIsoform),
          SchemaClass(name=GeneFamily),
          SchemaClass(name=Drug),
          SchemaClass(name=RnaProduct),
          SchemaClass(name=Protein),
          SchemaClass(name=Gene),
          SchemaClass(name=GenomicEntity),
          SchemaClass(name=Microrna),
          SchemaClass(name=CodingSequence),
          SchemaClass(name=MacromolecularMachine),
          SchemaClass(name=Exon),
          SchemaClass(name=SequenceVariant),
          SchemaClass(name=MacromolecularComplex),
          SchemaClass(name=Genotype),
          SchemaClass(name=NoncodingRnaProduct),
          SchemaClass(name=ChemicalSubstance)]

Find properties associated to a specific class

Only fetch properties specifically defined for this class

In [1]: from biothings_schema import Schema

In [2]: schema_url = 'https://raw.githubusercontent.com/data2health/schemas/biothings/biothings/biothings_curie_kevin.jsonld'

In [3]: se = Schema(schema=schema_url)

In [4]: scls = se.get_class("Gene")

In [5]: scls.list_properties()

Out [5]: [{'class': 'Gene',
           'properties': [SchemaProperty(name=hgnc),
                          SchemaProperty(name=mgi),
                          SchemaProperty(name=rgd),
                          SchemaProperty(name=zfin),
                          SchemaProperty(name=flybase),
                          SchemaProperty(name=sgd),
                          SchemaProperty(name=pombase),
                          SchemaProperty(name=dictybase),
                          SchemaProperty(name=tair),
                          SchemaProperty(name=inTaxon),
                          SchemaProperty(name=entrez),
                          SchemaProperty(name=pharos),
                          SchemaProperty(name=pharmgkb),
                          SchemaProperty(name=symbol),
                          SchemaProperty(name=omim),
                          SchemaProperty(name=umls),
                          SchemaProperty(name=unigene),
                          SchemaProperty(name=geneticallyInteractsWith),
                          SchemaProperty(name=hasGeneProduct),
                          SchemaProperty(name=hasTranscript),
                          SchemaProperty(name=geneAssociatedWithCondition)]}]

List all properties associated with a class (include properties for its ancestors)

In [1]: from biothings_schema import Schema

In [2]: schema_url = 'https://raw.githubusercontent.com/data2health/schemas/biothings/biothings/biothings_curie_kevin.jsonld'

In [3]: se = Schema(schema=schema_url)

In [4]: scls = se.get_class("Gene")

In [5]: scls.list_properties(class_specific=False)

Out [5]: [{'class': 'Gene',
           'properties': SchemaProperty(name=hgnc),
                         SchemaProperty(name=mgi),
                         SchemaProperty(name=rgd),
                         SchemaProperty(name=zfin),
                         SchemaProperty(name=flybase),
                         SchemaProperty(name=sgd),
                         SchemaProperty(name=pombase),
                         SchemaProperty(name=dictybase),
                         SchemaProperty(name=tair),
                         SchemaProperty(name=inTaxon),
                         SchemaProperty(name=entrez),
                         SchemaProperty(name=pharos),
                         SchemaProperty(name=pharmgkb),
                         SchemaProperty(name=symbol),
                         SchemaProperty(name=omim),
                         SchemaProperty(name=umls),
                         SchemaProperty(name=unigene),
                         SchemaProperty(name=geneticallyInteractsWith),
                         SchemaProperty(name=hasGeneProduct),
                         SchemaProperty(name=hasTranscript),
                         SchemaProperty(name=geneAssociatedWithCondition)]}]},
          {'class': 'GeneOrGeneProduct',
           'properties': [SchemaProperty(name=ensembl),
                          SchemaProperty(name=refseq),
                          SchemaProperty(name=metabolize),
                          SchemaProperty(name=targetedBy),
                          SchemaProperty(name=enablesMF),
                          SchemaProperty(name=involvedInBP),
                          SchemaProperty(name=involvedInPathway),
                          SchemaProperty(name=involvedInWikipathway),
                          SchemaProperty(name=involvedInReactomePathway),
                          SchemaProperty(name=hasHomolog),
                          SchemaProperty(name=orthologousTo),
                          SchemaProperty(name=hasProteinStructure),
                          SchemaProperty(name=inPathwayWith),
                          SchemaProperty(name=inComplexWith),
                          SchemaProperty(name=inCellPopulationWith),
                          SchemaProperty(name=expressedIn)]},
          {'class': 'MacromolecularMachine', 'properties': []},
          {'class': 'GenomicEntity', 'properties': []},
          {'class': 'MolecularEntity',
           'properties': [SchemaProperty(name=molecularlyInteractsWith),
                          SchemaProperty(name=affectsAbundanceOf),
                          SchemaProperty(name=increasesAbundanceOf),
                          SchemaProperty(name=decreasesAbundanceOf),
                          SchemaProperty(name=affectsActivityOf),
                          .....
                          SchemaProperty(name=decreasesUptakeOf),
                          SchemaProperty(name=regulates,EntityToEntity),
                          SchemaProperty(name=biomarkerFor)]},
          {'class': 'BiologicalEntity',
           'properties': [SchemaProperty(name=hasPhenotype)]},
          {'class': 'Thing',
           'properties': [SchemaProperty(name=sameAs),
                          SchemaProperty(name=alternateName),
                          SchemaProperty(name=image),
                          SchemaProperty(name=additionalType),
                          SchemaProperty(name=name),
                          SchemaProperty(name=identifier),
                          SchemaProperty(name=subjectOf),
                          SchemaProperty(name=mainEntityOfPage),
                          SchemaProperty(name=url),
                          SchemaProperty(name=potentialAction),
                          SchemaProperty(name=description),
                          SchemaProperty(name=disambiguatingDescription)]}]

Find class usage

Find where this class has been used in the schema

In [1]: from biothings_schema import Schema

In [2]: schema_url = 'https://raw.githubusercontent.com/data2health/schemas/biothings/biothings/biothings_curie_kevin.jsonld'

In [3]: se = Schema(schema=schema_url)

In [4]: scls = se.get_class("GenomicEntity")

In [5]: scls.used_by()

Out [5]: [{'property': SchemaProperty(name=affectsExpressionOf),
           'property_used_on_class': SchemaClass(name=MolecularEntity),
           'description': 'holds between two molecular entities where the action or effect of one changes the level of expression of the other within a system of interest'},
          {'property': SchemaProperty(name=increasesExpressionOf),
           'property_used_on_class': SchemaClass(name=MolecularEntity),
           'description': 'holds between two molecular entities where the action or effect of one increases the level of expression of the other within a system of interest'},
          {'property': SchemaProperty(name=decreasesExpressionOf),
           'property_used_on_class': SchemaClass(name=MolecularEntity),
           'description': 'holds between two molecular entities where the action or effect of one decreases the level of expression of the other within a system of interest'},
          {'property': SchemaProperty(name=affectsMutationRateOf),
           'property_used_on_class': SchemaClass(name=MolecularEntity),
           'description': 'holds between a molecular entity and a genomic entity where the action or effect of the molecular entity impacts the rate of mutation of the genomic entity within a system of interest'},
          {'property': SchemaProperty(name=increasesMutationRateOf),
           'property_used_on_class': SchemaClass(name=MolecularEntity),
           'description': 'holds between a molecular entity and a genomic entity where the action or effect of the molecular entity increases the rate of mutation of the genomic entity within a system of interest'},
          {'property': SchemaProperty(name=decreasesMutationRateOf),
           'property_used_on_class': SchemaClass(name=MolecularEntity),
           'description': 'holds between a molecular entity and a genomic entity where the action or effect of the molecular entity decreases the rate of mutation of the genomic entity within a system of interest'}]

Find all parents of a specific property

In [1]: from biothings_schema import Schema

In [2]: schema_url = 'https://raw.githubusercontent.com/data2health/schemas/biothings/biothings/biothings_curie_kevin.jsonld'

In [3]: se = Schema(schema=schema_url)

In [4]: sp = se.get_property("ensembl")

In [5]: sp.parent_properties

Out [5]: [SchemaClass(name=identifier)]

Find all children of a specific property

In [1]: from biothings_schema import Schema

In [2]: schema_url = 'https://raw.githubusercontent.com/data2health/schemas/biothings/biothings/biothings_curie_kevin.jsonld'

In [3]: se = Schema(schema=schema_url)

In [4]: sp = se.get_property("ensembl")

In [5]: sp.child_properties

Out [5]: [SchemaClass(name=ensembl),
          SchemaClass(name=hgnc),
          SchemaClass(name=mgi),
          SchemaClass(name=rgd),
          SchemaClass(name=zfin),
          SchemaClass(name=flybase),
          ......,
          SchemaClass(name=unigene),
          SchemaClass(name=inchi),
          SchemaClass(name=inchikey),
          SchemaClass(name=rxcui),
          SchemaClass(name=smiles),
          SchemaClass(name=pubchem),
          SchemaClass(name=chembl),
          SchemaClass(name=drugbank),
          SchemaClass(name=unii)]