samplesheet-parser 2.1.0__tar.gz → 2.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (138) hide show
  1. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/.gitignore +3 -0
  2. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/.zenodo.json +1 -1
  3. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/CHANGELOG.md +16 -0
  4. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/CITATION.cff +2 -2
  5. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/PKG-INFO +1 -1
  6. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/pyproject.toml +1 -1
  7. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/samplesheet_parser/validators.py +6 -2
  8. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/samplesheet_parser/writer.py +20 -2
  9. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/test_validators/test_hamming.py +49 -0
  10. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/test_writer.py +39 -1
  11. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/.github/workflows/ci.yml +0 -0
  12. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/.github/workflows/copilot-instructions.md +0 -0
  13. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/.pre-commit-config.yaml +0 -0
  14. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/.readthedocs.yaml +0 -0
  15. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/CONTRIBUTING.md +0 -0
  16. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/LICENSE +0 -0
  17. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/Makefile +0 -0
  18. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/README.md +0 -0
  19. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/docs/api.md +0 -0
  20. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/docs/changelog.md +0 -0
  21. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/docs/ci.md +0 -0
  22. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/docs/cli.md +0 -0
  23. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/docs/contributing.md +0 -0
  24. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/docs/examples.md +0 -0
  25. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/docs/guide/conversion.md +0 -0
  26. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/docs/guide/diffing.md +0 -0
  27. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/docs/guide/filtering.md +0 -0
  28. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/docs/guide/index_utils.md +0 -0
  29. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/docs/guide/merging.md +0 -0
  30. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/docs/guide/parsing.md +0 -0
  31. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/docs/guide/quickstart.md +0 -0
  32. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/docs/guide/splitting.md +0 -0
  33. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/docs/guide/validation.md +0 -0
  34. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/docs/guide/writing.md +0 -0
  35. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/docs/index.md +0 -0
  36. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/docs/installation.md +0 -0
  37. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/docs/requirements.txt +0 -0
  38. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/demo_converter.py +0 -0
  39. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/demo_diff.py +0 -0
  40. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/demo_filter.py +0 -0
  41. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/demo_index_utils.py +0 -0
  42. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/demo_merger.py +0 -0
  43. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/demo_splitter.py +0 -0
  44. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/demo_writer.py +0 -0
  45. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/parse_examples.py +0 -0
  46. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/sample_sheets/ProjectAlpha_SampleSheet.csv +0 -0
  47. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/sample_sheets/ProjectBeta_SampleSheet.csv +0 -0
  48. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/sample_sheets/ProjectDelta_SampleSheet_collision.csv +0 -0
  49. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/sample_sheets/ProjectGamma_SampleSheet.csv +0 -0
  50. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/sample_sheets/README.md +0 -0
  51. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/sample_sheets/combined_clean.csv +0 -0
  52. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/sample_sheets/combined_collision_forced.csv +0 -0
  53. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/sample_sheets/combined_mixed_formats.csv +0 -0
  54. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/sample_sheets/v1_dual_index.csv +0 -0
  55. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/sample_sheets/v1_multi_lane.csv +0 -0
  56. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/sample_sheets/v1_single_index.csv +0 -0
  57. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/sample_sheets/v1_with_lab_qc_settings.csv +0 -0
  58. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/sample_sheets/v1_with_manifests.csv +0 -0
  59. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/sample_sheets/v2_nextseq_single_index.csv +0 -0
  60. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/sample_sheets/v2_novaseq_x_dual_index.csv +0 -0
  61. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/sample_sheets/v2_with_cloud_settings.csv +0 -0
  62. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/sample_sheets/v2_with_index_umi.csv +0 -0
  63. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/sample_sheets/v2_with_pipeline_settings.csv +0 -0
  64. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/examples/sample_sheets/v2_with_read_umi.csv +0 -0
  65. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/images/samplesheet_parser_arch_v03.png +0 -0
  66. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/images/samplesheet_parser_overview.png +0 -0
  67. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/mkdocs.yml +0 -0
  68. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/convert/environment.yml +0 -0
  69. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/convert/main.nf +0 -0
  70. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/convert/meta.yml +0 -0
  71. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/convert/tests/main.nf.test +0 -0
  72. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/diff/environment.yml +0 -0
  73. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/diff/main.nf +0 -0
  74. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/diff/meta.yml +0 -0
  75. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/diff/tests/main.nf.test +0 -0
  76. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/diff/tests/main.nf.test.snap +0 -0
  77. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/filter/environment.yml +0 -0
  78. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/filter/main.nf +0 -0
  79. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/filter/meta.yml +0 -0
  80. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/filter/tests/main.nf.test +0 -0
  81. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/filter/tests/nextflow.config +0 -0
  82. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/info/environment.yml +0 -0
  83. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/info/main.nf +0 -0
  84. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/info/meta.yml +0 -0
  85. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/info/tests/main.nf.test +0 -0
  86. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/info/tests/main.nf.test.snap +0 -0
  87. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/merge/environment.yml +0 -0
  88. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/merge/main.nf +0 -0
  89. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/merge/meta.yml +0 -0
  90. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/merge/tests/main.nf.test +0 -0
  91. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/split/environment.yml +0 -0
  92. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/split/main.nf +0 -0
  93. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/split/meta.yml +0 -0
  94. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/split/tests/main.nf.test +0 -0
  95. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/validate/environment.yml +0 -0
  96. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/validate/main.nf +0 -0
  97. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/validate/meta.yml +0 -0
  98. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/validate/tests/main.nf.test +0 -0
  99. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/modules/nf-core/samplesheetparser/validate/tests/main.nf.test.snap +0 -0
  100. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/recipes/meta.yaml +0 -0
  101. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/samplesheet_parser/__init__.py +0 -0
  102. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/samplesheet_parser/cli.py +0 -0
  103. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/samplesheet_parser/converter.py +0 -0
  104. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/samplesheet_parser/diff.py +0 -0
  105. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/samplesheet_parser/enums.py +0 -0
  106. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/samplesheet_parser/factory.py +0 -0
  107. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/samplesheet_parser/filter.py +0 -0
  108. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/samplesheet_parser/index_utils.py +0 -0
  109. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/samplesheet_parser/instruments.py +0 -0
  110. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/samplesheet_parser/merger.py +0 -0
  111. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/samplesheet_parser/parsers/__init__.py +0 -0
  112. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/samplesheet_parser/parsers/v1.py +0 -0
  113. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/samplesheet_parser/parsers/v2.py +0 -0
  114. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/samplesheet_parser/protocol.py +0 -0
  115. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/samplesheet_parser/py.typed +0 -0
  116. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/samplesheet_parser/splitter.py +0 -0
  117. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/scripts/demo_converter.py +0 -0
  118. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/scripts/demo_diff.py +0 -0
  119. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/scripts/demo_writer.py +0 -0
  120. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/__init__.py +0 -0
  121. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/conftest.py +0 -0
  122. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/fixtures/SampleSheet_v1_dual_index.csv +0 -0
  123. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/fixtures/SampleSheet_v2_dual_index.csv +0 -0
  124. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/fixtures/SampleSheet_v2_modified.csv +0 -0
  125. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/test_cli.py +0 -0
  126. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/test_converter.py +0 -0
  127. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/test_diff.py +0 -0
  128. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/test_factory.py +0 -0
  129. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/test_filter.py +0 -0
  130. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/test_index_utils.py +0 -0
  131. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/test_instruments.py +0 -0
  132. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/test_merger.py +0 -0
  133. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/test_parsers/__init__.py +0 -0
  134. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/test_parsers/test_v1.py +0 -0
  135. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/test_parsers/test_v2.py +0 -0
  136. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/test_splitter.py +0 -0
  137. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/test_validators/__init__.py +0 -0
  138. {samplesheet_parser-2.1.0 → samplesheet_parser-2.2.0}/tests/test_validators/test_validators.py +0 -0
@@ -32,6 +32,9 @@ htmlcov/
32
32
  venv/
33
33
  env/
34
34
 
35
+ # uv (lockfile intentionally not tracked for this library)
36
+ uv.lock
37
+
35
38
  # Editor
36
39
  .vscode/
37
40
  .idea/
@@ -4,7 +4,7 @@
4
4
  "upload_type": "software",
5
5
  "access_right": "open",
6
6
  "license": "Apache-2.0",
7
- "version": "2.1.0",
7
+ "version": "2.2.0",
8
8
  "keywords": [
9
9
  "bioinformatics", "Illumina", "SampleSheet", "BCLConvert",
10
10
  "demultiplexing", "genomics", "sequencing", "Python"
@@ -10,6 +10,22 @@ The format follows [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
10
10
 
11
11
  _No unreleased changes._
12
12
 
13
+ ## [2.2.0] - 2026-06-10
14
+
15
+ ### Fixed
16
+
17
+ - **Index-free libraries are no longer dropped silently by the writer.** When
18
+ loading a parsed sheet with `SampleSheetWriter.from_sheet()`, a sample with a
19
+ valid `Sample_ID` but no index was skipped without notice (the writer
20
+ requires an index per sample). Such samples are still dropped, but now a
21
+ warning is logged naming the sample, so the loss is visible. This aligns the
22
+ writer with the validator, which treats index-free libraries as legitimate.
23
+ - **Index-distance check now accepts V2-style index keys.** The combined
24
+ index-distance check read only the lowercase `index`/`index2` keys, so
25
+ hand-built sample dicts (or the output of `normalize_index_lengths`) keyed
26
+ with `Index`/`Index2` were silently skipped. It now accepts both casings,
27
+ consistent with the duplicate-index and character checks.
28
+
13
29
  ## [2.1.0] - 2026-06-09
14
30
 
15
31
  ### Fixed
@@ -8,8 +8,8 @@ abstract: >
8
8
  Provides format auto-detection, bidirectional V1/V2 conversion,
9
9
  structural and index validation, sheet diffing, and cross-project
10
10
  merging with Hamming-distance collision detection.
11
- version: 2.1.0
12
- date-released: 2026-06-09
11
+ version: 2.2.0
12
+ date-released: 2026-06-10
13
13
  license: Apache-2.0
14
14
  url: "https://github.com/chaitanyakasaraneni/samplesheet-parser"
15
15
  repository-code: "https://github.com/chaitanyakasaraneni/samplesheet-parser"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: samplesheet-parser
3
- Version: 2.1.0
3
+ Version: 2.2.0
4
4
  Summary: Format-agnostic parser for Illumina SampleSheet.csv files — supports IEM V1 and BCLConvert V2
5
5
  Project-URL: Homepage, https://github.com/chaitanyakasaraneni/samplesheet-parser
6
6
  Project-URL: Documentation, https://illumina-samplesheet.readthedocs.io
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "samplesheet-parser"
7
- version = "2.1.0"
7
+ version = "2.2.0"
8
8
  description = "Format-agnostic parser for Illumina SampleSheet.csv files — supports IEM V1 and BCLConvert V2"
9
9
  readme = "README.md"
10
10
  license = { file = "LICENSE" }
@@ -419,8 +419,12 @@ class SampleSheetValidator:
419
419
 
420
420
  for sample in samples:
421
421
  lane = sample.get("lane")
422
- idx1 = (sample.get("index") or "").upper()
423
- idx2 = (sample.get("index2") or "").upper()
422
+ # Accept both V1-style (``index``/``index2``) and V2-style
423
+ # (``Index``/``Index2``) keys so hand-built dicts and the output of
424
+ # ``normalize_index_lengths`` are checked the same way the duplicate
425
+ # and character checks already handle them.
426
+ idx1 = (sample.get("index") or sample.get("Index") or "").upper()
427
+ idx2 = (sample.get("index2") or sample.get("Index2") or "").upper()
424
428
  sid = sample.get("sample_id", "?")
425
429
 
426
430
  if not idx1:
@@ -957,7 +957,16 @@ class SampleSheetWriter:
957
957
  }
958
958
  sid = std.get("Sample_ID", "")
959
959
  idx = std.get("index", "")
960
- if not sid or not idx:
960
+ if not sid:
961
+ continue
962
+ if not idx:
963
+ logger.warning(
964
+ "Sample %r has no index; the writer requires an index per "
965
+ "sample, so this index-free library is dropped from the "
966
+ "output. Add an index or write the sheet by another means "
967
+ "to preserve it.",
968
+ sid,
969
+ )
961
970
  continue
962
971
  self._samples.append(
963
972
  _SampleRecord(
@@ -1005,7 +1014,16 @@ class SampleSheetWriter:
1005
1014
  for record in sheet.records or []:
1006
1015
  sid = record.get("Sample_ID", "")
1007
1016
  idx = record.get("Index", "")
1008
- if not sid or not idx:
1017
+ if not sid:
1018
+ continue
1019
+ if not idx:
1020
+ logger.warning(
1021
+ "Sample %r has no index; the writer requires an index per "
1022
+ "sample, so this index-free library is dropped from the "
1023
+ "output. Add an index or write the sheet by another means "
1024
+ "to preserve it.",
1025
+ sid,
1026
+ )
1009
1027
  continue
1010
1028
  extra = {k: v for k, v in record.items() if k not in std_cols}
1011
1029
  self._samples.append(
@@ -874,3 +874,52 @@ Lane,Sample_ID,Index,Index2,Sample_Project
874
874
  )
875
875
  result = _validate(sheet)
876
876
  assert _distance_warnings(result) == []
877
+
878
+
879
+ # ---------------------------------------------------------------------------
880
+ # Index-key casing: the distance check accepts V2-style capital-I keys too
881
+ # ---------------------------------------------------------------------------
882
+
883
+
884
+ class _StubSheet:
885
+ """Minimal sheet exposing hand-built sample dicts to the validator.
886
+
887
+ The V1/V2 parsers always normalize index keys to lowercase, so
888
+ capital-I keys only reach the validator through hand-built dicts or the
889
+ output of ``normalize_index_lengths`` (whose documented examples use
890
+ ``Index``/``Index2``). This stub lets us exercise that path directly.
891
+ """
892
+
893
+ def __init__(self, samples: list[dict[str, Any]]) -> None:
894
+ self._samples = samples
895
+ self.adapters: list[str] = []
896
+
897
+ def samples(self) -> list[dict[str, Any]]:
898
+ return self._samples
899
+
900
+
901
+ class TestDistanceAcceptsCapitalIndexKeys:
902
+ def test_capital_index_keys_are_compared(self):
903
+ # Two dual-index samples differing by 1 on I7 and 1 on I5 (combined 2,
904
+ # below the default threshold). Keyed with V2-style Index/Index2, the
905
+ # distance check must still flag them rather than silently skip.
906
+ sheet = _StubSheet(
907
+ [
908
+ {"sample_id": "S1", "lane": "1", "Index": "ATTACTCG", "Index2": "TATAGCCT"},
909
+ {"sample_id": "S2", "lane": "1", "Index": "ATTACTCA", "Index2": "TATAGCCA"},
910
+ ]
911
+ )
912
+ result = SampleSheetValidator().validate(sheet) # type: ignore[arg-type]
913
+ warnings = _distance_warnings(result)
914
+ assert len(warnings) == 1
915
+ assert warnings[0].context["distance"] == 2
916
+
917
+ def test_capital_index_keys_well_separated_no_warning(self):
918
+ sheet = _StubSheet(
919
+ [
920
+ {"sample_id": "S1", "lane": "1", "Index": "ATTACTCG"},
921
+ {"sample_id": "S2", "lane": "1", "Index": "GCTAGCTA"},
922
+ ]
923
+ )
924
+ result = SampleSheetValidator().validate(sheet) # type: ignore[arg-type]
925
+ assert _distance_warnings(result) == []
@@ -795,7 +795,7 @@ class TestWriterFromV2SheetEdgeCases:
795
795
  assert "Custom_Setting,foo" in out.read_text()
796
796
 
797
797
  def test_incomplete_v2_record_skipped(self, tmp_path):
798
- """Line 966: record missing Sample_ID or Index is skipped in from_sheet."""
798
+ """A record missing Sample_ID or Index is skipped in from_sheet."""
799
799
  src = tmp_path / "v2.csv"
800
800
  src.write_text(
801
801
  "[Header]\nFileFormatVersion,2\nRunName,T\n\n"
@@ -808,6 +808,44 @@ class TestWriterFromV2SheetEdgeCases:
808
808
  assert len(w._samples) == 1
809
809
  assert w._samples[0].sample_id == "S1"
810
810
 
811
+ def test_index_free_v2_sample_dropped_with_warning(self, tmp_path, caplog):
812
+ """An index-free V2 sample (valid Sample_ID, empty Index) is dropped
813
+ from the writer, which requires an index, and a warning is logged so
814
+ the loss is not silent."""
815
+ src = tmp_path / "v2_indexfree.csv"
816
+ src.write_text(
817
+ "[Header]\nFileFormatVersion,2\nRunName,T\n\n"
818
+ "[BCLConvert_Data]\nSample_ID,Index\n"
819
+ "S1,ATTACTCG\n"
820
+ "WholeLane,\n" # valid Sample_ID, no index (legitimate library)
821
+ )
822
+ sheet = _parse(src)
823
+ with caplog.at_level("WARNING", logger="samplesheet_parser.writer"):
824
+ w = SampleSheetWriter.from_sheet(sheet, version=SampleSheetVersion.V2)
825
+ assert [s.sample_id for s in w._samples] == ["S1"]
826
+ assert "WholeLane" in caplog.text
827
+ assert "no index" in caplog.text
828
+
829
+
830
+ class TestWriterFromV1IndexFree:
831
+
832
+ def test_index_free_v1_sample_dropped_with_warning(self, tmp_path, caplog):
833
+ """An index-free V1 sample (valid Sample_ID, empty index) is dropped
834
+ from the writer with a warning rather than silently."""
835
+ src = tmp_path / "v1_indexfree.csv"
836
+ src.write_text(
837
+ "[Header]\nIEMFileVersion,5\nExperiment Name,T\n\n"
838
+ "[Data]\nSample_ID,index\n"
839
+ "S1,ATTACTCG\n"
840
+ "WholeLane,\n" # valid Sample_ID, no index
841
+ )
842
+ sheet = _parse(src)
843
+ with caplog.at_level("WARNING", logger="samplesheet_parser.writer"):
844
+ w = SampleSheetWriter.from_sheet(sheet, version=SampleSheetVersion.V1)
845
+ assert [s.sample_id for s in w._samples] == ["S1"]
846
+ assert "WholeLane" in caplog.text
847
+ assert "no index" in caplog.text
848
+
811
849
 
812
850
  class TestUpdateSampleLaneFilter:
813
851