Skip to content

Commit 4fddf2f

Browse files
committed
split multi-alt variant to multiple single-alt variants
1 parent 7e2e3eb commit 4fddf2f

File tree

3 files changed

+31
-20
lines changed

3 files changed

+31
-20
lines changed

src/pescanner.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ void PairEndScanner::consumerTask()
283283
void PairEndScanner::textReport(vector<Mutation>& mutationList, vector<Match*> *mutationMatches) {
284284
//output result
285285
bool found = false;
286+
int undetected = 0;
286287
for(int i=0;i<mutationList.size();i++){
287288
vector<Match*> matches = mutationMatches[i];
288289
if(matches.size()>=GlobalSettings::minReadSupport){
@@ -293,14 +294,16 @@ void PairEndScanner::textReport(vector<Mutation>& mutationList, vector<Match*> *
293294
cout<<m+1<<", ";
294295
matches[m]->print(mutationList[i].mLeft.length(), mutationList[i].mCenter.length(), mutationList[i].mRight.length());
295296
}
297+
} else {
298+
undetected++;
296299
}
297300
}
298301
if(found == false) {
299302
cout << "MutScan didn't find any mutation" << endl;
300303
}
301304
// if processing VCF, output those with no supporting reads found
302-
if(GlobalSettings::processingVCF) {
303-
cerr << "Following mutations are not detected" << endl;
305+
if(GlobalSettings::processingVCF && undetected>0) {
306+
cerr << undetected << " mutations of this VCF are not detected" << endl;
304307
for(int i=0;i<mutationList.size();i++){
305308
vector<Match*> matches = mutationMatches[i];
306309
if(matches.size()<GlobalSettings::minReadSupport){

src/sescanner.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ void SingleEndScanner::consumerTask()
255255
void SingleEndScanner::textReport(vector<Mutation>& mutationList, vector<Match*> *mutationMatches) {
256256
//output result
257257
bool found = false;
258+
int undetected = 0;
258259
for(int i=0;i<mutationList.size();i++){
259260
vector<Match*> matches = mutationMatches[i];
260261
if(matches.size()>=GlobalSettings::minReadSupport){
@@ -265,14 +266,16 @@ void SingleEndScanner::textReport(vector<Mutation>& mutationList, vector<Match*>
265266
cout<<m+1<<", ";
266267
matches[m]->print(mutationList[i].mLeft.length(), mutationList[i].mCenter.length(), mutationList[i].mRight.length());
267268
}
269+
} else {
270+
undetected++;
268271
}
269272
}
270273
if(found == false) {
271274
cout << "MutScan didn't find any mutation" << endl;
272275
}
273276
// if processing VCF, output those with no supporting reads found
274-
if(GlobalSettings::processingVCF) {
275-
cerr << "Following mutations are not detected" << endl;
277+
if(GlobalSettings::processingVCF && undetected>0) {
278+
cerr << undetected << " mutations of this VCF are not detected" << endl;
276279
for(int i=0;i<mutationList.size();i++){
277280
vector<Match*> matches = mutationMatches[i];
278281
if(matches.size()<GlobalSettings::minReadSupport){

src/vcfreader.cpp

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -54,22 +54,27 @@ bool VcfReader::readNext()
5454
if(items[0][0]=='#')
5555
return false;
5656

57-
int pos = atoi(items[1].c_str());
58-
Variant var;
59-
var.chrom = trim(items[0]);
60-
var.pos = pos;
61-
var.id = trim(items[2]);
62-
var.ref = trim(items[3]);
63-
var.alt = trim(items[4]);
64-
var.qual = trim(items[5]);
65-
var.filter = trim(items[6]);
66-
var.info = trim(items[7]);
67-
68-
// format is not required
69-
if(items.size()>=9)
70-
var.format = trim(items[8]);
71-
72-
mVariants.push_back(var);
57+
//split the alt by comma to make multiple variants, GATK usually output such kind of variant like C>T,AT
58+
vector<string> alts;
59+
split(trim(items[4]), alts, ",");
60+
for(int a=0; a<alts.size(); a++){
61+
int pos = atoi(items[1].c_str());
62+
Variant var;
63+
var.chrom = trim(items[0]);
64+
var.pos = pos;
65+
var.id = trim(items[2]);
66+
var.ref = trim(items[3]);
67+
var.alt = alts[a];
68+
var.qual = trim(items[5]);
69+
var.filter = trim(items[6]);
70+
var.info = trim(items[7]);
71+
72+
// format is not required
73+
if(items.size()>=9)
74+
var.format = trim(items[8]);
75+
76+
mVariants.push_back(var);
77+
}
7378

7479
return true;
7580
}

0 commit comments

Comments
 (0)