openInputFile(fastafile, in);
string name;
+ bool wroteSomething = false;
+
while(!in.eof()){
Sequence currSeq(in);
name = currSeq.getName();
//if this name is in the accnos file
if (names.count(name) == 1) {
+ wroteSomething = true;
+
currSeq.printSequence(out);
+
+ names.erase(name);
}
gobble(in);
}
in.close();
- out.close();
+ out.close();
+
+ if (wroteSomething == false) {
+ mothurOut("Your file does not contain any sequence from the .accnos file."); mothurOutEndLine();
+ remove(outputFileName.c_str());
+ }
}
catch(exception& e) {
openInputFile(namefile, in);
string name, firstCol, secondCol;
+ bool wroteSomething = false;
+
while(!in.eof()){
for (int i = 0; i < parsedNames.size(); i++) {
if (names.count(parsedNames[i]) == 1) {
validSecond.push_back(parsedNames[i]);
+ names.erase(parsedNames[i]);
}
}
//if the name in the first column is in the set then print it and any other names in second column also in set
if (names.count(firstCol) == 1) {
+
+ wroteSomething = true;
+
out << firstCol << '\t';
//you know you have at least one valid second since first column is valid
for (int i = 0; i < validSecond.size()-1; i++) { out << validSecond[i] << ','; }
out << validSecond[validSecond.size()-1] << endl;
+
+ names.erase(firstCol);
//make first name in set you come to first column and then add the remaining names to second column
}else {
//you want part of this row
if (validSecond.size() != 0) {
+
+ wroteSomething = true;
+
out << validSecond[0] << '\t';
//you know you have at least one valid second since first column is valid
in.close();
out.close();
+ if (wroteSomething == false) {
+ mothurOut("Your file does not contain any sequence from the .accnos file."); mothurOutEndLine();
+ remove(outputFileName.c_str());
+ }
+
}
catch(exception& e) {
errorOut(e, "GetSeqsCommand", "readName");
openInputFile(groupfile, in);
string name, group;
+ bool wroteSomething = false;
+
while(!in.eof()){
in >> name; //read from first column
//if this name is in the accnos file
if (names.count(name) == 1) {
+ wroteSomething = true;
+
out << name << '\t' << group << endl;
+
+ names.erase(name);
}
gobble(in);
}
in.close();
out.close();
+
+ if (wroteSomething == false) {
+ mothurOut("Your file does not contain any sequence from the .accnos file."); mothurOutEndLine();
+ remove(outputFileName.c_str());
+ }
}
catch(exception& e) {
openInputFile(alignfile, in);
string name, junk;
+ bool wroteSomething = false;
+
//read column headers
for (int i = 0; i < 16; i++) {
if (!in.eof()) { in >> junk; out << junk << '\t'; }
//if this name is in the accnos file
if (names.count(name) == 1) {
-
+ wroteSomething = true;
+
out << name << '\t';
//read rest
}
out << endl;
+ names.erase(name);
+
}else {//still read just don't do anything with it
//read rest
for (int i = 0; i < 15; i++) {
}
in.close();
out.close();
-
+
+ if (wroteSomething == false) {
+ mothurOut("Your file does not contain any sequence from the .accnos file."); mothurOutEndLine();
+ remove(outputFileName.c_str());
+ }
}
catch(exception& e) {