Skip to main content

generate_read_pair

Function generate_read_pair 

Source
pub fn generate_read_pair(
    fragment: &Fragment,
    contig_name: &str,
    read_num: u64,
    read_length: usize,
    paired: bool,
    adapter_r1: &[u8],
    adapter_r2: &[u8],
    max_n_frac: f64,
    model: &impl ErrorModel,
    simple_names: bool,
    methylation: Option<&MethylationConfig<'_>>,
    capture_pre_conversion: bool,
    rng: &mut impl Rng,
) -> Option<ReadPair>
Expand description

Generate a simulated read pair from a fragment.

Extracts R1 and optionally R2 bases from the fragment, applies the error model, constructs read names with truth information, and computes CIGARs from the fragment’s reference coordinate mapping.

Returns None if either R1 or R2 has a lowercase-base fraction greater than max_n_frac (i.e. too many bases came from ambiguity-resolved reference positions); the caller should resample. See the fragment module documentation for the lowercase-marker convention.

§Arguments

  • fragment — The source fragment with bases and reference positions.
  • contig_name — Contig name for read naming.
  • read_num — 1-based read pair number.
  • read_length — Desired read length.
  • paired — Whether to generate both R1 and R2.
  • adapter_r1 — Adapter sequence for R1.
  • adapter_r2 — Adapter sequence for R2.
  • max_n_frac — Reject the pair if R1 or R2 has a lowercase fraction exceeding this threshold. Use 1.0 to disable.
  • error_model — Error model to apply.
  • simple_names — Use simple names instead of encoded truth names.
  • methylation — Optional methylation chemistry configuration. When Some, the qualifying class of cytosines (unmethylated under em-seq, methylated under TAPS) in the genomic portion of each read is converted to T with probability conversion_rate before the error model is applied.
  • capture_pre_conversion — When true AND methylation is Some, capture the pre-conversion bases of each mate for the YS:Z golden-BAM tag. Has no effect when methylation is None.
  • rng — Random number generator.