|
@@ -386,28 +386,33 @@ pub fn parse_bin_record_into<'a>(
|
|
|
buf: &'a mut BinRowBuf,
|
|
buf: &'a mut BinRowBuf,
|
|
|
contig_expected: &str,
|
|
contig_expected: &str,
|
|
|
) -> anyhow::Result<(u32, &'a [u32], &'a [u32])> {
|
|
) -> anyhow::Result<(u32, &'a [u32], &'a [u32])> {
|
|
|
- // Adjust these indices to your actual TSV schema:
|
|
|
|
|
let i_contig = 0usize;
|
|
let i_contig = 0usize;
|
|
|
- let i_start = 1usize;
|
|
|
|
|
- let i_depths = 2usize;
|
|
|
|
|
- let i_lowq = 3usize;
|
|
|
|
|
|
|
+ let i_start = 1usize;
|
|
|
|
|
+ let i_end = 2usize;
|
|
|
|
|
|
|
|
- let contig = rec.get(i_contig).context("missing contig")?;
|
|
|
|
|
- let contig = std::str::from_utf8(contig).context("non-utf8 contig")?;
|
|
|
|
|
- anyhow::ensure!(
|
|
|
|
|
- contig == contig_expected,
|
|
|
|
|
- "unexpected contig {} (expected {})",
|
|
|
|
|
- contig,
|
|
|
|
|
- contig_expected
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ // adjust if your file has more/less scalar columns, but for your pasted line:
|
|
|
|
|
+ let i_depths = 9usize; // big CSV list
|
|
|
|
|
+ let i_lowq = 10usize; // big CSV list
|
|
|
|
|
+
|
|
|
|
|
+ let contig = std::str::from_utf8(rec.get(i_contig).context("missing contig")?)
|
|
|
|
|
+ .context("non-utf8 contig")?;
|
|
|
|
|
+ anyhow::ensure!(contig == contig_expected, "unexpected contig");
|
|
|
|
|
|
|
|
let start = parse_u32(rec.get(i_start).context("missing start")?)?;
|
|
let start = parse_u32(rec.get(i_start).context("missing start")?)?;
|
|
|
|
|
+ let end = parse_u32(rec.get(i_end).context("missing end")?)?;
|
|
|
|
|
|
|
|
- let depths_field = rec.get(i_depths).context("missing depths")?;
|
|
|
|
|
- parse_csv_u32_into(&mut buf.depths, depths_field).context("parse depths")?;
|
|
|
|
|
|
|
+ parse_csv_u32_into(&mut buf.depths, rec.get(i_depths).context("missing depths")?)
|
|
|
|
|
+ .context("parse depths")?;
|
|
|
|
|
+ parse_csv_u32_into(&mut buf.lowq, rec.get(i_lowq).context("missing lowq")?)
|
|
|
|
|
+ .context("parse lowq")?;
|
|
|
|
|
|
|
|
- let lowq_field = rec.get(i_lowq).context("missing lowq")?;
|
|
|
|
|
- parse_csv_u32_into(&mut buf.lowq, lowq_field).context("parse lowq")?;
|
|
|
|
|
|
|
+ // critical sanity check: end-start+1 should match vector length for per-base bins
|
|
|
|
|
+ anyhow::ensure!(
|
|
|
|
|
+ (end - start + 1) as usize == buf.depths.len(),
|
|
|
|
|
+ "bin width mismatch: {}..{} has width {}, depths has len {}",
|
|
|
|
|
+ start, end, end - start + 1, buf.depths.len()
|
|
|
|
|
+ );
|
|
|
|
|
+ anyhow::ensure!(buf.depths.len() == buf.lowq.len(), "depth/lowq len mismatch");
|
|
|
|
|
|
|
|
Ok((start, &buf.depths, &buf.lowq))
|
|
Ok((start, &buf.depths, &buf.lowq))
|
|
|
}
|
|
}
|