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
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
#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,
int ChimeraSlayer::doPrep() {
try {
-
//read in all query seqs
vector<Sequence*> tempQuerySeqs = readSeqs(fastafile);
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;
}
}
//***************************************************************************************************************
-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();
//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);
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) {
int ChimeraSlayer::getChimeras(Sequence* query) {
try {
chimeraFlags = "no";
-
+
//filter query
spotMap = runFilter(query);
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
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();
//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);
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());
//**********************************************************************************************************************
#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
//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;
/***********************************************************************/
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;
return nextCommand;
#endif
-
- mout->mothurOutEndLine();
+ #endif
}
catch(exception& e) {
# 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
-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
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
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; }
//cout << endl;
delete queryRight;
delete queryLeft;
- delete database;
-
+
return refResults;
}
catch(exception& e) {