From 43ed0accfbc2852849e104ff7eccdd2c42acd4ec Mon Sep 17 00:00:00 2001 From: Sarah Westcott Date: Tue, 13 Mar 2012 14:16:50 -0400 Subject: [PATCH] added unix to ifdefs. minor changes while testing 1.24.0. --- Mothur.xcodeproj/project.pbxproj | 8 +- aligncommand.cpp | 9 +- aligncommand.h | 2 +- bayesian.cpp | 2 +- bellerophon.cpp | 4 +- blastdb.cpp | 26 +- catchallcommand.cpp | 8 +- chimeraccodecommand.cpp | 6 +- chimeracheckcommand.cpp | 6 +- chimeraperseuscommand.cpp | 2 +- chimeraperseuscommand.h | 2 +- chimerapintailcommand.cpp | 6 +- chimeraslayercommand.cpp | 29 +- chimeraslayercommand.h | 2 +- chimerauchimecommand.cpp | 10 +- chimerauchimecommand.h | 6 +- classifyseqscommand.cpp | 7 +- classifyseqscommand.h | 2 +- clustersplitcommand.cpp | 4 +- clustersplitcommand.h | 2 +- cooccurrencecommand.cpp | 15 +- distancecommand.cpp | 8 +- distancecommand.h | 2 +- engine.cpp | 8 +- filterseqscommand.cpp | 16 +- filterseqscommand.h | 2 +- formatcolumn.cpp | 2 +- formatphylip.cpp | 2 +- indicatorcommand.cpp | 4 +- makefile | 16 +- matrixoutputcommand.cpp | 2 +- matrixoutputcommand.h | 2 +- metastatscommand.cpp | 2 +- metastatscommand.h | 2 +- mothur.cpp | 6 +- mothur.h | 2 +- mothurout.cpp | 22 +- myseqdist.cpp | 4 +- myutils.cpp | 10 +- otuassociationcommand.cpp | 12 - pairwiseseqscommand.cpp | 22 +- pairwiseseqscommand.h | 2 +- parsefastaqcommand.cpp | 4 +- parsimony.cpp | 4 +- phylodiversitycommand.cpp | 4 +- pintail.cpp | 4 +- preclustercommand.cpp | 2 +- preclustercommand.h | 2 +- rarefact.cpp | 4 +- rarefactcommand.cpp | 37 ++- rarefactcommand.h | 2 +- screenseqscommand.cpp | 16 +- screenseqscommand.h | 2 +- seqerrorcommand.cpp | 8 +- seqsummarycommand.cpp | 7 +- seqsummarycommand.h | 2 +- setdircommand.cpp | 6 +- sffinfocommand.cpp | 42 ++- sffinfocommand.h | 5 +- shhhercommand.cpp | 4 +- shhhercommand.h | 2 +- shhhseqscommand.cpp | 2 +- shhhseqscommand.h | 2 +- summaryqualcommand.cpp | 7 +- summaryqualcommand.h | 2 +- summarysharedcommand.cpp | 2 +- summarysharedcommand.h | 2 +- trialSwap2.cpp | 541 +------------------------------ trialswap2.h | 3 - trimflowscommand.cpp | 6 +- trimflowscommand.h | 2 +- trimseqscommand.cpp | 9 +- trimseqscommand.h | 2 +- unifracweightedcommand.cpp | 6 +- unweighted.cpp | 8 +- weighted.cpp | 4 +- 76 files changed, 301 insertions(+), 760 deletions(-) diff --git a/Mothur.xcodeproj/project.pbxproj b/Mothur.xcodeproj/project.pbxproj index 0951dd2..4d52554 100644 --- a/Mothur.xcodeproj/project.pbxproj +++ b/Mothur.xcodeproj/project.pbxproj @@ -2347,8 +2347,8 @@ GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( "MOTHUR_FILES=\"\\\"../release\\\"\"", - "VERSION=\"\\\"1.23.0\\\"\"", - "RELEASE_DATE=\"\\\"1/9/2012\\\"\"", + "VERSION=\"\\\"1.24.0\\\"\"", + "RELEASE_DATE=\"\\\"3/12/2012\\\"\"", ); "GCC_VERSION[arch=*]" = ""; GCC_WARN_ABOUT_MISSING_NEWLINE = YES; @@ -2383,8 +2383,8 @@ GCC_MODEL_TUNING = ""; GCC_OPTIMIZATION_LEVEL = 0; GCC_PREPROCESSOR_DEFINITIONS = ( - "VERSION=\"\\\"1.19.0\\\"\"", - "RELEASE_DATE=\"\\\"5/9/2011\\\"\"", + "VERSION=\"\\\"1.24.0\\\"\"", + "RELEASE_DATE=\"\\\"3/12/2012\\\"\"", ); GCC_WARN_ABOUT_MISSING_NEWLINE = YES; GCC_WARN_ABOUT_RETURN_TYPE = YES; diff --git a/aligncommand.cpp b/aligncommand.cpp index f03a901..8215de3 100644 --- a/aligncommand.cpp +++ b/aligncommand.cpp @@ -422,7 +422,7 @@ int AlignCommand::execute(){ #else vector positions; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) positions = m->divideFile(candidateFileNames[s], processors); for (int i = 0; i < (positions.size()-1); i++) { lines.push_back(new linePair(positions[i], positions[(i+1)])); } #else @@ -430,7 +430,8 @@ int AlignCommand::execute(){ lines.push_back(new linePair(0, 1000)); }else { positions = m->setFilePosFasta(candidateFileNames[s], numFastaSeqs); - + if (positions.size() < processors) { processors = positions.size(); } + //figure out how many sequences you have to process int numSeqsPerProcessor = numFastaSeqs / processors; for (int i = 0; i < processors; i++) { @@ -617,7 +618,7 @@ int AlignCommand::driver(linePair* filePos, string alignFName, string reportFNam } delete candidateSeq; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) unsigned long long pos = inFASTA.tellg(); if ((pos == -1) || (pos >= filePos->end)) { break; } #else @@ -826,7 +827,7 @@ int AlignCommand::createProcesses(string alignFileName, string reportFileName, s try { int num = 0; processIDS.resize(0); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 1; //loop through and create all the processes you want diff --git a/aligncommand.h b/aligncommand.h index b455761..c7ce144 100644 --- a/aligncommand.h +++ b/aligncommand.h @@ -120,7 +120,7 @@ struct alignData { }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MyAlignThreadFunction(LPVOID lpParam){ alignData* pDataArray; diff --git a/bayesian.cpp b/bayesian.cpp index eca63b1..54a123c 100644 --- a/bayesian.cpp +++ b/bayesian.cpp @@ -605,7 +605,7 @@ void Bayesian::readProbFile(ifstream& in, ifstream& inNum, string inName, string istringstream iss (tempBuf,istringstream::in); float probTemp; iss >> zeroCountProb[i] >> numbers[i] >> probTemp; - WordPairDiffArr[i].prob = tempProb; + WordPairDiffArr[i].prob = probTemp; } diff --git a/bellerophon.cpp b/bellerophon.cpp index 9dd21a4..833cfb9 100644 --- a/bellerophon.cpp +++ b/bellerophon.cpp @@ -314,7 +314,7 @@ int Bellerophon::getChimeras() { #else //divide breakpoints between processors - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if(processors == 1){ lines.push_back(linePair(0, iters)); @@ -356,7 +356,7 @@ int Bellerophon::getChimeras() { int Bellerophon::createProcesses(vector mid) { try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 0; int exitCommand = 1; vector processIDS; diff --git a/blastdb.cpp b/blastdb.cpp index bc646df..2eced7e 100644 --- a/blastdb.cpp +++ b/blastdb.cpp @@ -24,7 +24,7 @@ gapOpen(gO), gapExtend(gE), match(mm), misMatch(mM) { int randNumber = rand(); //int randNumber = 12345; string pid = ""; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) pid += getpid(); #else pid += toString(threadID); @@ -42,7 +42,7 @@ gapOpen(gO), gapExtend(gE), match(mm), misMatch(mM) { for (int i = 0; i < path.length(); i++) { tempPath[i] = tolower(path[i]); } path = path.substr(0, (tempPath.find_last_of('m'))); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) path += "blast/bin/"; #else path += "blast\\bin\\"; @@ -51,7 +51,7 @@ gapOpen(gO), gapExtend(gE), match(mm), misMatch(mM) { string formatdbCommand; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) formatdbCommand = path + "formatdb"; // format the database, -o option gives us the ability #else formatdbCommand = path + "formatdb.exe"; @@ -64,7 +64,7 @@ gapOpen(gO), gapExtend(gE), match(mm), misMatch(mM) { if(ableToOpen == 1) { m->mothurOut("[ERROR]: " + formatdbCommand + " file does not exist. mothur requires formatdb.exe."); m->mothurOutEndLine(); m->control_pressed = true; } string blastCommand; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) blastCommand = path + "blastall"; // format the database, -o option gives us the ability #else blastCommand = path + "blastall.exe"; @@ -80,7 +80,7 @@ gapOpen(gO), gapExtend(gE), match(mm), misMatch(mM) { string megablastCommand; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) megablastCommand = path + "megablast"; // format the database, -o option gives us the ability #else megablastCommand = path + "megablast.exe"; @@ -114,7 +114,7 @@ BlastDB::BlastDB(string b, int tid) : Database() { for (int i = 0; i < path.length(); i++) { tempPath[i] = tolower(path[i]); } path = path.substr(0, (tempPath.find_last_of('m'))); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) path += "blast/bin/"; #else path += "blast\\bin\\"; @@ -123,7 +123,7 @@ BlastDB::BlastDB(string b, int tid) : Database() { int randNumber = rand(); string pid = ""; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) pid += getpid(); #else pid += toString(threadID); @@ -134,7 +134,7 @@ BlastDB::BlastDB(string b, int tid) : Database() { blastFileName = pid + toString(randNumber) + ".blast"; string formatdbCommand; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) formatdbCommand = path + "formatdb"; // format the database, -o option gives us the ability #else formatdbCommand = path + "formatdb.exe"; @@ -149,7 +149,7 @@ BlastDB::BlastDB(string b, int tid) : Database() { if(ableToOpen == 1) { m->mothurOut("[ERROR]: " + formatdbCommand + " file does not exist. mothur requires formatdb.exe."); m->mothurOutEndLine(); m->control_pressed = true; } string blastCommand; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) blastCommand = path + "blastall"; // format the database, -o option gives us the ability #else blastCommand = path + "blastall.exe"; @@ -165,7 +165,7 @@ BlastDB::BlastDB(string b, int tid) : Database() { string megablastCommand; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) megablastCommand = path + "megablast"; // format the database, -o option gives us the ability #else megablastCommand = path + "megablast.exe"; @@ -226,7 +226,7 @@ vector BlastDB::findClosestSequences(Sequence* seq, int n) { // long. With this setting, it seems comparable in speed to the suffix tree approach. string blastCommand; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) blastCommand = path + "blastall -p blastn -d " + dbFileName + " -m 8 -W 28 -v " + toString(n) + " -b " + toString(n); blastCommand += (" -i " + (queryFileName+pid+toString(randNumber)) + " -o " + blastFileName+pid+toString(randNumber)); @@ -289,7 +289,7 @@ vector BlastDB::findClosestMegaBlast(Sequence* seq, int n, int minPerID) { // long. With this setting, it seems comparable in speed to the suffix tree approach. //7000004128189528left 0 100 66 0 0 1 66 61 126 1e-31 131 string blastCommand; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) blastCommand = path + "megablast -e 1e-10 -d " + dbFileName + " -m 8 -b " + toString(n) + " -v " + toString(n); //-W 28 -p blastn blastCommand += (" -i " + (queryFileName+pid+toString(randNumber)) + " -o " + blastFileName+pid+toString(randNumber)); #else @@ -363,7 +363,7 @@ void BlastDB::generateDB() { string formatdbCommand; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) formatdbCommand = path + "formatdb -p F -o T -i " + dbFileName; // format the database, -o option gives us the ability #else //formatdbCommand = path + "blast\\bin\\formatdb -p F -o T -i " + dbFileName; // format the database, -o option gives us the ability diff --git a/catchallcommand.cpp b/catchallcommand.cpp index 857f684..bf866cb 100644 --- a/catchallcommand.cpp +++ b/catchallcommand.cpp @@ -176,7 +176,7 @@ int CatchAllCommand::execute() { savedOutputDir = outputDir; string catchAllCommandExe = ""; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) catchAllCommandExe += "mono " + path + "CatchAllcmdL.exe "; if (outputDir == "") { outputDir = "./"; } //force full pathname to be created for catchall, this is necessary because if catchall is in the path it will look for input file whereever the exe is and not the cwd. #else @@ -224,7 +224,7 @@ int CatchAllCommand::execute() { //create system command string catchAllCommand = ""; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) catchAllCommand += catchAllCommandExe + filename + " " + outputPath + " 1"; #else if (outputPath.length() > 0) { outputPath = outputPath.substr(0, outputPath.length()-1); } @@ -269,7 +269,7 @@ int CatchAllCommand::execute() { //create system command string catchAllCommand = ""; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) catchAllCommand += catchAllCommandExe + filename + " " + outputPath + " 1"; #else if (outputPath.length() > 0) { outputPath = outputPath.substr(0, outputPath.length()-1); } @@ -334,7 +334,7 @@ int CatchAllCommand::execute() { //create system command string catchAllCommand = ""; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) catchAllCommand += catchAllCommandExe + filename + " " + outputPath + " 1"; #else if (outputPath.length() > 0) { outputPath = outputPath.substr(0, outputPath.length()-1); } diff --git a/chimeraccodecommand.cpp b/chimeraccodecommand.cpp index af6e33a..fc98e0f 100644 --- a/chimeraccodecommand.cpp +++ b/chimeraccodecommand.cpp @@ -393,7 +393,7 @@ int ChimeraCcodeCommand::execute(){ //break up file - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) vector positions = m->divideFile(fastaFileNames[s], processors); for (int i = 0; i < (positions.size()-1); i++) { @@ -524,7 +524,7 @@ int ChimeraCcodeCommand::driver(linePair* filePos, string outputFName, string fi } delete candidateSeq; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) unsigned long long pos = inFASTA.tellg(); if ((pos == -1) || (pos >= filePos->end)) { break; } #else @@ -611,7 +611,7 @@ int ChimeraCcodeCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File int ChimeraCcodeCommand::createProcesses(string outputFileName, string filename, string accnos) { try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 0; int num = 0; diff --git a/chimeracheckcommand.cpp b/chimeracheckcommand.cpp index 9f53b17..cc486d3 100644 --- a/chimeracheckcommand.cpp +++ b/chimeracheckcommand.cpp @@ -427,7 +427,7 @@ int ChimeraCheckCommand::execute(){ //break up file - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) vector positions = m->divideFile(fastaFileNames[i], processors); for (int s = 0; s < (positions.size()-1); s++) { @@ -522,7 +522,7 @@ int ChimeraCheckCommand::driver(linePair* filePos, string outputFName, string fi } delete candidateSeq; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) unsigned long long pos = inFASTA.tellg(); if ((pos == -1) || (pos >= filePos->end)) { break; } #else @@ -599,7 +599,7 @@ int ChimeraCheckCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_File int ChimeraCheckCommand::createProcesses(string outputFileName, string filename) { try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 0; int num = 0; diff --git a/chimeraperseuscommand.cpp b/chimeraperseuscommand.cpp index 76f0103..138a6b9 100644 --- a/chimeraperseuscommand.cpp +++ b/chimeraperseuscommand.cpp @@ -768,7 +768,7 @@ int ChimeraPerseusCommand::createProcessesGroups(SequenceParser& parser, string lines.push_back(linePair(startIndex, endIndex)); } -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want while (process != processors) { diff --git a/chimeraperseuscommand.h b/chimeraperseuscommand.h index 4562750..01f5768 100644 --- a/chimeraperseuscommand.h +++ b/chimeraperseuscommand.h @@ -98,7 +98,7 @@ struct perseusData { } }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MyPerseusThreadFunction(LPVOID lpParam){ perseusData* pDataArray; diff --git a/chimerapintailcommand.cpp b/chimerapintailcommand.cpp index 3eb6589..7311173 100644 --- a/chimerapintailcommand.cpp +++ b/chimerapintailcommand.cpp @@ -488,7 +488,7 @@ int ChimeraPintailCommand::execute(){ #else //break up file - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) vector positions = m->divideFile(fastaFileNames[s], processors); for (int i = 0; i < (positions.size()-1); i++) { @@ -611,7 +611,7 @@ int ChimeraPintailCommand::driver(linePair* filePos, string outputFName, string } delete candidateSeq; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) unsigned long long pos = inFASTA.tellg(); if ((pos == -1) || (pos >= filePos->end)) { break; } #else @@ -697,7 +697,7 @@ int ChimeraPintailCommand::driverMPI(int start, int num, MPI_File& inMPI, MPI_Fi int ChimeraPintailCommand::createProcesses(string outputFileName, string filename, string accnos) { try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 0; int num = 0; diff --git a/chimeraslayercommand.cpp b/chimeraslayercommand.cpp index cfcad15..8647e75 100644 --- a/chimeraslayercommand.cpp +++ b/chimeraslayercommand.cpp @@ -495,14 +495,14 @@ ChimeraSlayerCommand::ChimeraSlayerCommand(string option) { else { //add / to name if needed string lastChar = blastlocation.substr(blastlocation.length()-1); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if (lastChar != "/") { blastlocation += "/"; } #else if (lastChar != "\\") { blastlocation += "\\"; } #endif blastlocation = m->getFullPathName(blastlocation); string formatdbCommand = ""; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) formatdbCommand = blastlocation + "formatdb"; #else formatdbCommand = blastlocation + "formatdb.exe"; @@ -515,7 +515,7 @@ ChimeraSlayerCommand::ChimeraSlayerCommand(string option) { if(ableToOpen == 1) { m->mothurOut("[ERROR]: " + formatdbCommand + " file does not exist. mothur requires formatdb.exe to run chimera.slayer."); m->mothurOutEndLine(); abort = true; } string blastCommand = ""; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) blastCommand = blastlocation + "megablast"; #else blastCommand = blastlocation + "megablast.exe"; @@ -533,7 +533,7 @@ ChimeraSlayerCommand::ChimeraSlayerCommand(string option) { if (hasGroup && (templatefile != "self")) { m->mothurOut("You have provided a group file and the reference parameter is not set to self. I am not sure what reference you are trying to use, aborting."); m->mothurOutEndLine(); abort=true; } //until we resolve the issue 10-18-11 -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else //processors=1; #endif @@ -594,13 +594,14 @@ int ChimeraSlayerCommand::execute(){ #else //break up file vector positions; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) positions = m->divideFile(thisFastaName, processors); for (int i = 0; i < (positions.size()-1); i++) { lines.push_back(linePair(positions[i], positions[(i+1)])); } #else if (processors == 1) { lines.push_back(linePair(0, 1000)); } else { positions = m->setFilePosFasta(thisFastaName, numSeqs); + if (positions.size() < processors) { processors = positions.size(); } //figure out how many sequences you have to process int numSeqsPerProcessor = numSeqs / processors; @@ -900,6 +901,16 @@ int ChimeraSlayerCommand::deconvoluteResults(SequenceParser* parser, string outp map uniqueNames = parser->getAllSeqsMap(); map::iterator itUnique; int total = 0; + + if (trimera) { //add in more potential uniqueNames + map newUniqueNames = uniqueNames; + for (map::iterator it = uniqueNames.begin(); it != uniqueNames.end(); it++) { + newUniqueNames[(it->first)+"_LEFT"] = (it->first)+"_LEFT"; + newUniqueNames[(it->first)+"_RIGHT"] = (it->first)+"_RIGHT"; + } + uniqueNames = newUniqueNames; + newUniqueNames.clear(); + } //edit accnos file ifstream in2; @@ -1187,7 +1198,7 @@ int ChimeraSlayerCommand::driverGroups(string outputFName, string accnos, string m->mothurOutEndLine(); m->mothurOut("Checking sequences from group: " + fileGroup[thisFastaName] + "."); m->mothurOutEndLine(); lines.clear(); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int proc = 1; vector positions = m->divideFile(thisFastaName, proc); lines.push_back(linePair(positions[0], positions[1])); @@ -1244,7 +1255,7 @@ int ChimeraSlayerCommand::createProcessesGroups(string outputFName, string accno breakUp.push_back(thisFileToPriority); } -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want while (process != processors) { int pid = fork(); @@ -1447,7 +1458,7 @@ int ChimeraSlayerCommand::driver(linePair filePos, string outputFName, string fi count++; } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) unsigned long long pos = inFASTA.tellg(); if ((pos == -1) || (pos >= filePos.end)) { break; } #else @@ -1628,7 +1639,7 @@ int ChimeraSlayerCommand::createProcesses(string outputFileName, string filename int num = 0; processIDS.clear(); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want while (process != processors) { int pid = fork(); diff --git a/chimeraslayercommand.h b/chimeraslayercommand.h index 6f3455d..2c6fec8 100644 --- a/chimeraslayercommand.h +++ b/chimeraslayercommand.h @@ -172,7 +172,7 @@ struct slayerData { }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MySlayerThreadFunction(LPVOID lpParam){ slayerData* pDataArray; diff --git a/chimerauchimecommand.cpp b/chimerauchimecommand.cpp index 01289a0..98976ce 100644 --- a/chimerauchimecommand.cpp +++ b/chimerauchimecommand.cpp @@ -461,7 +461,7 @@ ChimeraUchimeCommand::ChimeraUchimeCommand(string option) { path = path.substr(0, (tempPath.find_last_of('m'))); string uchimeCommand; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) uchimeCommand = path + "uchime"; // format the database, -o option gives us the ability #else uchimeCommand = path + "uchime.exe"; @@ -1005,7 +1005,7 @@ int ChimeraUchimeCommand::driver(string outputFName, string filename, string acc path = path.substr(0, (tempPath.find_last_of('m'))); string uchimeCommand = path; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) uchimeCommand += "uchime "; #else uchimeCommand += "uchime"; @@ -1243,7 +1243,7 @@ int ChimeraUchimeCommand::driver(string outputFName, string filename, string acc //uchime_main(numArgs, uchimeParameters); //cout << "commandString = " << commandString << endl; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else commandString = "\"" + commandString + "\""; #endif @@ -1309,7 +1309,7 @@ int ChimeraUchimeCommand::createProcesses(string outputFileName, string filename int num = 0; vector files; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //break up file into multiple files m->divideFile(filename, processors, files); @@ -1492,7 +1492,7 @@ int ChimeraUchimeCommand::createProcessesGroups(SequenceParser& parser, string o lines.push_back(linePair(startIndex, endIndex)); } -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want while (process != processors) { diff --git a/chimerauchimecommand.h b/chimerauchimecommand.h index b401ae8..499b182 100644 --- a/chimerauchimecommand.h +++ b/chimerauchimecommand.h @@ -141,7 +141,7 @@ struct uchimeData { }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MyUchimeThreadFunction(LPVOID lpParam){ uchimeData* pDataArray; @@ -189,7 +189,7 @@ static DWORD WINAPI MyUchimeThreadFunction(LPVOID lpParam){ path = path.substr(0, (tempPath.find_last_of('m'))); string uchimeCommand = path; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) uchimeCommand += "uchime "; #else uchimeCommand += "uchime"; @@ -403,7 +403,7 @@ static DWORD WINAPI MyUchimeThreadFunction(LPVOID lpParam){ //uchime_main(numArgs, uchimeParameters); //cout << "commandString = " << commandString << endl; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else commandString = "\"" + commandString + "\""; #endif diff --git a/classifyseqscommand.cpp b/classifyseqscommand.cpp index 72acd22..664db6b 100644 --- a/classifyseqscommand.cpp +++ b/classifyseqscommand.cpp @@ -615,7 +615,7 @@ int ClassifySeqsCommand::execute(){ #else vector positions; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) positions = m->divideFile(fastaFileNames[s], processors); for (int i = 0; i < (positions.size()-1); i++) { lines.push_back(new linePair(positions[i], positions[(i+1)])); } #else @@ -623,6 +623,7 @@ int ClassifySeqsCommand::execute(){ lines.push_back(new linePair(0, 1000)); }else { positions = m->setFilePosFasta(fastaFileNames[s], numFastaSeqs); + if (positions.size() < processors) { processors = positions.size(); } //figure out how many sequences you have to process int numSeqsPerProcessor = numFastaSeqs / processors; @@ -821,7 +822,7 @@ int ClassifySeqsCommand::createProcesses(string taxFileName, string tempTaxFile, int num = 0; processIDS.clear(); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 1; //loop through and create all the processes you want @@ -1021,7 +1022,7 @@ int ClassifySeqsCommand::driver(linePair* filePos, string taxFName, string tempT } delete candidateSeq; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) unsigned long long pos = inFASTA.tellg(); if ((pos == -1) || (pos >= filePos->end)) { break; } #else diff --git a/classifyseqscommand.h b/classifyseqscommand.h index f0c67ba..d410558 100644 --- a/classifyseqscommand.h +++ b/classifyseqscommand.h @@ -130,7 +130,7 @@ struct classifyData { }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MyClassThreadFunction(LPVOID lpParam){ classifyData* pDataArray; diff --git a/clustersplitcommand.cpp b/clustersplitcommand.cpp index bb9296f..8a19f1d 100644 --- a/clustersplitcommand.cpp +++ b/clustersplitcommand.cpp @@ -554,7 +554,7 @@ int ClusterSplitCommand::execute(){ //sanity check if (processors > distName.size()) { processors = distName.size(); } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if(processors == 1){ listFileNames = cluster(distName, labels); //clusters individual files and returns names of list files }else{ @@ -868,7 +868,7 @@ vector ClusterSplitCommand::createProcesses(vector< map if (m->control_pressed) { return listFiles; } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 1; processIDS.clear(); diff --git a/clustersplitcommand.h b/clustersplitcommand.h index cf52ff2..0e32ffa 100644 --- a/clustersplitcommand.h +++ b/clustersplitcommand.h @@ -102,7 +102,7 @@ struct clusterData { }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MyClusterThreadFunction(LPVOID lpParam){ clusterData* pDataArray; diff --git a/cooccurrencecommand.cpp b/cooccurrencecommand.cpp index b67c6ea..6864f79 100644 --- a/cooccurrencecommand.cpp +++ b/cooccurrencecommand.cpp @@ -253,6 +253,7 @@ int CooccurrenceCommand::execute(){ //reset groups parameter delete input; + m->clearGroups(); m->mothurOutEndLine(); m->mothurOut("Output File Names: "); m->mothurOutEndLine(); @@ -271,12 +272,12 @@ int CooccurrenceCommand::execute(){ int CooccurrenceCommand::getCooccurrence(vector& thisLookUp, ofstream& out){ try { int numOTUS = thisLookUp[0]->getNumBins(); - vector< vector > initmatrix (thisLookUp.size()); - vector< vector > co_matrix (thisLookUp[0]->getNumBins()); + vector< vector > initmatrix; initmatrix.resize(thisLookUp.size()); + vector< vector > co_matrix; co_matrix.resize(thisLookUp[0]->getNumBins()); for (int i = 0; i < thisLookUp[0]->getNumBins(); i++) { co_matrix[i].resize((thisLookUp.size()), 0); } for (int i = 0; i < thisLookUp.size(); i++) { initmatrix[i].resize((thisLookUp[i]->getNumBins()), 0); } - vector columntotal(thisLookUp.size(), 0); - vector rowtotal(numOTUS, 0); + vector columntotal; columntotal.resize(thisLookUp.size(), 0); + vector rowtotal; rowtotal.resize(numOTUS, 0); int rowcount = 0; for (int i = 0; i < thisLookUp.size(); i++) { @@ -298,7 +299,7 @@ int CooccurrenceCommand::getCooccurrence(vector& thisLookUp //nrows is ncols of inital matrix. All the functions need this value. They assume the transposition has already taken place and nrows and ncols refer to that matrix. //comatrix and initmatrix are still vectors of vectors of ints as in the original script. The abundancevector is only what was read in ie not a co-occurrence matrix! int ncols = numOTUS;//rows of inital matrix - int nrows = thisLookUp.size();//OTUs + int nrows = thisLookUp.size();//groups double initscore = 0.0; //transpose matrix int newmatrows = ncols; @@ -308,8 +309,8 @@ int CooccurrenceCommand::getCooccurrence(vector& thisLookUp nrows = newmatrows;//ncols; ncols = newmatcols;//nrows; - vector initcolumntotal(ncols, 0); - vector initrowtotal(nrows, 0); + vector initcolumntotal; initcolumntotal.resize(ncols, 0); + vector initrowtotal; initrowtotal.resize(nrows, 0); vector stats; TrialSwap2 trial; diff --git a/distancecommand.cpp b/distancecommand.cpp index 0ac1787..79b8fe7 100644 --- a/distancecommand.cpp +++ b/distancecommand.cpp @@ -380,7 +380,7 @@ int DistanceCommand::execute(){ MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case #else - //#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + //#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //if you don't need to fork anything if(processors == 1){ if (output != "square") { driver(0, numSeqs, outputFile, cutoff); } @@ -507,7 +507,7 @@ int DistanceCommand::execute(){ /**************************************************************************************************/ void DistanceCommand::createProcesses(string filename) { try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 1; processIDS.clear(); @@ -1014,7 +1014,7 @@ int DistanceCommand::convertMatrix(string outputFile) { string outfile = m->getRootName(outputFile) + "sorted.dist.temp"; //use the unix sort - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) string command = "sort -n " + outputFile + " -o " + outfile; system(command.c_str()); #else //sort using windows sort @@ -1102,7 +1102,7 @@ int DistanceCommand::convertToLowerTriangle(string outputFile) { string outfile = m->getRootName(outputFile) + "sorted.dist.temp"; //use the unix sort - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) string command = "sort -n " + outputFile + " -o " + outfile; system(command.c_str()); #else //sort using windows sort diff --git a/distancecommand.h b/distancecommand.h index f55f714..91f0ed5 100644 --- a/distancecommand.h +++ b/distancecommand.h @@ -53,7 +53,7 @@ struct distanceData { }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MyDistThreadFunction(LPVOID lpParam){ distanceData* pDataArray; diff --git a/engine.cpp b/engine.cpp index ea1c0e1..ffbe324 100644 --- a/engine.cpp +++ b/engine.cpp @@ -34,7 +34,7 @@ string Engine::findMothursPath(){ //delimiting path char char delim; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) delim = ':'; #else delim = ';'; @@ -56,7 +56,7 @@ string Engine::findMothursPath(){ if (mothurPath != "") { //add mothur so it looks like what argv would look like - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) mothurPath += "/mothur"; #else mothurPath += "\\mothur"; @@ -71,7 +71,7 @@ string Engine::findMothursPath(){ //is this mothurs path? ifstream in; string tempIn = dirs[i]; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) tempIn += "/mothur"; #else tempIn += "\\mothur"; @@ -219,7 +219,7 @@ bool InteractEngine::getInput(){ string Engine::getCommand() { try { - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #ifdef USE_READLINE char* nextCommand = NULL; nextCommand = readline("mothur > "); diff --git a/filterseqscommand.cpp b/filterseqscommand.cpp index 9096bb6..93e18e8 100644 --- a/filterseqscommand.cpp +++ b/filterseqscommand.cpp @@ -424,16 +424,17 @@ int FilterSeqsCommand::filterSequences() { vector positions; if (savedPositions.size() != 0) { positions = savedPositions[s]; } else { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) positions = m->divideFile(fastafileNames[s], processors); #else if(processors != 1){ int numFastaSeqs = 0; positions = m->setFilePosFasta(fastafileNames[s], numFastaSeqs); + if (positions.size() < processors) { processors = positions.size(); } } #endif } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //vector positions = m->divideFile(fastafileNames[s], processors); for (int i = 0; i < (positions.size()-1); i++) { @@ -590,7 +591,7 @@ int FilterSeqsCommand::driverRunFilter(string F, string outputFilename, string i count++; } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) unsigned long long pos = in.tellg(); if ((pos == -1) || (pos >= filePos->end)) { break; } #else @@ -623,7 +624,7 @@ int FilterSeqsCommand::createProcessesRunFilter(string F, string filename, strin int num = 0; processIDS.clear(); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want @@ -811,7 +812,7 @@ string FilterSeqsCommand::createFilter() { #else vector positions; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) positions = m->divideFile(fastafileNames[s], processors); for (int i = 0; i < (positions.size()-1); i++) { lines.push_back(new linePair(positions[i], positions[(i+1)])); @@ -832,6 +833,7 @@ string FilterSeqsCommand::createFilter() { }else { int numFastaSeqs = 0; positions = m->setFilePosFasta(fastafileNames[s], numFastaSeqs); + if (positions.size() < processors) { processors = positions.size(); } //figure out how many sequences you have to process int numSeqsPerProcessor = numFastaSeqs / processors; @@ -969,7 +971,7 @@ int FilterSeqsCommand::driverCreateFilter(Filters& F, string filename, linePair* count++; } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) unsigned long long pos = in.tellg(); if ((pos == -1) || (pos >= filePos->end)) { break; } #else @@ -1045,7 +1047,7 @@ int FilterSeqsCommand::createProcessesCreateFilter(Filters& F, string filename) int num = 0; processIDS.clear(); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want while (process != processors) { diff --git a/filterseqscommand.h b/filterseqscommand.h index 16062f3..4405c33 100644 --- a/filterseqscommand.h +++ b/filterseqscommand.h @@ -121,7 +121,7 @@ struct filterRunData { }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MyCreateFilterThreadFunction(LPVOID lpParam){ filterData* pDataArray; diff --git a/formatcolumn.cpp b/formatcolumn.cpp index d43f85d..6b29f90 100644 --- a/formatcolumn.cpp +++ b/formatcolumn.cpp @@ -82,7 +82,7 @@ int FormatColumnMatrix::read(NameAssignment* nameMap){ string outfile = m->getRootName(squareFile) + "sorted.dist.temp"; //use the unix sort - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) string command = "sort -n " + squareFile + " -o " + outfile; system(command.c_str()); #else //sort using windows sort diff --git a/formatphylip.cpp b/formatphylip.cpp index de49daa..6059117 100644 --- a/formatphylip.cpp +++ b/formatphylip.cpp @@ -96,7 +96,7 @@ int FormatPhylipMatrix::read(NameAssignment* nameMap){ string outfile = m->getRootName(tempFile) + "sorted.dist.temp"; //use the unix sort - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) string command = "sort -n " + tempFile + " -o " + outfile; system(command.c_str()); #else //sort using windows sort diff --git a/indicatorcommand.cpp b/indicatorcommand.cpp index 1864f74..01d8c2e 100644 --- a/indicatorcommand.cpp +++ b/indicatorcommand.cpp @@ -1120,7 +1120,7 @@ vector IndicatorCommand::getPValues(vector< vector pvalues; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if(processors == 1){ pvalues = driver(groupings, groupingsMap, num, indicatorValues, iters); for (int i = 0; i < pvalues.size(); i++) { pvalues[i] /= (double)iters; } @@ -1234,7 +1234,7 @@ vector IndicatorCommand::getPValues(vector< vector > try { vector pvalues; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if(processors == 1){ pvalues = driver(groupings, groupingsMap, num, indicatorValues, iters); for (int i = 0; i < pvalues.size(); i++) { pvalues[i] /= (double)iters; } diff --git a/makefile b/makefile index 476070e..c389a94 100644 --- a/makefile +++ b/makefile @@ -9,15 +9,15 @@ # Macros # -USEMPI ?= no +USEMPI ?= yes 64BIT_VERSION ?= yes -USEREADLINE ?= yes +USEREADLINE ?= no CYGWIN_BUILD ?= no USECOMPRESSION ?= no MOTHUR_FILES="\"Enter_your_default_path_here\"" -RELEASE_DATE = "\"1/9/2012\"" -VERSION = "\"1.23.0\"" -FORTAN_COMPILER = gfortran +RELEASE_DATE = "\"3/12/2012\"" +VERSION = "\"1.24.4\"" +FORTAN_COMPILER = /usr/local/gfortran/bin/gfortran # Optimize to level 3: CXXFLAGS += -O3 @@ -38,7 +38,7 @@ ifeq ($(strip $(64BIT_VERSION)),yes) #if you are a linux user use the following line #CXXFLAGS += -mtune=native -march=native -m64 - CXXFLAGS += -DBIT_VERSION + CXXFLAGS += -DBIT_VERSION endif @@ -97,12 +97,12 @@ mothur : fortranSource $(OBJECTS) uchime $(CXX) $(LDFLAGS) $(TARGET_ARCH) -o $@ $(OBJECTS) $(LIBS) strip mothur - + uchime: cd uchime_src && ./mk && mv uchime .. && cd .. fortranSource: - ${FORTAN_COMPILER} -c *.f + ${FORTAN_COMPILER} -c -m64 *.f install : mothur # cp mothur ../Release/mothur diff --git a/matrixoutputcommand.cpp b/matrixoutputcommand.cpp index 6537963..5bfec37 100644 --- a/matrixoutputcommand.cpp +++ b/matrixoutputcommand.cpp @@ -425,7 +425,7 @@ int MatrixOutputCommand::process(vector thisLookup){ int process = 1; vector processIDS; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want while (process != processors) { int pid = fork(); diff --git a/matrixoutputcommand.h b/matrixoutputcommand.h index 762b0e1..dc77bdf 100644 --- a/matrixoutputcommand.h +++ b/matrixoutputcommand.h @@ -130,7 +130,7 @@ struct distSharedData { } }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MyDistSharedThreadFunction(LPVOID lpParam){ distSharedData* pDataArray; diff --git a/metastatscommand.cpp b/metastatscommand.cpp index 5991649..a0e6ed5 100644 --- a/metastatscommand.cpp +++ b/metastatscommand.cpp @@ -343,7 +343,7 @@ int MetaStatsCommand::process(vector& thisLookUp){ }else{ int process = 1; vector processIDS; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want while (process != processors) { int pid = fork(); diff --git a/metastatscommand.h b/metastatscommand.h index 2c5c80c..b4800b7 100644 --- a/metastatscommand.h +++ b/metastatscommand.h @@ -87,7 +87,7 @@ struct metastatsData { } }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MyMetastatsThreadFunction(LPVOID lpParam){ metastatsData* pDataArray; diff --git a/mothur.cpp b/mothur.cpp index c991422..accdb29 100644 --- a/mothur.cpp +++ b/mothur.cpp @@ -46,7 +46,7 @@ int main(int argc, char *argv[]){ m->setFileName(logFileName); - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) system("clear"); #else system("CLS"); @@ -57,7 +57,7 @@ int main(int argc, char *argv[]){ //add / to name if needed string lastChar = temp.substr(temp.length()-1); - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if (lastChar != "/") { temp += "/"; } #else if (lastChar != "\\") { temp += "\\"; } @@ -88,7 +88,7 @@ int main(int argc, char *argv[]){ if (outputHeader) { //version - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #if defined (__APPLE__) || (__MACH__) m->mothurOutJustToLog("Mac version"); m->mothurOutEndLine(); m->mothurOutEndLine(); diff --git a/mothur.h b/mothur.h index 57b409e..1a07b6f 100644 --- a/mothur.h +++ b/mothur.h @@ -54,7 +54,7 @@ #endif /***********************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #include #include #include diff --git a/mothurout.cpp b/mothurout.cpp index 25e534e..c89d580 100644 --- a/mothurout.cpp +++ b/mothurout.cpp @@ -143,7 +143,7 @@ void MothurOut::setDefaultPath(string pathname) { //add / to name if needed string lastChar = pathname.substr(pathname.length()-1); - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if (lastChar != "/") { pathname += "/"; } #else if (lastChar != "\\") { pathname += "\\"; } @@ -334,7 +334,7 @@ void MothurOut::errorOut(exception& e, string object, string function) { // // On failure, returns 0.0, 0.0 int MothurOut::mem_usage(double& vm_usage, double& resident_set) { - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) vm_usage = 0.0; resident_set = 0.0; @@ -506,7 +506,7 @@ string MothurOut::getline(ifstream& fileHandle) { } /***********************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #ifdef USE_COMPRESSION inline bool endsWith(string s, const char * suffix){ size_t suffixLength = strlen(suffix); @@ -520,7 +520,7 @@ string MothurOut::getRootName(string longName){ string rootName = longName; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #ifdef USE_COMPRESSION if (endsWith(rootName, ".gz") || endsWith(rootName, ".bz2")) { int pos = rootName.find_last_of('.'); @@ -675,7 +675,7 @@ string MothurOut::getFullPathName(string fileName){ string cwd; //get current working directory - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if (path.find("~") != -1) { //go to home directory string homeDir; @@ -798,7 +798,7 @@ int MothurOut::openInputFile(string fileName, ifstream& fileHandle, string m){ try { //get full path name string completeFileName = getFullPathName(fileName); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #ifdef USE_COMPRESSION // check for gzipped or bzipped file if (endsWith(completeFileName, ".gz") || endsWith(completeFileName, ".bz2")) { @@ -844,7 +844,7 @@ int MothurOut::openInputFile(string fileName, ifstream& fileHandle){ //get full path name string completeFileName = getFullPathName(fileName); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #ifdef USE_COMPRESSION // check for gzipped or bzipped file if (endsWith(completeFileName, ".gz") || endsWith(completeFileName, ".bz2")) { @@ -895,7 +895,7 @@ int MothurOut::renameFile(string oldName, string newName){ int exist = openInputFile(newName, inTest, ""); inTest.close(); - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if (exist == 0) { //you could open it so you want to delete it string command = "rm " + newName; system(command.c_str()); @@ -922,7 +922,7 @@ int MothurOut::openOutputFile(string fileName, ofstream& fileHandle){ try { string completeFileName = getFullPathName(fileName); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #ifdef USE_COMPRESSION // check for gzipped file if (endsWith(completeFileName, ".gz") || endsWith(completeFileName, ".bz2")) { @@ -998,7 +998,7 @@ string MothurOut::sortFile(string distFile, string outputDir){ //if you can, use the unix sort since its been optimized for years - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) string command = "sort -n -k +3 " + distFile + " -o " + outfile; system(command.c_str()); #else //you are stuck with my best attempt... @@ -1201,7 +1201,7 @@ vector MothurOut::divideFile(string filename, int& proc) { fclose (pFile); } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //estimate file breaks unsigned long long chunkSize = 0; diff --git a/myseqdist.cpp b/myseqdist.cpp index f5c8b40..78255d8 100644 --- a/myseqdist.cpp +++ b/myseqdist.cpp @@ -46,7 +46,7 @@ int correctDist::addSeq(string seqName, string seqSeq){ /**************************************************************************************************/ int correctDist::execute(string distanceFileName){ try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else processors = 1; #endif @@ -146,7 +146,7 @@ vector correctDist::fixSequence(string sequence){ int correctDist::createProcess(string distanceFileName){ try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 1; vector processIDs; diff --git a/myutils.cpp b/myutils.cpp index 226b0f6..b184649 100755 --- a/myutils.cpp +++ b/myutils.cpp @@ -11,7 +11,7 @@ #include #include -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #include #include #include @@ -139,7 +139,7 @@ bool myisatty(int fd) return isatty(fd) != 0; } -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else //#ifdef BIT_VERSION //#include @@ -176,7 +176,7 @@ void LogStdioFileState(FILE *f) Log("fpos %ld (retval %d)\n", (long) fpos, fgetpos_retval); // Log("eof %d\n", _eof(fd)); #endif -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else #ifdef BIT_VERSION __int64 pos64 = _ftelli64(f); @@ -612,7 +612,7 @@ void Die(const char *Format, ...) fprintf(stderr, "\n---Fatal error---\n%s\n", szStr); Log("\n---Fatal error---\n%s\n", szStr); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else //if (IsDebuggerPresent()) // __debugbreak(); @@ -1205,7 +1205,7 @@ static void AddOpt(const OptInfo &Opt) g_Opts.insert(Opt); } -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else #pragma warning(disable: 4505) // unreferenced local function #endif diff --git a/otuassociationcommand.cpp b/otuassociationcommand.cpp index 4b55964..b520ca6 100644 --- a/otuassociationcommand.cpp +++ b/otuassociationcommand.cpp @@ -300,18 +300,6 @@ int OTUAssociationCommand::process(vector& lookup){ for (int k = 0; k < i; k++) { if (m->control_pressed) { out.close(); return 0; } - - /*cout << m->binLabelsInFile[i] << " <- c(" << xy[i][0]; - for (int l = 1; l < xy[i].size(); l++){ - cout << ", " << xy[i][l]; - } - cout << ")\n"; - - cout << m->binLabelsInFile[k] << " <- c(" << xy[k][0]; - for (int l = 1; l < xy[k].size(); l++){ - cout << ", " << xy[k][l]; - } - cout << ")\n";*/ double coef = 0.0; double sig = 0.0; diff --git a/pairwiseseqscommand.cpp b/pairwiseseqscommand.cpp index ed11dfb..98b0fde 100644 --- a/pairwiseseqscommand.cpp +++ b/pairwiseseqscommand.cpp @@ -393,7 +393,7 @@ int PairwiseSeqsCommand::execute(){ if (output != "square"){ driverMPI(start, end, (outputFile + toString(pid) + ".temp"), size); } else { driverMPI(start, end, (outputFile + toString(pid) + ".temp"), size, output); } - if (m->control_pressed) { delete distCalculator; return 0; } + if (m->control_pressed) { return 0; } //tell parent you are done. MPI_Send(&size, 1, MPI_LONG, 0, tag, MPI_COMM_WORLD); @@ -402,7 +402,7 @@ int PairwiseSeqsCommand::execute(){ MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case #else - //#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + //#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //if you don't need to fork anything if(processors == 1){ if (output != "square") { driver(0, numSeqs, outputFile, cutoff); } @@ -494,7 +494,7 @@ void PairwiseSeqsCommand::createProcesses(string filename) { int process = 1; processIDS.clear(); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want @@ -991,6 +991,22 @@ int PairwiseSeqsCommand::driverMPI(int startLine, int endLine, string file, unsi alignment = new NeedlemanOverlap(gapOpen, match, misMatch, longestBase); } + ValidCalculators validCalculator; + Dist* distCalculator; + if (countends) { + if (validCalculator.isValidCalculator("distance", Estimators[0]) == true) { + if (Estimators[0] == "nogaps") { distCalculator = new ignoreGaps(); } + else if (Estimators[0] == "eachgap") { distCalculator = new eachGapDist(); } + else if (Estimators[0] == "onegap") { distCalculator = new oneGapDist(); } + } + }else { + if (validCalculator.isValidCalculator("distance", Estimators[0]) == true) { + if (Estimators[0] == "nogaps") { distCalculator = new ignoreGaps(); } + else if (Estimators[0] == "eachgap"){ distCalculator = new eachGapIgnoreTermGapDist(); } + else if (Estimators[0] == "onegap") { distCalculator = new oneGapIgnoreTermGapDist(); } + } + } + string outputString = ""; size = 0; diff --git a/pairwiseseqscommand.h b/pairwiseseqscommand.h index ba82f47..e75f63c 100644 --- a/pairwiseseqscommand.h +++ b/pairwiseseqscommand.h @@ -115,7 +115,7 @@ struct pairwiseData { }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MyPairwiseSquareThreadFunction(LPVOID lpParam){ pairwiseData* pDataArray; diff --git a/parsefastaqcommand.cpp b/parsefastaqcommand.cpp index 730873a..e6d7ce6 100644 --- a/parsefastaqcommand.cpp +++ b/parsefastaqcommand.cpp @@ -33,8 +33,10 @@ string ParseFastaQCommand::getHelpString(){ try { string helpString = ""; helpString += "The fastq.info command reads a fastq file and creates a fasta and quality file.\n"; - helpString += "The fastq.info command parameter is fastq, and it is required.\n"; + helpString += "The fastq.info command parameters are fastq, fasta and qfile; fastq is required.\n"; helpString += "The fastq.info command should be in the following format: fastq.info(fastaq=yourFastaQFile).\n"; + helpString += "The fasta parameter allows you to indicate whether you want a fasta file generated. Default=T.\n"; + helpString += "The qfile parameter allows you to indicate whether you want a quality file generated. Default=T.\n"; helpString += "Example fastq.info(fastaq=test.fastaq).\n"; helpString += "Note: No spaces between parameter labels (i.e. fastq), '=' and yourFastQFile.\n"; return helpString; diff --git a/parsimony.cpp b/parsimony.cpp index 49a7350..d26bc27 100644 --- a/parsimony.cpp +++ b/parsimony.cpp @@ -54,7 +54,7 @@ EstOutput Parsimony::getValues(Tree* t, int p, string o) { } } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if(processors == 1){ data = driver(t, namesOfGroupCombos, 0, namesOfGroupCombos.size()); }else{ @@ -91,7 +91,7 @@ EstOutput Parsimony::getValues(Tree* t, int p, string o) { EstOutput Parsimony::createProcesses(Tree* t, vector< vector > namesOfGroupCombos) { try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 1; vector processIDS; diff --git a/phylodiversitycommand.cpp b/phylodiversitycommand.cpp index 2b15d11..abf9591 100644 --- a/phylodiversitycommand.cpp +++ b/phylodiversitycommand.cpp @@ -353,7 +353,7 @@ int PhyloDiversityCommand::execute(){ if (numSampledList.count(diversity[mGroups[j]].size()-1) == 0) { numSampledList.insert(diversity[mGroups[j]].size()-1); } } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if(processors == 1){ driver(trees[i], diversity, sumDiversity, iters, increment, randomLeaf, numSampledList, outCollect, outSum, true); }else{ @@ -403,7 +403,7 @@ int PhyloDiversityCommand::execute(){ //********************************************************************************************************************** int PhyloDiversityCommand::createProcesses(vector& procIters, Tree* t, map< string, vector >& div, map >& sumDiv, int numIters, int increment, vector& randomLeaf, set& numSampledList, ofstream& outCollect, ofstream& outSum){ try { - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 1; vector processIDS; diff --git a/pintail.cpp b/pintail.cpp index af64c25..b9f2434 100644 --- a/pintail.cpp +++ b/pintail.cpp @@ -74,7 +74,7 @@ int Pintail::doPrep() { #ifdef USE_MPI //do nothing #else - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //find breakup of templatefile for quantiles if (processors == 1) { templateLines.push_back(new linePair(0, templateSeqs.size())); } else { @@ -529,7 +529,7 @@ Sequence* Pintail::findPairs(Sequence* q) { //************************************************************************************************** void Pintail::createProcessesQuan() { try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 1; vector processIDS; diff --git a/preclustercommand.cpp b/preclustercommand.cpp index 58fd997..3208087 100644 --- a/preclustercommand.cpp +++ b/preclustercommand.cpp @@ -302,7 +302,7 @@ int PreClusterCommand::createProcessesGroups(SequenceParser* parser, string newF lines.push_back(linePair(startIndex, endIndex)); } -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want while (process != processors) { diff --git a/preclustercommand.h b/preclustercommand.h index 3712302..64efc7f 100644 --- a/preclustercommand.h +++ b/preclustercommand.h @@ -113,7 +113,7 @@ struct preClusterData { }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MyPreclusterThreadFunction(LPVOID lpParam){ preClusterData* pDataArray; diff --git a/rarefact.cpp b/rarefact.cpp index ca105b7..6a9cb31 100644 --- a/rarefact.cpp +++ b/rarefact.cpp @@ -24,7 +24,7 @@ int Rarefact::getCurve(float percentFreq = 0.01, int nIters = 1000){ if (percentFreq < 1.0) { increment = numSeqs * percentFreq; } else { increment = percentFreq; } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if(processors == 1){ driver(rcd, increment, nIters); }else{ @@ -114,7 +114,7 @@ int Rarefact::driver(RarefactionCurveData* rcd, int increment, int nIters = 1000 int Rarefact::createProcesses(vector& procIters, RarefactionCurveData* rcd, int increment) { try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 1; vector processIDS; diff --git a/rarefactcommand.cpp b/rarefactcommand.cpp index b8c1c6f..47d55a0 100644 --- a/rarefactcommand.cpp +++ b/rarefactcommand.cpp @@ -287,7 +287,7 @@ int RareFactCommand::execute(){ if (m->control_pressed) { return 0; } - map nameMap; + map file2Group; //index in outputNames[i] -> group for (int p = 0; p < inputFileNames.size(); p++) { string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p])); @@ -296,7 +296,6 @@ int RareFactCommand::execute(){ if (inputFileNames.size() > 1) { m->mothurOutEndLine(); m->mothurOut("Processing group " + groups[p]); m->mothurOutEndLine(); m->mothurOutEndLine(); - nameMap[fileNameRoot] = groups[p]; } int i; ValidCalculators validCalculator; @@ -352,6 +351,7 @@ int RareFactCommand::execute(){ rDisplays.push_back(new RareDisplay(new NSeqs(), new ThreeColumnFile(fileNameRoot+"r_nseqs"))); outputNames.push_back(fileNameRoot+"r_nseqs"); outputTypes["r_nseqs"].push_back(fileNameRoot+"r_nseqs"); } + file2Group[outputNames.size()-1] = groups[p]; } } @@ -450,7 +450,7 @@ int RareFactCommand::execute(){ if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } //create summary file containing all the groups data for each label - this function just combines the info from the files already created. - if ((sharedfile != "") && (groupMode)) { outputNames = createGroupFile(outputNames, nameMap); } + if ((sharedfile != "") && (groupMode)) { outputNames = createGroupFile(outputNames, file2Group); } if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; } @@ -467,7 +467,7 @@ int RareFactCommand::execute(){ } } //********************************************************************************************************************** -vector RareFactCommand::createGroupFile(vector& outputNames, map nameMap) { +vector RareFactCommand::createGroupFile(vector& outputNames, map file2Group) { try { vector newFileNames; @@ -485,7 +485,7 @@ vector RareFactCommand::createGroupFile(vector& outputNames, map newLine += "\tGroup" + labels.substr(labels.find_first_of('\t')); - typesFiles[extension].push_back(outputNames[i]); + typesFiles[extension].push_back(outputNames[i]+"_"+file2Group[i]); string combineFileName = outputDir + m->getRootName(m->getSimpleName(sharedfile)) + "groups" + extension; @@ -513,23 +513,26 @@ vector RareFactCommand::createGroupFile(vector& outputNames, map int maxLines = 0; int numColumns = 0; for (int i=0; iopenInputFile(thisTypesFiles[i], temp); + m->openInputFile(thisfilename, temp); //read through first line - labels m->getline(temp); m->gobble(temp); vector thisFilesLines; - string fileNameRoot = m->getRootName(thisTypesFiles[i]); - map::iterator itName = nameMap.find(fileNameRoot); - string group = ""; - if (itName != nameMap.end()) { - group = itName->second; - }else { - group = "not found" + i; - m->mothurOut("[ERROR]: can't parse filename."); m->mothurOutEndLine(); - } + //string fileNameRoot = m->getRootName(thisTypesFiles[i]); + //map::iterator itName = nameMap.find(fileNameRoot); + //string group = ""; + //if (itName != nameMap.end()) { + // group = itName->second; + //}else { + // group = "not found" + i; + // m->mothurOut("[ERROR]: can't parse filename."); m->mothurOutEndLine(); + //} thisFilesLines.push_back(group); int count = 1; @@ -555,7 +558,7 @@ vector RareFactCommand::createGroupFile(vector& outputNames, map if (maxLines < thisFilesLines.size()) { maxLines = thisFilesLines.size(); } temp.close(); - m->mothurRemove(thisTypesFiles[i]); + m->mothurRemove(thisfilename); } diff --git a/rarefactcommand.h b/rarefactcommand.h index 72d2415..6aaa3de 100644 --- a/rarefactcommand.h +++ b/rarefactcommand.h @@ -51,7 +51,7 @@ private: string outputDir; vector parseSharedFile(string); - vector createGroupFile(vector&, map); + vector createGroupFile(vector&, map); }; #endif diff --git a/screenseqscommand.cpp b/screenseqscommand.cpp index 686bdaf..09ff9b5 100644 --- a/screenseqscommand.cpp +++ b/screenseqscommand.cpp @@ -288,7 +288,7 @@ int ScreenSeqsCommand::execute(){ getSummary(positions); } else { - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) positions = m->divideFile(fastafile, processors); for (int i = 0; i < (positions.size()-1); i++) { lines.push_back(linePair(positions[i], positions[(i+1)])); } #else @@ -296,6 +296,7 @@ int ScreenSeqsCommand::execute(){ else { int numFastaSeqs = 0; positions = m->setFilePosFasta(fastafile, numFastaSeqs); + if (positions.size() < processors) { processors = positions.size(); } //figure out how many sequences you have to process int numSeqsPerProcessor = numFastaSeqs / processors; @@ -611,7 +612,7 @@ int ScreenSeqsCommand::getSummary(vector& positions){ vector longHomoPolymer; vector positions; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) positions = m->divideFile(fastafile, processors); for (int i = 0; i < (positions.size()-1); i++) { lines.push_back(linePair(positions[i], positions[(i+1)])); } #else @@ -619,6 +620,7 @@ int ScreenSeqsCommand::getSummary(vector& positions){ else { int numFastaSeqs = 0; positions = m->setFilePosFasta(fastafile, numFastaSeqs); + if (positions.size() < processors) { processors = positions.size(); } //figure out how many sequences you have to process int numSeqsPerProcessor = numFastaSeqs / processors; @@ -638,7 +640,7 @@ int ScreenSeqsCommand::getSummary(vector& positions){ driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile, lines[0]); #else int numSeqs = 0; - //#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + //#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if(processors == 1){ numSeqs = driverCreateSummary(startPosition, endPosition, seqLength, ambigBases, longHomoPolymer, fastafile, lines[0]); }else{ @@ -743,7 +745,7 @@ int ScreenSeqsCommand::driverCreateSummary(vector& startPosition, vectormothurOut("Optimizing sequence: " + toString(count)); m->mothurOutEndLine(); } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) unsigned long long pos = in.tellg(); if ((pos == -1) || (pos >= filePos.end)) { break; } #else @@ -769,7 +771,7 @@ int ScreenSeqsCommand::createProcessesCreateSummary(vector& startPosition, int num = 0; vector processIDS; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want while (process != processors) { @@ -1163,7 +1165,7 @@ int ScreenSeqsCommand::driver(linePair filePos, string goodFName, string badAccn count++; } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) unsigned long long pos = inFASTA.tellg(); if ((pos == -1) || (pos >= filePos.end)) { break; } #else @@ -1275,7 +1277,7 @@ int ScreenSeqsCommand::createProcesses(string goodFileName, string badAccnos, st int process = 1; int num = 0; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want while (process != processors) { diff --git a/screenseqscommand.h b/screenseqscommand.h index 007b6d6..cbeed46 100644 --- a/screenseqscommand.h +++ b/screenseqscommand.h @@ -131,7 +131,7 @@ struct sumScreenData { /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MySumThreadFunction(LPVOID lpParam){ sumData* pDataArray; diff --git a/seqerrorcommand.cpp b/seqerrorcommand.cpp index d8ebe50..9bda05a 100644 --- a/seqerrorcommand.cpp +++ b/seqerrorcommand.cpp @@ -298,7 +298,7 @@ int SeqErrorCommand::execute(){ if(qualFileName == "") { qLines = lines; rLines = lines; } //fills with duds int numSeqs = 0; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if(processors == 1){ numSeqs = driver(queryFileName, qualFileName, reportFileName, errorSummaryFileName, errorSeqFileName, errorChimeraFileName, lines[0], qLines[0], rLines[0]); }else{ @@ -366,7 +366,7 @@ int SeqErrorCommand::createProcesses(string filename, string qFileName, string r processIDS.clear(); map >::iterator it; int num = 0; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want while (process != processors) { @@ -739,7 +739,7 @@ int SeqErrorCommand::driver(string filename, string qFileName, string rFileName, index++; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) unsigned long long pos = queryFile.tellg(); if ((pos == -1) || (pos >= line.end)) { break; } #else @@ -1215,7 +1215,7 @@ void SeqErrorCommand::printQualityFR(vector > qualForwardMap, vector int SeqErrorCommand::setLines(string filename, string qfilename, string rfilename, vector& fastaFilePos, vector& qfileFilePos, vector& rfileFilePos) { try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //set file positions for fasta file fastaFilePos = m->divideFile(filename, processors); diff --git a/seqsummarycommand.cpp b/seqsummarycommand.cpp index 647334a..68d3bf5 100644 --- a/seqsummarycommand.cpp +++ b/seqsummarycommand.cpp @@ -286,11 +286,12 @@ int SeqSummaryCommand::execute(){ MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case #else vector positions; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) positions = m->divideFile(fastafile, processors); for (int i = 0; i < (positions.size()-1); i++) { lines.push_back(new linePair(positions[i], positions[(i+1)])); } #else positions = m->setFilePosFasta(fastafile, numSeqs); + if (positions.size() < processors) { processors = positions.size(); } //figure out how many sequences you have to process int numSeqsPerProcessor = numSeqs / processors; @@ -433,7 +434,7 @@ int SeqSummaryCommand::driverCreateSummary(vector& startPosition, vector= filePos->end)) { break; } #else @@ -529,7 +530,7 @@ int SeqSummaryCommand::createProcessesCreateSummary(vector& startPosition, int num = 0; processIDS.clear(); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want while (process != processors) { diff --git a/seqsummarycommand.h b/seqsummarycommand.h index dcae434..d8837a3 100644 --- a/seqsummarycommand.h +++ b/seqsummarycommand.h @@ -91,7 +91,7 @@ struct seqSumData { }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MySeqSumThreadFunction(LPVOID lpParam){ seqSumData* pDataArray; diff --git a/setdircommand.cpp b/setdircommand.cpp index 67a1f59..081a306 100644 --- a/setdircommand.cpp +++ b/setdircommand.cpp @@ -122,7 +122,7 @@ int SetDirectoryCommand::execute(){ }else { //add / to name if needed string lastChar = output.substr(output.length()-1); - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if (lastChar != "/") { output += "/"; } #else if (lastChar != "\\") { output += "\\"; } @@ -154,7 +154,7 @@ int SetDirectoryCommand::execute(){ }else { //add / to name if needed string lastChar = input.substr(input.length()-1); - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if (lastChar != "/") { input += "/"; } #else if (lastChar != "\\") { input += "\\"; } @@ -196,7 +196,7 @@ int SetDirectoryCommand::execute(){ }else { //add / to name if needed string lastChar = tempdefault.substr(tempdefault.length()-1); - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if (lastChar != "/") { tempdefault += "/"; } #else if (lastChar != "\\") { tempdefault += "\\"; } diff --git a/sffinfocommand.cpp b/sffinfocommand.cpp index e008ce4..40dd09b 100644 --- a/sffinfocommand.cpp +++ b/sffinfocommand.cpp @@ -298,7 +298,6 @@ SffInfoCommand::SffInfoCommand(string option) { //********************************************************************************************************************** int SffInfoCommand::execute(){ try { - if (abort == true) { if (calledHelp) { return 0; } return 2; } for (int s = 0; s < filenames.size(); s++) { @@ -406,7 +405,9 @@ int SffInfoCommand::extractSffInfo(string input, string accnos){ //read data seqRead read; readSeqData(in, read, header.numFlowsPerRead, readheader.numBases); - + bool okay = sanityCheck(readheader, read); + if (!okay) { break; } + //if you have provided an accosfile and this seq is not in it, then dont print if (seqNames.size() != 0) { if (seqNames.count(readheader.name) == 0) { print = false; } } @@ -609,7 +610,7 @@ int SffInfoCommand::readSeqData(ifstream& in, seqRead& read, int numFlowReads, i in.read(buffer, 2); read.flowgram[i] = be_int2(*(unsigned short *)(&buffer)); } - + //read flowIndex read.flowIndex.resize(numBases); for (int i = 0; i < numBases; i++) { @@ -741,11 +742,39 @@ int SffInfoCommand::printHeader(ofstream& out, Header& header) { exit(1); } } - +//********************************************************************************************************************** +bool SffInfoCommand::sanityCheck(Header& header, seqRead& read) { + try { + bool okay = true; + string message = "[WARNING]: Your sff file may be corrupted! Sequence: " + header.name + "\n"; + + if (header.clipQualLeft > read.bases.length()) { + okay = false; message += "Clip Qual Left = " + toString(header.clipQualLeft) + ", but we only read " + toString(read.bases.length()) + " bases.\n"; + } + if (header.clipQualRight > read.bases.length()) { + okay = false; message += "Clip Qual Right = " + toString(header.clipQualRight) + ", but we only read " + toString(read.bases.length()) + " bases.\n"; + } + if (header.clipQualLeft > read.qualScores.size()) { + okay = false; message += "Clip Qual Left = " + toString(header.clipQualLeft) + ", but we only read " + toString(read.qualScores.size()) + " quality scores.\n"; + } + if (header.clipQualRight > read.qualScores.size()) { + okay = false; message += "Clip Qual Right = " + toString(header.clipQualRight) + ", but we only read " + toString(read.qualScores.size()) + " quality scores.\n"; + } + + if (okay == false) { + m->mothurOut(message); m->mothurOutEndLine(); + } + + return okay; + } + catch(exception& e) { + m->errorOut(e, "SffInfoCommand", "sanityCheck"); + exit(1); + } +} //********************************************************************************************************************** int SffInfoCommand::printSffTxtSeqData(ofstream& out, seqRead& read, Header& header) { try { - out << "Flowgram: "; for (int i = 0; i < read.flowgram.size(); i++) { out << setprecision(2) << (read.flowgram[i]/(float)100) << '\t'; } @@ -775,10 +804,9 @@ int SffInfoCommand::printSffTxtSeqData(ofstream& out, seqRead& read, Header& hea //********************************************************************************************************************** int SffInfoCommand::printFastaSeqData(ofstream& out, seqRead& read, Header& header) { try { - string seq = read.bases; - if (trim) { + if (trim) { if(header.clipQualRight < header.clipQualLeft){ seq = "NNNN"; } diff --git a/sffinfocommand.h b/sffinfocommand.h index 903a589..837435b 100644 --- a/sffinfocommand.h +++ b/sffinfocommand.h @@ -82,7 +82,7 @@ private: bool abort, fasta, qual, trim, flow, sfftxt, hasAccnos; int mycount; set seqNames; - + //extract sff file functions int extractSffInfo(string, string); int readCommonHeader(ifstream&, CommonHeader&); @@ -98,7 +98,8 @@ private: int printQualSeqData(ofstream&, seqRead&, Header&); int readAccnosFile(string); int parseSffTxt(); - + bool sanityCheck(Header&, seqRead&); + //parsesfftxt file functions int parseHeaderLineToInt(ifstream&); vector parseHeaderLineToFloatVector(ifstream&, int); diff --git a/shhhercommand.cpp b/shhhercommand.cpp index 5d8263c..28e6615 100644 --- a/shhhercommand.cpp +++ b/shhhercommand.cpp @@ -1823,7 +1823,7 @@ int ShhherCommand::execute(){ if (numFiles < processors) { processors = numFiles; } -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if (processors == 1) { driver(flowFileVector, compositeFASTAFileName, compositeNamesFileName, 0, flowFileVector.size()); } else { createProcesses(flowFileVector); } //each processor processes one file #else @@ -1869,7 +1869,7 @@ int ShhherCommand::createProcesses(vector filenames){ lines.push_back(linePair(startIndex, endIndex)); } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want while (process != processors) { diff --git a/shhhercommand.h b/shhhercommand.h index a7af7da..c9772af 100644 --- a/shhhercommand.h +++ b/shhhercommand.h @@ -202,7 +202,7 @@ struct shhhFlowsData { }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI ShhhFlowsThreadFunction(LPVOID lpParam){ shhhFlowsData* pDataArray; diff --git a/shhhseqscommand.cpp b/shhhseqscommand.cpp index 7250419..f6bfd81 100644 --- a/shhhseqscommand.cpp +++ b/shhhseqscommand.cpp @@ -364,7 +364,7 @@ vector ShhhSeqsCommand::createProcessesGroups(SequenceParser& parser, st lines.push_back(linePair(startIndex, endIndex)); } -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want while (process != processors) { diff --git a/shhhseqscommand.h b/shhhseqscommand.h index 1b0211a..7174ac7 100644 --- a/shhhseqscommand.h +++ b/shhhseqscommand.h @@ -97,7 +97,7 @@ struct shhhseqsData { }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MyShhhSeqsThreadFunction(LPVOID lpParam){ shhhseqsData* pDataArray; diff --git a/summaryqualcommand.cpp b/summaryqualcommand.cpp index a0d786f..5c17510 100644 --- a/summaryqualcommand.cpp +++ b/summaryqualcommand.cpp @@ -162,7 +162,7 @@ int SummaryQualCommand::execute(){ if (namefile != "") { nameMap = m->readNames(namefile); } vector positions; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) positions = m->divideFile(qualfile, processors); for (int i = 0; i < (positions.size()-1); i++) { lines.push_back(linePair(positions[i], positions[(i+1)])); } #else @@ -170,6 +170,7 @@ int SummaryQualCommand::execute(){ lines.push_back(linePair(0, 1000)); }else { positions = m->setFilePosFasta(qualfile, numSeqs); + if (positions.size() < processors) { processors = positions.size(); } //figure out how many sequences you have to process int numSeqsPerProcessor = numSeqs / processors; @@ -267,7 +268,7 @@ int SummaryQualCommand::driverCreateSummary(vector& position, vector& count += num; } -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) unsigned long long pos = in.tellg(); if ((pos == -1) || (pos >= filePos.end)) { break; } #else @@ -291,7 +292,7 @@ int SummaryQualCommand::createProcessesCreateSummary(vector& position, vect int numSeqs = 0; processIDS.clear(); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want while (process != processors) { diff --git a/summaryqualcommand.h b/summaryqualcommand.h index d7aa39a..bbd103c 100644 --- a/summaryqualcommand.h +++ b/summaryqualcommand.h @@ -81,7 +81,7 @@ struct seqSumQualData { }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MySeqSumQualThreadFunction(LPVOID lpParam){ seqSumQualData* pDataArray; diff --git a/summarysharedcommand.cpp b/summarysharedcommand.cpp index f63a2ad..8c4ea0d 100644 --- a/summarysharedcommand.cpp +++ b/summarysharedcommand.cpp @@ -484,7 +484,7 @@ int SummarySharedCommand::process(vector thisLookup, string int process = 1; vector processIDS; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want while (process != processors) { int pid = fork(); diff --git a/summarysharedcommand.h b/summarysharedcommand.h index 2ffe90d..fbfea7b 100644 --- a/summarysharedcommand.h +++ b/summarysharedcommand.h @@ -121,7 +121,7 @@ struct summarySharedData { } }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MySummarySharedThreadFunction(LPVOID lpParam){ summarySharedData* pDataArray; diff --git a/trialSwap2.cpp b/trialSwap2.cpp index 750c89f..c580436 100644 --- a/trialSwap2.cpp +++ b/trialSwap2.cpp @@ -4,7 +4,7 @@ //The sum_of_squares, havel_hakimi and calc_c_score algorithms have been adapted from I. Miklos and J. Podani. 2004. Randomization of presence-absence matrices: comments and new algorithms. Ecology 85:86-92. -/**************************************************************************************************/ +/************************************************************************************************** int TrialSwap2::intrand(int n){ try { double z; @@ -644,102 +644,6 @@ int TrialSwap2::sim8(vector columntotal, vector rowtotal, vector rowtotal,vector columntotal,vector > &co_matrix) -{ - try { - int nrows = co_matrix.size(); - int ncols = co_matrix[0].size(); - int i,j,k; - vector r1; r1.resize(nrows,0); - vector c; c.resize(ncols,0); - vector c1; c1.resize(ncols,0); - - - for(i=0;icontrol_pressed) { return 0; } - i=intrand(nrows); - while(r1[i]==0) { - if (m->control_pressed) { return 0; } - i=intrand(nrows); - } - r1[i]=0; - sho(c,c1,ncols); - for(j=0;jcontrol_pressed) { return 0; } - co_matrix[i][c1[j]]=1; - c[j]--; - if(c[j]<0) - m->mothurOut("Uhh! " + toString(c1[j]) + "\n"); - } - } - return 0; - } - catch(exception& e) { - m->errorOut(e, "TrialSwap2", "havel_hakimi"); - exit(1); - } -} -/**************************************************************************************************/ -int TrialSwap2::sho(vector c, vector c1, int k) -{ - try { - int i,j,temp; - - for(j=k-1;j>0;j--) - { - if (m->control_pressed) { return 0; } - for(i=0;icontrol_pressed) { return 0; } - i=intrand(k-1); - if(c[i]==c[i+1]) - { - temp=c[i]; - c[i]=c[i+1]; - c[i+1]=temp; - temp=c1[i]; - c1[i]=c1[i+1]; - c1[i+1]=temp; - } - } - return(0); - } - catch(exception& e) { - m->errorOut(e, "TrialSwap2", "sho"); - exit(1); - } -} -/**************************************************************************************************/ double TrialSwap2::calc_c_score (vector > &co_matrix,vector rowtotal) { try { @@ -749,7 +653,9 @@ double TrialSwap2::calc_c_score (vector > &co_matrix,vector ro double normcscore = 0.0; int nonzeros = 0; int ncols = co_matrix[0].size(); int nrows = rowtotal.size(); - vector > s(nrows, vector(nrows,0.0)); //only fill half the matrix + vector > s; s.resize(nrows); + for (int i = 0; i < nrows; i++) { s[i].resize(nrows,0.0); }//only fill half the matrix + for(int i=0;i > &co_matrix, vector rowt int cunits=0; //int s[nrows][ncols]; int ncols = co_matrix[0].size(); int nrows = rowtotal.size(); - vector > s(nrows, vector(nrows,0)); //only fill half the matrix + vector > s; s.resize(nrows); + for (int i = 0; i < nrows; i++) { s[i].resize(nrows,0); }//only fill half the matrix for(int i=0;i > &co_matrix) try { int ncols = co_matrix[0].size(); int nrows = co_matrix.size(); int i, j, k, l; - i=intrand(nrows); - while((j = intrand(nrows) ) == i ) {;if (m->control_pressed) { return 0; }} - k=intrand(ncols); - while((l = intrand(ncols) ) == k ) {;if (m->control_pressed) { return 0; }} + i = m->getRandomIndex(nrows-1); + while((j = m->getRandomIndex(nrows-1) ) == i ) {;if (m->control_pressed) { return 0; }} + k = m->getRandomIndex(ncols-1); + while((l = m->getRandomIndex(ncols-1)) == k ) {;if (m->control_pressed) { return 0; }} + //cout << co_matrix[i][k] << " " << co_matrix[j][l] << endl; //cout << co_matrix[i][l] << " " << co_matrix[j][k] << endl; //cout << co_matrix[i][l] << " " << co_matrix[j][k] << endl; @@ -1074,8 +982,8 @@ int TrialSwap2::update_row_col_totals(vector > &co_matrix, vector tmpcolumntotal(ncols, 0); - vector tmprowtotal(nrows, 0); + vector tmpcolumntotal; tmpcolumntotal.resize(ncols, 0); + vector tmprowtotal; tmprowtotal.resize(nrows, 0); int rowcount = 0; @@ -1109,431 +1017,8 @@ int TrialSwap2::update_row_col_totals(vector > &co_matrix, vector > co_matrix;//[nrows][ncols]; - vector > initmatrix; - vector tmprow; - vector stats; - int tmpnrows = nrows; - - for (int row1=0; row1> tmp; - - for (int col=0; col> tmp; - //cout << tmp << endl; - if (atoi(tmp.c_str()) > 0) - tmprow.push_back(1); - else - tmprow.push_back(0); - } - if (accumulate( tmprow.begin(), tmprow.end(), 0 ) == 0) - { - tmpnrows--; - } - else - initmatrix.push_back(tmprow); - //add the row to the matrix - //initmatrix.push_back(tmprow); - tmprow.clear(); - //cout << tmprow << endl; - } - - infile3.close(); - nrows = tmpnrows; - - //print init matrix - /* cout << "original matrix:" << endl; - - for (int i = 0; i < nrows; i++) - { - for (int j = 0; j < ncols; j++) - { - cout << initmatrix[i][j]; - } - cout << endl; - } */ - - //for (i=0;i columntotal(ncols, 0); - vector initcolumntotal(ncols, 0); - vector initrowtotal(nrows, 0); - vector rowtotal(nrows, 0); - - transpose_matrix(initmatrix,co_matrix); - //remove degenerate rows and cols - - //cout << "transposed matrix:" << endl; - int rowcount = 0; - for (int i = 0; i < nrows; i++) - { - for (int j = 0; j < ncols; j++) - { - if (co_matrix[i][j] == 1) - { - rowcount++; - columntotal[j]++; - } - //cout << co_matrix[i][j]; - } - //cout << " row total: " << rowcount << endl; - //cout << endl; - rowtotal[i] = rowcount; - rowcount = 0; - } - - initcolumntotal = rowtotal; - initrowtotal = columntotal; - - cout << endl; - - runs = atol(argv[2]); - int metric = atol(argv[3]); - int nullModel = atol(argv[4]); - double initscore; - update_row_col_totals(co_matrix, rowtotal, columntotal, ncols, nrows); - //do initial metric: checker, c score, v ratio or combo - switch(metric) - { - case 1: - //c score - initscore = calc_c_score(co_matrix, rowtotal); - cout << "initial c score: " << initscore << endl; - //print_matrix(co_matrix, nrows, ncols); - break; - - case 2: - //checker - initscore = calc_checker(co_matrix, rowtotal); - cout << "initial checker score: " << initscore << endl; - break; - - case 3: - //v ratio - initscore = calc_vratio(nrows, ncols, rowtotal, columntotal); - cout << "initial v ratio: " << initscore << endl; - break; - - case 4: - //combo - initscore = calc_combo(initrows, initcols, initmatrix); - cout << "initial combo score: " << initscore << endl; - //set co_matrix equal to initmatrix because combo requires row comparisons - co_matrix = initmatrix; - break; - - case 5: - //test! - - //print_matrix(co_matrix, nrows, ncols); - //sim1(nrows, ncols, co_matrix); - //sim2(nrows, ncols, co_matrix); - //sim3(initrows, initcols, initmatrix); - //sim4(columntotal, rowtotal, co_matrix); - //sim5(initcolumntotal, initmatrix); - //sim6(columntotal, co_matrix); - //sim7(initcolumntotal, initmatrix); - sim8(columntotal, rowtotal, co_matrix); - //print_matrix(initmatrix, initrows, initcols); - //print_matrix(co_matrix, nrows, ncols); - - break; - - default: - cout << "no metric selected!" << endl; - return 1; - - } - - //matrix initialization - //havel_hakimi(nrows, ncols, rowtotal, columntotal, co_matrix); - //sum_of_square(nrows, ncols, rowtotal, columntotal, co_matrix); - //co-matrix is now a random matrix with the same row and column totals as the initial matrix - - //null matrix burn in - cout << "initializing null matrix..."; - for(int l=0;l<10000;l++) - { - //swap_checkerboards (co_matrix); - //if(l%10 == 0) - switch(nullModel) - { - case 1: - // - sim1(nrows, ncols, co_matrix); - break; - - case 2: - //sim2 - sim2(nrows, ncols, co_matrix); - //sim2plus(nrows, ncols, initrowtotal, co_matrix); - break; - - case 3: - //sim3 - sim3(initrows, initcols, initmatrix); - //transpose_matrix(initmatrix,co_matrix); - co_matrix = initmatrix; - break; - - case 4: - //sim4 - sim4(columntotal, rowtotal, co_matrix); - break; - - case 5: - //sim5 - sim5(initcolumntotal, initrowtotal, initmatrix); - transpose_matrix(initmatrix,co_matrix); - //co_matrix = initmatrix; - break; - - case 6: - sim6(columntotal, co_matrix); - break; - - case 7: - //sim7(ncols, nrows, initrowtotal, co_matrix); - //transpose_matrix(initmatrix,co_matrix); - //co_matrix = initmatrix; - break; - - case 8: - sim8(columntotal, rowtotal, co_matrix); - break; - - case 9: - //swap_checkerboards - swap_checkerboards (co_matrix); - break; - default: - cout << "no null model selected!" << endl; - return 1; - } - } - cout << "done!" << endl; - - //generate null matrices and calculate the metrics - - cout << "run: " << endl; - for(int trial=0;trial, vector); int calc_checker (vector > &,vector); double calc_c_score (vector > &,vector); - int sho(vector,vector,int k); - int havel_hakimi(vector,vector,vector > &); - int intrand(int); int sim1 (vector > &); void sim2(vector >&); diff --git a/trimflowscommand.cpp b/trimflowscommand.cpp index c0c569c..00c4d94 100644 --- a/trimflowscommand.cpp +++ b/trimflowscommand.cpp @@ -235,7 +235,7 @@ int TrimFlowsCommand::execute(){ } vector flowFilePos; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) flowFilePos = getFlowFileBreaks(); for (int i = 0; i < (flowFilePos.size()-1); i++) { lines.push_back(new linePair(flowFilePos[i], flowFilePos[(i+1)])); @@ -468,7 +468,7 @@ int TrimFlowsCommand::driverCreateTrim(string flowFileName, string trimFlowFileN //report progress if((count) % 10000 == 0){ m->mothurOut(toString(count)); m->mothurOutEndLine(); } -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) unsigned long long pos = flowFile.tellg(); if ((pos == -1) || (pos >= line->end)) { break; } @@ -715,7 +715,7 @@ int TrimFlowsCommand::createProcessesCreateTrim(string flowFileName, string trim processIDS.clear(); int exitCommand = 1; -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 1; //loop through and create all the processes you want diff --git a/trimflowscommand.h b/trimflowscommand.h index 8c996dd..f4faacb 100644 --- a/trimflowscommand.h +++ b/trimflowscommand.h @@ -132,7 +132,7 @@ struct trimFlowData { }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MyTrimFlowThreadFunction(LPVOID lpParam){ trimFlowData* pDataArray; diff --git a/trimseqscommand.cpp b/trimseqscommand.cpp index 9913727..b0fa7a0 100644 --- a/trimseqscommand.cpp +++ b/trimseqscommand.cpp @@ -746,7 +746,7 @@ int TrimSeqsCommand::driverCreateTrim(string filename, string qFileName, string count++; } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) unsigned long long pos = inFASTA.tellg(); if ((pos == -1) || (pos >= line.end)) { break; } @@ -786,7 +786,7 @@ int TrimSeqsCommand::createProcessesCreateTrim(string filename, string qFileName int exitCommand = 1; processIDS.clear(); -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //loop through and create all the processes you want while (process != processors) { int pid = fork(); @@ -1027,7 +1027,7 @@ int TrimSeqsCommand::createProcessesCreateTrim(string filename, string qFileName } } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if(createGroup){ ifstream in; string tempFile = filename + toString(processIDS[i]) + ".num.temp"; @@ -1067,7 +1067,7 @@ int TrimSeqsCommand::setLines(string filename, string qfilename) { vector fastaFilePos; vector qfileFilePos; - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) //set file positions for fasta file fastaFilePos = m->divideFile(filename, processors); @@ -1157,6 +1157,7 @@ int TrimSeqsCommand::setLines(string filename, string qfilename) { }else{ int numFastaSeqs = 0; fastaFilePos = m->setFilePosFasta(filename, numFastaSeqs); + if (fastaFilePos.size() < processors) { processors = fastaFilePos.size(); } if (qfilename != "") { int numQualSeqs = 0; diff --git a/trimseqscommand.h b/trimseqscommand.h index 5006ce9..780b4c7 100644 --- a/trimseqscommand.h +++ b/trimseqscommand.h @@ -169,7 +169,7 @@ struct trimData { } }; /**************************************************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #else static DWORD WINAPI MyTrimThreadFunction(LPVOID lpParam){ trimData* pDataArray; diff --git a/unifracweightedcommand.cpp b/unifracweightedcommand.cpp index f9dc450..b3a54c9 100644 --- a/unifracweightedcommand.cpp +++ b/unifracweightedcommand.cpp @@ -342,7 +342,7 @@ int UnifracWeightedCommand::execute() { lines.clear(); - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if(processors != 1){ int numPairs = namesOfGroupCombos.size(); int numPairsPerProcessor = numPairs / processors; @@ -361,7 +361,7 @@ int UnifracWeightedCommand::execute() { //get scores for random trees for (int j = 0; j < iters; j++) { - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if(processors == 1){ driver(T[i], namesOfGroupCombos, 0, namesOfGroupCombos.size(), rScores); }else{ @@ -459,7 +459,7 @@ int UnifracWeightedCommand::execute() { int UnifracWeightedCommand::createProcesses(Tree* t, vector< vector > namesOfGroupCombos, vector< vector >& scores) { try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 1; vector processIDS; diff --git a/unweighted.cpp b/unweighted.cpp index 431323f..d4fd327 100644 --- a/unweighted.cpp +++ b/unweighted.cpp @@ -48,7 +48,7 @@ EstOutput Unweighted::getValues(Tree* t, int p, string o) { } } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if(processors == 1){ data = driver(t, namesOfGroupCombos, 0, namesOfGroupCombos.size()); }else{ @@ -83,7 +83,7 @@ EstOutput Unweighted::getValues(Tree* t, int p, string o) { EstOutput Unweighted::createProcesses(Tree* t, vector< vector > namesOfGroupCombos) { try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 1; vector processIDS; @@ -291,7 +291,7 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB, int p, st } } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if(processors == 1){ data = driver(t, namesOfGroupCombos, 0, namesOfGroupCombos.size(), true); }else{ @@ -326,7 +326,7 @@ EstOutput Unweighted::getValues(Tree* t, string groupA, string groupB, int p, st EstOutput Unweighted::createProcesses(Tree* t, vector< vector > namesOfGroupCombos, bool usingGroups) { try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 1; vector processIDS; diff --git a/weighted.cpp b/weighted.cpp index d8a4b85..7a31da4 100644 --- a/weighted.cpp +++ b/weighted.cpp @@ -34,7 +34,7 @@ EstOutput Weighted::getValues(Tree* t, int p, string o) { } } - #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) + #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) if(processors == 1){ data = driver(t, namesOfGroupCombos, 0, namesOfGroupCombos.size()); }else{ @@ -69,7 +69,7 @@ EstOutput Weighted::getValues(Tree* t, int p, string o) { EstOutput Weighted::createProcesses(Tree* t, vector< vector > namesOfGroupCombos) { try { -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) int process = 1; vector processIDS; -- 2.39.2