pub struct Scan2 {
pub min_mapq_uni: i32,
pub linear_range_size_min: i32,
pub index1: HashMap<String, Vec<CandidateBreakpoint>>,
pub index2: HashMap<String, Vec<CandidateBreakpoint>>,
pub site_array1: HashMap<String, HashSet<i32>>,
pub site_array2: HashMap<String, HashSet<i32>>,
pub fsj_map: HashMap<String, i32>,
pub mem_limit: u64,
pub scan1_ids: HashSet<String>,
pub seq_len: i32,
pub rescued_reads: usize,
pub final_bsj_reads: usize,
}Expand description
Core logic for the second scan pass.
Fields§
§min_mapq_uni: i32Minimum mapping quality for a read.
linear_range_size_min: i32Minimum linear range size for competition check.
index1: HashMap<String, Vec<CandidateBreakpoint>>Index for BSJ candidates (indexed by Site1).
Java parity note:
- Backed by de-duplicated
siteInforrecords (site1..sum_q), not raw BSJ1 lines. - Candidate payload layout is
[site1, site2, strand, signal1, signal2, sum_q].
index2: HashMap<String, Vec<CandidateBreakpoint>>Index for BSJ candidates (indexed by Site2).
site_array1: HashMap<String, HashSet<i32>>Java parity gate: existing buckets for Site1 index.
site_array2: HashMap<String, HashSet<i32>>Java parity gate: existing buckets for Site2 index.
fsj_map: HashMap<String, i32>Map to store Forward Spliced Junction (FSJ) counts.
mem_limit: u64Memory limit per thread for Page Cache eviction.
scan1_ids: HashSet<String>Read IDs already assigned in Scan1 (Java parity: skip in Scan2).
seq_len: i32Java Scan2 bucket size (seqLen) used for directional candidate traversal.
rescued_reads: usizeUnique read IDs rescued by Scan2 and appended to the final BSJ file.
final_bsj_reads: usizeTotal unique BSJ-supporting read IDs in the final merged BSJ file.
Implementations§
Source§impl Scan2
impl Scan2
Sourcepub fn new(min_mapq_uni: i32, linear_range_size_min: i32, seq_len: i32) -> Self
pub fn new(min_mapq_uni: i32, linear_range_size_min: i32, seq_len: i32) -> Self
Creates a Scan2 runner with CIRI3-compatible thresholds and bucket size.
Sourcepub fn set_mem_limit(&mut self, limit: u64)
pub fn set_mem_limit(&mut self, limit: u64)
Overrides the per-thread page-cache eviction threshold.
Sourcepub fn release_working_set(&mut self)
pub fn release_working_set(&mut self)
Drops Scan2-only indexing state once rescue is complete.
Summary only needs the merged fsj_map, so the large candidate indexes and
Scan1 read-id filter can be released explicitly before the final stage to
keep peak RSS lower on whole-genome inputs.
Sourcepub fn build_index(&mut self, bsj1_file: &str) -> Result<()>
pub fn build_index(&mut self, bsj1_file: &str) -> Result<()>
Loads Scan1 BSJ1 output and builds the de-duplicated Scan2 candidate index.
This function intentionally mirrors Java’s unique-site indexing semantics:
the traversal order of candidates must match Java, because Scan2 returns on
the first valid non-2 tag it encounters.
Two details here are easy to “simplify” incorrectly:
- Scan2 de-duplicates by circ site payload before building the index, so repeated BSJ1 rows for the same circ do not create extra candidates.
- The insertion order is preserved through
order, then reused after the final per-bucket sort, because Java’sHashSet -> ArrayListpath still leaves a stable first-hit order once the same inputs are replayed.
Sourcepub fn add_external_circ_candidates(
&mut self,
candidates: &[CircCatalogRecord],
reference: &HashMap<String, String>,
) -> Result<usize>
pub fn add_external_circ_candidates( &mut self, candidates: &[CircCatalogRecord], reference: &HashMap<String, String>, ) -> Result<usize>
Adds cohort-level external BSJ sites to the Scan2 candidate indexes.
--circ candidates come from BED6 catalog coordinates rather than from
Scan1 read evidence. They are therefore appended after the Java-parity
Scan1 candidates: default runs stay unchanged, while a second-pass run can
test additional cohort-supported BSJ boundaries against this sample’s own
reads. The left/right signal fields are reconstructed from the reference
so the existing is_bsj_hg2 validator can remain the single source of
sequence-match decisions.
Sourcepub fn run(
&mut self,
sam_file: &str,
output_bsj2: &str,
output_fsj: &str,
chr_tcga_map: &HashMap<String, String>,
) -> Result<()>
pub fn run( &mut self, sam_file: &str, output_bsj2: &str, output_fsj: &str, chr_tcga_map: &HashMap<String, String>, ) -> Result<()>
Dispatches to the SAM or BAM Scan2 implementation.
Sourcepub fn run_with_display(
&mut self,
sam_file: &str,
output_bsj2: &str,
output_fsj: &str,
scan1_display_path: Option<&str>,
display_output_path: Option<&str>,
chr_tcga_map: &HashMap<String, String>,
) -> Result<()>
pub fn run_with_display( &mut self, sam_file: &str, output_bsj2: &str, output_fsj: &str, scan1_display_path: Option<&str>, display_output_path: Option<&str>, chr_tcga_map: &HashMap<String, String>, ) -> Result<()>
Runs Scan2 and optionally emits mate-level priority=0 rescue rows into
the same .bsj2 stream during the scan.
Sourcepub fn run_with_display_and_segments(
&mut self,
sam_file: &str,
output_bsj2: &str,
output_fsj: &str,
scan1_display_path: Option<&str>,
display_output_path: Option<&str>,
segments_output_path: Option<&str>,
non_bsj_segments_output_path: Option<&str>,
chr_tcga_map: &HashMap<String, String>,
) -> Result<Scan2SegmentArtifacts>
pub fn run_with_display_and_segments( &mut self, sam_file: &str, output_bsj2: &str, output_fsj: &str, scan1_display_path: Option<&str>, display_output_path: Option<&str>, segments_output_path: Option<&str>, non_bsj_segments_output_path: Option<&str>, chr_tcga_map: &HashMap<String, String>, ) -> Result<Scan2SegmentArtifacts>
Runs Scan2 while also writing a segments-evidence sidecar for rescued BSJ reads.
The extra sidecar is independent from .bsj2 and FSJ counting. It records
mapper alignment blocks for read groups with Scan2 BSJ evidence so the
post-Summary segments stage can reconstruct confirmed BSJ rows without
scanning the input alignment file again.
Sourcepub fn run_sam(
&mut self,
sam_file: &str,
output_bsj2: &str,
output_fsj: &str,
chr_tcga_map: &HashMap<String, String>,
) -> Result<()>
pub fn run_sam( &mut self, sam_file: &str, output_bsj2: &str, output_fsj: &str, chr_tcga_map: &HashMap<String, String>, ) -> Result<()>
Runs Scan2 on SAM input.
The SAM path preserves queryname groups before batch-parallel processing, matching the BAM path’s read-group semantics while avoiding shard-boundary FSJ duplication.
Auto Trait Implementations§
impl Freeze for Scan2
impl RefUnwindSafe for Scan2
impl Send for Scan2
impl Sync for Scan2
impl Unpin for Scan2
impl UnsafeUnpin for Scan2
impl UnwindSafe for Scan2
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more