Repository navigation
Preserve zero-padded identifiers when reading SDRFs - #385
Conversation
|
Important Review skippedBot user detected. To trigger a single review, invoke the
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 0 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Co-authored-by: ypriverol <52113+ypriverol@users.noreply.github.com>
|
ⓘ Qodo reviews are paused because the subscription is no longer active. Ask your workspace admin to reactivate the subscription to resume reviews. Manage billing |
timosachsenberg
left a comment
There was a problem hiding this comment.
Reviewed at b799cc1 and ran an independent set of regression tests against it (written separately for #379, offline, pandas 3.1.1 / duckdb 2.0.0). The two readers changed here behave as intended: zero-padded source names and data-file stems survive into sample.parquet, run.parquet and SDRFHandler.get_sample_map_run(), and blank cells stay missing. Two things the tests found:
-
update-metadatastill reads with type inference.transforms/sdrf_updater.pyhas its own reader,_read_sdrf_normalizedL34-L38 (pd.read_csv(path, sep="\t")), used by_check_protected_changes. Old and new SDRFs are therefore still compared as numbers, so renaming a sample001→1is not reported as a changed sample-run mapping:# old: source name 001, new: source name 1, same label and data file a.raw _check_protected_changes(old_sdrf, new_sdrf) # no "sample-run-label mapping changed" warning
Reading it the same way as the other two (
dtype=str, keep_default_na=False, na_values=[""]) fixes it. -
Minor: replicates written with a decimal point. With text input,
_run_samplesL252-L264 doesint(row[...]), so a cell1.0now givesNone(before, the column was read as float and gave 1). Spreadsheet exports sometimes write replicates that way. Parsing viafloatand accepting only integral values would keep them, e.g.:def _replicate_number(value): try: number = float(str(value).strip()) except (TypeError, ValueError): return None return int(number) if number.is_integer() and number > 0 else None
#384 and this PR conflict only in tests/converters/test_sdrf_run_metadata.py (both append at the end), and #384 needs this one for numeric-looking comment values such as 007.
Pandas type inference converted numeric-looking SDRF identifiers such as
001to1, potentially collapsing distinct samples and breaking joins.dtype=str, keep_default_na=False.001and01remain distinct in sample/run outputs and core sample mappings.For example,
source namevalues001and01now remain"001"and"01"rather than becoming the same numeric value.