Permalink
Browse files

Adds tax spaces to get/remove.lineage

  • Loading branch information...
1 parent 1dba3f4 commit fadc872fe20df1f84585ebfdf0d142cbb5d7803c @mothur-westcott mothur-westcott committed Aug 24, 2016
Showing with 28 additions and 15 deletions.
  1. +4 −6 source/commands/getlineagecommand.cpp
  2. +4 −5 source/commands/removelineagecommand.cpp
  3. +20 −4 source/optionparser.cpp
@@ -350,7 +350,7 @@ int GetLineageCommand::execute(){
m->mothurOut("\n[NOTE]: The count file should contain only unique names, so mothur assumes your fasta, list and taxonomy files also contain only uniques.\n\n");
}
}
-
+
//read through the correct file and output lines you want to keep
if (taxfile != "") {
readTax(); //fills the set of names to get
@@ -1081,8 +1081,8 @@ int GetLineageCommand::readTax(){
if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
- in >> name; //read from first column
- in >> tax; //read from second column
+ in >> name; m->gobble(in);
+ tax = m->getline(in); m->gobble(in);
string noQuotesTax = m->removeQuotes(tax);
@@ -1178,8 +1178,6 @@ int GetLineageCommand::readTax(){
}
}
-
- m->gobble(in);
}
in.close();
out.close();
@@ -1239,7 +1237,7 @@ int GetLineageCommand::readConsTax(){
in >> otuLabel; m->gobble(in);
in >> numReps; m->gobble(in);
- in >> tax; m->gobble(in);
+ tax = m->getline(in); m->gobble(in);
string noQuotesTax = m->removeQuotes(tax);
@@ -1070,9 +1070,9 @@ int RemoveLineageCommand::readTax(){
if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; }
- in >> name; //read from first column
- in >> tax; //read from second column
-
+ in >> name; m->gobble(in);
+ tax = m->getline(in); m->gobble(in);
+
bool remove = false;
string noQuotesTax = m->removeQuotes(tax);
@@ -1176,7 +1176,6 @@ int RemoveLineageCommand::readTax(){
}
if (!remove) { wroteSomething = true; out << name << '\t' << tax << endl; }
- m->gobble(in);
}
in.close();
out.close();
@@ -1237,7 +1236,7 @@ int RemoveLineageCommand::readConsTax(){
in >> otuLabel; m->gobble(in);
in >> numReps; m->gobble(in);
- in >> tax; m->gobble(in);
+ tax = m->getline(in); m->gobble(in);
bool remove = false;
View
@@ -24,7 +24,11 @@ OptionParser::OptionParser(string option) {
if ((key == "candidate") || (key == "query")) { key = "fasta"; }
if (key == "template") { key = "reference"; }
key = m->splitWhiteSpace(key).front();
- value = m->splitWhiteSpace(value).front();
+ //if value is wrapped in '' preserve spaces
+ if ((value[0] == '\'') && (value[(value.length()-1)] == '\'')) { value = value.substr(1); value = value.substr(0, (value.length()-1)); }
+ else {
+ value = m->splitWhiteSpace(value).front();
+ }
parameters[key] = value;
}
@@ -33,7 +37,11 @@ OptionParser::OptionParser(string option) {
if ((key == "candidate") || (key == "query")) { key = "fasta"; }
if (key == "template") { key = "reference"; }
key = m->splitWhiteSpace(key).front();
- option = m->splitWhiteSpace(option).front();
+ //if value is wrapped in '' preserve spaces
+ if ((option[0] == '\'') && (option[(option.length()-1)] == '\'')) { option = option.substr(1); option = option.substr(0, (option.length()-1)); }
+ else {
+ option = m->splitWhiteSpace(option).front();
+ }
parameters[key] = option;
}
}
@@ -57,7 +65,11 @@ OptionParser::OptionParser(string option, map<string, string>& copy) {
if ((key == "candidate") || (key == "query")) { key = "fasta"; }
if (key == "template") { key = "reference"; }
key = m->splitWhiteSpace(key).front();
- value = m->splitWhiteSpace(value).front();
+ //if value is wrapped in '' preserve spaces
+ if ((value[0] == '\'') && (value[(value.length()-1)] == '\'')) { value = value.substr(1); value = value.substr(0, (value.length()-1)); }
+ else {
+ value = m->splitWhiteSpace(value).front();
+ }
parameters[key] = value;
}
@@ -66,7 +78,11 @@ OptionParser::OptionParser(string option, map<string, string>& copy) {
if ((key == "candidate") || (key == "query")) { key = "fasta"; }
if (key == "template") { key = "reference"; }
key = m->splitWhiteSpace(key).front();
- option = m->splitWhiteSpace(option).front();
+ //if value is wrapped in '' preserve spaces
+ if ((option[0] == '\'') && (option[(option.length()-1)] == '\'')) { option = option.substr(1); option = option.substr(0, (option.length()-1)); }
+ else {
+ option = m->splitWhiteSpace(option).front();
+ }
parameters[key] = option;
}

0 comments on commit fadc872

Please sign in to comment.