Debian Codegraph @

bcftools/read_consensus.h

raw symbols SCIP
1 /* read_consensus.h -- create and maintain consensus of reads
2
3 Copyright (C) 2022 Genome Research Ltd.
4
5 Author: pd3@sanger
6
7 Permission is hereby granted, free of charge, to any person obtaining a copy
8 of this software and associated documentation files (the "Software"), to deal
9 in the Software without restriction, including without limitation the rights
10 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 copies of the Software, and to permit persons to whom the Software is
12 furnished to do so, subject to the following conditions:
13
14 The above copyright notice and this permission notice shall be included in
15 all copies or substantial portions of the Software.
16
17 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
22 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 DEALINGS IN THE SOFTWARE. */
24
25 #ifndef READ_CONSENSUS_H
26 #define READ_CONSENSUS_H
27
28 #include <stdint.h>
29 #include <htslib/hts.h>
30 #include <htslib/sam.h>
31
32 #ifndef DEBUG_RCNS
33 #define DEBUG_RCNS 0
34 #endif
35
36 typedef struct
37 {
38 char *seq; // nt5 sequence: "ACGTN"[(int)seq[i]]
39 int nseq, ipos; // the sequence length and the `pos` index relative to seq
40 }
41 cns_seq_t;
42
43 typedef struct _read_cns_t read_cns_t;
44
45 // Init and destroy read consensus
46 read_cns_t *rcns_init(hts_pos_t pos, hts_pos_t beg, hts_pos_t end);
47 void rcns_destroy(read_cns_t *rcns);
48
49 // Reset the structures for new sample and/or position
50 int rcns_reset(read_cns_t *rcns, hts_pos_t pos, hts_pos_t beg, hts_pos_t end);
51
52 // Add reads to consensus. The provided structures must continue to exist
53 // until rcns_get_consensus() is called.
54 //
55 // Todo (easy): allow it to be called once or multiple times, eg for
56 // creating a shared consensus for multiple samples
57 int rcns_set_reads(read_cns_t *rcns, bam_pileup1_t *plp, int nplp);
58
59 // Generate up to two consensus sequences, cns_seq[1].nseq is 0 when only
60 // the first is set
61 cns_seq_t *rcns_get_consensus(read_cns_t *rcns, const char *ref);
62
63 #endif