From 23a6c0b4d9c8a099eb60f23c17ec3e3d083c5cde Mon Sep 17 00:00:00 2001 From: Charles Tapley Hoyt Date: Mon, 13 Jan 2025 15:22:37 -0500 Subject: [PATCH] Reorganize sources (#305) --- src/pyobo/cli/database_utils.py | 3 ++- src/pyobo/sources/__init__.py | 22 ++++++------------- src/pyobo/sources/chembl/__init__.py | 7 ++++++ .../{chembl.py => chembl/chembl_compound.py} | 5 +---- src/pyobo/sources/drugbank/__init__.py | 9 ++++++++ src/pyobo/sources/{ => drugbank}/drugbank.py | 10 ++++----- .../sources/{ => drugbank}/drugbank_salt.py | 2 +- src/pyobo/sources/gwascentral/__init__.py | 9 ++++++++ .../gwascentral_phenotype.py | 3 ++- .../{ => gwascentral}/gwascentral_study.py | 0 src/pyobo/sources/hgnc/__init__.py | 9 ++++++++ src/pyobo/sources/{ => hgnc}/hgnc.py | 0 .../sources/{ => hgnc}/hgncgenefamily.py | 6 ++--- src/pyobo/sources/icd/__init__.py | 9 ++++++++ src/pyobo/sources/{ => icd}/icd10.py | 6 ++--- src/pyobo/sources/{ => icd}/icd11.py | 4 ++-- src/pyobo/sources/{ => icd}/icd_utils.py | 4 ++-- src/pyobo/sources/mirbase/__init__.py | 11 ++++++++++ src/pyobo/sources/{ => mirbase}/mirbase.py | 3 ++- .../{ => mirbase}/mirbase_constants.py | 0 .../sources/{ => mirbase}/mirbase_family.py | 5 +++-- .../sources/{ => mirbase}/mirbase_mature.py | 3 ++- src/pyobo/sources/ncbi/__init__.py | 9 ++++++++ src/pyobo/sources/{ => ncbi}/ncbi_gc.py | 0 src/pyobo/sources/{ => ncbi}/ncbigene.py | 4 ++-- src/pyobo/sources/pfam/__init__.py | 9 ++++++++ src/pyobo/sources/{ => pfam}/pfam.py | 4 ++-- src/pyobo/sources/{ => pfam}/pfam_clan.py | 2 +- 28 files changed, 112 insertions(+), 46 deletions(-) create mode 100644 src/pyobo/sources/chembl/__init__.py rename src/pyobo/sources/{chembl.py => chembl/chembl_compound.py} (96%) create mode 100644 src/pyobo/sources/drugbank/__init__.py rename src/pyobo/sources/{ => drugbank}/drugbank.py (97%) rename src/pyobo/sources/{ => drugbank}/drugbank_salt.py (97%) create mode 100644 src/pyobo/sources/gwascentral/__init__.py rename src/pyobo/sources/{ => gwascentral}/gwascentral_phenotype.py (97%) rename src/pyobo/sources/{ => gwascentral}/gwascentral_study.py (100%) create mode 100644 src/pyobo/sources/hgnc/__init__.py rename src/pyobo/sources/{ => hgnc}/hgnc.py (100%) rename src/pyobo/sources/{ => hgnc}/hgncgenefamily.py (95%) create mode 100644 src/pyobo/sources/icd/__init__.py rename src/pyobo/sources/{ => icd}/icd10.py (93%) rename src/pyobo/sources/{ => icd}/icd11.py (96%) rename src/pyobo/sources/{ => icd}/icd_utils.py (98%) create mode 100644 src/pyobo/sources/mirbase/__init__.py rename src/pyobo/sources/{ => mirbase}/mirbase.py (98%) rename src/pyobo/sources/{ => mirbase}/mirbase_constants.py (100%) rename src/pyobo/sources/{ => mirbase}/mirbase_family.py (97%) rename src/pyobo/sources/{ => mirbase}/mirbase_mature.py (95%) create mode 100644 src/pyobo/sources/ncbi/__init__.py rename src/pyobo/sources/{ => ncbi}/ncbi_gc.py (100%) rename src/pyobo/sources/{ => ncbi}/ncbigene.py (98%) create mode 100644 src/pyobo/sources/pfam/__init__.py rename src/pyobo/sources/{ => pfam}/pfam.py (95%) rename src/pyobo/sources/{ => pfam}/pfam_clan.py (96%) diff --git a/src/pyobo/cli/database_utils.py b/src/pyobo/cli/database_utils.py index e5bdfc0f..44895a56 100644 --- a/src/pyobo/cli/database_utils.py +++ b/src/pyobo/cli/database_utils.py @@ -27,7 +27,8 @@ get_xrefs_df, ) from ..getters import IterHelperHelperDict, iter_helper, iter_helper_helper -from ..sources import ncbigene, pubchem +from ..sources import pubchem +from ..sources.ncbi import ncbigene from ..utils.path import ensure_path from ..xrefdb.sources import iter_xref_plugins diff --git a/src/pyobo/sources/__init__.py b/src/pyobo/sources/__init__.py index 6e5ac0bb..6cf2124d 100644 --- a/src/pyobo/sources/__init__.py +++ b/src/pyobo/sources/__init__.py @@ -15,8 +15,7 @@ from .cvx import CVXGetter from .depmap import DepMapGetter from .dictybase_gene import DictybaseGetter -from .drugbank import DrugBankGetter -from .drugbank_salt import DrugBankSaltGetter +from .drugbank import DrugBankGetter, DrugBankSaltGetter from .drugcentral import DrugCentralGetter from .expasy import ExpasyGetter from .famplex import FamPlexGetter @@ -24,29 +23,22 @@ from .gard import GARDGetter from .geonames import GeonamesFeatureGetter, GeonamesGetter from .gtdb import GTDBGetter -from .gwascentral_phenotype import GWASCentralPhenotypeGetter -from .gwascentral_study import GWASCentralStudyGetter -from .hgnc import HGNCGetter -from .hgncgenefamily import HGNCGroupGetter -from .icd10 import ICD10Getter -from .icd11 import ICD11Getter +from .gwascentral import GWASCentralPhenotypeGetter, GWASCentralStudyGetter +from .hgnc import HGNCGetter, HGNCGroupGetter +from .icd import ICD10Getter, ICD11Getter from .interpro import InterProGetter from .itis import ITISGetter from .kegg import KEGGGeneGetter, KEGGGenomeGetter, KEGGPathwayGetter from .mesh import MeSHGetter from .mgi import MGIGetter -from .mirbase import MiRBaseGetter -from .mirbase_family import MiRBaseFamilyGetter -from .mirbase_mature import MiRBaseMatureGetter +from .mirbase import MiRBaseFamilyGetter, MiRBaseGetter, MiRBaseMatureGetter from .msigdb import MSigDBGetter -from .ncbi_gc import NCBIGCGetter -from .ncbigene import NCBIGeneGetter +from .ncbi import NCBIGCGetter, NCBIGeneGetter from .nlm import NLMCatalogGetter, NLMPublisherGetter from .npass import NPASSGetter from .omim_ps import OMIMPSGetter from .pathbank import PathBankGetter -from .pfam import PfamGetter -from .pfam_clan import PfamClanGetter +from .pfam import PfamClanGetter, PfamGetter from .pid import PIDGetter from .pombase import PomBaseGetter from .pubchem import PubChemCompoundGetter diff --git a/src/pyobo/sources/chembl/__init__.py b/src/pyobo/sources/chembl/__init__.py new file mode 100644 index 00000000..e87e3eb3 --- /dev/null +++ b/src/pyobo/sources/chembl/__init__.py @@ -0,0 +1,7 @@ +"""Resources from ChEMBL.""" + +from .chembl_compound import ChEMBLCompoundGetter + +__all__ = [ + "ChEMBLCompoundGetter", +] diff --git a/src/pyobo/sources/chembl.py b/src/pyobo/sources/chembl/chembl_compound.py similarity index 96% rename from src/pyobo/sources/chembl.py rename to src/pyobo/sources/chembl/chembl_compound.py index 07e5abee..00552af3 100644 --- a/src/pyobo/sources/chembl.py +++ b/src/pyobo/sources/chembl/chembl_compound.py @@ -1,7 +1,4 @@ -"""Converter for ChEMBL. - -Run with ``python -m pyobo.sources.chembl -vv``. -""" +"""Converter for ChEMBL Compounds.""" import logging from collections.abc import Iterable diff --git a/src/pyobo/sources/drugbank/__init__.py b/src/pyobo/sources/drugbank/__init__.py new file mode 100644 index 00000000..817cb196 --- /dev/null +++ b/src/pyobo/sources/drugbank/__init__.py @@ -0,0 +1,9 @@ +"""Resources from DrugBank.""" + +from .drugbank import DrugBankGetter +from .drugbank_salt import DrugBankSaltGetter + +__all__ = [ + "DrugBankGetter", + "DrugBankSaltGetter", +] diff --git a/src/pyobo/sources/drugbank.py b/src/pyobo/sources/drugbank/drugbank.py similarity index 97% rename from src/pyobo/sources/drugbank.py rename to src/pyobo/sources/drugbank/drugbank.py index c6a1e4bc..6ca00c96 100644 --- a/src/pyobo/sources/drugbank.py +++ b/src/pyobo/sources/drugbank/drugbank.py @@ -14,11 +14,11 @@ import pystow from tqdm.auto import tqdm -from ..getters import NoBuildError -from ..struct import Obo, Reference, Term -from ..struct.typedef import has_inchi, has_salt, has_smiles -from ..utils.cache import cached_pickle -from ..utils.path import prefix_directory_join +from ...getters import NoBuildError +from ...struct import Obo, Reference, Term +from ...struct.typedef import has_inchi, has_salt, has_smiles +from ...utils.cache import cached_pickle +from ...utils.path import prefix_directory_join __all__ = [ "DrugBankGetter", diff --git a/src/pyobo/sources/drugbank_salt.py b/src/pyobo/sources/drugbank/drugbank_salt.py similarity index 97% rename from src/pyobo/sources/drugbank_salt.py rename to src/pyobo/sources/drugbank/drugbank_salt.py index 3e95c02c..e0e88b90 100644 --- a/src/pyobo/sources/drugbank_salt.py +++ b/src/pyobo/sources/drugbank/drugbank_salt.py @@ -16,7 +16,7 @@ from collections.abc import Iterable from .drugbank import iterate_drug_info -from ..struct import Obo, Reference, Term +from ...struct import Obo, Reference, Term __all__ = [ "DrugBankSaltGetter", diff --git a/src/pyobo/sources/gwascentral/__init__.py b/src/pyobo/sources/gwascentral/__init__.py new file mode 100644 index 00000000..15778786 --- /dev/null +++ b/src/pyobo/sources/gwascentral/__init__.py @@ -0,0 +1,9 @@ +"""Resources from GWAS Central.""" + +from .gwascentral_phenotype import GWASCentralPhenotypeGetter +from .gwascentral_study import GWASCentralStudyGetter + +__all__ = [ + "GWASCentralPhenotypeGetter", + "GWASCentralStudyGetter", +] diff --git a/src/pyobo/sources/gwascentral_phenotype.py b/src/pyobo/sources/gwascentral/gwascentral_phenotype.py similarity index 97% rename from src/pyobo/sources/gwascentral_phenotype.py rename to src/pyobo/sources/gwascentral/gwascentral_phenotype.py index 990a03c7..814cc8e0 100644 --- a/src/pyobo/sources/gwascentral_phenotype.py +++ b/src/pyobo/sources/gwascentral/gwascentral_phenotype.py @@ -5,10 +5,11 @@ from tqdm.auto import tqdm, trange -from pyobo.sources.gwascentral_study import VERSION from pyobo.struct import Obo, Reference, Term from pyobo.utils.path import ensure_path +from .gwascentral_study import VERSION + __all__ = [ "GWASCentralPhenotypeGetter", ] diff --git a/src/pyobo/sources/gwascentral_study.py b/src/pyobo/sources/gwascentral/gwascentral_study.py similarity index 100% rename from src/pyobo/sources/gwascentral_study.py rename to src/pyobo/sources/gwascentral/gwascentral_study.py diff --git a/src/pyobo/sources/hgnc/__init__.py b/src/pyobo/sources/hgnc/__init__.py new file mode 100644 index 00000000..f91521d7 --- /dev/null +++ b/src/pyobo/sources/hgnc/__init__.py @@ -0,0 +1,9 @@ +"""Resources from HGNC.""" + +from .hgnc import HGNCGetter +from .hgncgenefamily import HGNCGroupGetter + +__all__ = [ + "HGNCGetter", + "HGNCGroupGetter", +] diff --git a/src/pyobo/sources/hgnc.py b/src/pyobo/sources/hgnc/hgnc.py similarity index 100% rename from src/pyobo/sources/hgnc.py rename to src/pyobo/sources/hgnc/hgnc.py diff --git a/src/pyobo/sources/hgncgenefamily.py b/src/pyobo/sources/hgnc/hgncgenefamily.py similarity index 95% rename from src/pyobo/sources/hgncgenefamily.py rename to src/pyobo/sources/hgnc/hgncgenefamily.py index 78ed6204..7074005d 100644 --- a/src/pyobo/sources/hgncgenefamily.py +++ b/src/pyobo/sources/hgnc/hgncgenefamily.py @@ -5,9 +5,9 @@ import pandas as pd -from ..struct import Obo, Reference, SynonymTypeDef, Term, has_citation -from ..struct.typedef import enables, exact_match, from_species -from ..utils.path import ensure_path +from ...struct import Obo, Reference, SynonymTypeDef, Term, has_citation +from ...struct.typedef import enables, exact_match, from_species +from ...utils.path import ensure_path __all__ = [ "HGNCGroupGetter", diff --git a/src/pyobo/sources/icd/__init__.py b/src/pyobo/sources/icd/__init__.py new file mode 100644 index 00000000..14702d1d --- /dev/null +++ b/src/pyobo/sources/icd/__init__.py @@ -0,0 +1,9 @@ +"""Resources from ICD.""" + +from .icd10 import ICD10Getter +from .icd11 import ICD11Getter + +__all__ = [ + "ICD10Getter", + "ICD11Getter", +] diff --git a/src/pyobo/sources/icd10.py b/src/pyobo/sources/icd/icd10.py similarity index 93% rename from src/pyobo/sources/icd10.py rename to src/pyobo/sources/icd/icd10.py index 18ceda19..ec558790 100644 --- a/src/pyobo/sources/icd10.py +++ b/src/pyobo/sources/icd/icd10.py @@ -9,14 +9,14 @@ from tqdm.auto import tqdm -from ..sources.icd_utils import ( +from .icd_utils import ( ICD10_TOP_LEVEL_URL, get_child_identifiers, get_icd, visiter, ) -from ..struct import Obo, Reference, Synonym, Term, has_category -from ..utils.path import prefix_directory_join +from ...struct import Obo, Reference, Synonym, Term, has_category +from ...utils.path import prefix_directory_join __all__ = [ "ICD10Getter", diff --git a/src/pyobo/sources/icd11.py b/src/pyobo/sources/icd/icd11.py similarity index 96% rename from src/pyobo/sources/icd11.py rename to src/pyobo/sources/icd/icd11.py index 851e3cec..60deabcc 100644 --- a/src/pyobo/sources/icd11.py +++ b/src/pyobo/sources/icd/icd11.py @@ -18,8 +18,8 @@ get_icd_11_mms, visiter, ) -from ..struct import Obo, Reference, Synonym, Term, TypeDef, default_reference -from ..utils.path import prefix_directory_join +from ...struct import Obo, Reference, Synonym, Term, TypeDef, default_reference +from ...utils.path import prefix_directory_join __all__ = [ "ICD11Getter", diff --git a/src/pyobo/sources/icd_utils.py b/src/pyobo/sources/icd/icd_utils.py similarity index 98% rename from src/pyobo/sources/icd_utils.py rename to src/pyobo/sources/icd/icd_utils.py index 846468bb..6ef4baf6 100644 --- a/src/pyobo/sources/icd_utils.py +++ b/src/pyobo/sources/icd/icd_utils.py @@ -19,8 +19,8 @@ from pystow.config_api import ConfigError from tqdm.auto import tqdm -from ..getters import NoBuildError -from ..struct import Term +from ...getters import NoBuildError +from ...struct import Term TOKEN_URL = "https://icdaccessmanagement.who.int/connect/token" # noqa:S105 diff --git a/src/pyobo/sources/mirbase/__init__.py b/src/pyobo/sources/mirbase/__init__.py new file mode 100644 index 00000000..7584aa44 --- /dev/null +++ b/src/pyobo/sources/mirbase/__init__.py @@ -0,0 +1,11 @@ +"""Resources from miRBase.""" + +from .mirbase import MiRBaseGetter +from .mirbase_family import MiRBaseFamilyGetter +from .mirbase_mature import MiRBaseMatureGetter + +__all__ = [ + "MiRBaseFamilyGetter", + "MiRBaseGetter", + "MiRBaseMatureGetter", +] diff --git a/src/pyobo/sources/mirbase.py b/src/pyobo/sources/mirbase/mirbase.py similarity index 98% rename from src/pyobo/sources/mirbase.py rename to src/pyobo/sources/mirbase/mirbase.py index b68c81e5..f3cc588e 100644 --- a/src/pyobo/sources/mirbase.py +++ b/src/pyobo/sources/mirbase/mirbase.py @@ -6,12 +6,13 @@ from tqdm.auto import tqdm -from pyobo.sources.mirbase_constants import BASE_URL, _assert_frozen_version from pyobo.struct import Obo, Reference, Synonym, Term, from_species from pyobo.struct.typedef import has_mature from pyobo.utils.cache import cached_mapping from pyobo.utils.path import ensure_df, ensure_path, prefix_directory_join +from .mirbase_constants import BASE_URL, _assert_frozen_version + __all__ = [ "MiRBaseGetter", ] diff --git a/src/pyobo/sources/mirbase_constants.py b/src/pyobo/sources/mirbase/mirbase_constants.py similarity index 100% rename from src/pyobo/sources/mirbase_constants.py rename to src/pyobo/sources/mirbase/mirbase_constants.py diff --git a/src/pyobo/sources/mirbase_family.py b/src/pyobo/sources/mirbase/mirbase_family.py similarity index 97% rename from src/pyobo/sources/mirbase_family.py rename to src/pyobo/sources/mirbase/mirbase_family.py index b2ec88e6..84c9e557 100644 --- a/src/pyobo/sources/mirbase_family.py +++ b/src/pyobo/sources/mirbase/mirbase_family.py @@ -5,12 +5,13 @@ import pandas as pd from tqdm.auto import tqdm -from pyobo.sources.mirbase_constants import ( +from pyobo.struct import Obo, Reference, Term, has_member + +from .mirbase_constants import ( get_premature_df, get_premature_family_df, get_premature_to_prefamily_df, ) -from pyobo.struct import Obo, Reference, Term, has_member __all__ = [ "MiRBaseFamilyGetter", diff --git a/src/pyobo/sources/mirbase_mature.py b/src/pyobo/sources/mirbase/mirbase_mature.py similarity index 95% rename from src/pyobo/sources/mirbase_mature.py rename to src/pyobo/sources/mirbase/mirbase_mature.py index e12d2cd6..94413525 100644 --- a/src/pyobo/sources/mirbase_mature.py +++ b/src/pyobo/sources/mirbase/mirbase_mature.py @@ -5,9 +5,10 @@ import pandas as pd from tqdm.auto import tqdm -from pyobo.sources.mirbase_constants import get_mature_df from pyobo.struct import Obo, Reference, Synonym, Term +from .mirbase_constants import get_mature_df + __all__ = [ "MiRBaseMatureGetter", ] diff --git a/src/pyobo/sources/ncbi/__init__.py b/src/pyobo/sources/ncbi/__init__.py new file mode 100644 index 00000000..14e84695 --- /dev/null +++ b/src/pyobo/sources/ncbi/__init__.py @@ -0,0 +1,9 @@ +"""Resources from NCBI.""" + +from .ncbi_gc import NCBIGCGetter +from .ncbigene import NCBIGeneGetter + +__all__ = [ + "NCBIGCGetter", + "NCBIGeneGetter", +] diff --git a/src/pyobo/sources/ncbi_gc.py b/src/pyobo/sources/ncbi/ncbi_gc.py similarity index 100% rename from src/pyobo/sources/ncbi_gc.py rename to src/pyobo/sources/ncbi/ncbi_gc.py diff --git a/src/pyobo/sources/ncbigene.py b/src/pyobo/sources/ncbi/ncbigene.py similarity index 98% rename from src/pyobo/sources/ncbigene.py rename to src/pyobo/sources/ncbi/ncbigene.py index 692242bb..176e31ba 100644 --- a/src/pyobo/sources/ncbigene.py +++ b/src/pyobo/sources/ncbi/ncbigene.py @@ -7,8 +7,8 @@ import pandas as pd from tqdm.auto import tqdm -from ..struct import Obo, Reference, Term, from_species -from ..utils.path import ensure_df +from ...struct import Obo, Reference, Term, from_species +from ...utils.path import ensure_df __all__ = [ "NCBIGeneGetter", diff --git a/src/pyobo/sources/pfam/__init__.py b/src/pyobo/sources/pfam/__init__.py new file mode 100644 index 00000000..d2729eb0 --- /dev/null +++ b/src/pyobo/sources/pfam/__init__.py @@ -0,0 +1,9 @@ +"""Resources from PFAM.""" + +from .pfam import PfamGetter +from .pfam_clan import PfamClanGetter + +__all__ = [ + "PfamClanGetter", + "PfamGetter", +] diff --git a/src/pyobo/sources/pfam.py b/src/pyobo/sources/pfam/pfam.py similarity index 95% rename from src/pyobo/sources/pfam.py rename to src/pyobo/sources/pfam/pfam.py index 28dea166..0b72f464 100644 --- a/src/pyobo/sources/pfam.py +++ b/src/pyobo/sources/pfam/pfam.py @@ -4,8 +4,8 @@ import pandas as pd -from ..struct import Obo, Reference, Term -from ..utils.path import ensure_df +from ...struct import Obo, Reference, Term +from ...utils.path import ensure_df __all__ = [ "PfamGetter", diff --git a/src/pyobo/sources/pfam_clan.py b/src/pyobo/sources/pfam/pfam_clan.py similarity index 96% rename from src/pyobo/sources/pfam_clan.py rename to src/pyobo/sources/pfam/pfam_clan.py index 0bc1a938..a42f855b 100644 --- a/src/pyobo/sources/pfam_clan.py +++ b/src/pyobo/sources/pfam/pfam_clan.py @@ -5,7 +5,7 @@ from tqdm.auto import tqdm from .pfam import get_pfam_clan_df -from ..struct import Obo, Reference, Term +from ...struct import Obo, Reference, Term __all__ = [ "PfamClanGetter",