]> git.donarmstrong.com Git - mothur.git/commitdiff
a few modifications for 1.9
authorwestcott <westcott>
Tue, 20 Apr 2010 11:34:53 +0000 (11:34 +0000)
committerwestcott <westcott>
Tue, 20 Apr 2010 11:34:53 +0000 (11:34 +0000)
chimera.cpp
chimeraslayer.cpp
chimeraslayercommand.cpp
engine.cpp
makefile
maligner.cpp

index 32351f942eaea499f321720bb36caf335f68d306..83d40fe8342558eacb598525862364dba0f7e5ca 100644 (file)
@@ -109,7 +109,7 @@ vector<Sequence*> Chimera::readSeqs(string file) {
                        MPI_File inMPI;
                        MPI_Comm_rank(MPI_COMM_WORLD, &pid); //find out who we are
 
-                       char* inFileName = new char[file.length()];\r
+                       char* inFileName = new char[file.length()];
                        memcpy(inFileName, file.c_str(), file.length());
        
                        MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
@@ -199,7 +199,7 @@ void Chimera::setMask(string filename) {
                        MPI_Offset size;
                        MPI_Status status;
                        
-                       char* inFileName = new char[filename.length()];\r
+                       char* inFileName = new char[filename.length()];
                        memcpy(inFileName, filename.c_str(), filename.length());
        
                        MPI_File_open(MPI_COMM_WORLD, inFileName, MPI_MODE_RDONLY, MPI_INFO_NULL, &inMPI);  //comm, filename, mode, info, filepointer
index c30404ff965012565b39b8aec0cda823a3bfd139..2c4f7fba4253c2cb4c2693bb3cb18e676c5d938b 100644 (file)
@@ -10,6 +10,7 @@
 #include "chimeraslayer.h"
 #include "chimerarealigner.h"
 #include "kmerdb.hpp"
+#include "blastdb.hpp"
 
 //***************************************************************************************************************
 ChimeraSlayer::ChimeraSlayer(string file, string temp, string mode, int k, int ms, int mms, int win, float div, 
@@ -46,7 +47,6 @@ int minsim, int mincov, int minbs, int minsnp, int par, int it, int inc, int num
 int ChimeraSlayer::doPrep() {
        try {
                
-               
                //read in all query seqs
                vector<Sequence*> tempQuerySeqs = readSeqs(fastafile);
                
@@ -148,6 +148,13 @@ int ChimeraSlayer::doPrep() {
                        
                        databaseRight->setNumSeqs(templateSeqs.size());
                #endif  
+               }else if (searchMethod == "blast") {
+               
+                       //generate blastdb
+                       databaseLeft = new BlastDB(-2.0, -1.0, match, misMatch);
+                       for (int i = 0; i < templateSeqs.size(); i++) {         databaseLeft->addSequence(*templateSeqs[i]);    }
+                       databaseLeft->generateDB();
+                       databaseLeft->setNumSeqs(templateSeqs.size());
                }
                
                return 0;
@@ -159,7 +166,11 @@ int ChimeraSlayer::doPrep() {
        }
 }
 //***************************************************************************************************************
-ChimeraSlayer::~ChimeraSlayer() {      delete decalc;  if (searchMethod == "kmer") {  delete databaseRight;  delete databaseLeft;  }    }
+ChimeraSlayer::~ChimeraSlayer() {      
+       delete decalc;  
+       if (searchMethod == "kmer") {  delete databaseRight;  delete databaseLeft;  }   
+       else if (searchMethod == "blast") {  delete databaseLeft; }
+}
 //***************************************************************************************************************
 void ChimeraSlayer::printHeader(ostream& out) {
        m->mothurOutEndLine();
@@ -221,7 +232,7 @@ int ChimeraSlayer::print(MPI_File& out, MPI_File& outAcc) {
                                        
                                        //write to accnos file
                                        int length = outAccString.length();
-                                       char* buf2 = new char[length];\r
+                                       char* buf2 = new char[length];
                                        memcpy(buf2, outAccString.c_str(), length);
                                
                                        MPI_File_write_shared(outAcc, buf2, length, MPI_CHAR, &status);
@@ -231,17 +242,28 @@ int ChimeraSlayer::print(MPI_File& out, MPI_File& outAcc) {
                        
                        outputString = getBlock(chimeraResults[0]);
                        outputString += "\n";
-                       
-               }else {  outputString += querySeq->getName() + "\tno\n";  }
-               
-               //write to output file
-               int length = outputString.length();
-               char* buf = new char[length];\r
-               memcpy(buf, outputString.c_str(), length);
+       //cout << outputString << endl;         
+                       //write to output file
+                       int length = outputString.length();
+                       char* buf = new char[length];
+                       memcpy(buf, outputString.c_str(), length);
                                
-               MPI_File_write_shared(out, buf, length, MPI_CHAR, &status);
-               delete buf;
+                       MPI_File_write_shared(out, buf, length, MPI_CHAR, &status);
+                       delete buf;
 
+               }else {  
+                       outputString += querySeq->getName() + "\tno\n";  
+       //cout << outputString << endl;
+                       //write to output file
+                       int length = outputString.length();
+                       char* buf = new char[length];
+                       memcpy(buf, outputString.c_str(), length);
+                               
+                       MPI_File_write_shared(out, buf, length, MPI_CHAR, &status);
+                       delete buf;
+               }
+               
+               
                return results;
        }
        catch(exception& e) {
@@ -255,7 +277,7 @@ int ChimeraSlayer::print(MPI_File& out, MPI_File& outAcc) {
 int ChimeraSlayer::getChimeras(Sequence* query) {
        try {
                chimeraFlags = "no";
-               
+
                //filter query
                spotMap = runFilter(query);     
                
index 777584bf0c75cdc8f26d5125defa5e20f296ce6e..4b309c0124a2038cb49db3980345e10e535ce84d 100644 (file)
@@ -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()];\r
+                       char* outFilename = new char[outputFileName.length()];
                        memcpy(outFilename, outputFileName.c_str(), outputFileName.length());
                        
-                       char* outAccnosFilename = new char[accnosFileName.length()];\r
+                       char* outAccnosFilename = new char[accnosFileName.length()];
                        memcpy(outAccnosFilename, accnosFileName.c_str(), accnosFileName.length());
 
-                       char* inFileName = new char[fastafile.length()];\r
+                       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];\r
+                               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<long>& 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;
index c6ceb59d051d6fb88fe1e169bdd9206da9d58ef8..b68bf61e4703fbd77133f8ba72c8488a78519d29 100644 (file)
@@ -99,6 +99,15 @@ bool InteractEngine::getInput(){
 /***********************************************************************/
 string Engine::getCommand()  {
        try {
+       #ifdef USE_MPI //mpirun doesn't work with readline
+                               string nextCommand = "";
+                               
+                               mout->mothurOut("mothur > ");
+                               getline(cin, nextCommand);
+                               mout->mothurOutJustToLog(toString(nextCommand));
+                               
+                               return nextCommand;
+       #else
                #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
                        #ifdef USE_READLINE
                                char* nextCommand = NULL;
@@ -129,8 +138,7 @@ string Engine::getCommand()  {
                                
                                return nextCommand;
                #endif
-               
-               mout->mothurOutEndLine();
+       #endif
                                                
        }
        catch(exception& e) {
index 99152863384e31256a81f9e946862c588b2e6c58..d95b5ef31c04f2e119136d2cc0d146bb2343397b 100644 (file)
--- a/makefile
+++ b/makefile
@@ -10,9 +10,8 @@
 # Macros\r
 #\r
 \r
-CC = mpic++\r
+CC = g++\r
 CC_OPTIONS = -O3\r
-LNK_OPTIONS = \r
 \r
 # if you do not want to use the readline library set to no, default yes.\r
 # make sure you have the library installed\r
@@ -27,7 +26,7 @@ ifeq  ($(strip $(USEREADLINE)),yes)
       -L../readline-6.0\r
 endif\r
 \r
-USEMPI ?= yes\r
+USEMPI ?= no\r
 \r
 ifeq  ($(strip $(USEMPI)),yes)\r
     CC_OPTIONS += -DUSE_MPI\r
index f06884fcad747a84e8c3d8ae673a5eabf839f2ec..5da4b9f9cece7a9e64dd4a5dd621477fc365e94e 100644 (file)
@@ -496,12 +496,7 @@ vector<Sequence*> Maligner::getBlastSeqs(Sequence* q, int num) {
        try {   
                indexes.clear();
                vector<Sequence*> refResults;
-               //generate blastdb
-               Database* database = new BlastDB(-2.0, -1.0, matchScore, misMatchPenalty);
-               for (int i = 0; i < db.size(); i++) {   database->addSequence(*db[i]);  }
-               database->generateDB();
-               database->setNumSeqs(db.size());
-               
+                               
                //get parts of query
                string queryUnAligned = q->getUnaligned();
                string leftQuery = queryUnAligned.substr(0, int(queryUnAligned.length() * 0.33)); //first 1/3 of the sequence
@@ -510,8 +505,8 @@ vector<Sequence*> Maligner::getBlastSeqs(Sequence* q, int num) {
                Sequence* queryLeft = new Sequence(q->getName(), leftQuery);
                Sequence* queryRight = new Sequence(q->getName(), rightQuery);
                
-               vector<int> tempIndexesRight = database->findClosestMegaBlast(queryRight, num+1);
-               vector<int> tempIndexesLeft = database->findClosestMegaBlast(queryLeft, num+1);
+               vector<int> tempIndexesRight = databaseLeft->findClosestMegaBlast(queryRight, num+1);
+               vector<int> tempIndexesLeft = databaseLeft->findClosestMegaBlast(queryLeft, num+1);
                
                //if ((tempIndexesRight.size() != (num+1)) || (tempIndexesLeft.size() != (num+1)))  {  m->mothurOut("megablast returned " + toString(tempIndexesRight.size()) + " results for the right end, and " + toString(tempIndexesLeft.size()) + " for the left end. Needed " + toString(num+1) + ". Unable to porcess sequence " + q->getName()); m->mothurOutEndLine(); return refResults; }
                
@@ -564,8 +559,7 @@ vector<Sequence*> Maligner::getBlastSeqs(Sequence* q, int num) {
 //cout << endl;                
                delete queryRight;
                delete queryLeft;
-               delete database;
-               
+                       
                return refResults;
        }
        catch(exception& e) {