Skip to content

Commit a787f5f

Browse files
author
Hossein Asghari
committed
integrate cigar generation
1 parent f6df13f commit a787f5f

File tree

2 files changed

+7
-20
lines changed

2 files changed

+7
-20
lines changed

include/Util.hpp

+2-14
Original file line numberDiff line numberDiff line change
@@ -397,13 +397,11 @@ Compile-time selection between list-like and map-like printing.
397397
std::vector<int32_t> cigar_counts;
398398
std::string cigar_types;
399399
int32_t begin_softclip_len{0}, end_softclip_len{0};
400-
bool beginOverhang{false}, endOverhang{false};
401400
// bool allowOverhangSoftClip{false};
402401

403402
void clear() {
404403
cigar_counts.clear(); cigar_types.clear();
405404
begin_softclip_len = end_softclip_len = 0;
406-
beginOverhang = endOverhang = false;
407405
}
408406

409407
void add_item(int32_t count, char type) {
@@ -414,13 +412,13 @@ Compile-time selection between list-like and map-like printing.
414412
// void get_approx_cigar(int32_t readLen, std::string& cigar) {
415413
// if (begin_softclip_len > 0) {
416414
// cigar += std::to_string(begin_softclip_len);
417-
// cigar += beginOverhang and allowOverhangSoftClip ? "I" : "S";
415+
// cigar += allowOverhangSoftClip ? "I" : "S";
418416
// }
419417
// cigar += std::to_string(readLen - (begin_softclip_len + end_softclip_len));
420418
// cigar += "M";
421419
// if (end_softclip_len > 0) {
422420
// cigar += std::to_string(end_softclip_len);
423-
// cigar += endOverhang and allowOverhangSoftClip ? "I" : "S";
421+
// cigar += allowOverhangSoftClip ? "I" : "S";
424422
// }
425423
// }
426424

@@ -485,11 +483,6 @@ Compile-time selection between list-like and map-like printing.
485483
if (cigar_counts.size() != cigar_types.size()) return "!";
486484

487485
std::string cigar = "";
488-
if (begin_softclip_len > 0) {
489-
cigar += std::to_string(begin_softclip_len);
490-
cigar += 'S';
491-
}
492-
//
493486
int32_t last_count = cigar_counts[0];
494487
char last_type = cigar_types[0];
495488
for (size_t i = 1; i < cigar_counts.size(); i++) {
@@ -507,11 +500,6 @@ Compile-time selection between list-like and map-like printing.
507500
// add last
508501
cigar += std::to_string(last_count);
509502
cigar += last_type;
510-
//
511-
if (end_softclip_len > 0) {
512-
cigar += std::to_string(end_softclip_len);
513-
cigar += 'S';
514-
}
515503
return cigar;
516504
}
517505
};

src/PuffAligner.cpp

+5-6
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,8 @@ bool PuffAligner::alignRead(std::string& read, std::string& read_rc, const std::
591591
{
592592
part_score = ez.max;
593593
openGapLen = ez.max_t + 1;
594-
cigarGen.begin_softclip_len = readWindow.length() - (ez.max_q + 1);
594+
cigarGen.add_item(readWindow.length() - (ez.max_q + 1), 'S');
595+
595596
}
596597
alignmentScore += part_score;
597598
addCigar(cigarGen, ez, true);
@@ -613,8 +614,7 @@ bool PuffAligner::alignRead(std::string& read, std::string& read_rc, const std::
613614

614615
if (mopts.computeCIGAR) {
615616
if (allowSoftclip && remainedSoftClipLen >= 0) {
616-
cigarGen.begin_softclip_len = firstMemStart_read;
617-
cigarGen.beginOverhang = true;
617+
cigarGen.add_item(firstMemStart_read, 'S');
618618
openGapLen = 0;
619619
} else {
620620
cigarGen.add_item(firstMemStart_read, 'I');
@@ -860,7 +860,7 @@ bool PuffAligner::alignRead(std::string& read, std::string& read_rc, const std::
860860
else
861861
{
862862
part_score = ez.max;
863-
cigarGen.end_softclip_len = readWindow.length() - (ez.max_q + 1);
863+
cigarGen.add_item(readWindow.length() - (ez.max_q + 1), 'S');
864864
}
865865
alignmentScore += part_score;
866866
addCigar(cigarGen, ez, false);
@@ -885,8 +885,7 @@ bool PuffAligner::alignRead(std::string& read, std::string& read_rc, const std::
885885
-1 * mopts.gapExtendPenalty * readWindow.length());
886886
if (mopts.computeCIGAR) {
887887
if (allowSoftclip && remainedSoftClipLen >= 0) {
888-
cigarGen.end_softclip_len = readWindow.length();
889-
cigarGen.endOverhang = true;
888+
cigarGen.add_item(readWindow.length(), 'S');
890889
} else {
891890
cigarGen.add_item(readWindow.length(), 'I');
892891
}

0 commit comments

Comments
 (0)