Skip to content

Commit 122e64f

Browse files
committed
revise Cluster::addRead
1 parent cc5483f commit 122e64f

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/cluster.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -646,16 +646,21 @@ int Cluster::makeConsensus(vector<bam1_t* >& reads, bam1_t* out, vector<char*>&
646646

647647
void Cluster::addRead(bam1_t* b) {
648648
// left
649+
string qname = BamUtil::getQName(b);
650+
map<string, Pair*>::iterator iter = mPairs.find(qname);
651+
649652
if(b->core.isize > 0) {
653+
if(iter!=mPairs.end()) {
654+
delete iter->second;
655+
}
650656
Pair* p = new Pair(mOptions);
651657
p->setLeft(b);
652-
mPairs[p->getQName()]=p;
658+
mPairs[qname]=p;
653659
return;
654660
}
655661

656-
string qname = BamUtil::getQName(b);
657-
if(mPairs.count(qname) > 0)
658-
mPairs[qname]->setRight(b);
662+
if(iter!=mPairs.end())
663+
iter->second->setRight(b);
659664
else {
660665
Pair* p = new Pair(mOptions);
661666
if(b->core.isize < 0)

0 commit comments

Comments
 (0)