pyobo 0.12.9__tar.gz → 0.12.11__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pyobo-0.12.9 → pyobo-0.12.11}/PKG-INFO +8 -1
- {pyobo-0.12.9 → pyobo-0.12.11}/pyproject.toml +12 -2
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/__init__.py +6 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/api/__init__.py +11 -1
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/api/alts.py +18 -4
- pyobo-0.12.11/src/pyobo/api/embedding.py +247 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/api/names.py +28 -6
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/api/xrefs.py +26 -1
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/constants.py +38 -2
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/getters.py +8 -3
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/ner/api.py +14 -10
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/ner/scispacy_utils.py +15 -21
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/__init__.py +2 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/antibodyregistry.py +3 -3
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/bigg/bigg_compartment.py +1 -1
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/complexportal.py +3 -3
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/conso.py +3 -3
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/famplex.py +3 -3
- pyobo-0.12.11/src/pyobo/sources/goldbook.py +86 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/hgnc/hgnc.py +157 -96
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/hgnc/hgncgenefamily.py +14 -13
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/msigdb.py +3 -3
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/omim_ps.py +8 -2
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/reactome.py +3 -3
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/rgd.py +7 -11
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/slm.py +3 -3
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/uniprot/uniprot.py +3 -3
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/wikipathways.py +7 -2
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/__init__.py +2 -2
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/functional/macros.py +1 -1
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/functional/obo_to_functional.py +7 -3
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/obo/reader.py +1 -1
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/struct.py +88 -18
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/struct_utils.py +19 -5
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/typedef.py +16 -3
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/vocabulary.py +4 -3
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/utils/path.py +5 -4
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/version.py +1 -1
- pyobo-0.12.9/src/pyobo/api/embedding.py +0 -148
- {pyobo-0.12.9 → pyobo-0.12.11}/LICENSE +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/README.md +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/.DS_Store +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/__main__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/api/combine.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/api/edges.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/api/hierarchy.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/api/metadata.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/api/properties.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/api/relations.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/api/species.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/api/typedefs.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/api/utils.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/cli/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/cli/cli.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/cli/database.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/cli/database_utils.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/cli/lookup.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/cli/utils.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/gilda_utils.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/identifier_utils/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/identifier_utils/api.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/identifier_utils/relations/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/identifier_utils/relations/api.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/identifier_utils/relations/data.json +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/identifier_utils/relations/data_owl.json +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/identifier_utils/relations/data_rdf.json +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/identifier_utils/relations/data_rdfs.json +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/mocks.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/ner/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/ner/normalizer.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/plugins.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/py.typed +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/resource_utils.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/resources/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/resources/ncbitaxon.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/resources/ncbitaxon.tsv.gz +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/resources/ro.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/resources/ro.tsv +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/resources/so.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/resources/so.tsv +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/README.md +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/agrovoc.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/bigg/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/bigg/bigg_metabolite.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/bigg/bigg_model.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/bigg/bigg_reaction.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/biogrid.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/ccle.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/cgnc.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/chebi.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/chembl/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/chembl/chembl_cell.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/chembl/chembl_compound.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/chembl/chembl_mechanism.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/chembl/chembl_target.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/chembl/chembl_tissue.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/civic_gene.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/clinicaltrials.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/cpt.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/credit.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/cvx.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/depmap.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/dictybase_gene.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/drugbank/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/drugbank/drugbank.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/drugbank/drugbank_salt.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/drugcentral.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/expasy.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/flybase.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/gard.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/geonames/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/geonames/features.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/geonames/geonames.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/geonames/utils.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/gmt_utils.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/go.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/gtdb.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/gwascentral/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/gwascentral/gwascentral_phenotype.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/gwascentral/gwascentral_study.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/hgnc/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/iana_media_type.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/icd/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/icd/icd10.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/icd/icd11.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/icd/icd_utils.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/iconclass.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/intact.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/interpro.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/itis.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/kegg/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/kegg/api.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/kegg/genes.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/kegg/genome.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/kegg/pathway.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/mesh.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/mgi.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/mirbase/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/mirbase/mirbase.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/mirbase/mirbase_constants.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/mirbase/mirbase_family.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/mirbase/mirbase_mature.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/ncbi/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/ncbi/ncbi_gc.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/ncbi/ncbigene.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/nih_reporter.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/nlm/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/nlm/nlm_catalog.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/nlm/nlm_publisher.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/nlm/utils.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/npass.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/pathbank.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/pfam/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/pfam/pfam.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/pfam/pfam_clan.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/pharmgkb/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/pharmgkb/pharmgkb_chemical.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/pharmgkb/pharmgkb_disease.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/pharmgkb/pharmgkb_gene.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/pharmgkb/pharmgkb_pathway.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/pharmgkb/pharmgkb_variant.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/pharmgkb/utils.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/pid.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/pombase.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/pubchem.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/rhea.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/ror.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/selventa/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/selventa/schem.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/selventa/scomp.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/selventa/sdis.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/selventa/sfam.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/sgd.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/signor/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/signor/download.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/signor/signor_complexes.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/spdx.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/umls/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/umls/__main__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/umls/get_synonym_types.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/umls/sty.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/umls/synonym_types.tsv +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/umls/umls.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/unimod.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/uniprot/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/uniprot/uniprot_ptm.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/utils.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/sources/zfin.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/ssg/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/ssg/base.html +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/ssg/index.html +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/ssg/term.html +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/ssg/typedef.html +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/functional/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/functional/dsl.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/functional/ontology.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/functional/utils.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/obo/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/obo/reader_utils.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/obograph/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/obograph/export.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/obograph/reader.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/obograph/utils.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/reference.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/struct/utils.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/utils/__init__.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/utils/cache.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/utils/io.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/utils/iter.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/utils/misc.py +0 -0
- {pyobo-0.12.9 → pyobo-0.12.11}/src/pyobo/utils/ndex_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: pyobo
|
|
3
|
-
Version: 0.12.
|
|
3
|
+
Version: 0.12.11
|
|
4
4
|
Summary: A python package for handling and generating OBO
|
|
5
5
|
Keywords: snekpack,cookiecutter,ontologies,biomedical ontologies,life sciences,natural sciences,bioinformatics,cheminformatics,Open Biomedical Ontologies,OBO
|
|
6
6
|
Author: Charles Tapley Hoyt
|
|
@@ -55,10 +55,15 @@ Requires-Dist: nih-reporter-downloader>=0.0.1
|
|
|
55
55
|
Requires-Dist: typing-extensions
|
|
56
56
|
Requires-Dist: rdflib
|
|
57
57
|
Requires-Dist: obographs>=0.0.8
|
|
58
|
+
Requires-Dist: sssom-pydantic
|
|
58
59
|
Requires-Dist: psycopg2-binary ; extra == 'drugcentral'
|
|
59
60
|
Requires-Dist: ssslm[gilda] ; extra == 'gilda'
|
|
60
61
|
Requires-Dist: ssslm[gilda-slim] ; extra == 'gilda-slim'
|
|
62
|
+
Requires-Dist: grape ; extra == 'grape'
|
|
63
|
+
Requires-Dist: embiggen ; extra == 'grape'
|
|
64
|
+
Requires-Dist: ensmallen ; extra == 'grape'
|
|
61
65
|
Requires-Dist: protmapper ; extra == 'pid'
|
|
66
|
+
Requires-Dist: pykeen ; extra == 'pykeen'
|
|
62
67
|
Requires-Dist: scispacy ; python_full_version < '3.13' and extra == 'scispacy'
|
|
63
68
|
Requires-Dist: spacy ; python_full_version < '3.13' and extra == 'scispacy'
|
|
64
69
|
Requires-Dist: scipy<1.11 ; python_full_version < '3.13' and extra == 'scispacy'
|
|
@@ -74,7 +79,9 @@ Project-URL: Repository, https://github.com/biopragmatics/pyobo.git
|
|
|
74
79
|
Provides-Extra: drugcentral
|
|
75
80
|
Provides-Extra: gilda
|
|
76
81
|
Provides-Extra: gilda-slim
|
|
82
|
+
Provides-Extra: grape
|
|
77
83
|
Provides-Extra: pid
|
|
84
|
+
Provides-Extra: pykeen
|
|
78
85
|
Provides-Extra: scispacy
|
|
79
86
|
Provides-Extra: sources
|
|
80
87
|
Description-Content-Type: text/markdown
|
|
@@ -4,7 +4,7 @@ build-backend = "uv_build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "pyobo"
|
|
7
|
-
version = "0.12.
|
|
7
|
+
version = "0.12.11"
|
|
8
8
|
description = "A python package for handling and generating OBO"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
|
@@ -89,6 +89,7 @@ dependencies = [
|
|
|
89
89
|
"typing_extensions",
|
|
90
90
|
"rdflib",
|
|
91
91
|
"obographs>=0.0.8",
|
|
92
|
+
"sssom_pydantic",
|
|
92
93
|
]
|
|
93
94
|
|
|
94
95
|
# see https://peps.python.org/pep-0735/ and https://docs.astral.sh/uv/concepts/dependencies/#dependency-groups
|
|
@@ -102,6 +103,7 @@ docs = [
|
|
|
102
103
|
"sphinx-rtd-theme>=3.0",
|
|
103
104
|
"sphinx-click",
|
|
104
105
|
"sphinx_automodapi",
|
|
106
|
+
"sphinx_toolbox",
|
|
105
107
|
]
|
|
106
108
|
lint = [
|
|
107
109
|
"ruff",
|
|
@@ -174,6 +176,14 @@ scispacy = [
|
|
|
174
176
|
"spacy; python_version <= '3.12'",
|
|
175
177
|
"scipy<1.11; python_version <= '3.12'",
|
|
176
178
|
]
|
|
179
|
+
pykeen = [
|
|
180
|
+
"pykeen",
|
|
181
|
+
]
|
|
182
|
+
grape = [
|
|
183
|
+
"grape",
|
|
184
|
+
"embiggen",
|
|
185
|
+
"ensmallen",
|
|
186
|
+
]
|
|
177
187
|
|
|
178
188
|
# See https://packaging.python.org/en/latest/guides/writing-pyproject-toml/#urls
|
|
179
189
|
# and also https://packaging.python.org/en/latest/specifications/well-known-project-urls/
|
|
@@ -305,7 +315,7 @@ known-first-party = [
|
|
|
305
315
|
docstring-code-format = true
|
|
306
316
|
|
|
307
317
|
[tool.bumpversion]
|
|
308
|
-
current_version = "0.12.
|
|
318
|
+
current_version = "0.12.11"
|
|
309
319
|
parse = "(?P<major>\\d+)\\.(?P<minor>\\d+)\\.(?P<patch>\\d+)(?:-(?P<release>[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?(?:\\+(?P<build>[0-9A-Za-z-]+(?:\\.[0-9A-Za-z-]+)*))?"
|
|
310
320
|
serialize = [
|
|
311
321
|
"{major}.{minor}.{patch}-{release}+{build}",
|
|
@@ -14,6 +14,7 @@ from .api import (
|
|
|
14
14
|
get_filtered_relations_df,
|
|
15
15
|
get_filtered_xrefs,
|
|
16
16
|
get_graph,
|
|
17
|
+
get_graph_embeddings_df,
|
|
17
18
|
get_hierarchy,
|
|
18
19
|
get_id_definition_mapping,
|
|
19
20
|
get_id_multirelations_mapping,
|
|
@@ -37,6 +38,7 @@ from .api import (
|
|
|
37
38
|
get_obsolete,
|
|
38
39
|
get_primary_curie,
|
|
39
40
|
get_primary_identifier,
|
|
41
|
+
get_primary_reference,
|
|
40
42
|
get_properties,
|
|
41
43
|
get_properties_df,
|
|
42
44
|
get_property,
|
|
@@ -44,6 +46,7 @@ from .api import (
|
|
|
44
46
|
get_relation,
|
|
45
47
|
get_relation_mapping,
|
|
46
48
|
get_relations_df,
|
|
49
|
+
get_semantic_mappings,
|
|
47
50
|
get_species,
|
|
48
51
|
get_sssom_df,
|
|
49
52
|
get_subhierarchy,
|
|
@@ -114,6 +117,7 @@ __all__ = [
|
|
|
114
117
|
"get_filtered_relations_df",
|
|
115
118
|
"get_filtered_xrefs",
|
|
116
119
|
"get_graph",
|
|
120
|
+
"get_graph_embeddings_df",
|
|
117
121
|
"get_grounder",
|
|
118
122
|
"get_hierarchy",
|
|
119
123
|
"get_id_definition_mapping",
|
|
@@ -139,6 +143,7 @@ __all__ = [
|
|
|
139
143
|
"get_ontology",
|
|
140
144
|
"get_primary_curie",
|
|
141
145
|
"get_primary_identifier",
|
|
146
|
+
"get_primary_reference",
|
|
142
147
|
"get_properties",
|
|
143
148
|
"get_properties_df",
|
|
144
149
|
"get_property",
|
|
@@ -149,6 +154,7 @@ __all__ = [
|
|
|
149
154
|
"get_scispacy_entities",
|
|
150
155
|
"get_scispacy_entity_linker",
|
|
151
156
|
"get_scispacy_knowledgebase",
|
|
157
|
+
"get_semantic_mappings",
|
|
152
158
|
"get_species",
|
|
153
159
|
"get_sssom_df",
|
|
154
160
|
"get_subhierarchy",
|
|
@@ -5,10 +5,16 @@ from .alts import (
|
|
|
5
5
|
get_id_to_alts,
|
|
6
6
|
get_primary_curie,
|
|
7
7
|
get_primary_identifier,
|
|
8
|
+
get_primary_reference,
|
|
8
9
|
)
|
|
9
10
|
from .combine import get_literal_mappings_subset
|
|
10
11
|
from .edges import get_edges, get_edges_df, get_graph
|
|
11
|
-
from .embedding import
|
|
12
|
+
from .embedding import (
|
|
13
|
+
get_graph_embeddings_df,
|
|
14
|
+
get_text_embedding,
|
|
15
|
+
get_text_embedding_similarity,
|
|
16
|
+
get_text_embeddings_df,
|
|
17
|
+
)
|
|
12
18
|
from .hierarchy import (
|
|
13
19
|
get_ancestors,
|
|
14
20
|
get_children,
|
|
@@ -59,6 +65,7 @@ from .typedefs import get_typedef_df
|
|
|
59
65
|
from .xrefs import (
|
|
60
66
|
get_filtered_xrefs,
|
|
61
67
|
get_mappings_df,
|
|
68
|
+
get_semantic_mappings,
|
|
62
69
|
get_sssom_df,
|
|
63
70
|
get_xref,
|
|
64
71
|
get_xrefs,
|
|
@@ -80,6 +87,7 @@ __all__ = [
|
|
|
80
87
|
"get_filtered_relations_df",
|
|
81
88
|
"get_filtered_xrefs",
|
|
82
89
|
"get_graph",
|
|
90
|
+
"get_graph_embeddings_df",
|
|
83
91
|
"get_hierarchy",
|
|
84
92
|
"get_id_definition_mapping",
|
|
85
93
|
"get_id_multirelations_mapping",
|
|
@@ -105,6 +113,7 @@ __all__ = [
|
|
|
105
113
|
"get_ontology",
|
|
106
114
|
"get_primary_curie",
|
|
107
115
|
"get_primary_identifier",
|
|
116
|
+
"get_primary_reference",
|
|
108
117
|
"get_priority_curie",
|
|
109
118
|
"get_properties",
|
|
110
119
|
"get_properties_df",
|
|
@@ -113,6 +122,7 @@ __all__ = [
|
|
|
113
122
|
"get_relation",
|
|
114
123
|
"get_relation_mapping",
|
|
115
124
|
"get_relations_df",
|
|
125
|
+
"get_semantic_mappings",
|
|
116
126
|
"get_species",
|
|
117
127
|
"get_sssom_df",
|
|
118
128
|
"get_subhierarchy",
|
|
@@ -20,6 +20,7 @@ __all__ = [
|
|
|
20
20
|
"get_id_to_alts",
|
|
21
21
|
"get_primary_curie",
|
|
22
22
|
"get_primary_identifier",
|
|
23
|
+
"get_primary_reference",
|
|
23
24
|
]
|
|
24
25
|
|
|
25
26
|
logger = logging.getLogger(__name__)
|
|
@@ -61,13 +62,13 @@ def get_alts_to_id(prefix: str, **kwargs: Unpack[GetOntologyKwargs]) -> Mapping[
|
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
|
|
64
|
-
def
|
|
65
|
+
def get_primary_reference(
|
|
65
66
|
prefix: str | curies.Reference | curies.ReferenceTuple,
|
|
66
67
|
identifier: str | None = None,
|
|
67
68
|
/,
|
|
68
69
|
**kwargs: Unpack[GetOntologyKwargs],
|
|
69
|
-
) ->
|
|
70
|
-
"""Get the primary
|
|
70
|
+
) -> curies.ReferenceTuple | None:
|
|
71
|
+
"""Get the primary reference for an entity."""
|
|
71
72
|
reference = _get_pi(prefix, identifier)
|
|
72
73
|
try:
|
|
73
74
|
primary_identifier = get_primary_identifier(reference, **kwargs)
|
|
@@ -76,7 +77,20 @@ def get_primary_curie(
|
|
|
76
77
|
raise
|
|
77
78
|
# this happens on invalid prefix. maybe revise?
|
|
78
79
|
return None
|
|
79
|
-
return
|
|
80
|
+
return curies.ReferenceTuple(reference.prefix, primary_identifier)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def get_primary_curie(
|
|
84
|
+
prefix: str | curies.Reference | curies.ReferenceTuple,
|
|
85
|
+
identifier: str | None = None,
|
|
86
|
+
/,
|
|
87
|
+
**kwargs: Unpack[GetOntologyKwargs],
|
|
88
|
+
) -> str | None:
|
|
89
|
+
"""Get the primary curie for an entity."""
|
|
90
|
+
reference = get_primary_reference(prefix, identifier, **kwargs)
|
|
91
|
+
if reference is None:
|
|
92
|
+
return None
|
|
93
|
+
return reference.curie
|
|
80
94
|
|
|
81
95
|
|
|
82
96
|
def get_primary_identifier(
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
"""Embeddings for entities."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import tempfile
|
|
6
|
+
from pathlib import Path
|
|
7
|
+
from typing import TYPE_CHECKING, Literal
|
|
8
|
+
|
|
9
|
+
import bioregistry
|
|
10
|
+
import curies
|
|
11
|
+
import numpy as np
|
|
12
|
+
import pandas as pd
|
|
13
|
+
from tqdm import tqdm
|
|
14
|
+
from typing_extensions import Unpack
|
|
15
|
+
|
|
16
|
+
from pyobo.api.edges import get_edges_df
|
|
17
|
+
from pyobo.api.names import get_definition, get_id_name_mapping, get_name
|
|
18
|
+
from pyobo.api.utils import get_version_from_kwargs
|
|
19
|
+
from pyobo.constants import GetOntologyKwargs, check_should_force
|
|
20
|
+
from pyobo.identifier_utils import wrap_norm_prefix
|
|
21
|
+
from pyobo.utils.path import CacheArtifact, get_cache_path
|
|
22
|
+
|
|
23
|
+
if TYPE_CHECKING:
|
|
24
|
+
import sentence_transformers
|
|
25
|
+
|
|
26
|
+
__all__ = [
|
|
27
|
+
"get_graph_embeddings_df",
|
|
28
|
+
"get_text_embedding",
|
|
29
|
+
"get_text_embedding_model",
|
|
30
|
+
"get_text_embedding_similarity",
|
|
31
|
+
"get_text_embeddings_df",
|
|
32
|
+
]
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_text_embedding_model() -> sentence_transformers.SentenceTransformer:
|
|
36
|
+
"""Get the default text embedding model."""
|
|
37
|
+
from sentence_transformers import SentenceTransformer
|
|
38
|
+
|
|
39
|
+
model = SentenceTransformer("all-MiniLM-L6-v2")
|
|
40
|
+
return model
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def _get_text(
|
|
44
|
+
reference: str | curies.Reference | curies.ReferenceTuple,
|
|
45
|
+
/,
|
|
46
|
+
*,
|
|
47
|
+
name: str | None = None,
|
|
48
|
+
**kwargs: Unpack[GetOntologyKwargs],
|
|
49
|
+
) -> str | None:
|
|
50
|
+
if name is None:
|
|
51
|
+
name = get_name(reference, **kwargs)
|
|
52
|
+
if name is None:
|
|
53
|
+
return None
|
|
54
|
+
description = get_definition(reference, **kwargs)
|
|
55
|
+
if description:
|
|
56
|
+
name += " " + description
|
|
57
|
+
return name
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
def get_graph_embeddings_df(
|
|
61
|
+
prefix: str,
|
|
62
|
+
*,
|
|
63
|
+
method: Literal["pykeen", "grape"] | None = None,
|
|
64
|
+
epochs: int = 30,
|
|
65
|
+
dimension: int = 32,
|
|
66
|
+
**kwargs: Unpack[GetOntologyKwargs],
|
|
67
|
+
) -> pd.DataFrame:
|
|
68
|
+
"""Get graph machine learning embeddings."""
|
|
69
|
+
if method == "pykeen" or method is None:
|
|
70
|
+
from pykeen.models import PairRE
|
|
71
|
+
from pykeen.training import SLCWATrainingLoop
|
|
72
|
+
from pykeen.triples import TriplesFactory
|
|
73
|
+
from torch.optim import Adam
|
|
74
|
+
|
|
75
|
+
triples_df = get_edges_df(prefix, **kwargs)
|
|
76
|
+
training = TriplesFactory.from_labeled_triples(triples_df.values)
|
|
77
|
+
model = PairRE(triples_factory=training, embedding_dim=dimension)
|
|
78
|
+
optimizer = Adam(params=model.get_grad_params())
|
|
79
|
+
training_loop = SLCWATrainingLoop(
|
|
80
|
+
model=model, triples_factory=training, optimizer=optimizer
|
|
81
|
+
)
|
|
82
|
+
# can also set batch size here
|
|
83
|
+
training_loop.train(triples_factory=training, num_epochs=epochs)
|
|
84
|
+
embeddings = model.entity_representations[0]()
|
|
85
|
+
df = pd.DataFrame(
|
|
86
|
+
embeddings.detach().numpy(),
|
|
87
|
+
index=[training.entity_id_to_label[i] for i in range(embeddings.shape[0])],
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
elif method == "grape":
|
|
91
|
+
from ensmallen import Graph
|
|
92
|
+
|
|
93
|
+
edges_df = get_edges_df(prefix, **kwargs)
|
|
94
|
+
with tempfile.TemporaryDirectory() as d:
|
|
95
|
+
path = Path(d).joinpath("test.tsv")
|
|
96
|
+
edges_df[[":START_ID", ":END_ID"]].to_csv(path, header=None, sep="\t", index=False)
|
|
97
|
+
graph = Graph.from_csv(
|
|
98
|
+
edge_path=str(path),
|
|
99
|
+
edge_list_separator="\t",
|
|
100
|
+
sources_column_number=0,
|
|
101
|
+
destinations_column_number=1,
|
|
102
|
+
edge_list_numeric_node_ids=False,
|
|
103
|
+
directed=True,
|
|
104
|
+
name=bioregistry.get_name(prefix, strict=True),
|
|
105
|
+
verbose=True,
|
|
106
|
+
)
|
|
107
|
+
graph = graph.remove_disconnected_nodes()
|
|
108
|
+
|
|
109
|
+
from embiggen.embedders.ensmallen_embedders.second_order_line import (
|
|
110
|
+
SecondOrderLINEEnsmallen,
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
embedding = SecondOrderLINEEnsmallen(embedding_size=dimension, epochs=epochs).fit_transform(
|
|
114
|
+
graph
|
|
115
|
+
)
|
|
116
|
+
df = embedding.get_all_node_embedding()[0].sort_index()
|
|
117
|
+
# df.columns = [str(c) for c in df.columns]
|
|
118
|
+
else:
|
|
119
|
+
raise ValueError(f"invalid graph machine learning method: {method}")
|
|
120
|
+
|
|
121
|
+
df.index.name = "curie"
|
|
122
|
+
return df
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
@wrap_norm_prefix
|
|
126
|
+
def get_text_embeddings_df(
|
|
127
|
+
prefix: str,
|
|
128
|
+
*,
|
|
129
|
+
model: sentence_transformers.SentenceTransformer | None = None,
|
|
130
|
+
**kwargs: Unpack[GetOntologyKwargs],
|
|
131
|
+
) -> pd.DataFrame:
|
|
132
|
+
"""Get embeddings for all entities in the resource.
|
|
133
|
+
|
|
134
|
+
:param prefix: A reference, either as a string or Reference object
|
|
135
|
+
:param model: A sentence transformer model. Defaults to ``all-MiniLM-L6-v2`` if not
|
|
136
|
+
given.
|
|
137
|
+
:param kwargs: The keyword arguments to forward to ontology getter functions for
|
|
138
|
+
names, definitions, and version
|
|
139
|
+
|
|
140
|
+
:returns: A pandas dataframe with an index representing local unique identifiers and
|
|
141
|
+
columns for the values of the model returned vectors
|
|
142
|
+
"""
|
|
143
|
+
path = get_cache_path(
|
|
144
|
+
prefix, CacheArtifact.embeddings, version=get_version_from_kwargs(prefix, kwargs)
|
|
145
|
+
)
|
|
146
|
+
if path.is_file() and not check_should_force(kwargs):
|
|
147
|
+
df = pd.read_csv(path, sep="\t").set_index(0)
|
|
148
|
+
return df
|
|
149
|
+
|
|
150
|
+
id_to_name = get_id_name_mapping(prefix, **kwargs)
|
|
151
|
+
|
|
152
|
+
luids, texts = [], []
|
|
153
|
+
for identifier, name in tqdm(id_to_name.items(), desc=f"[{prefix}] constructing text"):
|
|
154
|
+
text = _get_text(curies.ReferenceTuple(prefix, identifier), name=name, **kwargs)
|
|
155
|
+
if text is None:
|
|
156
|
+
continue
|
|
157
|
+
luids.append(identifier)
|
|
158
|
+
texts.append(text)
|
|
159
|
+
if model is None:
|
|
160
|
+
model = get_text_embedding_model()
|
|
161
|
+
res = model.encode(texts, show_progress_bar=True)
|
|
162
|
+
df = pd.DataFrame(res, index=luids)
|
|
163
|
+
df.to_csv(path, sep="\t") # index is important here!
|
|
164
|
+
return df
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def get_text_embedding(
|
|
168
|
+
reference: str | curies.Reference | curies.ReferenceTuple,
|
|
169
|
+
*,
|
|
170
|
+
model: sentence_transformers.SentenceTransformer | None = None,
|
|
171
|
+
) -> np.ndarray | None:
|
|
172
|
+
"""Get a text embedding for an entity, or return none if no text is available.
|
|
173
|
+
|
|
174
|
+
:param reference: A reference, either as a string or Reference object
|
|
175
|
+
:param model: A sentence transformer model. Defaults to ``all-MiniLM-L6-v2`` if not
|
|
176
|
+
given.
|
|
177
|
+
|
|
178
|
+
:returns: A 1D numpy float array of embeddings from :class:`sentence_transformers`
|
|
179
|
+
|
|
180
|
+
.. code-block:: python
|
|
181
|
+
|
|
182
|
+
import pyobo
|
|
183
|
+
|
|
184
|
+
embedding = pyobo.get_text_embedding("GO:0000001")
|
|
185
|
+
# [-5.68335280e-02 7.96175096e-03 -3.36112119e-02 2.34440481e-03 ... ]
|
|
186
|
+
|
|
187
|
+
If you want to do multiple operations, load up the model for reuse
|
|
188
|
+
|
|
189
|
+
.. code-block:: python
|
|
190
|
+
|
|
191
|
+
import pyobo
|
|
192
|
+
from pyobo.api.embedding import get_text_embedding_model
|
|
193
|
+
|
|
194
|
+
model = get_text_embedding_model()
|
|
195
|
+
embedding = pyobo.get_text_embedding("GO:0000001", model=model)
|
|
196
|
+
# [-5.68335280e-02 7.96175096e-03 -3.36112119e-02 2.34440481e-03 ... ]
|
|
197
|
+
"""
|
|
198
|
+
text = _get_text(reference)
|
|
199
|
+
if text is None:
|
|
200
|
+
return None
|
|
201
|
+
if model is None:
|
|
202
|
+
model = get_text_embedding_model()
|
|
203
|
+
res = model.encode([text])
|
|
204
|
+
return res[0]
|
|
205
|
+
|
|
206
|
+
|
|
207
|
+
def get_text_embedding_similarity(
|
|
208
|
+
reference_1: str | curies.Reference | curies.ReferenceTuple,
|
|
209
|
+
reference_2: str | curies.Reference | curies.ReferenceTuple,
|
|
210
|
+
*,
|
|
211
|
+
model: sentence_transformers.SentenceTransformer | None = None,
|
|
212
|
+
) -> float | None:
|
|
213
|
+
"""Get the pairwise similarity.
|
|
214
|
+
|
|
215
|
+
:param reference_1: A reference, given as a string or Reference object
|
|
216
|
+
:param reference_2: A second reference
|
|
217
|
+
:param model: A sentence transformer model. Defaults to ``all-MiniLM-L6-v2`` if not
|
|
218
|
+
given.
|
|
219
|
+
|
|
220
|
+
:returns: A floating point similarity, if text is available for both references,
|
|
221
|
+
otherwise none
|
|
222
|
+
|
|
223
|
+
.. code-block:: python
|
|
224
|
+
|
|
225
|
+
import pyobo
|
|
226
|
+
|
|
227
|
+
similarity = pyobo.get_text_embedding_similarity("GO:0000001", "GO:0000004")
|
|
228
|
+
# 0.24702128767967224
|
|
229
|
+
|
|
230
|
+
If you want to do multiple operations, load up the model for reuse
|
|
231
|
+
|
|
232
|
+
.. code-block:: python
|
|
233
|
+
|
|
234
|
+
import pyobo
|
|
235
|
+
from pyobo.api.embedding import get_text_embedding_model
|
|
236
|
+
|
|
237
|
+
model = get_text_embedding_model()
|
|
238
|
+
similarity = pyobo.get_text_embedding_similarity("GO:0000001", "GO:0000004", model=model)
|
|
239
|
+
# 0.24702128767967224
|
|
240
|
+
"""
|
|
241
|
+
if model is None:
|
|
242
|
+
model = get_text_embedding_model()
|
|
243
|
+
e1 = get_text_embedding(reference_1, model=model)
|
|
244
|
+
e2 = get_text_embedding(reference_2, model=model)
|
|
245
|
+
if e1 is None or e2 is None:
|
|
246
|
+
return None
|
|
247
|
+
return model.similarity(e1, e2)[0][0].item()
|
|
@@ -6,7 +6,7 @@ import logging
|
|
|
6
6
|
import subprocess
|
|
7
7
|
from collections.abc import Callable, Mapping
|
|
8
8
|
from functools import lru_cache
|
|
9
|
-
from typing import
|
|
9
|
+
from typing import TypeVar
|
|
10
10
|
|
|
11
11
|
import curies
|
|
12
12
|
import pandas as pd
|
|
@@ -49,9 +49,15 @@ __all__ = [
|
|
|
49
49
|
logger = logging.getLogger(__name__)
|
|
50
50
|
|
|
51
51
|
|
|
52
|
-
def get_name_by_curie(
|
|
52
|
+
def get_name_by_curie(
|
|
53
|
+
curie: str,
|
|
54
|
+
/,
|
|
55
|
+
*,
|
|
56
|
+
upgrade_identifier: bool | None = None,
|
|
57
|
+
**kwargs: Unpack[GetOntologyKwargs],
|
|
58
|
+
) -> str | None:
|
|
53
59
|
"""Get the name for a CURIE, if possible."""
|
|
54
|
-
return get_name(curie, **kwargs)
|
|
60
|
+
return get_name(curie, upgrade_identifier=upgrade_identifier, **kwargs)
|
|
55
61
|
|
|
56
62
|
|
|
57
63
|
X = TypeVar("X")
|
|
@@ -63,6 +69,8 @@ NO_BUILD_LOGGED: set = set()
|
|
|
63
69
|
def _help_get(
|
|
64
70
|
f: Callable[[str, Unpack[GetOntologyKwargs]], Mapping[str, X]],
|
|
65
71
|
reference: Reference,
|
|
72
|
+
*,
|
|
73
|
+
upgrade_identifier: bool | None = None,
|
|
66
74
|
**kwargs: Unpack[GetOntologyKwargs],
|
|
67
75
|
) -> X | None:
|
|
68
76
|
"""Get the result for an entity based on a mapping maker function ``f``."""
|
|
@@ -87,19 +95,32 @@ def _help_get(
|
|
|
87
95
|
NO_BUILD_PREFIXES.add(reference.prefix)
|
|
88
96
|
return None
|
|
89
97
|
|
|
90
|
-
|
|
91
|
-
|
|
98
|
+
if upgrade_identifier is None:
|
|
99
|
+
if reference.identifier in mapping:
|
|
100
|
+
return mapping[reference.identifier]
|
|
101
|
+
else:
|
|
102
|
+
primary_id = get_primary_identifier(reference, **kwargs)
|
|
103
|
+
return mapping.get(primary_id)
|
|
104
|
+
elif upgrade_identifier is True:
|
|
105
|
+
primary_id = get_primary_identifier(reference, **kwargs)
|
|
106
|
+
return mapping.get(primary_id)
|
|
107
|
+
else:
|
|
108
|
+
return mapping.get(reference.identifier)
|
|
92
109
|
|
|
93
110
|
|
|
94
111
|
def get_name(
|
|
95
112
|
prefix: str | curies.Reference | curies.ReferenceTuple,
|
|
96
113
|
identifier: str | None = None,
|
|
97
114
|
/,
|
|
115
|
+
*,
|
|
116
|
+
upgrade_identifier: bool | None = None,
|
|
98
117
|
**kwargs: Unpack[GetOntologyKwargs],
|
|
99
118
|
) -> str | None:
|
|
100
119
|
"""Get the name for an entity."""
|
|
101
120
|
reference = _get_pi(prefix, identifier)
|
|
102
|
-
return _help_get(
|
|
121
|
+
return _help_get(
|
|
122
|
+
get_id_name_mapping, reference, upgrade_identifier=upgrade_identifier, **kwargs
|
|
123
|
+
)
|
|
103
124
|
|
|
104
125
|
|
|
105
126
|
@lru_cache
|
|
@@ -325,6 +346,7 @@ def get_literal_mappings(
|
|
|
325
346
|
return rv
|
|
326
347
|
|
|
327
348
|
|
|
349
|
+
@wrap_norm_prefix
|
|
328
350
|
def get_literal_mappings_df(
|
|
329
351
|
prefix: str,
|
|
330
352
|
**kwargs: Unpack[GetOntologyKwargs],
|
|
@@ -5,8 +5,11 @@ import warnings
|
|
|
5
5
|
from collections.abc import Mapping
|
|
6
6
|
from functools import lru_cache
|
|
7
7
|
|
|
8
|
+
import curies
|
|
8
9
|
import pandas as pd
|
|
9
10
|
from curies import ReferenceTuple
|
|
11
|
+
from sssom_pydantic import SemanticMapping
|
|
12
|
+
from sssom_pydantic.io import parse_record, parse_row
|
|
10
13
|
from typing_extensions import Unpack
|
|
11
14
|
|
|
12
15
|
from .utils import get_version_from_kwargs
|
|
@@ -19,7 +22,7 @@ from ..constants import (
|
|
|
19
22
|
check_should_use_tqdm,
|
|
20
23
|
)
|
|
21
24
|
from ..getters import get_ontology
|
|
22
|
-
from ..identifier_utils import wrap_norm_prefix
|
|
25
|
+
from ..identifier_utils import get_converter, wrap_norm_prefix
|
|
23
26
|
from ..struct import Obo
|
|
24
27
|
from ..utils.cache import cached_df
|
|
25
28
|
from ..utils.path import CacheArtifact, get_cache_path
|
|
@@ -27,6 +30,7 @@ from ..utils.path import CacheArtifact, get_cache_path
|
|
|
27
30
|
__all__ = [
|
|
28
31
|
"get_filtered_xrefs",
|
|
29
32
|
"get_mappings_df",
|
|
33
|
+
"get_semantic_mappings",
|
|
30
34
|
"get_sssom_df",
|
|
31
35
|
"get_xref",
|
|
32
36
|
"get_xrefs",
|
|
@@ -107,6 +111,27 @@ def get_sssom_df(
|
|
|
107
111
|
return get_mappings_df(prefix=prefix, names=names, **kwargs)
|
|
108
112
|
|
|
109
113
|
|
|
114
|
+
def get_semantic_mappings(
|
|
115
|
+
prefix: str,
|
|
116
|
+
converter: curies.Converter | None = None,
|
|
117
|
+
names: bool = True,
|
|
118
|
+
include_mapping_source_column: bool = False,
|
|
119
|
+
**kwargs: Unpack[GetOntologyKwargs],
|
|
120
|
+
) -> list[SemanticMapping]:
|
|
121
|
+
"""Get semantic mapping objects."""
|
|
122
|
+
df = get_mappings_df(
|
|
123
|
+
prefix, names=names, include_mapping_source_column=include_mapping_source_column, **kwargs
|
|
124
|
+
)
|
|
125
|
+
if converter is None:
|
|
126
|
+
converter = get_converter()
|
|
127
|
+
rv = []
|
|
128
|
+
for _, row in df.iterrows():
|
|
129
|
+
record = parse_row(row.to_dict())
|
|
130
|
+
mapping = parse_record(record, converter=converter)
|
|
131
|
+
rv.append(mapping)
|
|
132
|
+
return rv
|
|
133
|
+
|
|
134
|
+
|
|
110
135
|
def get_mappings_df(
|
|
111
136
|
prefix: str | Obo,
|
|
112
137
|
*,
|