Skip to content

Commit

Permalink
split multi-alt variant to multiple single-alt variants
Browse files Browse the repository at this point in the history
  • Loading branch information
sfchen committed Oct 22, 2017
1 parent 7e2e3eb commit 4fddf2f
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 20 deletions.
7 changes: 5 additions & 2 deletions src/pescanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ void PairEndScanner::consumerTask()
void PairEndScanner::textReport(vector<Mutation>& mutationList, vector<Match*> *mutationMatches) {
//output result
bool found = false;
int undetected = 0;
for(int i=0;i<mutationList.size();i++){
vector<Match*> matches = mutationMatches[i];
if(matches.size()>=GlobalSettings::minReadSupport){
Expand All @@ -293,14 +294,16 @@ void PairEndScanner::textReport(vector<Mutation>& mutationList, vector<Match*> *
cout<<m+1<<", ";
matches[m]->print(mutationList[i].mLeft.length(), mutationList[i].mCenter.length(), mutationList[i].mRight.length());
}
} else {
undetected++;
}
}
if(found == false) {
cout << "MutScan didn't find any mutation" << endl;
}
// if processing VCF, output those with no supporting reads found
if(GlobalSettings::processingVCF) {
cerr << "Following mutations are not detected" << endl;
if(GlobalSettings::processingVCF && undetected>0) {
cerr << undetected << " mutations of this VCF are not detected" << endl;
for(int i=0;i<mutationList.size();i++){
vector<Match*> matches = mutationMatches[i];
if(matches.size()<GlobalSettings::minReadSupport){
Expand Down
7 changes: 5 additions & 2 deletions src/sescanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ void SingleEndScanner::consumerTask()
void SingleEndScanner::textReport(vector<Mutation>& mutationList, vector<Match*> *mutationMatches) {
//output result
bool found = false;
int undetected = 0;
for(int i=0;i<mutationList.size();i++){
vector<Match*> matches = mutationMatches[i];
if(matches.size()>=GlobalSettings::minReadSupport){
Expand All @@ -265,14 +266,16 @@ void SingleEndScanner::textReport(vector<Mutation>& mutationList, vector<Match*>
cout<<m+1<<", ";
matches[m]->print(mutationList[i].mLeft.length(), mutationList[i].mCenter.length(), mutationList[i].mRight.length());
}
} else {
undetected++;
}
}
if(found == false) {
cout << "MutScan didn't find any mutation" << endl;
}
// if processing VCF, output those with no supporting reads found
if(GlobalSettings::processingVCF) {
cerr << "Following mutations are not detected" << endl;
if(GlobalSettings::processingVCF && undetected>0) {
cerr << undetected << " mutations of this VCF are not detected" << endl;
for(int i=0;i<mutationList.size();i++){
vector<Match*> matches = mutationMatches[i];
if(matches.size()<GlobalSettings::minReadSupport){
Expand Down
37 changes: 21 additions & 16 deletions src/vcfreader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,22 +54,27 @@ bool VcfReader::readNext()
if(items[0][0]=='#')
return false;

int pos = atoi(items[1].c_str());
Variant var;
var.chrom = trim(items[0]);
var.pos = pos;
var.id = trim(items[2]);
var.ref = trim(items[3]);
var.alt = trim(items[4]);
var.qual = trim(items[5]);
var.filter = trim(items[6]);
var.info = trim(items[7]);

// format is not required
if(items.size()>=9)
var.format = trim(items[8]);

mVariants.push_back(var);
//split the alt by comma to make multiple variants, GATK usually output such kind of variant like C>T,AT
vector<string> alts;
split(trim(items[4]), alts, ",");
for(int a=0; a<alts.size(); a++){
int pos = atoi(items[1].c_str());
Variant var;
var.chrom = trim(items[0]);
var.pos = pos;
var.id = trim(items[2]);
var.ref = trim(items[3]);
var.alt = alts[a];
var.qual = trim(items[5]);
var.filter = trim(items[6]);
var.info = trim(items[7]);

// format is not required
if(items.size()>=9)
var.format = trim(items[8]);

mVariants.push_back(var);
}

return true;
}
Expand Down

0 comments on commit 4fddf2f

Please sign in to comment.