MCPcopy Create free account
hub / github.com/BirolLab/abyss / getTreeTraces

Function getTreeTraces

RResolver/SequenceTree.cpp:118–170  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

116typedef std::list<Trace> Traces;
117
118static Traces
119getTreeTraces(
120 const ContigNode& start,
121 const int overlap,
122 const int maxLength,
123 const bool forward,
124 const int maxPaths)
125{
126 assert(maxLength > 0);
127
128 Traces traces;
129 std::queue<std::reference_wrapper<Trace>> queue;
130
131 SequenceTreeNode root(start, overlap, maxLength, forward);
132
133 int level = 1;
134 (void)level;
135 int leaves = 1;
136 traces.push_back({ root });
137 queue.push(traces.back());
138 while (!queue.empty()) {
139 Trace& trace = queue.front();
140 queue.pop();
141
142 const SequenceTreeNode& node = trace.back();
143 assert(node.maxLength > 0 && node.maxLength <= maxLength);
144
145 assert(int(trace.size()) >= level);
146 level = trace.size();
147
148 auto children = node.getChildren();
149 if ((children.size() > 0) && (leaves + int(children.size()) - 1 <= maxPaths)) {
150 for (size_t i = 0; i < children.size(); i++) {
151 const auto& child = children[i];
152 assert(child.maxLength > 0);
153 assert(child.maxLength < node.maxLength);
154 if (i < children.size() - 1) {
155 Trace childTrace = trace;
156 childTrace.push_back(child);
157 assert(childTrace.size() == trace.size() + 1);
158 traces.push_back(childTrace);
159 queue.push(traces.back());
160 } else {
161 trace.push_back(child);
162 queue.push(trace);
163 }
164 }
165 leaves += children.size() - 1;
166 }
167 }
168
169 return traces;
170}
171
172std::vector<Sequence>
173getTreeSequences(

Callers 1

getTreeSequencesFunction · 0.85

Calls 8

pushMethod · 0.80
popMethod · 0.80
getChildrenMethod · 0.80
push_backMethod · 0.45
backMethod · 0.45
emptyMethod · 0.45
frontMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected