kg_microbe.transform_utils.bactotraits package
Submodules
kg_microbe.transform_utils.bactotraits.bactotraits module
BactoTraits transform class.
- class kg_microbe.transform_utils.bactotraits.bactotraits.BactoTraitsTransform(input_dir, output_dir)
Bases:
TransformBactoTraits transform.
Essentially just ingests and transforms this file: https://ordar.otelo.univ-lorraine.fr/files/ORDAR-53/BactoTraits_databaseV2_Jun2022.csv
Columns available in the file: - strain n¡ - Bacdive_ID - culture collection codes - Kingdom - Phylum - Class - Order - Family - Genus - Species - Full_name - pHO_0_to_6 - pHO_6_to_7 - pHO_7_to_8 - pHO_8_to_14 - pHR_0_to_4 - pHR_4_to_6 - pHR_6_to_7 - pHR_7_to_8 - pHR_8_to_10 - 10_to_14 - pHd_<=1 - pHd_1_2 - pHd_2_3 - pHd_3_4 - pHd_4_5 - pHd_5_9 - NaO_<=1 - NaO_1_to_3 - NaO_3_to_8 - NaO_>8 - NaR_<=1 - NaR_1_to_3 - NaR_3_to_8 - NaR_>8 - Nad_<=1 - Nad_1_3 - Nad_3_8 - Nad_>8 - TO_<=10 - TO_10_to_22 - TO_22_to_27 - TO_27_to_30 - TO_30_to_34 - TO_34_to_40 - TO_>40 - TR_<=10 - TR_10_to_22 - TR_22_to_27 - TR_27_to_30 - TR_30_to_34 - TR_34_to_40 - TR_>40 - Td_1_5 - Td_5_10 - Td_10_20 - Td_20_30 - Td_>30 - Ox_anaerobic - Ox_aerobic - Ox_facultative_aerobe_anaerobe - Ox_microerophile - G_negative - G_positive - non-motile - motile - spore - no_spore - GC_<=42.65 - GC_42.65_57.0 - GC_57.0_66.3 - GC_>66.3 - W_<=0.5 - W_0.5_0.65 - W_0.65_0.9 - W_>0.9 - L_<=1.3 - L_1.3_2 - L_2_3 - L_>3 - S_rod - S_sphere - S_curved_spiral - S_filament - S_ovoid - S_star_dumbbell_pleomorphic - TT_heterotroph - TT_autotroph - TT_organotroph - TT_lithotroph - TT_chemotroph - TT_phototroph - TT_copiotroph_diazotroph - TT_methylotroph - TT_oligotroph - Pigment_pink - Pigment_yellow - Pigment_brown - Pigment_black - Pigment_orange - Pigment_white - Pigment_cream - Pigment_red - Pigment_green - Pigment_carotenoid
-
DATA_INPUTS:
tuple= ('mappings/canonical/bactotraits_identity_quarantine.json',) 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.
- IDENTITY_QUARANTINE_POLICY = PosixPath('/home/runner/work/kg-microbe/kg-microbe/mappings/canonical/bactotraits_identity_quarantine.json')
-
REQUIRED_AUDIT_FILES:
tuple= ('bactotraits_identity_quarantine.tsv',) Producer-owned disposition reports whose emitted bytes must survive finalization/merge.
-
REQUIRED_CONSUMED_INPUTS:
tuple= ('bacdive_taxon_lookup', 'bactotraits_identity_policy', 'bactotraits_source') 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= ('bacdive',) The BacDive-produced intermediate TSV supplies strain-taxid mappings (#1091).
- run(data_file=None, show_status=True)
Run BactoTraitsTransform.
- Return type:
None
-
DATA_INPUTS:
kg_microbe.transform_utils.bactotraits.identity_quarantine module
Withhold only reviewed BactoTraits rows with incompatible strain identities.
- class kg_microbe.transform_utils.bactotraits.identity_quarantine.IdentityQuarantine(policy_text)
Bases:
objectValidate a finite policy and identify its exact rows before graph emission.
- preflight(raw)
Find each reviewed row exactly once; an altered or absent row needs new review.
- verify_lookup(lookup)
Do not silently reinterpret the reviewed row after its mapped taxon changes.
- write_audit(stream)
Preserve original source identities and raw rows, including an empty audit header.
- kg_microbe.transform_utils.bactotraits.identity_quarantine.raw_row_sha256(row)
Replay EdgeMech’s complete Latin-1-decoded source-record-json-canonical/v1 row.
Module contents
BactoTraits transform.
- class kg_microbe.transform_utils.bactotraits.BactoTraitsTransform(input_dir, output_dir)
Bases:
TransformBactoTraits transform.
Essentially just ingests and transforms this file: https://ordar.otelo.univ-lorraine.fr/files/ORDAR-53/BactoTraits_databaseV2_Jun2022.csv
Columns available in the file: - strain n¡ - Bacdive_ID - culture collection codes - Kingdom - Phylum - Class - Order - Family - Genus - Species - Full_name - pHO_0_to_6 - pHO_6_to_7 - pHO_7_to_8 - pHO_8_to_14 - pHR_0_to_4 - pHR_4_to_6 - pHR_6_to_7 - pHR_7_to_8 - pHR_8_to_10 - 10_to_14 - pHd_<=1 - pHd_1_2 - pHd_2_3 - pHd_3_4 - pHd_4_5 - pHd_5_9 - NaO_<=1 - NaO_1_to_3 - NaO_3_to_8 - NaO_>8 - NaR_<=1 - NaR_1_to_3 - NaR_3_to_8 - NaR_>8 - Nad_<=1 - Nad_1_3 - Nad_3_8 - Nad_>8 - TO_<=10 - TO_10_to_22 - TO_22_to_27 - TO_27_to_30 - TO_30_to_34 - TO_34_to_40 - TO_>40 - TR_<=10 - TR_10_to_22 - TR_22_to_27 - TR_27_to_30 - TR_30_to_34 - TR_34_to_40 - TR_>40 - Td_1_5 - Td_5_10 - Td_10_20 - Td_20_30 - Td_>30 - Ox_anaerobic - Ox_aerobic - Ox_facultative_aerobe_anaerobe - Ox_microerophile - G_negative - G_positive - non-motile - motile - spore - no_spore - GC_<=42.65 - GC_42.65_57.0 - GC_57.0_66.3 - GC_>66.3 - W_<=0.5 - W_0.5_0.65 - W_0.65_0.9 - W_>0.9 - L_<=1.3 - L_1.3_2 - L_2_3 - L_>3 - S_rod - S_sphere - S_curved_spiral - S_filament - S_ovoid - S_star_dumbbell_pleomorphic - TT_heterotroph - TT_autotroph - TT_organotroph - TT_lithotroph - TT_chemotroph - TT_phototroph - TT_copiotroph_diazotroph - TT_methylotroph - TT_oligotroph - Pigment_pink - Pigment_yellow - Pigment_brown - Pigment_black - Pigment_orange - Pigment_white - Pigment_cream - Pigment_red - Pigment_green - Pigment_carotenoid
-
DATA_INPUTS:
tuple= ('mappings/canonical/bactotraits_identity_quarantine.json',) 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.
- IDENTITY_QUARANTINE_POLICY = PosixPath('/home/runner/work/kg-microbe/kg-microbe/mappings/canonical/bactotraits_identity_quarantine.json')
-
REQUIRED_AUDIT_FILES:
tuple= ('bactotraits_identity_quarantine.tsv',) Producer-owned disposition reports whose emitted bytes must survive finalization/merge.
-
REQUIRED_CONSUMED_INPUTS:
tuple= ('bacdive_taxon_lookup', 'bactotraits_identity_policy', 'bactotraits_source') 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= ('bacdive',) The BacDive-produced intermediate TSV supplies strain-taxid mappings (#1091).
- run(data_file=None, show_status=True)
Run BactoTraitsTransform.
- Return type:
None
-
DATA_INPUTS: