Repository navigation
Map C. elegans sex XX/XO to hermaphrodite/male - #1976
Conversation
nwbinspector (CRITICAL under its "dandi" config) requires Subject.sex to be XX (hermaphrodite) or XO (male) for C. elegans, while extract_sex raised "Cannot interpret sex field" on both, so no C. elegans NWB file could satisfy both. Map them for C. elegans only; elsewhere XX/XO do not unambiguously designate a sex and keep raising. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NdN9xPzPo1AzsnEMuU8UQs
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1976 +/- ##
==========================================
+ Coverage 91.04% 91.12% +0.08%
==========================================
Files 95 95
Lines 14599 14645 +46
==========================================
+ Hits 13291 13345 +54
+ Misses 1308 1300 -8
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
There is another place to look; this is why for something like the ndx-subjects extension, the approach was to set the global field to O and have an extended field |
CElegansSubject of ndx-subjects fixes Subject.sex to "O" and records XX/XO in a separate c_elegans_sex field (e.g. Dandiset 001075). Extract that field along with the other subject fields and use it when sex is "O" or unset. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01NdN9xPzPo1AzsnEMuU8UQs
|
Thanks, I had missed that. 2ab90c0 also reads The two conventions conflict with each other, though. For species "Caenorhabditis elegans", nwbinspector's Generated by Claude Code |
Yep, go ahead and fork that repo and make that PR |
|
Did you confirm that the extension field will show up in that metadata dictionary object passed to that level? |
|
Not before you asked, but I have now, end to end. I wrote NWB files with ndx-subjects 0.2.0's
So the extension field reaches I could add this as a test. The test would need ndx-subjects, or a hand-built extension namespace, in the test environment. I left it out because that adds a test dependency, but I'm happy to add it, guarded by Generated by Claude Code |
|
that's fine thanks for checking |
|
Wow, thank you @CodyCBakerPhD for guiding my corporate friend to conclusion here. I just came to review its work and was pleased to see it "fully done"! ;) |
Unfortunately it did not pass my smoke test to
So I guess 'someone' should do that eventually, if they ever want to use that extension |
|
sorry, do you mean this logic which is part of the PR https://github.com/dandi/dandi-cli/pull/1976/changes#diff-f1fffc52a57ec0f6b12d707f48d19c51f4dd81a4606d3535935d38e10e710bbdR317 or there is more todo? |
|
With respect to
|
|
🚀 PR was released in |
|
ah, gotcha, it didn't obey to your order! |
Follow-up to #1949.
Problem
For C. elegans, nwbinspector's
check_subject_sexaccepts onlyXX(hermaphrodite) orXO(male) asSubject.sex. That check is CRITICAL under the "dandi" config, sodandi validateanddandi uploadreport it as an error.extract_sex, however, raisedValueError: Cannot interpret sex field: xx(orxo). No C. elegans NWB file could satisfy both:XX/XOpasses the inspector, but asset metadata extraction fails;Oextracts as "Other", but fails the CRITICAL inspector check.Existing C. elegans Dandisets (e.g. 000472, 000541, 000776, 000981) record their subjects as "Other".
Change
extract_sexmapsXX/XO(any case) whenspeciesdesignates C. elegans:sexXXPATO_0001340XOPATO_0000384C. elegans is recognized from "Caenorhabditis elegans" and "C. elegans" (the two values nwbinspector checks), "Caenorhabditis elegans - …", and the NCBITaxon IRI
NCBITaxon_6239.It also reads
c_elegans_sexfrom the subject. TheCElegansSubjecttype of ndx-subjects fixessextoOand recordsXX/XOthere, as in Dandiset 001075. WhensexisOor unset, that value is used. An explicitM/Finsexstill wins.For any other or missing species,
XX/XOstill raise. In mammals, for example,XXwould mean female, so the codes are not unambiguous outside C. elegans.Tests
test_extract_sex_c_eleganscovers the four species spellings and both codes, in upper and lower case.test_extract_sex_chromosomal_other_specieschecks thatXX/XOstill raise without a species, and for mouse and fly.test_extract_sex_ndx_subjects_c_eleganscoversc_elegans_sex, and checks that an explicitsexstill wins.@pytest.mark.ai_generated.Related: NeurodataWithoutBorders/nwbinspector#353 (added the C. elegans rule), NeurodataWithoutBorders/nwb-schema#575, dandi/dandi-schema#171.
Generated by Claude Code