Debian Codegraph @

samtools/consensus_pileup.h

raw symbols SCIP
1 /* consensus_pileup.h -- Pileup orientated data per consensus column
2
3 Copyright (C) 2013-2016, 2020-2022 Genome Research Ltd.
4
5 Author: James Bonfied <[email protected]>
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 notices 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 #include <htslib/sam.h>
26
27 typedef struct pileup {
28 // commonly used things together, to fit in a cache line (64 bytes)
29 struct pileup *next; // A link list, for active seqs
30 void *cd; // General purpose per-seq client-data
31 int eof; // True if this sequence has finished
32 int qual; // Current qual (for active seq only)
33 char start; // True if this is a new sequence
34 char base; // Current base (for active seq only) in ASCII
35 char ref_skip; // True if the cause of eof or start is cigar N
36 char padding; // True if the base was added due to another seq
37 int base4; // Base in 4-bit notation (0-15)
38 hts_pos_t pos; // Current unpadded position in seq
39 int nth; // nth base at unpadded position 'pos'
40 int b_is_rev; // 0 => fwd, 1 => rev
41 int seq_offset; // Current base position in s->seq[] array.
42
43 unsigned char *b_qual;// cached bam_qual
44 unsigned char *b_seq; // cached bam_seq
45
46 // --- 64 bytes
47 struct pileup *eofn; // p->eof set, next eof member
48 struct pileup *eofl; // last non-eof that points to p with p->eof
49
50 uint32_t *b_cigar; // cached bam_cigar
51
52 int cigar_ind; // Current location in s->alignment cigar str
53 int cigar_op; // Current cigar operation
54 int cigar_len; // Remaining length of this cigar op
55
56 int first_del; // Used when first base is a deletion
57
58 bam1_t b; // Bam entry associated with struct
59 } pileup_t;
60
61 /*
62 * The pileup loop executes and calls callbacks to perform the work.
63 *
64 * seq_fetch returns the next sequence. Return 0 from this indicates no
65 * more data.
66 *
67 * seq_init is called, if non-NULL, when a sequence is added to the pileup,
68 * seq_free likewise, if non-NULL, is called when a sequence is removed
69 * from the pileup.
70 * These two functions are akin to the constructor and destructors added
71 * to mpileup.
72 *
73 * seq_column is the primary work horse which is executed for each
74 * reference position, and for each inserted base per ref pos.
75 *
76 * If we were to invert this from a loop generating callbacks to a polled
77 * style interface like mpileup, then the seq_column bit would be dropped
78 * and replaced by the returned pileup and associated parameters.
79 */
80 int pileup_loop(samFile *fp,
81 sam_hdr_t *h,
82 int (*seq_fetch)(void *client_data,
83 samFile *fp,
84 sam_hdr_t *h,
85 bam1_t *b),
86 int (*seq_init)(void *client_data,
87 samFile *fp,
88 sam_hdr_t *h,
89 pileup_t *p),
90 int (*seq_column)(void *client_data,
91 samFile *fp,
92 sam_hdr_t *h,
93 pileup_t *p,
94 int depth,
95 hts_pos_t pos,
96 int nth,
97 int is_insert),
98 void (*seq_free)(void *client_data,
99 samFile *fp,
100 sam_hdr_t *h,
101 pileup_t *p),
102 void *client_data);