Skip to main content

Scan2

Struct Scan2 

Source
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: i32

Minimum mapping quality for a read.

§linear_range_size_min: i32

Minimum 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 siteInfor records (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: u64

Memory limit per thread for Page Cache eviction.

§scan1_ids: HashSet<String>

Read IDs already assigned in Scan1 (Java parity: skip in Scan2).

§seq_len: i32

Java Scan2 bucket size (seqLen) used for directional candidate traversal.

§rescued_reads: usize

Unique read IDs rescued by Scan2 and appended to the final BSJ file.

§final_bsj_reads: usize

Total unique BSJ-supporting read IDs in the final merged BSJ file.

Implementations§

Source§

impl Scan2

Source

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.

Source

pub fn set_mem_limit(&mut self, limit: u64)

Overrides the per-thread page-cache eviction threshold.

Source

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.

Source

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’s HashSet -> ArrayList path still leaves a stable first-hit order once the same inputs are replayed.
Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn run_bam( &mut self, bam_file: &str, output_bsj2: &str, output_fsj: &str, chr_tcga_map: &HashMap<String, String>, ) -> Result<()>

Runs Scan2 on BAM input using BGZF-aware sharding.

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.