Skip to content

Commit 43d6e9f

Browse files
rob-pclaude
andcommitted
Thread --dict through quant/multiplex-quant; add sample_bc_ori plumbing
Extends the dictionary-backend selection (previously wired only on `simpleaf index`) to the two mapping commands so that the map-time dictionary can be chosen explicitly when the index's embedded default is not desired: - `simpleaf quant`: `--dict {auto,sshash,tiny}` forwarded to `piscem map-sc`. - `simpleaf multiplex-quant`: `--dict` forwarded to both `piscem build` (for the auto-built probe index) and `piscem map-sc`. Adds `sample_bc_ori` support needed for correct Flex v2 processing (where the sample BC on R1 downstream of the anchor is the reverse complement of the vendor-published whitelist): - `utils::chem_utils::SampleBcListInfo` gains an optional `sample_bc_ori` field carried in the chemistry registry. - `multiplex-quant` forwards the chemistry's declared orientation as `--sample-bc-ori` to `alevin-fry generate-permit-list`. Snapshot updates for `simpleaf index|quant|multiplex-quant --help` reflect the new `--dict` option. Tui/workflow and rsjsonnet migration work has been split onto the `tui-workflow` branch and will be merged in a later release. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 1bc79e7 commit 43d6e9f

7 files changed

Lines changed: 55 additions & 1 deletion

File tree

src/simpleaf_commands.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,16 @@ pub struct MapQuantOpts {
184184
help_heading = "Piscem Mapping Options")]
185185
pub max_read_occ: u32,
186186

187+
/// Piscem dictionary backend to use at map time: `auto` (default, honors the
188+
/// index's embedded choice), `sshash`, or `tiny`.
189+
#[arg(
190+
long,
191+
value_enum,
192+
default_value_t = PiscemDict::Auto,
193+
help_heading = "Piscem Mapping Options"
194+
)]
195+
pub dict: PiscemDict,
196+
187197
/// Path to a mapped output directory containing a RAD file to skip mapping
188198
#[arg(long = "map-dir", conflicts_with_all = ["index", "reads1", "reads2"], help_heading = "Mapping Options")]
189199
pub map_dir: Option<PathBuf>,
@@ -651,6 +661,16 @@ pub struct MultiplexQuantOpts {
651661
#[arg(long, default_value_t = DefaultParams::MAX_EC_CARD, help_heading = "Piscem Mapping Options")]
652662
pub max_ec_card: u32,
653663

664+
/// Piscem dictionary backend: `auto` (default), `sshash`, or `tiny`. Applies
665+
/// both to the auto-built probe index (build time) and to map-sc (map time).
666+
#[arg(
667+
long,
668+
value_enum,
669+
default_value_t = PiscemDict::Auto,
670+
help_heading = "Piscem Mapping Options"
671+
)]
672+
pub dict: PiscemDict,
673+
654674
/// Minimum read count threshold for unfiltered permit list
655675
#[arg(long, default_value_t = 10, help_heading = "Permit List Options")]
656676
pub min_reads: usize,

src/simpleaf_commands/multiplex_quant.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,9 @@ pub fn multiplex_map_and_quant(af_home: &Path, opts: MultiplexQuantOpts) -> anyh
356356
.arg("--skipping-strategy")
357357
.arg(&opts.skipping_strategy)
358358
.arg("--max-ec-card")
359-
.arg(format!("{}", opts.max_ec_card));
359+
.arg(format!("{}", opts.max_ec_card))
360+
.arg("--dict")
361+
.arg(opts.dict.as_cli());
360362

361363
let r1_str: Vec<String> = opts
362364
.reads1
@@ -404,6 +406,16 @@ pub fn multiplex_map_and_quant(af_home: &Path, opts: MultiplexQuantOpts) -> anyh
404406
.arg("--min-reads")
405407
.arg(format!("{}", opts.min_reads));
406408

409+
// If the chemistry declares a sample-barcode orientation (e.g. 10x Flex v2
410+
// where the whitelist is the RC of what appears on the read), forward it.
411+
if let Some(c) = chem.as_ref() {
412+
if let Some(sbc_info) = c.sample_bc_list.as_ref() {
413+
if let Some(ori) = sbc_info.sample_bc_ori.as_deref() {
414+
gpl_cmd.arg("--sample-bc-ori").arg(ori);
415+
}
416+
}
417+
}
418+
407419
let gpl_cmd_str = prog_utils::get_cmd_line_string(&gpl_cmd);
408420
info!("generate-permit-list cmd: {}", gpl_cmd_str);
409421
let gpl_start = Instant::now();
@@ -650,6 +662,8 @@ fn build_index_from_probe_set(
650662
.arg(format!("{}", opts.kmer_length))
651663
.arg("-t")
652664
.arg(format!("{}", opts.threads))
665+
.arg("--dict")
666+
.arg(opts.dict.as_cli())
653667
.arg("--overwrite");
654668

655669
info!(
@@ -841,6 +855,7 @@ mod tests {
841855
skipping_strategy: String::from("permissive"),
842856
struct_constraints: false,
843857
max_ec_card: 4096,
858+
dict: crate::simpleaf_commands::PiscemDict::Auto,
844859
min_reads: 10,
845860
anndata_out: false,
846861
};

src/simpleaf_commands/quant.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,8 @@ fn run_mapping_stage(
429429
piscem_quant_cmd
430430
.arg("--threads")
431431
.arg(format!("{}", setup.threads))
432+
.arg("--dict")
433+
.arg(opts.dict.as_cli())
432434
.arg("-o")
433435
.arg(&map_output);
434436

src/utils/chem_utils.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ pub struct SampleBcListInfo {
143143
pub plist_name: Option<String>,
144144
#[serde(skip_serializing_if = "Option::is_none")]
145145
pub remote_url: Option<String>,
146+
/// Orientation of the whitelist entries relative to how the sample BC
147+
/// appears in the read. `"forward"` (default) means no transformation;
148+
/// `"reverse"` means the observed BC on the read is the reverse
149+
/// complement of the whitelist entry (e.g., 10x Flex v2).
150+
#[serde(skip_serializing_if = "Option::is_none")]
151+
pub sample_bc_ori: Option<String>,
146152
}
147153

148154
/// Info for a specific probe set (organism-specific, for Flex protocols).

tests/snapshots/cli-help/simpleaf_index___help.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,7 @@ Piscem Index Options:
5353
index build fails) [default: 1]
5454
--work-dir <WORK_DIR>
5555
The working directory where temporary files should be placed [default: ./workdir.noindex]
56+
--dict <DICT>
57+
Piscem dictionary backend: `auto` (default, emits Tiny artifacts for small references),
58+
`sshash` (compact), or `tiny` (fast-path) [default: auto] [possible values: auto, sshash,
59+
tiny]

tests/snapshots/cli-help/simpleaf_multiplex_quant___help.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ Piscem Mapping Options:
6262
If piscem >= 0.7.0, enable structural constraints
6363
--max-ec-card <MAX_EC_CARD>
6464
Maximum cardinality equivalence class to examine [default: 4096]
65+
--dict <DICT>
66+
Piscem dictionary backend: `auto` (default), `sshash`, or `tiny`. Applies both to the
67+
auto-built probe index (build time) and to map-sc (map time) [default: auto] [possible
68+
values: auto, sshash, tiny]
6569

6670
Output Options:
6771
--anndata-out Generate an anndata (h5ad format) count matrix from the standard (matrix-market

tests/snapshots/cli-help/simpleaf_quant___help.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ Piscem Mapping Options:
4242
second pass and consider k-mers having <= --max-hit-occ-recover hits [default: 1024]
4343
--max-read-occ <MAX_READ_OCC>
4444
Threshold for discarding reads with too many mappings [default: 2500]
45+
--dict <DICT>
46+
Piscem dictionary backend to use at map time: `auto` (default, honors the index's embedded
47+
choice), `sshash`, or `tiny` [default: auto] [possible values: auto, sshash, tiny]
4548

4649
Permit List Generation Options:
4750
-k, --knee

0 commit comments

Comments
 (0)