]> git.donarmstrong.com Git - mothur.git/blobdiff - chimeraccodecommand.cpp
fixed problem with class.fy.seqs where group totals did not add up. added constructo...
[mothur.git] / chimeraccodecommand.cpp
index 748163e04d447258b3a1e0ecfe62ea70ef382801..cc046ea3dcd44c5443434d84493025791ab2910e 100644 (file)
@@ -190,20 +190,33 @@ int ChimeraCcodeCommand::execute(){
                        
                        int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
                        int inMode=MPI_MODE_RDONLY; 
-                                                       
-                       char outFilename[outputFileName.length()];
+
+                       //char* outFilename = new char[outputFileName.length()];
+                       //memcpy(outFilename, outputFileName.c_str(), outputFileName.length());
+                       
+                       char outFilename[1024];
                        strcpy(outFilename, outputFileName.c_str());
                        
-                       char outAccnosFilename[accnosFileName.length()];
+                       //char* outAccnosFilename = new char[accnosFileName.length()];
+                       //memcpy(outAccnosFilename, accnosFileName.c_str(), accnosFileName.length());
+                       
+                       char outAccnosFilename[1024];
                        strcpy(outAccnosFilename, accnosFileName.c_str());
+
+                       //char* inFileName = new char[fastafile.length()];
+                       //memcpy(inFileName, fastafile.c_str(), fastafile.length());
                        
-                       char inFileName[fastafile.length()];
+                       char inFileName[1024];
                        strcpy(inFileName, fastafile.c_str());
 
                        MPI_File_open(MPI_COMM_WORLD, inFileName, inMode, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
                        MPI_File_open(MPI_COMM_WORLD, outFilename, outMode, MPI_INFO_NULL, &outMPI);
                        MPI_File_open(MPI_COMM_WORLD, outAccnosFilename, outMode, MPI_INFO_NULL, &outMPIAccnos);
-               
+                       
+                       //delete inFileName;
+                       //delete outFilename;
+                       //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 
@@ -211,10 +224,12 @@ int ChimeraCcodeCommand::execute(){
                                
                                //print header
                                int length = outTemp.length();
-                               char buf2[length];
-                               strcpy(buf2, outTemp.c_str()); 
+                               char* buf2 = new char[length];
+                               memcpy(buf2, outTemp.c_str(), length);
+
                                MPI_File_write_shared(outMPI, buf2, length, MPI_CHAR, &status);
-                               
+                               delete buf2;
+
                                MPIPos = setFilePosFasta(fastafile, numSeqs); //fills MPIPos, returns numSeqs
                                
                                //send file positions to all processes
@@ -223,8 +238,9 @@ int ChimeraCcodeCommand::execute(){
                                
                                //figure out how many sequences you have to align
                                numSeqsPerProcessor = numSeqs / processors;
-                               if(pid == (processors - 1)){    numSeqsPerProcessor = numSeqs - pid * numSeqsPerProcessor;      }
                                int startIndex =  pid * numSeqsPerProcessor;
+                               if(pid == (processors - 1)){    numSeqsPerProcessor = numSeqs - pid * numSeqsPerProcessor;      }
+                               
                        
                                //align your part
                                driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, MPIPos);
@@ -243,8 +259,9 @@ int ChimeraCcodeCommand::execute(){
                                
                                //figure out how many sequences you have to align
                                numSeqsPerProcessor = numSeqs / processors;
-                               if(pid == (processors - 1)){    numSeqsPerProcessor = numSeqs - pid * numSeqsPerProcessor;      }
                                int startIndex =  pid * numSeqsPerProcessor;
+                               if(pid == (processors - 1)){    numSeqsPerProcessor = numSeqs - pid * numSeqsPerProcessor;      }
+                               
                                
                                //align your part
                                driverMPI(startIndex, numSeqsPerProcessor, inMPI, outMPI, outMPIAccnos, MPIPos);
@@ -371,7 +388,7 @@ int ChimeraCcodeCommand::execute(){
 
                #else
                        ifstream inFASTA;
-                       openInputFile(candidateFileNames[s], inFASTA);
+                       openInputFile(fastafile, inFASTA);
                        numSeqs=count(istreambuf_iterator<char>(inFASTA),istreambuf_iterator<char>(), '>');
                        inFASTA.close();
                        lines.push_back(new linePair(0, numSeqs));
@@ -493,12 +510,14 @@ int ChimeraCcodeCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File
                        //read next sequence
                        int length = MPIPos[start+i+1] - MPIPos[start+i];
        
-                       char buf4[length];
+                       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);