Skip to content

Preserve zero-padded identifiers when reading SDRFs - #385

Merged
Shen-YuFei merged 4 commits into
devfrom
copilot/fix-leading-zeros-sdrf
Nov 12, 2026
Merged

Shen-YuFei merged 4 commits into
devfrom
copilot/fix-leading-zeros-sdrf

Conversation

Copilot AI commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Pandas type inference converted numeric-looking SDRF identifiers such as 001 to 1, potentially collapsing distinct samples and breaking joins.

  • Read values as text: Both SDRF readers use dtype=str, keep_default_na=False.
  • Preserve intended types: Replicate fields continue to be converted to integers where used; fraction identifiers remain text.
  • Regression coverage: Verify 001 and 01 remain distinct in sample/run outputs and core sample mappings.

For example, source name values 001 and 01 now remain "001" and "01" rather than becoming the same numeric value.

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Bot user detected.

To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: feffd100-356f-478a-ab27-15705910942b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@codacy-production

codacy-production Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 0 complexity · 0 duplication

Metric Results
Complexity 0
Duplication 0

View in Codacy

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>
Copilot AI changed the title [WIP] Fix leading zeros loss in SDRF source names Preserve zero-padded identifiers when reading SDRFs Nov 10, 2026
Copilot AI requested a review from ypriverol November 10, 2026 06:18
@ypriverol
ypriverol requested review from timosachsenberg and a balanced review from Copilot and removed request for Copilot and ypriverol November 10, 2026 06:58
@ypriverol
ypriverol marked this pull request as ready for review November 10, 2026 06:59
@qodo-code-review

Copy link
Copy Markdown

ⓘ 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 timosachsenberg left a comment

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.

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:

  1. update-metadata still reads with type inference. transforms/sdrf_updater.py has its own reader, _read_sdrf_normalized L34-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 sample 001 → 1 is 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.

  2. Minor: replicates written with a decimal point. With text input, _run_samples L252-L264 does int(row[...]), so a cell 1.0 now gives None (before, the column was read as float and gave 1). Spreadsheet exports sometimes write replicates that way. Parsing via float and 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.

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.

SDRF is read with inferred dtypes: zero-padded source names lose their leading zeros

4 participants