X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=aligncommand.cpp;h=b6a2c0bcd46b7bfeaf48ad548dea6dec5ca3a823;hb=5d6d303e481489e226fdf8d6c5385b99b50718bc;hp=63a117d5064cc8178051017173bacdfd80cb6b3a;hpb=f09bacac01a842a74c1c1b69070852cc969ff506;p=mothur.git diff --git a/aligncommand.cpp b/aligncommand.cpp index 63a117d..b6a2c0b 100644 --- a/aligncommand.cpp +++ b/aligncommand.cpp @@ -64,6 +64,7 @@ vector AlignCommand::getRequiredFiles(){ //********************************************************************************************************************** AlignCommand::AlignCommand(){ try { + abort = true; //initialize outputTypes vector tempOutNames; outputTypes["fasta"] = tempOutNames; @@ -153,15 +154,17 @@ AlignCommand::AlignCommand(string option) { int ableToOpen; ifstream in; - ableToOpen = m->openInputFile(candidateFileNames[i], in, "noerror"); - + in.close(); + //if you can't open it, try default location if (ableToOpen == 1) { if (m->getDefaultPath() != "") { //default path is set string tryPath = m->getDefaultPath() + m->getSimpleName(candidateFileNames[i]); m->mothurOut("Unable to open " + candidateFileNames[i] + ". Trying default " + tryPath); m->mothurOutEndLine(); - ableToOpen = m->openInputFile(tryPath, in, "noerror"); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); candidateFileNames[i] = tryPath; } } @@ -171,12 +174,14 @@ AlignCommand::AlignCommand(string option) { if (m->getOutputDir() != "") { //default path is set string tryPath = m->getOutputDir() + m->getSimpleName(candidateFileNames[i]); m->mothurOut("Unable to open " + candidateFileNames[i] + ". Trying output directory " + tryPath); m->mothurOutEndLine(); - ableToOpen = m->openInputFile(tryPath, in, "noerror"); + ifstream in2; + ableToOpen = m->openInputFile(tryPath, in2, "noerror"); + in2.close(); candidateFileNames[i] = tryPath; } } - in.close(); + if (ableToOpen == 1) { m->mothurOut("Unable to open " + candidateFileNames[i] + ". It will be disregarded."); m->mothurOutEndLine(); @@ -305,7 +310,7 @@ int AlignCommand::execute(){ int start = time(NULL); #ifdef USE_MPI - int pid, end, numSeqsPerProcessor; + int pid, numSeqsPerProcessor; int tag = 2001; vector MPIPos; MPIWroteAccnos = false; @@ -550,7 +555,8 @@ int AlignCommand::driver(linePair* filePos, string alignFName, string reportFNam if (m->control_pressed) { return 0; } Sequence* candidateSeq = new Sequence(inFASTA); m->gobble(inFASTA); - + report.setCandidate(candidateSeq); + int origNumBases = candidateSeq->getNumBases(); string originalUnaligned = candidateSeq->getUnaligned(); int numBasesNeeded = origNumBases * threshold; @@ -613,7 +619,6 @@ int AlignCommand::driver(linePair* filePos, string alignFName, string reportFNam accnosFile << candidateSeq->getName() << wasBetter << endl; } - report.setCandidate(candidateSeq); report.setTemplate(templateSeq); report.setSearchParameters(search, searchScore); report.setAlignmentParameters(align, alignment); @@ -701,7 +706,8 @@ int AlignCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& align istringstream iss (tempBuf,istringstream::in); Sequence* candidateSeq = new Sequence(iss); - + report.setCandidate(candidateSeq); + int origNumBases = candidateSeq->getNumBases(); string originalUnaligned = candidateSeq->getUnaligned(); int numBasesNeeded = origNumBases * threshold; @@ -750,6 +756,7 @@ int AlignCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& align delete nast; nast = nast2; needToDeleteCopy = true; + wasBetter = "\treverse complement produced a better alignment, so mothur used the reverse complement."; }else{ wasBetter = "\treverse complement did NOT produce a better alignment, please check sequence."; delete nast2; @@ -771,7 +778,6 @@ int AlignCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& align MPIWroteAccnos = true; } - report.setCandidate(candidateSeq); report.setTemplate(templateSeq); report.setSearchParameters(search, searchScore); report.setAlignmentParameters(align, alignment); @@ -844,7 +850,11 @@ int AlignCommand::createProcesses(string alignFileName, string reportFileName, s out.close(); exit(0); - }else { m->mothurOut("unable to spawn the necessary processes."); m->mothurOutEndLine(); exit(0); } + }else { + m->mothurOut("[ERROR]: unable to spawn the necessary processes."); m->mothurOutEndLine(); + for (int i = 0; i < processIDS.size(); i++) { kill (processIDS[i], SIGINT); } + exit(0); + } } //force parent to wait until all the processes are done