X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=seqerrorcommand.cpp;h=0dc15f59ee98d0ee2d93659c4c3ad1f033f8a193;hb=d205e70ae86dbee2efc2df02f2717975854de6ba;hp=fc027b9261822880ac0afa1cc99929791a309df4;hpb=65b6a38d00b3a72021611211e7c25392022c69ed;p=mothur.git diff --git a/seqerrorcommand.cpp b/seqerrorcommand.cpp index fc027b9..0dc15f5 100644 --- a/seqerrorcommand.cpp +++ b/seqerrorcommand.cpp @@ -176,9 +176,13 @@ SeqErrorCommand::SeqErrorCommand(string option) { if (queryFileName != "") { m->mothurOut("Using " + queryFileName + " as input file for the fasta parameter."); m->mothurOutEndLine(); } else { m->mothurOut("You have no current fasta file and the fasta parameter is required."); m->mothurOutEndLine(); abort = true; } } - else if (queryFileName == "not open") { abort = true; } + else if (queryFileName == "not open") { queryFileName = ""; abort = true; } else { m->setFastaFile(queryFileName); } - + + referenceFileName = validParameter.validFile(parameters, "reference", true); + if (referenceFileName == "not found") { m->mothurOut("reference is a required parameter for the seq.error command."); m->mothurOutEndLine(); abort = true; } + else if (referenceFileName == "not open") { abort = true; } + //check for optional parameters namesFileName = validParameter.validFile(parameters, "name", true); if(namesFileName == "not found"){ namesFileName = ""; } @@ -209,7 +213,7 @@ SeqErrorCommand::SeqErrorCommand(string option) { //check for optional parameter and set defaults // ...at some point should added some additional type checking... temp = validParameter.validFile(parameters, "threshold", false); if (temp == "not found") { temp = "1.00"; } - convert(temp, threshold); + m->mothurConvert(temp, threshold); temp = validParameter.validFile(parameters, "save", false); if (temp == "not found"){ temp = "f"; } save = m->isTrue(temp); @@ -238,10 +242,15 @@ SeqErrorCommand::SeqErrorCommand(string option) { temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found"){ temp = m->getProcessors(); } m->setProcessors(temp); - convert(temp, processors); + m->mothurConvert(temp, processors); substitutionMatrix.resize(6); for(int i=0;i<6;i++){ substitutionMatrix[i].resize(6,0); } + + if ((namesFileName == "") && (queryFileName != "")){ + vector files; files.push_back(queryFileName); + parser.getNameFile(files); + } } } catch(exception& e) { @@ -273,9 +282,9 @@ int SeqErrorCommand::execute(){ if(namesFileName != ""){ weights = getWeights(); } - vector fastaFilePos; - vector qFilePos; - vector reportFilePos; + vector fastaFilePos; + vector qFilePos; + vector reportFilePos; setLines(queryFileName, qualFileName, reportFileName, fastaFilePos, qFilePos, reportFilePos); @@ -289,7 +298,7 @@ int SeqErrorCommand::execute(){ if(qualFileName == "") { qLines = lines; rLines = lines; } //fills with duds int numSeqs = 0; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if(processors == 1){ numSeqs = driver(queryFileName, qualFileName, reportFileName, errorSummaryFileName, errorSeqFileName, errorChimeraFileName, lines[0], qLines[0], rLines[0]); }else{ @@ -306,7 +315,7 @@ int SeqErrorCommand::execute(){ printErrorFRFile(errorForward, errorReverse); - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } string errorCountFileName = queryFileName.substr(0,queryFileName.find_last_of('.')) + ".error.count"; ofstream errorCountFile; @@ -321,7 +330,7 @@ int SeqErrorCommand::execute(){ } errorCountFile.close(); - if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { remove(outputNames[i].c_str()); } return 0; } + if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } printSubMatrix(); @@ -357,7 +366,7 @@ int SeqErrorCommand::createProcesses(string filename, string qFileName, string r processIDS.clear(); map >::iterator it; int num = 0; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want while (process != processors) { @@ -478,11 +487,11 @@ int SeqErrorCommand::createProcesses(string filename, string qFileName, string r m->mothurOut("Appending files from process " + toString(processIDS[i])); m->mothurOutEndLine(); m->appendFiles((summaryFileName + toString(processIDS[i]) + ".temp"), summaryFileName); - remove((summaryFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((summaryFileName + toString(processIDS[i]) + ".temp")); m->appendFiles((errorOutputFileName + toString(processIDS[i]) + ".temp"), errorOutputFileName); - remove((errorOutputFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((errorOutputFileName + toString(processIDS[i]) + ".temp")); m->appendFiles((chimeraOutputFileName + toString(processIDS[i]) + ".temp"), chimeraOutputFileName); - remove((chimeraOutputFileName + toString(processIDS[i]) + ".temp").c_str()); + m->mothurRemove((chimeraOutputFileName + toString(processIDS[i]) + ".temp")); ifstream in; string tempFile = filename + toString(processIDS[i]) + ".info.temp"; @@ -577,7 +586,7 @@ int SeqErrorCommand::createProcesses(string filename, string qFileName, string r } m->gobble(in); - in.close(); remove(tempFile.c_str()); + in.close(); m->mothurRemove(tempFile); } #endif @@ -673,7 +682,8 @@ int SeqErrorCommand::driver(string filename, string qFileName, string rFileName, if(numParentSeqs > 1 && ignoreChimeras == 1) { ignoreSeq = 1; } else { ignoreSeq = 0; } - Compare minCompare = getErrors(query, referenceSeqs[closestRefIndex]); + Compare minCompare; + getErrors(query, referenceSeqs[closestRefIndex], minCompare); if(namesFileName != ""){ it = weights.find(query.getName()); @@ -730,8 +740,8 @@ int SeqErrorCommand::driver(string filename, string qFileName, string rFileName, index++; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) - unsigned long int pos = queryFile.tellg(); + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) + unsigned long long pos = queryFile.tellg(); if ((pos == -1) || (pos >= line.end)) { break; } #else if (queryFile.eof()) { break; } @@ -830,7 +840,7 @@ void SeqErrorCommand::getReferences(){ //*************************************************************************************************************** -Compare SeqErrorCommand::getErrors(Sequence query, Sequence reference){ +int SeqErrorCommand::getErrors(Sequence query, Sequence reference, Compare& errors){ try { if(query.getAlignLength() != reference.getAlignLength()){ m->mothurOut("Warning: " + toString(query.getName()) + " and " + toString(reference.getName()) + " are different lengths\n"); @@ -841,7 +851,7 @@ Compare SeqErrorCommand::getErrors(Sequence query, Sequence reference){ string r = reference.getAligned(); int started = 0; - Compare errors; + //Compare errors; for(int i=0;ierrorOut(e, "SeqErrorCommand", "getErrors"); @@ -1204,9 +1215,9 @@ void SeqErrorCommand::printQualityFR(vector > qualForwardMap, vector } /**************************************************************************************************/ -int SeqErrorCommand::setLines(string filename, string qfilename, string rfilename, vector& fastaFilePos, vector& qfileFilePos, vector& rfileFilePos) { +int SeqErrorCommand::setLines(string filename, string qfilename, string rfilename, vector& fastaFilePos, vector& qfileFilePos, vector& rfileFilePos) { try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //set file positions for fasta file fastaFilePos = m->divideFile(filename, processors); @@ -1246,7 +1257,7 @@ int SeqErrorCommand::setLines(string filename, string qfilename, string rfilenam map::iterator it = firstSeqNames.find(sname); if(it != firstSeqNames.end()) { //this is the start of a new chunk - unsigned long int pos = inQual.tellg(); + unsigned long long pos = inQual.tellg(); qfileFilePos.push_back(pos - input.length() - 1); firstSeqNames.erase(it); } @@ -1267,7 +1278,7 @@ int SeqErrorCommand::setLines(string filename, string qfilename, string rfilenam //get last file position of qfile FILE * pFile; - unsigned long int size; + unsigned long long size; //get num bytes in file pFile = fopen (qfilename.c_str(),"rb"); @@ -1305,7 +1316,7 @@ int SeqErrorCommand::setLines(string filename, string qfilename, string rfilenam map::iterator it = firstSeqNamesReport.find(sname); if(it != firstSeqNamesReport.end()) { //this is the start of a new chunk - unsigned long int pos = inR.tellg(); + unsigned long long pos = inR.tellg(); rfileFilePos.push_back(pos - input.length() - 1); firstSeqNamesReport.erase(it); } @@ -1326,7 +1337,7 @@ int SeqErrorCommand::setLines(string filename, string qfilename, string rfilenam //get last file position of qfile FILE * rFile; - unsigned long int sizeR; + unsigned long long sizeR; //get num bytes in file rFile = fopen (rfilename.c_str(),"rb"); @@ -1346,7 +1357,7 @@ int SeqErrorCommand::setLines(string filename, string qfilename, string rfilenam fastaFilePos.push_back(0); qfileFilePos.push_back(0); //get last file position of fastafile FILE * pFile; - unsigned long int size; + unsigned long long size; //get num bytes in file pFile = fopen (filename.c_str(),"rb");