Skip to content

Allow NEON soil translator to take selected list of dnaSampleID values as input - #1398

Merged
sujaypatil96 merged 9 commits into
mainfrom
constrain-neon-soil-translator-by-dna-sample-ids
Mar 12, 2026
Merged

sujaypatil96 merged 9 commits into
mainfrom
constrain-neon-soil-translator-by-dna-sample-ids

Conversation

@sujaypatil96

@sujaypatil96 sujaypatil96 commented Mar 2, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Add a dnaSampleID filter to the NEON soil translator, allowing jobs to constrain translation to a specific set of DNA samples. The filter is configured via a new get_neon_soil_sample_filter Dagster op and applied to mms_metagenomeDnaExtraction, mms_metagenomeSequencing, and
    raw data file mappings at load time.
  • Fix missing ProcessedSample records for non-pooled Extractions — the else branch was only creating the Extraction record but not the corresponding output ProcessedSample.
  • Fix invalid carb_nitro_ratio unit: change from "ratio" (not in the NMDC schema enum) to "1" (dimensionless unit).
  • Handle empty data objects gracefully: guard _id_minter call for DataObject IDs with a length check to avoid minting zero IDs.
  • Add nmdc:Manifest support: create Manifest records when a dnaSampleID has more than 2 raw data files, and link each DataObject to its Manifest via in_manifest.
  • Create one NucleotideSequencing record per R1/R2 file pair instead of one per dnaSampleID. Files are paired by basename (stripping the directory path) to correctly match R1 and R2 files that live in different directories.

Changes

  • neon_soil_translator.py: Accept optional allowed_dna_sample_ids parameter; filter MMS and raw data file tables by dnaSampleID; fix carb_nitro_ratio unit; guard empty neon_raw_file_paths; add missing processed_sample_set.append() for non-pooled extractions; add
    _translate_manifest() method; add manifest_id parameter to _translate_data_object() with in_manifest field; group raw data files into R1/R2 pairs by filename basename; mint one NucleotideSequencing ID per pair; create one NucleotideSequencing record per pair with both
    DataObject IDs in has_output; create Manifest records for dnaSampleIDs with >2 raw files.
  • ops.py: Add get_neon_soil_sample_filter op with dna_sample_ids config; pass allowed_dna_sample_ids through to the translator.
  • graphs.py: Wire get_neon_soil_sample_filter into both translate_neon_api_soil_metadata_to_nmdc_schema_database and ingest_neon_soil_metadata graphs.
  • repository.py: Add default (empty) config for get_neon_soil_sample_filter in both job presets.

Test plan

  • Run pytest tests/ -k "neon_soil" -v to verify existing translator tests pass
  • Verify that passing an empty allowed_dna_sample_ids set produces the same output as before (no filtering)
  • Verify that passing a specific set of dnaSampleID values correctly constrains the translated output
  • Confirm processed_sample_set count matches expected for both pooled and non-pooled extractions
  • Verify each NucleotideSequencing record has exactly 2 DataObjects (one R1, one R2) in has_output
  • Verify Manifest records are created only when a dnaSampleID has >2 raw data files, and that corresponding DataObject records reference the Manifest via in_manifest

Related issue: microbiomedata/issues#1271

Constrain the NEON soil translator to only process a configurable
subset of samples by dnaSampleID. The filter is provided as a list
of IDs via the Dagster launchpad UI at job launch time.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sujaypatil96
sujaypatil96 marked this pull request as draft March 2, 2026 23:29
github-actions and others added 5 commits March 2, 2026 23:30
…bjects

Use "1" (dimensionless) instead of "ratio" for carb_nitro_ratio unit to
match nmdc_schema UnitEnum. Skip id minting when there are no raw data
file paths to avoid 422 error from PositiveInt validation.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Wire get_neon_soil_sample_filter op config into the translate and ingest
NEON soil metadata job definitions. Remove unused Optional import and
default value from allowed_dna_sample_ids parameter.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The else branch (non-pooled samples) in the extraction processing loop
was missing the processed_sample_set.append() call, causing 24
ProcessedSample records to be omitted from the output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sujaypatil96
sujaypatil96 force-pushed the constrain-neon-soil-translator-by-dna-sample-ids branch from b701e40 to 12d76d2 Compare March 5, 2026 18:09
@sujaypatil96
sujaypatil96 marked this pull request as ready for review March 5, 2026 18:28
@sujaypatil96
sujaypatil96 requested a review from aclum March 5, 2026 18:28
@@ -770,4 +792,4 @@
processed_sample_id, genomics_sample_id

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

name of the processed sample that is output of extraction should be the dnaSampleID, not the genomics_sample_id

@sujaypatil96 sujaypatil96 Mar 11, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll make another PR to address this. We should leave the scope of this PR to just "adding include list capability".

processed_sample_id, genomics_sample_id
)
)
else:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What use case is this else block supposed to be addressing so I can check how the processed sample should be named.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would you be able to highlight the snippet you want to verify again @aclum?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should be genomics_sample_id, not dna_sample_id

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above, I'll make another PR to address this. We should leave the scope of this PR to just "adding include list capability".

…e always created

- Use genomicsSampleID (not dnaSampleID) to name pooled ProcessedSample records
- Use dna_sample_input (not genomics_sample_id) to name extraction ProcessedSample records
- Move data_generation_set.append() outside the raw data files check so sequencing
  records are created even when no raw file paths are present
- Remove unused has_output = None assignment

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@sujaypatil96 sujaypatil96 changed the title Add dnaSampleID filter to NEON soil translator Allow NEON soil translator to take selected list of dnaSampleID values as input Mar 9, 2026
sujaypatil96 and others added 2 commits March 9, 2026 16:51
…ranslator

Create one NucleotideSequencing record per R1/R2 file pair instead of
one per dnaSampleID, pairing files by basename to handle R1/R2 living
in different directories. Add Manifest records for dnaSampleIDs with
multiple R1/R2 pairs, linking their DataObjects via in_manifest.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sujaypatil96
sujaypatil96 requested a review from aclum March 11, 2026 23:22
@sujaypatil96

Copy link
Copy Markdown
Collaborator Author

Based on the JSON file we recently submitted to dev and prod Mongo (see microbiomedata/issues#1271 (comment)), I think we're ready to merge in this PR.

@sujaypatil96
sujaypatil96 merged commit f19ecb9 into main Mar 12, 2026
@sujaypatil96
sujaypatil96 deleted the constrain-neon-soil-translator-by-dna-sample-ids branch March 12, 2026 18:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants