//get names you want to keep
readAccnos();
+ if (m->control_pressed) { return 0; }
+
//read through the correct file and output lines you want to keep
if (fastafile != "") { readFasta(); }
else if (namefile != "") { readName(); }
else if (alignfile != "") { readAlign(); }
else if (listfile != "") { readList(); }
+ if (m->control_pressed) { return 0; }
+
if (outputNames.size() != 0) {
m->mothurOutEndLine();
m->mothurOut("Output File Names: "); m->mothurOutEndLine();
}
//**********************************************************************************************************************
-void GetSeqsCommand::readFasta(){
+int GetSeqsCommand::readFasta(){
try {
if (outputDir == "") { outputDir += hasPath(fastafile); }
string outputFileName = outputDir + getRootName(getSimpleName(fastafile)) + "pick" + getExtension(fastafile);
bool wroteSomething = false;
while(!in.eof()){
+
+ if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; }
+
Sequence currSeq(in);
name = currSeq.getName();
m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();
remove(outputFileName.c_str());
}else { outputNames.push_back(outputFileName); }
+
+ return 0;
}
catch(exception& e) {
}
}
//**********************************************************************************************************************
-void GetSeqsCommand::readList(){
+int GetSeqsCommand::readList(){
try {
if (outputDir == "") { outputDir += hasPath(listfile); }
string outputFileName = outputDir + getRootName(getSimpleName(listfile)) + "pick" + getExtension(listfile);
bool wroteSomething = false;
while(!in.eof()){
+
+ if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; }
+
//read in list vector
ListVector list(in);
}
//get last name
- if (names.count(binnames) == 1) { newNames += binnames; }
+ if (names.count(binnames) == 1) { newNames += binnames + ","; }
//if there are names in this bin add to new list
- if (newNames != "") { newList.push_back(newNames); }
+ if (newNames != "") {
+ newNames = newNames.substr(0, newNames.length()-1); //rip off extra comma
+ newList.push_back(newNames);
+ }
}
//print new listvector
m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();
remove(outputFileName.c_str());
}else { outputNames.push_back(outputFileName); }
+
+ return 0;
}
catch(exception& e) {
}
}
//**********************************************************************************************************************
-void GetSeqsCommand::readName(){
+int GetSeqsCommand::readName(){
try {
if (outputDir == "") { outputDir += hasPath(namefile); }
string outputFileName = outputDir + getRootName(getSimpleName(namefile)) + "pick" + getExtension(namefile);
while(!in.eof()){
+
+ if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; }
in >> firstCol;
in >> secondCol;
remove(outputFileName.c_str());
}else { outputNames.push_back(outputFileName); }
+ return 0;
+
}
catch(exception& e) {
m->errorOut(e, "GetSeqsCommand", "readName");
}
//**********************************************************************************************************************
-void GetSeqsCommand::readGroup(){
+int GetSeqsCommand::readGroup(){
try {
if (outputDir == "") { outputDir += hasPath(groupfile); }
string outputFileName = outputDir + getRootName(getSimpleName(groupfile)) + "pick" + getExtension(groupfile);
while(!in.eof()){
+ if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; }
+
+
in >> name; //read from first column
in >> group; //read from second column
m->mothurOut("Your file does not contain any sequence from the .accnos file."); m->mothurOutEndLine();
remove(outputFileName.c_str());
}else { outputNames.push_back(outputFileName); }
+
+ return 0;
}
catch(exception& e) {
//**********************************************************************************************************************
//alignreport file has a column header line then all other lines contain 16 columns. we just want the first column since that contains the name
-void GetSeqsCommand::readAlign(){
+int GetSeqsCommand::readAlign(){
try {
if (outputDir == "") { outputDir += hasPath(alignfile); }
string outputFileName = outputDir + getRootName(getSimpleName(alignfile)) + "pick.align.report";
out << endl;
while(!in.eof()){
+
+ if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; }
+
in >> name; //read from first column
remove(outputFileName.c_str());
}else { outputNames.push_back(outputFileName); }
+ return 0;
+
}
catch(exception& e) {
m->errorOut(e, "GetSeqsCommand", "readAlign");
}
//**********************************************************************************************************************
-void GetSeqsCommand::readAccnos(){
+int GetSeqsCommand::readAccnos(){
try {
ifstream in;
gobble(in);
}
- in.close();
+ in.close();
+
+ return 0;
}
catch(exception& e) {