]> git.donarmstrong.com Git - mothur.git/blobdiff - chimerapintailcommand.cpp
fixed bug in cluster.split with classify method
[mothur.git] / chimerapintailcommand.cpp
index 40a161036de19d7cbff03bbeb5a631a90d1caa02..6cef8bbec330c3d345d332f772970ff33a988f79 100644 (file)
@@ -147,7 +147,7 @@ void ChimeraPintailCommand::help(){
                #ifdef USE_MPI
                m->mothurOut("When using MPI, the processors parameter is set to the number of MPI processes running. \n");
                #endif
-               m->mothurOut("The window parameter allows you to specify the window size for searching for chimeras, default=1/4 sequence length. \n");
+               m->mothurOut("The window parameter allows you to specify the window size for searching for chimeras, default=300. \n");
                m->mothurOut("The increment parameter allows you to specify how far you move each window while finding chimeric sequences, default=25.\n");
                m->mothurOut("The conservation parameter allows you to enter a frequency file containing the highest bases frequency at each place in the alignment.\n");
                m->mothurOut("The quantile parameter allows you to enter a file containing quantiles for a template files sequences, if you use the filter the quantile file generated becomes unique to the fasta file you used.\n");
@@ -175,12 +175,11 @@ int ChimeraPintailCommand::execute(){
                
                int start = time(NULL); 
                
-               chimera = new Pintail(fastafile, templatefile, filter, processors, maskfile, consfile, quanfile, window, increment, outputDir);
-               
                //set user options
                if (maskfile == "default") { m->mothurOut("I am using the default 236627 EU009184.1 Shigella dysenteriae str. FBD013."); m->mothurOutEndLine();  }
                
-
+               chimera = new Pintail(fastafile, templatefile, filter, processors, maskfile, consfile, quanfile, window, increment, outputDir);
+               
                string outputFileName, accnosFileName;
                if (maskfile != "") {
                        outputFileName = outputDir + getRootName(getSimpleName(fastafile)) + maskfile + ".pintail.chimeras";
@@ -217,22 +216,31 @@ int ChimeraPintailCommand::execute(){
                        int outMode=MPI_MODE_CREATE|MPI_MODE_WRONLY; 
                        int inMode=MPI_MODE_RDONLY; 
                        
-                       char* outFilename = new char[outputFileName.length()];\r
-                       memcpy(outFilename, outputFileName.c_str(), 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 = new char[accnosFileName.length()];\r
-                       memcpy(outAccnosFilename, accnosFileName.c_str(), 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()];\r
-                       memcpy(inFileName, fastafile.c_str(), fastafile.length());
+                       //char* inFileName = new char[fastafile.length()];
+                       //memcpy(inFileName, fastafile.c_str(), 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;
+                       //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;  }
 
@@ -241,13 +249,16 @@ int ChimeraPintailCommand::execute(){
                                MPIPos = setFilePosFasta(fastafile, numSeqs); //fills MPIPos, returns numSeqs
                                
                                //send file positions to all processes
-                               MPI_Bcast(&numSeqs, 1, MPI_INT, 0, MPI_COMM_WORLD);  //send numSeqs
-                               MPI_Bcast(&MPIPos[0], (numSeqs+1), MPI_LONG, 0, MPI_COMM_WORLD); //send file pos        
+                               for(int i = 1; i < processors; i++) { 
+                                       MPI_Send(&numSeqs, 1, MPI_INT, i, tag, MPI_COMM_WORLD);
+                                       MPI_Send(&MPIPos[0], (numSeqs+1), MPI_LONG, i, tag, MPI_COMM_WORLD);
+                               }
                                
                                //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);
@@ -260,14 +271,15 @@ int ChimeraPintailCommand::execute(){
                                        if (tempResult != 0) { MPIWroteAccnos = true; }
                                }
                        }else{ //you are a child process
-                               MPI_Bcast(&numSeqs, 1, MPI_INT, 0, MPI_COMM_WORLD); //get numSeqs
+                               MPI_Recv(&numSeqs, 1, MPI_INT, 0, tag, MPI_COMM_WORLD, &status);
                                MPIPos.resize(numSeqs+1);
-                               MPI_Bcast(&MPIPos[0], (numSeqs+1), MPI_LONG, 0, MPI_COMM_WORLD); //get file positions
+                               MPI_Recv(&MPIPos[0], (numSeqs+1), MPI_LONG, 0, tag, MPI_COMM_WORLD, &status);
                                
                                //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);
@@ -281,6 +293,7 @@ int ChimeraPintailCommand::execute(){
                        MPI_File_close(&inMPI);
                        MPI_File_close(&outMPI);
                        MPI_File_close(&outMPIAccnos);
+                       MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
                        
                        //delete accnos file if blank
                        if (pid == 0) {