kg_microbe.transform_utils package
Subpackages
- kg_microbe.transform_utils.bacdive package
- Submodules
- kg_microbe.transform_utils.bacdive.bacdive module
- kg_microbe.transform_utils.bacdive.emission module
- kg_microbe.transform_utils.bacdive.references module
- Module contents
BacDiveTransformBacDiveTransform.DATA_INPUTSBacDiveTransform.TRANSFORM_INPUTSBacDiveTransform.assay_edges_generatedBacDiveTransform.assay_nodes_generatedBacDiveTransform.assay_raw_dataBacDiveTransform.assay_target_nodes_generatedBacDiveTransform.chebi_categoriesBacDiveTransform.isolation_source_mappingsBacDiveTransform.ncbitaxon_fallback_cacheBacDiveTransform.ncbitaxon_labelsBacDiveTransform.ncbitaxon_name_to_idBacDiveTransform.ncbitaxon_synonymsBacDiveTransform.pathogenicity_mappingsBacDiveTransform.phenotype_routingBacDiveTransform.run()
- kg_microbe.transform_utils.bactotraits package
- kg_microbe.transform_utils.bakta package
- Submodules
- kg_microbe.transform_utils.bakta.bakta module
BaktaTransformBaktaTransform.add_cog_annotation()BaktaTransform.add_ec_annotation()BaktaTransform.add_edge()BaktaTransform.add_functional_annotations()BaktaTransform.add_gene_node()BaktaTransform.add_go_annotation()BaktaTransform.add_kegg_annotation()BaktaTransform.add_organism_node()BaktaTransform.add_protein_node()BaktaTransform.get_ncbitaxon_id()BaktaTransform.get_organism_id()BaktaTransform.process_gene()BaktaTransform.process_genome()BaktaTransform.run()BaktaTransform.write_output()
- kg_microbe.transform_utils.bakta.create_samn_mapping module
- kg_microbe.transform_utils.bakta.utils module
- Module contents
BaktaTransformBaktaTransform.add_cog_annotation()BaktaTransform.add_ec_annotation()BaktaTransform.add_edge()BaktaTransform.add_functional_annotations()BaktaTransform.add_gene_node()BaktaTransform.add_go_annotation()BaktaTransform.add_kegg_annotation()BaktaTransform.add_organism_node()BaktaTransform.add_protein_node()BaktaTransform.get_ncbitaxon_id()BaktaTransform.get_organism_id()BaktaTransform.process_gene()BaktaTransform.process_genome()BaktaTransform.run()BaktaTransform.write_output()
- kg_microbe.transform_utils.cog package
- kg_microbe.transform_utils.ctd package
- kg_microbe.transform_utils.disbiome package
- kg_microbe.transform_utils.example_transform package
- kg_microbe.transform_utils.gold package
- kg_microbe.transform_utils.gtdb package
- kg_microbe.transform_utils.kegg package
- kg_microbe.transform_utils.lpsn package
- kg_microbe.transform_utils.lpsn_api package
- kg_microbe.transform_utils.madin_etal package
- kg_microbe.transform_utils.mediadive package
- Submodules
- kg_microbe.transform_utils.mediadive.bulk_inputs module
- kg_microbe.transform_utils.mediadive.mediadive module
MediaDiveTransformMediaDiveTransform.DATA_INPUTSMediaDiveTransform.DEFAULT_INPUT_DIRMediaDiveTransform.OPTIONAL_RAW_CONSUMED_INPUTSMediaDiveTransform.REQUIRED_CONSUMED_INPUTSMediaDiveTransform.TRANSFORM_INPUTSMediaDiveTransform.consume_bulk_input()MediaDiveTransform.download_yaml_and_get_json()MediaDiveTransform.get_compounds_of_solution()MediaDiveTransform.get_json_object()MediaDiveTransform.get_solution_recipe_occurrences()MediaDiveTransform.producer_native_inputsMediaDiveTransform.run()MediaDiveTransform.standardize_compound_id()MediaDiveTransform.verify_native_inputs()MediaDiveTransform.verify_recorded_native_inputs()
- Module contents
MediaDiveTransformMediaDiveTransform.DATA_INPUTSMediaDiveTransform.DEFAULT_INPUT_DIRMediaDiveTransform.OPTIONAL_RAW_CONSUMED_INPUTSMediaDiveTransform.REQUIRED_CONSUMED_INPUTSMediaDiveTransform.TRANSFORM_INPUTSMediaDiveTransform.chebi_categoriesMediaDiveTransform.chebi_labelsMediaDiveTransform.chebi_role_edgesMediaDiveTransform.chebi_rolesMediaDiveTransform.consume_bulk_input()MediaDiveTransform.download_yaml_and_get_json()MediaDiveTransform.get_compounds_of_solution()MediaDiveTransform.get_json_object()MediaDiveTransform.get_solution_recipe_occurrences()MediaDiveTransform.producer_native_inputsMediaDiveTransform.run()MediaDiveTransform.standardize_compound_id()MediaDiveTransform.verify_native_inputs()MediaDiveTransform.verify_recorded_native_inputs()
- kg_microbe.transform_utils.metatraits package
- Submodules
- kg_microbe.transform_utils.metatraits.io module
- kg_microbe.transform_utils.metatraits.metatraits module
- Module contents
MetaTraitsTransformMetaTraitsTransform.DATA_INPUTSMetaTraitsTransform.MEASUREMENT_TRAITSMetaTraitsTransform.OPTIONAL_CONSUMED_INPUTSMetaTraitsTransform.TRANSFORM_INPUTSMetaTraitsTransform.discovered_data_inputs()MetaTraitsTransform.indeterminate_traits_fileMetaTraitsTransform.ncbitaxon_name_to_idMetaTraitsTransform.run()MetaTraitsTransform.trait_mapping
- kg_microbe.transform_utils.metatraits_gtdb package
- Submodules
- kg_microbe.transform_utils.metatraits_gtdb.metatraits_gtdb module
- Module contents
MetaTraitsGTDBTransformMetaTraitsGTDBTransform.CODE_INPUTSMetaTraitsGTDBTransform.DATA_INPUTSMetaTraitsGTDBTransform.TRANSFORM_INPUTSMetaTraitsGTDBTransform.accession_to_gtdb_speciesMetaTraitsGTDBTransform.accession_to_ncbiMetaTraitsGTDBTransform.gtdb_preferred_ncbiMetaTraitsGTDBTransform.gtdb_to_ncbiMetaTraitsGTDBTransform.ncbitaxon_name_to_idMetaTraitsGTDBTransform.run()MetaTraitsGTDBTransform.synthetic_nodes_metadataMetaTraitsGTDBTransform.trait_mapping
- kg_microbe.transform_utils.microbedecoder package
- kg_microbe.transform_utils.mim_ingredients package
- kg_microbe.transform_utils.ontologies package
- kg_microbe.transform_utils.ontologies_stubs package
- kg_microbe.transform_utils.prego package
- kg_microbe.transform_utils.rhea_mappings package
- kg_microbe.transform_utils.uniprot_functional_microbes package
- kg_microbe.transform_utils.uniprot_human package
- kg_microbe.transform_utils.uniprot_trembl package
- kg_microbe.transform_utils.wallen_etal package
Submodules
kg_microbe.transform_utils.constants module
Constants for transform_utilities.
- kg_microbe.transform_utils.constants.GTDB_NCBI_POOLING_REPORT = 'gtdb_ncbi_pooling_report.tsv'
Report of NCBI taxa that several GTDB taxa map onto (#883). Written on every gtdb run, empty or not.
kg_microbe.transform_utils.transform module
Transform utility module.
- class kg_microbe.transform_utils.transform.Transform(source_name, input_dir=None, output_dir=None, nlp=False)
Bases:
objectParent class for transforms, that sets up a lot of default file info.
-
CODE_INPUTS:
tuple= () Additional repo-relative Python packages/files whose behavior this producer inherits. This is code provenance, never a dependency on another producer’s graph outputs.
- DATA_DIR = PosixPath('/home/runner/work/kg-microbe/kg-microbe/kg_microbe/transform_utils/data')
-
DATA_INPUTS:
tuple= () Repo-relative curation files this transform reads, beyond its own
data/raw/download.Declared so freshness tooling can tell that an output is stale against its data rather than only its code. Without it a mapping correction lands, every consumer keeps reporting FRESH, and a re-merge silently ships the old groundings: #778 corrected 16 isolation-source ids and #786 rewrote the unified chemical SSSOM, and the merged KG built afterwards still asserted 75 organisms isolated from a “Cell Line”, because nothing re-ran the transforms that read those files (#812).
Paths are relative to the repo root. Keep them tracked in git — the freshness check uses commit time, not mtime, because git checkout rewrites mtimes without changing content (#797).
List every curation file read, not a representative one. A partial declaration fails silently and looks identical to a complete one: ontologies_stubs declared 1 of the 11 files it read and was reported fresh after changes to the other ten (#839). Where the set comes from a constant, derive this from it rather than restating it.
- DEFAULT_INPUT_DIR = PosixPath('/home/runner/work/kg-microbe/kg-microbe/kg_microbe/transform_utils/data/raw')
- DEFAULT_OUTPUT_DIR = PosixPath('/home/runner/work/kg-microbe/kg-microbe/kg_microbe/transform_utils/data/transformed')
-
OPTIONAL_CONSUMED_INPUTS:
tuple= () Named optional repository-relative reads; absence is evidence, never a required file. Unlike DATA_INPUTS these locators do not relocate to input_base_dir.
-
OPTIONAL_RAW_CONSUMED_INPUTS:
tuple= () Named optional reads relative to the effective input_base_dir, including explicit absence. Kept separate so repository-relative optional inputs never silently relocate.
-
REQUIRED_CONSUMED_INPUTS:
tuple= () Named generated inputs that must actually be read before fresh finalization. Unlike DATA_INPUTS, these are checked after upstream producers have run.
-
TRANSFORM_INPUTS:
tuple= () Registered source names whose output this transform reads.
DATA_INPUTS covers curation files under
mappings/. It does not cover a dependency on another transform’s output, and eight sources have one: gold readsontologies/ncbitaxon_nodes.tsv(and refuses to run without it) plusontologies_stubs/po_nodes.tsv, lpsn readsgtdb/nodes.tsv, lpsn_api and microbedecoder readlpsn/nodes.tsv, prego readsontologies/, and bacdive, mediadive and metatraits reachontologies/through theNCBITAXON_NODES_FILE/CHEBI_NODES_FILEconstants (metatraits_gtdb inherits metatraits’). Those last three went undeclared for months precisely because the path is spelled inconstants.pyrather than in the transform, which the guard below could not see until #1035.Undeclared, re-running an upstream leaves every downstream genuinely stale while all three freshness signals report fresh — the #812 shape, across transforms rather than within one (#845). The ordering was already encoded in
DATA_SOURCEScomments (“Run gold after ontologies…”); this makes it machine-readable so the fingerprint can fold the upstream in.tests/test_cross_transform_inputs.py derives the real dependency map from the source and fails on anything undeclared, because every previous version of this contract was opt-in and was forgotten (#812, #839, #876).
- begin_consumed_inputs()
Start a real producer run with no inherited input-consumption claims.
- begin_dependency_admission()
Bind discovered curation and inherited code before a producer loads either.
- consume_input(name, path)
Read a generated UTF-8 input from an immutable, exact-byte tracked snapshot.
- consume_optional_input(name)
Read one declared optional input immutably, retaining its locator and explicit absence.
- property consumed_input_snapshots
Return copied named path/digest snapshots so callers cannot mutate recorded evidence.
- finalize(*, file_prefix='', fresh_run=False)
Validate and finalize produced TSVs before publication as a current source.
The CLI invokes this after
runand before writing the source fingerprint. Direct Python callers must invoke it explicitly afterrun; producer writes themselves are not a bundle transaction.
- property optional_consumed_inputs
Return independent serialized state without replacing original read evidence.
- pass_through(nodes_file, edges_file)
Copy nodes and edges files to output directory.
- Parameters:
nodes_file (
str) – nodes files to take from raw directory and put in transform directoryedges_file (
str) – edges files to take from raw directory and put in transform directory
- Return type:
None
- run(data_file=None)
Run the transform.
- Parameters:
data_file (
Union[Path,None,str]) – Input data file, defaults to None
- verify_consumed_inputs()
Reject missing required reads or changed/deleted bytes consumed by this run.
- verify_declared_dependencies()
Refuse drift without replacing the original producer-time dependency snapshot.
-
CODE_INPUTS:
Module contents
Transform utilities module.