X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=getlineagecommand.cpp;h=c2be580bb73313c91322e903c87027dc5da405d9;hb=2c97dd48b8e27ee0a6a86c7a082f4c504c3357c6;hp=fc173100942199c9f5f5ea1b400d0cb0ad978303;hpb=f06fdb807822f8e06db003ed809c87250905cfc8;p=mothur.git diff --git a/getlineagecommand.cpp b/getlineagecommand.cpp index fc17310..c2be580 100644 --- a/getlineagecommand.cpp +++ b/getlineagecommand.cpp @@ -168,16 +168,19 @@ GetLineageCommand::GetLineageCommand(string option) { //check for required parameters fastafile = validParameter.validFile(parameters, "fasta", true); - if (fastafile == "not open") { abort = true; } - else if (fastafile == "not found") { fastafile = ""; } + if (fastafile == "not open") { fastafile = ""; abort = true; } + else if (fastafile == "not found") { fastafile = ""; } + else { m->setFastaFile(fastafile); } namefile = validParameter.validFile(parameters, "name", true); - if (namefile == "not open") { abort = true; } + if (namefile == "not open") { namefile = ""; abort = true; } else if (namefile == "not found") { namefile = ""; } + else { m->setNameFile(namefile); } groupfile = validParameter.validFile(parameters, "group", true); if (groupfile == "not open") { abort = true; } else if (groupfile == "not found") { groupfile = ""; } + else { m->setGroupFile(groupfile); } alignfile = validParameter.validFile(parameters, "alignreport", true); if (alignfile == "not open") { abort = true; } @@ -186,14 +189,15 @@ GetLineageCommand::GetLineageCommand(string option) { listfile = validParameter.validFile(parameters, "list", true); if (listfile == "not open") { abort = true; } else if (listfile == "not found") { listfile = ""; } + else { m->setListFile(listfile); } taxfile = validParameter.validFile(parameters, "taxonomy", true); - if (taxfile == "not open") { abort = true; } + if (taxfile == "not open") { taxfile = ""; abort = true; } else if (taxfile == "not found") { taxfile = m->getTaxonomyFile(); if (taxfile != "") { m->mothurOut("Using " + taxfile + " as input file for the taxonomy parameter."); m->mothurOutEndLine(); } else { m->mothurOut("You have no current taxonomy file and the taxonomy parameter is required."); m->mothurOutEndLine(); abort = true; } - } + }else { m->setTaxonomyFile(taxfile); } string usedDups = "true"; string temp = validParameter.validFile(parameters, "dups", false); @@ -213,6 +217,11 @@ GetLineageCommand::GetLineageCommand(string option) { m->splitAtChar(taxons, listOfTaxons, '-'); if ((fastafile == "") && (namefile == "") && (groupfile == "") && (alignfile == "") && (listfile == "") && (taxfile == "")) { m->mothurOut("You must provide one of the following: fasta, name, group, alignreport, taxonomy or listfile."); m->mothurOutEndLine(); abort = true; } + + if ((namefile == "") && ((fastafile != "") || (taxfile != ""))){ + vector files; files.push_back(fastafile); files.push_back(taxfile); + parser.getNameFile(files); + } } } @@ -239,7 +248,7 @@ int GetLineageCommand::execute(){ if (listfile != "") { readList(); } - if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } if (outputNames.size() != 0) { m->mothurOutEndLine(); @@ -302,7 +311,7 @@ int GetLineageCommand::readFasta(){ while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } Sequence currSeq(in); name = currSeq.getName(); @@ -347,7 +356,7 @@ int GetLineageCommand::readList(){ while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } //read in list vector ListVector list(in); @@ -422,7 +431,7 @@ int GetLineageCommand::readName(){ while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> firstCol; in >> secondCol; @@ -507,7 +516,7 @@ int GetLineageCommand::readGroup(){ while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> name; //read from first column @@ -560,14 +569,15 @@ int GetLineageCommand::readTax(){ if (hasConPos != string::npos) { taxonsHasConfidence[i] = true; searchTaxons[i] = getTaxons(listOfTaxons[i]); - noConfidenceTaxons[i] = removeConfidences(listOfTaxons[i]); + noConfidenceTaxons[i] = listOfTaxons[i]; + m->removeConfidences(noConfidenceTaxons[i]); } } while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + 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 @@ -580,7 +590,8 @@ int GetLineageCommand::readTax(){ if (!taxonsHasConfidence[j]) { int hasConfidences = tax.find_first_of('('); if (hasConfidences != string::npos) { - newtax = removeConfidences(tax); + newtax = tax; + m->removeConfidences(newtax); } int pos = newtax.find(noConfidenceTaxons[j]); @@ -609,7 +620,8 @@ int GetLineageCommand::readTax(){ string noNewTax = tax; int hasConfidences = tax.find_first_of('('); if (hasConfidences != string::npos) { - noNewTax = removeConfidences(tax); + noNewTax = tax; + m->removeConfidences(noNewTax); } int pos = noNewTax.find(noConfidenceTaxons[j]); @@ -721,29 +733,6 @@ vector< map > GetLineageCommand::getTaxons(string tax) { exit(1); } } -/**************************************************************************************************/ -string GetLineageCommand::removeConfidences(string tax) { - try { - - string taxon = ""; - int taxLength = tax.length(); - for(int i=0;ierrorOut(e, "GetLineageCommand", "removeConfidences"); - exit(1); - } -} //********************************************************************************************************************** //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 int GetLineageCommand::readAlign(){ @@ -770,7 +759,7 @@ int GetLineageCommand::readAlign(){ while(!in.eof()){ - if (m->control_pressed) { in.close(); out.close(); remove(outputFileName.c_str()); return 0; } + if (m->control_pressed) { in.close(); out.close(); m->mothurRemove(outputFileName); return 0; } in >> name; //read from first column