From: Don Armstrong Date: Fri, 11 Apr 2014 21:43:41 +0000 (-0700) Subject: add primary_seqname command to determine the primary sequence (first before ,) X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=7923e15da15050e9b88af8a9bb75df1de2a0646c;p=mothur.git add primary_seqname command to determine the primary sequence (first before ,) --- diff --git a/deconvolutecommand.cpp b/deconvolutecommand.cpp index cf1646e..94d01b5 100644 --- a/deconvolutecommand.cpp +++ b/deconvolutecommand.cpp @@ -278,10 +278,10 @@ int DeconvoluteCommand::execute() { m->mothurOut("[ERROR]: " + seq.getName() + " is in your fasta file, and not in your namefile, please correct."); m->mothurOutEndLine(); } else if (countfile != "") { - int num = ct.getNumSeqs(seq.getName()); //checks to make sure seq is in table - if (num != 0) { //its in the table - ct.mergeCounts(itStrings->second.second, seq.getName()); //merges counts and saves in uniques name - } + int num = ct.getNumSeqs(seq.getName()); //checks to make sure seq is in table + if (num != 0) { //its in the table + ct.mergeCounts(primary_seqname(itStrings->second.second), seq.getName()); //merges counts and saves in uniques name + } } itStrings->second.second += "," + seq.getName(); } @@ -311,22 +311,10 @@ int DeconvoluteCommand::execute() { if (countfile == "") { //get rep name - int pos = (it->second.second).find_first_of(','); - - if (pos == string::npos) { // only reps itself - outNames << it->second.second << '\t' << it->second.second << endl; - }else { - outNames << (it->second.second).substr(0, pos) << '\t' << it->second.second << endl; - } + outNames << primary_seqname(it->second.second) << '\t' << it->second.second << endl; } else { //get rep name - int pos = (it->second.second).find_first_of(','); - if (pos == string::npos) { // only reps itself - ct.printSeq(outNames, it->second.second); - } else { - m->mothurOut("Duplicate " + it->second.second + " " + (it->second.second).substr(0,pos) + "\n"); - ct.printSeq(outNames, (it->second.second).substr(0,pos)); - } + ct.printSeq(outNames,primary_seqname(it->second.second); } } outNames.close(); @@ -392,3 +380,12 @@ multimap>::iterator fasta_file.seekg(cur_pos); return seq_strings.end(); } + + +string primary_seqname(string name) { + int pos = name.find_first_of(','); + if (pos == string::npos) { + return name; + } + return name.substr(0,pos); +} diff --git a/deconvolutecommand.h b/deconvolutecommand.h index 3634306..7f3628d 100644 --- a/deconvolutecommand.h +++ b/deconvolutecommand.h @@ -51,4 +51,6 @@ multimap>::iterator Sequence&, ifstream&); +string primary_seqname(string); + #endif