speconsense 0.7.2__tar.gz → 0.7.4__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 (55) hide show
  1. {speconsense-0.7.2/speconsense.egg-info → speconsense-0.7.4}/PKG-INFO +79 -12
  2. {speconsense-0.7.2 → speconsense-0.7.4}/README.md +78 -11
  3. {speconsense-0.7.2 → speconsense-0.7.4}/pyproject.toml +1 -1
  4. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/__init__.py +1 -1
  5. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/core/cli.py +18 -0
  6. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/profiles/__init__.py +2 -0
  7. speconsense-0.7.4/speconsense/profiles/compressed.yaml +28 -0
  8. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/profiles/example.yaml +1 -0
  9. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/summarize/cli.py +60 -3
  10. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/summarize/fields.py +5 -3
  11. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/summarize/io.py +10 -1
  12. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/summarize/merging.py +97 -76
  13. {speconsense-0.7.2 → speconsense-0.7.4/speconsense.egg-info}/PKG-INFO +79 -12
  14. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense.egg-info/SOURCES.txt +2 -0
  15. speconsense-0.7.4/tests/test_complement_flags.py +180 -0
  16. {speconsense-0.7.2 → speconsense-0.7.4}/tests/test_summarize.py +406 -0
  17. {speconsense-0.7.2 → speconsense-0.7.4}/LICENSE +0 -0
  18. {speconsense-0.7.2 → speconsense-0.7.4}/setup.cfg +0 -0
  19. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/cli.py +0 -0
  20. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/core/__init__.py +0 -0
  21. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/core/__main__.py +0 -0
  22. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/core/clusterer.py +0 -0
  23. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/core/workers.py +0 -0
  24. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/msa.py +0 -0
  25. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/profiles/herbarium.yaml +0 -0
  26. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/profiles/largedata.yaml +0 -0
  27. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/profiles/nostalgia.yaml +0 -0
  28. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/profiles/strict.yaml +0 -0
  29. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/quality_report.py +0 -0
  30. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/scalability/__init__.py +0 -0
  31. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/scalability/base.py +0 -0
  32. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/scalability/config.py +0 -0
  33. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/scalability/vsearch.py +0 -0
  34. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/summarize/__init__.py +0 -0
  35. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/summarize/__main__.py +0 -0
  36. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/summarize/analysis.py +0 -0
  37. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/summarize/clustering.py +0 -0
  38. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/summarize/iupac.py +0 -0
  39. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/synth.py +0 -0
  40. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense/types.py +0 -0
  41. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense.egg-info/dependency_links.txt +0 -0
  42. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense.egg-info/entry_points.txt +0 -0
  43. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense.egg-info/requires.txt +0 -0
  44. {speconsense-0.7.2 → speconsense-0.7.4}/speconsense.egg-info/top_level.txt +0 -0
  45. {speconsense-0.7.2 → speconsense-0.7.4}/tests/test_ambiguity_calling.py +0 -0
  46. {speconsense-0.7.2 → speconsense-0.7.4}/tests/test_augment_input.py +0 -0
  47. {speconsense-0.7.2 → speconsense-0.7.4}/tests/test_fields.py +0 -0
  48. {speconsense-0.7.2 → speconsense-0.7.4}/tests/test_haplotype_filtering.py +0 -0
  49. {speconsense-0.7.2 → speconsense-0.7.4}/tests/test_orientation.py +0 -0
  50. {speconsense-0.7.2 → speconsense-0.7.4}/tests/test_overlap_merge.py +0 -0
  51. {speconsense-0.7.2 → speconsense-0.7.4}/tests/test_overlap_merge_integration.py +0 -0
  52. {speconsense-0.7.2 → speconsense-0.7.4}/tests/test_profiles.py +0 -0
  53. {speconsense-0.7.2 → speconsense-0.7.4}/tests/test_regression.py +0 -0
  54. {speconsense-0.7.2 → speconsense-0.7.4}/tests/test_synth.py +0 -0
  55. {speconsense-0.7.2 → speconsense-0.7.4}/tests/test_variant_phasing.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: speconsense
3
- Version: 0.7.2
3
+ Version: 0.7.4
4
4
  Summary: High-quality clustering and consensus generation for Oxford Nanopore amplicon reads
5
5
  Author-email: Josh Walker <joshowalker@yahoo.com>
6
6
  License: BSD-3-Clause
@@ -171,6 +171,7 @@ speconsense input.fastq -p herbarium --min-size 10
171
171
  ```
172
172
 
173
173
  **Bundled profiles:**
174
+ - `compressed` — Compress variants into minimal IUPAC consensus sequences (aggressive merging with indels, 20% thresholds, full consensus, 20% selection size ratio)
174
175
  - `herbarium` — High-recall for degraded DNA/type specimens
175
176
  - `largedata` — Experimental settings for large input files
176
177
  - `nostalgia` — Simulate older bioinformatics pipelines
@@ -294,12 +295,14 @@ When using `speconsense-summarize` for post-processing, creates `__Summary__/` d
294
295
  |---------------|-------------|------------|-------------|
295
296
  | **Original** | Source `cluster_debug/` | `-c1`, `-c2`, `-c3` | Preserves speconsense clustering results |
296
297
  | **Summarization** | `__Summary__/`, `FASTQ Files/`, `variants/` | `-1.v1`, `-1.v2`, `-2.v1`, `.raw1` | Post-processing groups and variants |
298
+ | **Full consensus** | `__Summary__/` | `-1.full` | IUPAC consensus from all pre-merge variants in a group |
297
299
 
298
300
  ### Example Directory Structure
299
301
  ```
300
302
  __Summary__/
301
303
  ├── sample-1.v1-RiC45.fasta # Primary variant (group 1, merged)
302
304
  ├── sample-1.v2-RiC23.fasta # Additional variant (not merged)
305
+ ├── sample-1.full-RiC68.fasta # Full IUPAC consensus for group 1 (all pre-merge variants)
303
306
  ├── sample-2.v1-RiC30.fasta # Second organism group, primary variant
304
307
  ├── summary.fasta # All final consensus sequences (excludes .raw)
305
308
  ├── summary.txt # Statistics
@@ -675,6 +678,18 @@ speconsense-summarize --select-strategy diversity --select-max-variants 2
675
678
  - Output up to select_max_variants per group
676
679
  3. Final output contains representatives from all groups, ensuring both biological diversity (between groups) and appropriate sampling within each biological entity (within groups)
677
680
 
681
+ **Selection Size Ratio Filtering:**
682
+ ```bash
683
+ speconsense-summarize --select-min-size-ratio 0.2
684
+ ```
685
+ - Filters out post-merge variants whose size is too small relative to the largest variant in their group
686
+ - Ratio calculated as `variant_size / largest_size` — must be ≥ threshold to keep
687
+ - Example: `--select-min-size-ratio 0.2` means a variant must have ≥20% the reads of the largest variant in its group
688
+ - Default is 0 (disabled) — all post-merge variants pass through to selection
689
+ - Applied after merging but before variant selection
690
+ - Useful for suppressing noise variants that survived merging but are too small to be meaningful
691
+ - Set to 0.2 in the `compressed` profile to match the 20% calling threshold theme
692
+
678
693
  This two-stage process ensures that distinct biological sequences are preserved as separate groups, while providing control over variant complexity within each group.
679
694
 
680
695
  ### Customizing FASTA Header Fields
@@ -810,6 +825,18 @@ For high-throughput workflows (e.g., 100K sequences/year), this prioritization e
810
825
 
811
826
  ### Additional Summarize Options
812
827
 
828
+ **Full Consensus:**
829
+ ```bash
830
+ speconsense-summarize --enable-full-consensus
831
+ ```
832
+ - Generates a full IUPAC consensus sequence per variant group from all pre-merge variants
833
+ - Output named `{specimen}-{group}.full-RiC{reads}.fasta` in the `__Summary__/` directory
834
+ - Uses majority voting across all variants in the group; **gaps never win** — at each alignment column, the most common non-gap base is chosen, with IUPAC codes for ties among bases
835
+ - Useful when you want a single representative sequence that captures all variation within a group as IUPAC ambiguity codes
836
+ - Included in `summary.fasta` (but excluded from total RiC to avoid double-counting)
837
+ - Enabled by default in the `compressed` profile
838
+ - Use `--disable-full-consensus` to override when set by a profile
839
+
813
840
  **Quality Filtering:**
814
841
  ```bash
815
842
  speconsense-summarize --min-ric 5
@@ -1044,8 +1071,10 @@ The complete speconsense-summarize workflow operates in this order:
1044
1071
  2. **HAC variant grouping** by sequence identity to separate dissimilar sequences (`--group-identity`); uses single-linkage when overlap merging is enabled
1045
1072
  3. **Group filtering** to limit output groups (`--select-max-groups`)
1046
1073
  4. **Homopolymer-aware MSA-based variant merging** within each group, including **overlap merging** for different-length sequences (`--disable-merging`, `--merge-effort`, `--merge-position-count`, `--merge-indel-length`, `--min-merge-overlap`, `--merge-snp`, `--merge-min-size-ratio`, `--disable-homopolymer-equivalence`)
1047
- 5. **Variant selection** within each group (`--select-max-variants`, `--select-strategy`)
1048
- 6. **Output generation** with customizable header fields (`--fasta-fields`) and full traceability
1074
+ 5. **Selection size ratio filtering** to remove tiny post-merge variants (`--select-min-size-ratio`)
1075
+ 6. **Variant selection** within each group (`--select-max-variants`, `--select-strategy`)
1076
+ 7. **Full consensus generation** (optional) — IUPAC consensus from all pre-merge variants per group (`--enable-full-consensus`)
1077
+ 8. **Output generation** with customizable header fields (`--fasta-fields`) and full traceability
1049
1078
 
1050
1079
  **Key architectural features**:
1051
1080
  - HAC grouping occurs BEFORE merging to prevent inappropriate merging of dissimilar sequences (e.g., contaminants with primary targets)
@@ -1098,17 +1127,20 @@ usage: speconsense [-h] [-O OUTPUT_DIR] [--primers PRIMERS]
1098
1127
  [--min-cluster-ratio MIN_CLUSTER_RATIO]
1099
1128
  [--max-sample-size MAX_SAMPLE_SIZE]
1100
1129
  [--outlier-identity OUTLIER_IDENTITY]
1101
- [--disable-position-phasing]
1130
+ [--disable-position-phasing] [--enable-position-phasing]
1102
1131
  [--min-variant-frequency MIN_VARIANT_FREQUENCY]
1103
1132
  [--min-variant-count MIN_VARIANT_COUNT]
1104
- [--disable-ambiguity-calling]
1133
+ [--disable-ambiguity-calling] [--enable-ambiguity-calling]
1105
1134
  [--min-ambiguity-frequency MIN_AMBIGUITY_FREQUENCY]
1106
1135
  [--min-ambiguity-count MIN_AMBIGUITY_COUNT]
1107
- [--disable-cluster-merging]
1136
+ [--disable-cluster-merging] [--enable-cluster-merging]
1108
1137
  [--disable-homopolymer-equivalence]
1138
+ [--enable-homopolymer-equivalence]
1109
1139
  [--orient-mode {skip,keep-all,filter-failed}]
1110
1140
  [--presample PRESAMPLE] [--scale-threshold SCALE_THRESHOLD]
1111
- [--threads N] [--enable-early-filter] [--collect-discards]
1141
+ [--threads N] [--enable-early-filter]
1142
+ [--disable-early-filter] [--collect-discards]
1143
+ [--no-collect-discards]
1112
1144
  [--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
1113
1145
  [--version] [-p NAME] [--list-profiles]
1114
1146
  input_file
@@ -1167,6 +1199,8 @@ Variant Phasing:
1167
1199
  default). MCL graph clustering already separates most
1168
1200
  variants; this second pass analyzes MSA positions to
1169
1201
  phase remaining variants.
1202
+ --enable-position-phasing
1203
+ Override --disable-position-phasing or profile setting
1170
1204
  --min-variant-frequency MIN_VARIANT_FREQUENCY
1171
1205
  Minimum alternative allele frequency to call variant
1172
1206
  (default: 0.10 for 10%)
@@ -1178,6 +1212,9 @@ Ambiguity Calling:
1178
1212
  --disable-ambiguity-calling
1179
1213
  Disable IUPAC ambiguity code calling for unphased
1180
1214
  variant positions
1215
+ --enable-ambiguity-calling
1216
+ Override --disable-ambiguity-calling or profile
1217
+ setting
1181
1218
  --min-ambiguity-frequency MIN_AMBIGUITY_FREQUENCY
1182
1219
  Minimum alternative allele frequency for IUPAC
1183
1220
  ambiguity calling (default: 0.10 for 10%)
@@ -1189,9 +1226,14 @@ Cluster Merging:
1189
1226
  --disable-cluster-merging
1190
1227
  Disable merging of clusters with identical consensus
1191
1228
  sequences
1229
+ --enable-cluster-merging
1230
+ Override --disable-cluster-merging or profile setting
1192
1231
  --disable-homopolymer-equivalence
1193
1232
  Disable homopolymer equivalence in cluster merging
1194
1233
  (only merge identical sequences)
1234
+ --enable-homopolymer-equivalence
1235
+ Override --disable-homopolymer-equivalence or profile
1236
+ setting
1195
1237
 
1196
1238
  Orientation:
1197
1239
  --orient-mode {skip,keep-all,filter-failed}
@@ -1213,10 +1255,14 @@ Performance:
1213
1255
  Enable early filtering to skip small clusters before
1214
1256
  variant phasing (improves performance for large
1215
1257
  datasets)
1258
+ --disable-early-filter
1259
+ Override --enable-early-filter or profile setting
1216
1260
 
1217
1261
  Debugging:
1218
1262
  --collect-discards Write discarded reads (outliers and filtered clusters)
1219
1263
  to cluster_debug/{sample}-discards.fastq
1264
+ --no-collect-discards
1265
+ Override --collect-discards or profile setting
1220
1266
  --log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
1221
1267
  ```
1222
1268
 
@@ -1227,15 +1273,22 @@ usage: speconsense-summarize [-h] [--source SOURCE]
1227
1273
  [--summary-dir SUMMARY_DIR]
1228
1274
  [--fasta-fields FASTA_FIELDS] [--min-ric MIN_RIC]
1229
1275
  [--min-len MIN_LEN] [--max-len MAX_LEN]
1230
- [--group-identity GROUP_IDENTITY] [--merge-snp]
1276
+ [--group-identity GROUP_IDENTITY]
1277
+ [--disable-merging] [--enable-merging]
1278
+ [--merge-snp | --no-merge-snp]
1231
1279
  [--merge-indel-length MERGE_INDEL_LENGTH]
1232
1280
  [--merge-position-count MERGE_POSITION_COUNT]
1233
1281
  [--merge-min-size-ratio MERGE_MIN_SIZE_RATIO]
1234
1282
  [--min-merge-overlap MIN_MERGE_OVERLAP]
1235
1283
  [--disable-homopolymer-equivalence]
1284
+ [--enable-homopolymer-equivalence]
1285
+ [--merge-effort LEVEL]
1236
1286
  [--select-max-groups SELECT_MAX_GROUPS]
1237
1287
  [--select-max-variants SELECT_MAX_VARIANTS]
1238
1288
  [--select-strategy {size,diversity}]
1289
+ [--select-min-size-ratio SELECT_MIN_SIZE_RATIO]
1290
+ [--enable-full-consensus]
1291
+ [--disable-full-consensus]
1239
1292
  [--scale-threshold SCALE_THRESHOLD] [--threads N]
1240
1293
  [--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
1241
1294
  [--version] [-p NAME] [--list-profiles]
@@ -1281,10 +1334,7 @@ Grouping:
1281
1334
  Merging:
1282
1335
  --disable-merging Disable all variant merging (skip MSA-based merge
1283
1336
  evaluation entirely)
1284
- --merge-effort LEVEL Merging effort level: fast (8), balanced (10),
1285
- thorough (12), or numeric 6-14. Higher values allow
1286
- larger batch sizes for exhaustive subset search.
1287
- Default: balanced
1337
+ --enable-merging Override --disable-merging or profile setting
1288
1338
  --merge-snp, --no-merge-snp
1289
1339
  Enable SNP-based merging (default: True, use --no-
1290
1340
  merge-snp to disable)
@@ -1303,6 +1353,13 @@ Merging:
1303
1353
  --disable-homopolymer-equivalence
1304
1354
  Disable homopolymer equivalence in merging (treat AAA
1305
1355
  vs AAAA as different)
1356
+ --enable-homopolymer-equivalence
1357
+ Override --disable-homopolymer-equivalence or profile
1358
+ setting
1359
+ --merge-effort LEVEL Merging effort level: fast (8), balanced (10),
1360
+ thorough (12), or numeric 6-14. Higher values allow
1361
+ larger batch sizes for exhaustive subset search.
1362
+ Default: balanced
1306
1363
 
1307
1364
  Selection:
1308
1365
  --select-max-groups SELECT_MAX_GROUPS, --max-groups SELECT_MAX_GROUPS
@@ -1314,6 +1371,16 @@ Selection:
1314
1371
  --select-strategy {size,diversity}, --variant-selection {size,diversity}
1315
1372
  Variant selection strategy: size or diversity
1316
1373
  (default: size)
1374
+ --select-min-size-ratio SELECT_MIN_SIZE_RATIO
1375
+ Minimum size ratio (variant/largest) to include in
1376
+ output (default: 0 = disabled, e.g. 0.2 for 20%
1377
+ cutoff)
1378
+ --enable-full-consensus
1379
+ Generate a full consensus per variant group
1380
+ representing all variation from pre-merge variants
1381
+ (gaps never win)
1382
+ --disable-full-consensus
1383
+ Override --enable-full-consensus or profile setting
1317
1384
 
1318
1385
  Performance:
1319
1386
  --scale-threshold SCALE_THRESHOLD
@@ -136,6 +136,7 @@ speconsense input.fastq -p herbarium --min-size 10
136
136
  ```
137
137
 
138
138
  **Bundled profiles:**
139
+ - `compressed` — Compress variants into minimal IUPAC consensus sequences (aggressive merging with indels, 20% thresholds, full consensus, 20% selection size ratio)
139
140
  - `herbarium` — High-recall for degraded DNA/type specimens
140
141
  - `largedata` — Experimental settings for large input files
141
142
  - `nostalgia` — Simulate older bioinformatics pipelines
@@ -259,12 +260,14 @@ When using `speconsense-summarize` for post-processing, creates `__Summary__/` d
259
260
  |---------------|-------------|------------|-------------|
260
261
  | **Original** | Source `cluster_debug/` | `-c1`, `-c2`, `-c3` | Preserves speconsense clustering results |
261
262
  | **Summarization** | `__Summary__/`, `FASTQ Files/`, `variants/` | `-1.v1`, `-1.v2`, `-2.v1`, `.raw1` | Post-processing groups and variants |
263
+ | **Full consensus** | `__Summary__/` | `-1.full` | IUPAC consensus from all pre-merge variants in a group |
262
264
 
263
265
  ### Example Directory Structure
264
266
  ```
265
267
  __Summary__/
266
268
  ├── sample-1.v1-RiC45.fasta # Primary variant (group 1, merged)
267
269
  ├── sample-1.v2-RiC23.fasta # Additional variant (not merged)
270
+ ├── sample-1.full-RiC68.fasta # Full IUPAC consensus for group 1 (all pre-merge variants)
268
271
  ├── sample-2.v1-RiC30.fasta # Second organism group, primary variant
269
272
  ├── summary.fasta # All final consensus sequences (excludes .raw)
270
273
  ├── summary.txt # Statistics
@@ -640,6 +643,18 @@ speconsense-summarize --select-strategy diversity --select-max-variants 2
640
643
  - Output up to select_max_variants per group
641
644
  3. Final output contains representatives from all groups, ensuring both biological diversity (between groups) and appropriate sampling within each biological entity (within groups)
642
645
 
646
+ **Selection Size Ratio Filtering:**
647
+ ```bash
648
+ speconsense-summarize --select-min-size-ratio 0.2
649
+ ```
650
+ - Filters out post-merge variants whose size is too small relative to the largest variant in their group
651
+ - Ratio calculated as `variant_size / largest_size` — must be ≥ threshold to keep
652
+ - Example: `--select-min-size-ratio 0.2` means a variant must have ≥20% the reads of the largest variant in its group
653
+ - Default is 0 (disabled) — all post-merge variants pass through to selection
654
+ - Applied after merging but before variant selection
655
+ - Useful for suppressing noise variants that survived merging but are too small to be meaningful
656
+ - Set to 0.2 in the `compressed` profile to match the 20% calling threshold theme
657
+
643
658
  This two-stage process ensures that distinct biological sequences are preserved as separate groups, while providing control over variant complexity within each group.
644
659
 
645
660
  ### Customizing FASTA Header Fields
@@ -775,6 +790,18 @@ For high-throughput workflows (e.g., 100K sequences/year), this prioritization e
775
790
 
776
791
  ### Additional Summarize Options
777
792
 
793
+ **Full Consensus:**
794
+ ```bash
795
+ speconsense-summarize --enable-full-consensus
796
+ ```
797
+ - Generates a full IUPAC consensus sequence per variant group from all pre-merge variants
798
+ - Output named `{specimen}-{group}.full-RiC{reads}.fasta` in the `__Summary__/` directory
799
+ - Uses majority voting across all variants in the group; **gaps never win** — at each alignment column, the most common non-gap base is chosen, with IUPAC codes for ties among bases
800
+ - Useful when you want a single representative sequence that captures all variation within a group as IUPAC ambiguity codes
801
+ - Included in `summary.fasta` (but excluded from total RiC to avoid double-counting)
802
+ - Enabled by default in the `compressed` profile
803
+ - Use `--disable-full-consensus` to override when set by a profile
804
+
778
805
  **Quality Filtering:**
779
806
  ```bash
780
807
  speconsense-summarize --min-ric 5
@@ -1009,8 +1036,10 @@ The complete speconsense-summarize workflow operates in this order:
1009
1036
  2. **HAC variant grouping** by sequence identity to separate dissimilar sequences (`--group-identity`); uses single-linkage when overlap merging is enabled
1010
1037
  3. **Group filtering** to limit output groups (`--select-max-groups`)
1011
1038
  4. **Homopolymer-aware MSA-based variant merging** within each group, including **overlap merging** for different-length sequences (`--disable-merging`, `--merge-effort`, `--merge-position-count`, `--merge-indel-length`, `--min-merge-overlap`, `--merge-snp`, `--merge-min-size-ratio`, `--disable-homopolymer-equivalence`)
1012
- 5. **Variant selection** within each group (`--select-max-variants`, `--select-strategy`)
1013
- 6. **Output generation** with customizable header fields (`--fasta-fields`) and full traceability
1039
+ 5. **Selection size ratio filtering** to remove tiny post-merge variants (`--select-min-size-ratio`)
1040
+ 6. **Variant selection** within each group (`--select-max-variants`, `--select-strategy`)
1041
+ 7. **Full consensus generation** (optional) — IUPAC consensus from all pre-merge variants per group (`--enable-full-consensus`)
1042
+ 8. **Output generation** with customizable header fields (`--fasta-fields`) and full traceability
1014
1043
 
1015
1044
  **Key architectural features**:
1016
1045
  - HAC grouping occurs BEFORE merging to prevent inappropriate merging of dissimilar sequences (e.g., contaminants with primary targets)
@@ -1063,17 +1092,20 @@ usage: speconsense [-h] [-O OUTPUT_DIR] [--primers PRIMERS]
1063
1092
  [--min-cluster-ratio MIN_CLUSTER_RATIO]
1064
1093
  [--max-sample-size MAX_SAMPLE_SIZE]
1065
1094
  [--outlier-identity OUTLIER_IDENTITY]
1066
- [--disable-position-phasing]
1095
+ [--disable-position-phasing] [--enable-position-phasing]
1067
1096
  [--min-variant-frequency MIN_VARIANT_FREQUENCY]
1068
1097
  [--min-variant-count MIN_VARIANT_COUNT]
1069
- [--disable-ambiguity-calling]
1098
+ [--disable-ambiguity-calling] [--enable-ambiguity-calling]
1070
1099
  [--min-ambiguity-frequency MIN_AMBIGUITY_FREQUENCY]
1071
1100
  [--min-ambiguity-count MIN_AMBIGUITY_COUNT]
1072
- [--disable-cluster-merging]
1101
+ [--disable-cluster-merging] [--enable-cluster-merging]
1073
1102
  [--disable-homopolymer-equivalence]
1103
+ [--enable-homopolymer-equivalence]
1074
1104
  [--orient-mode {skip,keep-all,filter-failed}]
1075
1105
  [--presample PRESAMPLE] [--scale-threshold SCALE_THRESHOLD]
1076
- [--threads N] [--enable-early-filter] [--collect-discards]
1106
+ [--threads N] [--enable-early-filter]
1107
+ [--disable-early-filter] [--collect-discards]
1108
+ [--no-collect-discards]
1077
1109
  [--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
1078
1110
  [--version] [-p NAME] [--list-profiles]
1079
1111
  input_file
@@ -1132,6 +1164,8 @@ Variant Phasing:
1132
1164
  default). MCL graph clustering already separates most
1133
1165
  variants; this second pass analyzes MSA positions to
1134
1166
  phase remaining variants.
1167
+ --enable-position-phasing
1168
+ Override --disable-position-phasing or profile setting
1135
1169
  --min-variant-frequency MIN_VARIANT_FREQUENCY
1136
1170
  Minimum alternative allele frequency to call variant
1137
1171
  (default: 0.10 for 10%)
@@ -1143,6 +1177,9 @@ Ambiguity Calling:
1143
1177
  --disable-ambiguity-calling
1144
1178
  Disable IUPAC ambiguity code calling for unphased
1145
1179
  variant positions
1180
+ --enable-ambiguity-calling
1181
+ Override --disable-ambiguity-calling or profile
1182
+ setting
1146
1183
  --min-ambiguity-frequency MIN_AMBIGUITY_FREQUENCY
1147
1184
  Minimum alternative allele frequency for IUPAC
1148
1185
  ambiguity calling (default: 0.10 for 10%)
@@ -1154,9 +1191,14 @@ Cluster Merging:
1154
1191
  --disable-cluster-merging
1155
1192
  Disable merging of clusters with identical consensus
1156
1193
  sequences
1194
+ --enable-cluster-merging
1195
+ Override --disable-cluster-merging or profile setting
1157
1196
  --disable-homopolymer-equivalence
1158
1197
  Disable homopolymer equivalence in cluster merging
1159
1198
  (only merge identical sequences)
1199
+ --enable-homopolymer-equivalence
1200
+ Override --disable-homopolymer-equivalence or profile
1201
+ setting
1160
1202
 
1161
1203
  Orientation:
1162
1204
  --orient-mode {skip,keep-all,filter-failed}
@@ -1178,10 +1220,14 @@ Performance:
1178
1220
  Enable early filtering to skip small clusters before
1179
1221
  variant phasing (improves performance for large
1180
1222
  datasets)
1223
+ --disable-early-filter
1224
+ Override --enable-early-filter or profile setting
1181
1225
 
1182
1226
  Debugging:
1183
1227
  --collect-discards Write discarded reads (outliers and filtered clusters)
1184
1228
  to cluster_debug/{sample}-discards.fastq
1229
+ --no-collect-discards
1230
+ Override --collect-discards or profile setting
1185
1231
  --log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}
1186
1232
  ```
1187
1233
 
@@ -1192,15 +1238,22 @@ usage: speconsense-summarize [-h] [--source SOURCE]
1192
1238
  [--summary-dir SUMMARY_DIR]
1193
1239
  [--fasta-fields FASTA_FIELDS] [--min-ric MIN_RIC]
1194
1240
  [--min-len MIN_LEN] [--max-len MAX_LEN]
1195
- [--group-identity GROUP_IDENTITY] [--merge-snp]
1241
+ [--group-identity GROUP_IDENTITY]
1242
+ [--disable-merging] [--enable-merging]
1243
+ [--merge-snp | --no-merge-snp]
1196
1244
  [--merge-indel-length MERGE_INDEL_LENGTH]
1197
1245
  [--merge-position-count MERGE_POSITION_COUNT]
1198
1246
  [--merge-min-size-ratio MERGE_MIN_SIZE_RATIO]
1199
1247
  [--min-merge-overlap MIN_MERGE_OVERLAP]
1200
1248
  [--disable-homopolymer-equivalence]
1249
+ [--enable-homopolymer-equivalence]
1250
+ [--merge-effort LEVEL]
1201
1251
  [--select-max-groups SELECT_MAX_GROUPS]
1202
1252
  [--select-max-variants SELECT_MAX_VARIANTS]
1203
1253
  [--select-strategy {size,diversity}]
1254
+ [--select-min-size-ratio SELECT_MIN_SIZE_RATIO]
1255
+ [--enable-full-consensus]
1256
+ [--disable-full-consensus]
1204
1257
  [--scale-threshold SCALE_THRESHOLD] [--threads N]
1205
1258
  [--log-level {DEBUG,INFO,WARNING,ERROR,CRITICAL}]
1206
1259
  [--version] [-p NAME] [--list-profiles]
@@ -1246,10 +1299,7 @@ Grouping:
1246
1299
  Merging:
1247
1300
  --disable-merging Disable all variant merging (skip MSA-based merge
1248
1301
  evaluation entirely)
1249
- --merge-effort LEVEL Merging effort level: fast (8), balanced (10),
1250
- thorough (12), or numeric 6-14. Higher values allow
1251
- larger batch sizes for exhaustive subset search.
1252
- Default: balanced
1302
+ --enable-merging Override --disable-merging or profile setting
1253
1303
  --merge-snp, --no-merge-snp
1254
1304
  Enable SNP-based merging (default: True, use --no-
1255
1305
  merge-snp to disable)
@@ -1268,6 +1318,13 @@ Merging:
1268
1318
  --disable-homopolymer-equivalence
1269
1319
  Disable homopolymer equivalence in merging (treat AAA
1270
1320
  vs AAAA as different)
1321
+ --enable-homopolymer-equivalence
1322
+ Override --disable-homopolymer-equivalence or profile
1323
+ setting
1324
+ --merge-effort LEVEL Merging effort level: fast (8), balanced (10),
1325
+ thorough (12), or numeric 6-14. Higher values allow
1326
+ larger batch sizes for exhaustive subset search.
1327
+ Default: balanced
1271
1328
 
1272
1329
  Selection:
1273
1330
  --select-max-groups SELECT_MAX_GROUPS, --max-groups SELECT_MAX_GROUPS
@@ -1279,6 +1336,16 @@ Selection:
1279
1336
  --select-strategy {size,diversity}, --variant-selection {size,diversity}
1280
1337
  Variant selection strategy: size or diversity
1281
1338
  (default: size)
1339
+ --select-min-size-ratio SELECT_MIN_SIZE_RATIO
1340
+ Minimum size ratio (variant/largest) to include in
1341
+ output (default: 0 = disabled, e.g. 0.2 for 20%
1342
+ cutoff)
1343
+ --enable-full-consensus
1344
+ Generate a full consensus per variant group
1345
+ representing all variation from pre-merge variants
1346
+ (gaps never win)
1347
+ --disable-full-consensus
1348
+ Override --enable-full-consensus or profile setting
1282
1349
 
1283
1350
  Performance:
1284
1351
  --scale-threshold SCALE_THRESHOLD
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "speconsense"
7
- version = "0.7.2"
7
+ version = "0.7.4"
8
8
  description = "High-quality clustering and consensus generation for Oxford Nanopore amplicon reads"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -5,7 +5,7 @@ A Python tool for experimental clustering and consensus generation as an alterna
5
5
  in the fungal DNA barcoding pipeline.
6
6
  """
7
7
 
8
- __version__ = "0.7.2"
8
+ __version__ = "0.7.4"
9
9
  __author__ = "Josh Walker"
10
10
  __email__ = "joshowalker@yahoo.com"
11
11
 
@@ -66,6 +66,9 @@ def main():
66
66
  help="Disable position-based variant phasing (enabled by default). "
67
67
  "MCL graph clustering already separates most variants; this "
68
68
  "second pass analyzes MSA positions to phase remaining variants.")
69
+ phasing_group.add_argument("--enable-position-phasing", action="store_false",
70
+ dest="disable_position_phasing",
71
+ help="Override --disable-position-phasing or profile setting")
69
72
  phasing_group.add_argument("--min-variant-frequency", type=float, default=0.10,
70
73
  help="Minimum alternative allele frequency to call variant (default: 0.10 for 10%%)")
71
74
  phasing_group.add_argument("--min-variant-count", type=int, default=5,
@@ -75,6 +78,9 @@ def main():
75
78
  ambiguity_group = parser.add_argument_group("Ambiguity Calling")
76
79
  ambiguity_group.add_argument("--disable-ambiguity-calling", action="store_true",
77
80
  help="Disable IUPAC ambiguity code calling for unphased variant positions")
81
+ ambiguity_group.add_argument("--enable-ambiguity-calling", action="store_false",
82
+ dest="disable_ambiguity_calling",
83
+ help="Override --disable-ambiguity-calling or profile setting")
78
84
  ambiguity_group.add_argument("--min-ambiguity-frequency", type=float, default=0.10,
79
85
  help="Minimum alternative allele frequency for IUPAC ambiguity calling (default: 0.10 for 10%%)")
80
86
  ambiguity_group.add_argument("--min-ambiguity-count", type=int, default=3,
@@ -84,8 +90,14 @@ def main():
84
90
  merging_group = parser.add_argument_group("Cluster Merging")
85
91
  merging_group.add_argument("--disable-cluster-merging", action="store_true",
86
92
  help="Disable merging of clusters with identical consensus sequences")
93
+ merging_group.add_argument("--enable-cluster-merging", action="store_false",
94
+ dest="disable_cluster_merging",
95
+ help="Override --disable-cluster-merging or profile setting")
87
96
  merging_group.add_argument("--disable-homopolymer-equivalence", action="store_true",
88
97
  help="Disable homopolymer equivalence in cluster merging (only merge identical sequences)")
98
+ merging_group.add_argument("--enable-homopolymer-equivalence", action="store_false",
99
+ dest="disable_homopolymer_equivalence",
100
+ help="Override --disable-homopolymer-equivalence or profile setting")
89
101
 
90
102
  # Orientation group
91
103
  orient_group = parser.add_argument_group("Orientation")
@@ -104,11 +116,17 @@ def main():
104
116
  "0=auto-detect, default=1 (safe for parallel workflows).")
105
117
  perf_group.add_argument("--enable-early-filter", action="store_true",
106
118
  help="Enable early filtering to skip small clusters before variant phasing (improves performance for large datasets)")
119
+ perf_group.add_argument("--disable-early-filter", action="store_false",
120
+ dest="enable_early_filter",
121
+ help="Override --enable-early-filter or profile setting")
107
122
 
108
123
  # Debugging group
109
124
  debug_group = parser.add_argument_group("Debugging")
110
125
  debug_group.add_argument("--collect-discards", action="store_true",
111
126
  help="Write discarded reads (outliers and filtered clusters) to cluster_debug/{sample}-discards.fastq")
127
+ debug_group.add_argument("--no-collect-discards", action="store_false",
128
+ dest="collect_discards",
129
+ help="Override --collect-discards or profile setting")
112
130
  debug_group.add_argument("--log-level", default="INFO",
113
131
  choices=["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"])
114
132
 
@@ -103,6 +103,8 @@ VALID_SUMMARIZE_KEYS = {
103
103
  "select-max-groups",
104
104
  "select-max-variants",
105
105
  "select-strategy",
106
+ "select-min-size-ratio",
107
+ "enable-full-consensus",
106
108
  # Processing
107
109
  "scale-threshold",
108
110
  "threads",
@@ -0,0 +1,28 @@
1
+ # Compress variants into minimal IUPAC consensus sequences
2
+ #
3
+ # Aggressively merges similar variants (including indels) into single
4
+ # IUPAC consensus sequences. Only truly dissimilar sequences remain
5
+ # separate. Uses 20% frequency thresholds throughout.
6
+ #
7
+ # Designed for workflows where reviewers want fewer sequences to
8
+ # examine, with all variation represented via IUPAC ambiguity codes.
9
+ # Partial overlap merging is disabled as a safety measure.
10
+ #
11
+ # Use with:
12
+ # speconsense input.fastq -p compressed
13
+ # speconsense-summarize -p compressed
14
+
15
+ speconsense-version: "0.7.*"
16
+ description: "Compress variants into minimal IUPAC consensus sequences"
17
+
18
+ speconsense:
19
+ min-ambiguity-frequency: 0.20 # 20% threshold for IUPAC ambiguity calling
20
+ min-variant-frequency: 0.20 # 20% threshold for variant phasing
21
+
22
+ speconsense-summarize:
23
+ merge-indel-length: 5 # Merge indels up to 5bp
24
+ merge-position-count: 10 # Allow up to 10 variant positions in a merge
25
+ merge-min-size-ratio: 0.2 # Match 20% calling threshold
26
+ select-min-size-ratio: 0.2 # Match 20% calling threshold
27
+ min-merge-overlap: 0 # Disable partial overlap merging
28
+ enable-full-consensus: true # Include full IUPAC consensus per group
@@ -91,6 +91,7 @@ speconsense-summarize:
91
91
  # select-max-groups: -1 # Max groups to output (-1 = no limit)
92
92
  # select-max-variants: -1 # Max variants per group (-1 = no limit)
93
93
  # select-strategy: size # Selection strategy: size or diversity
94
+ # select-min-size-ratio: 0 # Min size ratio to include variant (0 = disabled)
94
95
 
95
96
  # --- Processing ---
96
97
  # threads: 0 # Max threads (0 = auto-detect)