X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=chimeraslayercommand.cpp;h=4b309c0124a2038cb49db3980345e10e535ce84d;hb=813f0516e9c7533859f57ebe6d7b8854896bf009;hp=777584bf0c75cdc8f26d5125defa5e20f296ce6e;hpb=2bbb7273d4bf5209f098c764551c6e072d60df36;p=mothur.git diff --git a/chimeraslayercommand.cpp b/chimeraslayercommand.cpp index 777584b..4b309c0 100644 --- a/chimeraslayercommand.cpp +++ b/chimeraslayercommand.cpp @@ -217,13 +217,13 @@ int ChimeraSlayerCommand::execute(){ int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; int inMode=MPI_MODE_RDONLY; - char* outFilename = new char[outputFileName.length()]; + char* outFilename = new char[outputFileName.length()]; memcpy(outFilename, outputFileName.c_str(), outputFileName.length()); - char* outAccnosFilename = new char[accnosFileName.length()]; + char* outAccnosFilename = new char[accnosFileName.length()]; memcpy(outAccnosFilename, accnosFileName.c_str(), accnosFileName.length()); - char* inFileName = new char[fastafile.length()]; + char* inFileName = new char[fastafile.length()]; memcpy(inFileName, fastafile.c_str(), fastafile.length()); MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI); //comm, filename, mode, info, filepointer @@ -235,7 +235,6 @@ int ChimeraSlayerCommand::execute(){ delete outAccnosFilename; if (m->control_pressed) { MPI_File_close(&inMPI); MPI_File_close(&outMPI); MPI_File_close(&outMPIAccnos); delete chimera; return 0; } - if (pid == 0) { //you are the root process m->mothurOutEndLine(); @@ -246,7 +245,7 @@ int ChimeraSlayerCommand::execute(){ //print header int length = outTemp.length(); - char* buf2 = new char[length]; + char* buf2 = new char[length]; memcpy(buf2, outTemp.c_str(), length); MPI_File_write_shared(outMPI, buf2, length, MPI_CHAR, &status); @@ -427,7 +426,7 @@ int ChimeraSlayerCommand::execute(){ if (isBlank(accnosFileName)) { remove(accnosFileName.c_str()); hasAccnos = false; } #endif - appendFiles(tempHeader, outputFileName); + appendFiles(outputFileName, tempHeader); remove(outputFileName.c_str()); rename(tempHeader.c_str(), outputFileName.c_str()); @@ -510,8 +509,7 @@ int ChimeraSlayerCommand::driver(linePair* line, string outputFName, string file //********************************************************************************************************************** #ifdef USE_MPI int ChimeraSlayerCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File& outMPI, MPI_File& outAccMPI, vector& MPIPos){ - try { - + try { MPI_Status status; int pid; MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are @@ -522,30 +520,33 @@ int ChimeraSlayerCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_Fil //read next sequence int length = MPIPos[start+i+1] - MPIPos[start+i]; - + char* buf4 = new char[length]; MPI_File_read_at(inMPI, MPIPos[start+i], buf4, length, MPI_CHAR, &status); - + string tempBuf = buf4; if (tempBuf.length() > length) { tempBuf = tempBuf.substr(0, length); } istringstream iss (tempBuf,istringstream::in); + delete buf4; Sequence* candidateSeq = new Sequence(iss); gobble(iss); - + if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file if (candidateSeq->getAligned().length() != templateSeqsLength) { m->mothurOut(candidateSeq->getName() + " is not the same length as the template sequences. Skipping."); m->mothurOutEndLine(); }else{ + //find chimeras chimera->getChimeras(candidateSeq); - + if (m->control_pressed) { delete candidateSeq; return 1; } - + //cout << "about to print" << endl; //print results bool isChimeric = chimera->print(outMPI, outAccMPI); if (isChimeric) { MPIWroteAccnos = true; } + } } delete candidateSeq;