minimap2_paf_io/data/
mod.rs

1/// A line in a minimap PAF file.
2///
3/// The field names are adapted from the [minimap2 man-page][1]. Check it out for more info.
4///
5/// [1]: https://lh3.github.io/minimap2/minimap2.html#10
6#[derive(Clone, Debug, PartialEq)]
7#[allow(missing_docs)]
8pub struct PAFLine {
9    // required fields
10    pub query_sequence_name: String,
11    pub query_sequence_length: usize,
12    pub query_start_coordinate: usize,
13    pub query_end_coordinate: usize,
14    pub strand: bool,
15    pub target_sequence_name: String,
16    pub target_sequence_length: usize,
17    pub target_start_coordinate_on_original_strand: usize,
18    pub target_end_coordinate_on_original_strand: usize,
19    pub number_of_matching_bases: usize,
20    pub number_of_bases_and_gaps: usize,
21    pub mapping_quality: u8,
22
23    // optional fields
24    pub alignment_type: Option<AlignmentType>,
25    pub number_of_minimisers: Option<usize>,
26    pub chaining_score: Option<isize>,
27    pub best_secondary_chaining_score: Option<isize>,
28    pub total_number_of_mismatches_and_gaps: Option<usize>,
29    pub unknown_md: Option<String>,
30    pub dp_alignment_score: Option<isize>,
31    pub supplementary_alignments: Option<String>,
32    pub best_segment_dp_score: Option<isize>,
33    pub number_of_ambiguous_bases: Option<usize>,
34    pub transcript_strand: Option<String>,
35    pub cigar_string: Option<Cigar>,
36    pub difference_string: Option<AlignmentDifference>,
37    pub approximate_per_base_sequence_divergence: Option<f64>,
38    pub gap_compressed_per_base_sequence_divergence: Option<f64>,
39    pub length_of_query_regions_with_repetitive_seeds: Option<usize>,
40
41    pub unknown_fields: Vec<String>,
42}
43
44/// The type of a minimap2 alignment. See the [minimap2 readme](https://github.com/lh3/minimap2#algorithm-overview) for more information.
45#[allow(missing_docs)]
46#[derive(Clone, Debug, Eq, PartialEq)]
47pub enum AlignmentType {
48    Primary,
49    Secondary,
50    PrimaryInversion,
51    SecondaryInversion,
52}
53
54/// A CIGAR string. See the [this page](https://www.drive5.com/usearch/manual/cigar.html) for more information.
55#[derive(Clone, Debug, Eq, PartialEq)]
56pub struct Cigar(pub Vec<CigarColumn>);
57
58/// A column of a CIGAR string. See the [this page](https://www.drive5.com/usearch/manual/cigar.html) for more information.
59#[allow(missing_docs)]
60#[derive(Clone, Debug, Eq, PartialEq)]
61pub enum CigarColumn {
62    Match(usize),
63    Insertion(usize),
64    Deletion(usize),
65    Mismatch(usize),
66}
67
68/// An alignment difference string. See the [minimap2 man-page](https://lh3.github.io/minimap2/minimap2.html#10) for more information.
69#[derive(Clone, Debug, Eq, PartialEq)]
70pub struct AlignmentDifference(pub Vec<DifferenceColumn>);
71
72/// A column of a difference string. See the [minimap2 man-page](https://lh3.github.io/minimap2/minimap2.html#10) for more information.
73#[allow(missing_docs)]
74#[derive(Clone, Debug, Eq, PartialEq)]
75pub enum DifferenceColumn {
76    Match {
77        length: usize,
78    },
79    Insertion {
80        superfluous_query_characters: String,
81    },
82    Deletion {
83        missing_query_characters: String,
84    },
85    Mismatch {
86        reference: char,
87        query: char,
88    },
89}