X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=preclustercommand.cpp;h=f2fbc80088b1adf2927ee78d5b1e02fbf9691cb1;hb=9aa36ad8297141ef9fcab04fea10e96d2fed26fe;hp=cac80b8d775d2e5bd4810198e69a2d5ad625c04d;hpb=0ca63a8165baa0afa459e644ebe140ba496d5ba0;p=mothur.git diff --git a/preclustercommand.cpp b/preclustercommand.cpp index cac80b8..f2fbc80 100644 --- a/preclustercommand.cpp +++ b/preclustercommand.cpp @@ -147,7 +147,7 @@ PreClusterCommand::PreClusterCommand(string option) { // ...at some point should added some additional type checking... namefile = validParameter.validFile(parameters, "name", true); if (namefile == "not found") { namefile = ""; } - else if (namefile == "not open") { abort = true; } + else if (namefile == "not open") { namefile = ""; abort = true; } else { m->setNameFile(namefile); } groupfile = validParameter.validFile(parameters, "group", true); @@ -162,7 +162,10 @@ PreClusterCommand::PreClusterCommand(string option) { m->setProcessors(temp); m->mothurConvert(temp, processors); - + if (namefile == "") { + vector files; files.push_back(fastafile); + parser.getNameFile(files); + } } } @@ -214,17 +217,19 @@ int PreClusterCommand::execute(){ m->mothurOutEndLine(); m->mothurOut("/******************************************/"); m->mothurOutEndLine(); m->mothurOut("Running command: unique.seqs(" + inputString + ")"); m->mothurOutEndLine(); - + m->mothurCalling = true; + Command* uniqueCommand = new DeconvoluteCommand(inputString); uniqueCommand->execute(); map > filenames = uniqueCommand->getOutputFiles(); delete uniqueCommand; - + m->mothurCalling = false; m->mothurOut("/******************************************/"); m->mothurOutEndLine(); m->renameFile(filenames["fasta"][0], newFastaFile); + m->renameFile(filenames["name"][0], newNamesFile); m->mothurOut("It took " + toString(time(NULL) - start) + " secs to run pre.cluster."); m->mothurOutEndLine(); @@ -299,7 +304,7 @@ int PreClusterCommand::createProcessesGroups(SequenceParser* parser, string newF lines.push_back(linePair(startIndex, endIndex)); } -#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) { @@ -372,9 +377,9 @@ int PreClusterCommand::createProcessesGroups(SequenceParser* parser, string newF //append output files for(int i=0;igetFullPathName(".\\" + newFName); - newNName = m->getFullPathName(".\\" + newNName); - cout << newFName << endl; + //newFName = m->getFullPathName(".\\" + newFName); + //newNName = m->getFullPathName(".\\" + newNName); + m->appendFiles((newFName + toString(processIDS[i]) + ".temp"), newFName); m->mothurRemove((newFName + toString(processIDS[i]) + ".temp")); @@ -511,7 +516,7 @@ int PreClusterCommand::readFASTA(){ m->openInputFile(fastafile, inFasta); //string firstCol, secondCol, nameString; - length = 0; + set lengths; while (!inFasta.eof()) { @@ -537,17 +542,21 @@ int PreClusterCommand::readFASTA(){ else{ seqPNode tempNode(itSize->second, seq, names[seq.getName()]); alignSeqs.push_back(tempNode); - if (seq.getAligned().length() > length) { length = seq.getAligned().length(); } + lengths.insert(seq.getAligned().length()); } }else { //no names file, you are identical to yourself seqPNode tempNode(1, seq, seq.getName()); alignSeqs.push_back(tempNode); - if (seq.getAligned().length() > length) { length = seq.getAligned().length(); } + lengths.insert(seq.getAligned().length()); } } } inFasta.close(); //inNames.close(); + + if (lengths.size() > 1) { m->control_pressed = true; m->mothurOut("[ERROR]: your sequences are not all the same length. pre.cluster requires sequences to be aligned."); m->mothurOutEndLine(); } + else if (lengths.size() == 1) { length = *(lengths.begin()); } + return alignSeqs.size(); } @@ -559,7 +568,7 @@ int PreClusterCommand::readFASTA(){ /**************************************************************************************************/ int PreClusterCommand::loadSeqs(map& thisName, vector& thisSeqs){ try { - length = 0; + set lengths; alignSeqs.clear(); map::iterator it; bool error = false; @@ -582,15 +591,18 @@ int PreClusterCommand::loadSeqs(map& thisName, vector& seqPNode tempNode(numReps, thisSeqs[i], it->second); alignSeqs.push_back(tempNode); - if (thisSeqs[i].getAligned().length() > length) { length = thisSeqs[i].getAligned().length(); } + lengths.insert(thisSeqs[i].getAligned().length()); } }else { //no names file, you are identical to yourself seqPNode tempNode(1, thisSeqs[i], thisSeqs[i].getName()); alignSeqs.push_back(tempNode); - if (thisSeqs[i].getAligned().length() > length) { length = thisSeqs[i].getAligned().length(); } + lengths.insert(thisSeqs[i].getAligned().length()); } } + if (lengths.size() > 1) { error = true; m->mothurOut("[ERROR]: your sequences are not all the same length. pre.cluster requires sequences to be aligned."); m->mothurOutEndLine(); } + else if (lengths.size() == 1) { length = *(lengths.begin()); } + //sanity check if (error) { m->control_pressed = true; }