Debian Codegraph @

SeqLib/FermiAssembler.h

raw symbols ◀ ▶
Source reconstructed at patch state 1 of 2 — not the installed (fully patched) source.
2 Debian patches touch this file
1 #ifndef SEQLIB_FERMI_H
2 #define SEQLIB_FERMI_H
3
4 #include <string>
5 #include <cstdlib>
6 #include <iostream>
7
8 #include "SeqLib/BamRecord.h"
9
10 extern "C"
11 {
12 #include "fermi-lite/htab.h"
13 #include "fermi-lite/fml.h"
14 #include "fermi-lite/bfc.h"
15 }
16 namespace SeqLib {
17
18 /** Sequence assembly using FermiKit from Heng Li
19 */
20 class FermiAssembler {
21
22 public:
23
24 /** Create an empty FermiAssembler with default parameters */
25 FermiAssembler ();
26
27 /** Create an Empty FermiAssembler with the provided parameters */
28 FermiAssembler(fml_opt_t &_opt);
29 /** Destroy by clearing all stored reads from memory */
30 ~FermiAssembler();
31
32 /** Provide a set of reads to be assembled
33 * @param brv Reads with or without quality scores
34 * @note This will copy the reads and quality scores
35 * into this object. Deallocation is automatic with object
36 * destruction, or with ClearReads.
37 */
38 void AddReads(const BamRecordVector& brv);
39
40 /** Clear all of the sequences and deallocate memory.
41 * This is not required, as it will be done on object destruction
42 */
43 void ClearReads();
44
45 /** Clear all of the contigs and deallocate memory.
46 * This is not required, as it will be done on object destruction
47 */
48 void ClearContigs();
49
50 /** Peform Bloom filter error correction of the reads
51 * in place. */
52 void CorrectReads();
53
54 /** Peform Bloom filter error correction of the reads
55 * in place. Also remove unique reads.
56 */
57 void CorrectAndFilterReads();
58
59 /** Return the sequences in this object, which may have
60 * been error-corrected
61 */
62 UnalignedSequenceVector GetSequences() const;
63
64 /** Perform the string graph assembly.
65 * This will product the string graph,
66 * and travserse the graph to emit contigs
67 */
68 void PerformAssembly();
69
70 /** Return the assembled contigs
71 * @return Assembled contigs in upper case strings (ACTGN)
72 */
73 std::vector<std::string> GetContigs() const;
74
75 /** Perform assembly, without error correction */
76 void DirectAssemble(float kcov);
77
78 /** Set the minimum overlap between reads during string graph construction */
79 void SetMinOverlap(uint32_t m) { opt.min_asm_ovlp = m; }
80
81 /** Aggressively trim graph to discard heterozygotes.
82 * Suggested by lh3 for bacterial assembly
83 * @note See: https://github.com/lh3/fermi-lite/blob/master/example.c
84 */
85 void SetAggressiveTrim() { opt.mag_opt.flag |= MAG_F_AGGRESSIVE; }
86
87 // Added by Cristian Groza
88 void SetSimplifyBubble() {
89 opt.mag_opt.flag &= ~MAG_F_NO_SIMPL;
90 }
91
92 /** From lh3: Drop an overlap if its length is below max_overlap * ratio
93 * @param ratio Overlaps below ratio * max_overlap will be removed
94 */
95 void SetDropOverlapRatio(double ratio) { opt.mag_opt.min_dratio1 = ratio; }
96
97 /** From lh3: Min k-mer & read count thresholds for ec and graph cleaning
98 */
99 void SetKmerMinThreshold(int min) { opt.min_cnt = min; }
100
101 /** From lh3: Max k-mer & read count thresholds for ec and graph cleaning
102 */
103 void SetKmerMaxThreshold(int max) { opt.max_cnt = max; }
104
105 // From lh3: retain a bubble if one side is longer than the other side by >INT-bp
106 //void SetBubbleDifference(int bdiff) { opt.mag_opt.max_bdiff; }
107
108 /** Return the minimum overlap parameter for this assembler */
109 uint32_t GetMinOverlap() const { return opt.min_asm_ovlp; }
110
111 /** Add a set of unaligned sequences to stage for assembly */
112 void AddReads(const UnalignedSequenceVector& v);
113
114 /** Add a single sequence to be assembled */
115 void AddRead(const UnalignedSequence& r);
116
117 /** Add a single sequence from an aligned reads to be assembled */
118 void AddRead(const BamRecord& r);
119
120 /** Return the number of sequences that are controlled by this assembler */
121 size_t NumSequences() const { return n_seqs; }
122
123 void WriteGFA(std::ostream &out);
124 private:
125
126 // reads to assemble
127 fml_seq1_t *m_seqs;
128
129 // size of m_seqs
130 size_t m;
131
132 std::vector<std::string> m_names;
133
134 // number of base-pairs
135 uint64_t size;
136
137 // number of reads
138 size_t n_seqs;
139
140 // number of contigs
141 int n_utg;
142
143 // options
144 fml_opt_t opt;
145
146 // the unitigs
147 fml_utg_t *m_utgs;
148
149 };
150
151
152 }
153
154 #endif