Skip to content

Commit 8628a22

Browse files
committed
fixed warn about scaffolding logic, proper overlapping edges output
1 parent 17f9726 commit 8628a22

File tree

1 file changed

+23
-5
lines changed
  • assembler/src/modules/algorithms/path_extend

1 file changed

+23
-5
lines changed

assembler/src/modules/algorithms/path_extend/pe_io.hpp

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,37 @@ class ContigWriter {
4343
ss << constructor_.construct(path[0]).first.substr(0, k_);
4444
}
4545

46-
for (size_t i = 0; i < path.Size(); ++i) {
46+
47+
size_t i = 0;
48+
while (i < path.Size()) {
4749
int gap = i == 0 ? 0 : path.GapAt(i);
4850
if (gap > (int) k_) {
4951
for (size_t j = 0; j < gap - k_; ++j) {
5052
ss << "N";
5153
}
5254
ss << constructor_.construct(path[i]).first;
53-
} else {
55+
}
56+
else {
5457
int overlapLen = (int) k_ - gap;
5558
if (overlapLen >= (int) g_.length(path[i]) + (int) k_) {
56-
if(overlapLen > (int) g_.length(path[i]) + (int) k_) {
57-
WARN("Such scaffolding logic leads to local misassemblies");
59+
overlapLen -= (int) g_.length(path[i]) + (int) k_;
60+
++i;
61+
//skipping overlapping edges
62+
while (i < path.Size() && overlapLen >= (int) g_.length(path[i]) + path.GapAt(i)) {
63+
overlapLen -= (int) g_.length(path[i]) + path.GapAt(i);
64+
++i;
65+
}
66+
if (i == path.Size()) {
67+
break;
68+
}
69+
70+
overlapLen = overlapLen + (int) k_ - path.GapAt(i);
71+
if(overlapLen < 0) {
72+
for (size_t j = 0; j < abs(overlapLen); ++j) {
73+
ss << "N";
74+
}
75+
overlapLen = 0;
5876
}
59-
continue;
6077
}
6178
auto temp_str = g_.EdgeNucls(path[i]).Subseq(overlapLen).str();
6279
if(i != path.Size() - 1) {
@@ -69,6 +86,7 @@ class ContigWriter {
6986
}
7087
ss << temp_str;
7188
}
89+
++i;
7290
}
7391
return ss.str();
7492
}

0 commit comments

Comments
 (0)