X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=trimflowscommand.cpp;h=d17e000e9ce3a2d36f6a432f8647e99b7f58549f;hb=19fcbbdba99658f5eca244803280f9ee7f9f6607;hp=bb0fa0475d2bfbb344d025ae493a95c557712592;hpb=86c838c428a9e7d26f902f5492738241fa72c4e7;p=mothur.git diff --git a/trimflowscommand.cpp b/trimflowscommand.cpp index bb0fa04..d17e000 100644 --- a/trimflowscommand.cpp +++ b/trimflowscommand.cpp @@ -18,8 +18,6 @@ vector TrimFlowsCommand::setParameters(){ CommandParameter pmaxhomop("maxhomop", "Number", "", "9", "", "", "",false,false); parameters.push_back(pmaxhomop); CommandParameter pmaxflows("maxflows", "Number", "", "720", "", "", "",false,false); parameters.push_back(pmaxflows); CommandParameter pminflows("minflows", "Number", "", "360", "", "", "",false,false); parameters.push_back(pminflows); - CommandParameter pminlength("minlength", "Number", "", "0", "", "", "",false,false); parameters.push_back(pminlength); - CommandParameter pmaxlength("maxlength", "Number", "", "0", "", "", "",false,false); parameters.push_back(pmaxlength); CommandParameter ppdiffs("pdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ppdiffs); CommandParameter pbdiffs("bdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(pbdiffs); CommandParameter ptdiffs("tdiffs", "Number", "", "0", "", "", "",false,false); parameters.push_back(ptdiffs); @@ -81,6 +79,7 @@ TrimFlowsCommand::TrimFlowsCommand(string option) { //allow user to run help if(option == "help") { help(); abort = true; calledHelp = true; } + else if(option == "citation") { citation(); abort = true; calledHelp = true;} else { @@ -123,14 +122,6 @@ TrimFlowsCommand::TrimFlowsCommand(string option) { if (path == "") { parameters["oligos"] = inputDir + it->second; } } - -// it = parameters.find("group"); -// //user has given a template file -// if(it != parameters.end()){ -// path = m->hasPath(it->second); -// //if the user has not given a path then, add inputdir. else leave path alone. -// if (path == "") { parameters["group"] = inputDir + it->second; } -// } } @@ -156,17 +147,17 @@ TrimFlowsCommand::TrimFlowsCommand(string option) { // ...at some point should added some additional type checking... string temp; - temp = validParameter.validFile(parameters, "minflows", false); if (temp == "not found") { temp = "360"; } + temp = validParameter.validFile(parameters, "minflows", false); if (temp == "not found") { temp = "450"; } convert(temp, minFlows); - temp = validParameter.validFile(parameters, "maxflows", false); if (temp == "not found") { temp = "720"; } + temp = validParameter.validFile(parameters, "maxflows", false); if (temp == "not found") { temp = "450"; } convert(temp, maxFlows); temp = validParameter.validFile(parameters, "oligos", true); if (temp == "not found") { oligoFileName = ""; } else if(temp == "not open") { abort = true; } - else { oligoFileName = temp; } + else { oligoFileName = temp; m->setOligosFile(oligoFileName); } temp = validParameter.validFile(parameters, "fasta", false); if (temp == "not found"){ fasta = 0; } else if(m->isTrue(temp)) { fasta = 1; } @@ -179,13 +170,7 @@ TrimFlowsCommand::TrimFlowsCommand(string option) { temp = validParameter.validFile(parameters, "noise", false); if (temp == "not found"){ temp = "0.70"; } convert(temp, noise); - - temp = validParameter.validFile(parameters, "minlength", false); if (temp == "not found"){ temp = "0"; } - convert(temp, minLength); - - temp = validParameter.validFile(parameters, "maxlength", false); if (temp == "not found"){ temp = "0"; } - convert(temp, maxLength); - + temp = validParameter.validFile(parameters, "bdiffs", false); if (temp == "not found"){ temp = "0"; } convert(temp, bdiffs); @@ -197,9 +182,6 @@ TrimFlowsCommand::TrimFlowsCommand(string option) { convert(temp, tdiffs); if(tdiffs == 0){ tdiffs = bdiffs + pdiffs; } - temp = validParameter.validFile(parameters, "allfiles", false); if (temp == "not found"){ temp = "T"; } - allFiles = m->isTrue(temp); - temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found"){ temp = m->getProcessors(); } m->setProcessors(temp); convert(temp, processors); @@ -210,7 +192,8 @@ TrimFlowsCommand::TrimFlowsCommand(string option) { m->mothurOut("The value of the order option must be four bases long\n"); } - if(oligoFileName == ""){ allFiles = 0; } + if(oligoFileName == "") { allFiles = 0; } + else { allFiles = 1; } numFPrimers = 0; numRPrimers = 0; @@ -282,15 +265,17 @@ int TrimFlowsCommand::execute(){ if (pFile==NULL) perror ("Error opening file"); else{ fseek (pFile, 0, SEEK_END); - size=ftell (pFile); + size=ftell(pFile); fclose (pFile); } if(size < 10){ - remove(barcodePrimerComboFileNames[i][j].c_str()); + m->mothurRemove(barcodePrimerComboFileNames[i][j]); } else{ output << barcodePrimerComboFileNames[i][j] << endl; + outputNames.push_back(barcodePrimerComboFileNames[i][j]); + outputTypes["flow"].push_back(barcodePrimerComboFileNames[i][j]); } } } @@ -305,14 +290,14 @@ int TrimFlowsCommand::execute(){ output.close(); } outputTypes["flow.files"].push_back(flowFilesFileName); - outputNames.push_back(flowFileName); + outputNames.push_back(flowFilesFileName); - //set fasta file as new current fastafile - string current = ""; - itTypes = outputTypes.find("fasta"); - if (itTypes != outputTypes.end()) { - if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } - } +// set fasta file as new current fastafile +// string current = ""; +// itTypes = outputTypes.find("fasta"); +// if (itTypes != outputTypes.end()) { +// if ((itTypes->second).size() != 0) { current = (itTypes->second)[0]; m->setFastaFile(current); } +// } m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); @@ -385,14 +370,6 @@ int TrimFlowsCommand::driverCreateTrim(string flowFileName, string trimFlowFileN trashCode += 'l'; } - if(minLength > 0 || maxLength > 0){ //screen to see if sequence is above and below a specific number of bases - int seqLength = currSeq.getNumBases(); - if(seqLength < minLength || seqLength > maxLength){ - success = 0; - trashCode += 'l'; - } - } - int primerIndex = 0; int barcodeIndex = 0; @@ -580,8 +557,6 @@ void TrimFlowsCommand::getOligos(vector >& outFlowFileNames){ fileName = outputDir + m->getRootName(m->getSimpleName(flowFileName)) + comboGroupName + ".flow"; } - outputNames.push_back(fileName); - outputTypes["flow"].push_back(fileName); outFlowFileNames[itBar->second][itPrimer->second] = fileName; ofstream temp; @@ -637,7 +612,7 @@ int TrimFlowsCommand::stripBarcode(Sequence& seq, int& group){ if (barcodes.size() > 0) { map::iterator it=barcodes.begin(); - for(it;it!=barcodes.end();it++){ + for(map::iterator it=barcodes.begin();it!=barcodes.end();it++){ if(it->first.length() > maxLength){ maxLength = it->first.length(); } @@ -1083,23 +1058,23 @@ int TrimFlowsCommand::createProcessesCreateTrim(string flowFileName, string trim m->mothurOut("Appending files from process " + toString(processIDS[i])); m->mothurOutEndLine(); m->appendFiles((trimFlowFileName + toString(processIDS[i]) + ".temp"), trimFlowFileName); - remove((trimFlowFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((trimFlowFileName + toString(processIDS[i]) + ".temp")); // m->mothurOut("\tDone with trim.flow file"); m->mothurOutEndLine(); m->appendFiles((scrapFlowFileName + toString(processIDS[i]) + ".temp"), scrapFlowFileName); - remove((scrapFlowFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((scrapFlowFileName + toString(processIDS[i]) + ".temp")); // m->mothurOut("\tDone with scrap.flow file"); m->mothurOutEndLine(); if(fasta){ m->appendFiles((fastaFileName + toString(processIDS[i]) + ".temp"), fastaFileName); - remove((fastaFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((fastaFileName + toString(processIDS[i]) + ".temp")); // m->mothurOut("\tDone with flow.fasta file"); m->mothurOutEndLine(); } if(allFiles){ for (int j = 0; j < barcodePrimerComboFileNames.size(); j++) { for (int k = 0; k < barcodePrimerComboFileNames[0].size(); k++) { m->appendFiles((barcodePrimerComboFileNames[j][k] + toString(processIDS[i]) + ".temp"), barcodePrimerComboFileNames[j][k]); - remove((barcodePrimerComboFileNames[j][k] + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((barcodePrimerComboFileNames[j][k] + toString(processIDS[i]) + ".temp")); } } }