sigalign_core/results/
mod.rs

1/*!
2Alignment results.
3
4Example in JSON format:
5```json
6{
7  "QueryAlignment": [
8    {
9      "TargetAlignment": {
10        "index": 0,
11        "alignments": [
12          {
13            "Alignment": {
14              "penalty": 4,
15              "length": 100,
16              "position": {
17                "query": [0, 100],
18                "target": [0, 100]
19              },
20              "operations": [
21                {
22                  "AlignmentOperations": {
23                    "operation": "Match",
24                    "count": 99
25                  }
26                },
27                {
28                  "AlignmentOperations": {
29                    "operation": "Subst",
30                    "count": 1
31                  }
32                }
33              ]
34            }
35          }
36        ]
37      }
38    }
39  ]
40}
41```
42*/ 
43use serde::{Deserialize, Serialize};
44
45#[derive(Debug, Clone, Serialize, Deserialize)]
46#[cfg_attr(feature = "short_key", serde(rename = "QryAln"))]
47pub struct QueryAlignment(
48    pub Vec<TargetAlignment>
49);
50
51#[derive(Debug, Clone)]
52#[derive(Serialize, Deserialize)]
53#[cfg_attr(feature = "short_key", serde(rename = "TgtAln"))]
54pub struct TargetAlignment {
55    #[cfg_attr(feature = "short_key", serde(rename = "idx"))]
56    pub index: u32,
57    #[cfg_attr(feature = "short_key", serde(rename = "aln"))]
58    pub alignments: Vec<Alignment>,
59}
60
61#[derive(Debug, PartialEq, Eq, Hash, Clone)]
62#[derive(Serialize, Deserialize)]
63#[cfg_attr(feature = "short_key", serde(rename = "Aln"))]
64pub struct Alignment {
65    #[cfg_attr(feature = "short_key", serde(rename = "pen"))]
66    pub penalty: u32,
67    #[cfg_attr(feature = "short_key", serde(rename = "len"))]
68    pub length: u32,
69    #[cfg_attr(feature = "short_key", serde(rename = "pos"))]
70    pub position: AlignmentPosition,
71    #[cfg_attr(feature = "short_key", serde(rename = "ops"))]
72    pub operations: Vec<AlignmentOperations>,
73}
74
75#[derive(Debug, PartialEq, Eq, Hash, Clone)]
76#[derive(Serialize, Deserialize)]
77#[cfg_attr(feature = "short_key", serde(rename = "Pos"))]
78pub struct AlignmentPosition {
79    #[cfg_attr(feature = "short_key", serde(rename = "qry"))]
80    pub query: (u32, u32),
81    #[cfg_attr(feature = "short_key", serde(rename = "tgt"))]
82    pub target: (u32, u32),
83}
84
85#[derive(Debug, PartialEq, Eq, Hash, Clone)]
86#[derive(Serialize, Deserialize)]
87#[cfg_attr(feature = "short_key", serde(rename = "Ops"))]
88pub struct AlignmentOperations {
89    #[cfg_attr(feature = "short_key", serde(rename = "op"))]
90    pub operation: AlignmentOperation,
91    #[cfg_attr(feature = "short_key", serde(rename = "n"))]
92    pub count: u32,
93}
94
95#[derive(Debug, PartialEq, Eq, Hash, Clone)]
96#[derive(Serialize, Deserialize)]
97pub enum AlignmentOperation {
98    #[cfg_attr(feature = "short_key", serde(rename = "M"))]
99    Match,
100    #[cfg_attr(feature = "short_key", serde(rename = "S"))]
101    Subst,
102    #[cfg_attr(feature = "short_key", serde(rename = "D"))]
103    Deletion,
104    #[cfg_attr(feature = "short_key", serde(rename = "I"))]
105    Insertion,
106}
107
108mod to_json;
109
110// Features
111mod count_alignments;
112mod deduplicate;