[med-svn] [mothur] 01/04: New upstream version 1.39.4
Tomasz Buchert
tomasz at moszumanska.debian.org
Tue Mar 14 23:04:32 UTC 2017
This is an automated email from the git hooks/post-receive script.
tomasz pushed a commit to branch master
in repository mothur.
commit e59bb6f8af24aa9a79e1047ca10458babce16731
Author: Tomasz Buchert <tomasz at debian.org>
Date: Tue Mar 14 23:03:14 2017 +0100
New upstream version 1.39.4
---
Makefile | 4 +-
Mothur.xcodeproj/project.pbxproj | 59 +++++------
makefile-internal | 4 +-
source/chimera/chimeracheckrdp.cpp | 2 +-
source/chimera/slayer.cpp | 4 +-
source/classifier/bayesian.cpp | 2 +-
source/clusterclassic.cpp | 2 +-
source/commands/aligncommand.cpp | 2 +-
source/commands/amovacommand.cpp | 2 +-
source/commands/anosimcommand.cpp | 2 +-
source/commands/chimeraslayercommand.cpp | 4 +-
source/commands/classifyseqscommand.cpp | 6 +-
source/commands/cooccurrencecommand.cpp | 8 +-
source/commands/homovacommand.cpp | 2 +-
source/commands/lefsecommand.cpp | 6 +-
source/commands/makecontigscommand.cpp | 6 +-
source/commands/makecontigscommand.h | 4 +
source/commands/makefilecommand.cpp | 130 +++++++++++++----------
source/commands/makefilecommand.h | 2 +-
source/commands/mantelcommand.cpp | 2 +-
source/commands/nmdscommand.cpp | 4 +-
source/commands/phylodiversitycommand.cpp | 2 +-
source/commands/phylodiversitycommand.h | 2 +-
source/commands/sparcccommand.cpp | 2 +-
source/commands/sparcccommand.h | 2 +-
source/commands/subsamplecommand.cpp | 28 +++--
source/commands/summarytaxcommand.cpp | 4 +-
source/communitytype/communitytype.cpp | 2 +-
source/datastructures/blastalign.cpp | 2 +-
source/datastructures/blastdb.cpp | 8 +-
source/datastructures/oligos.cpp | 2 +
source/datastructures/sparsedistancematrix.cpp | 2 +-
source/datastructures/sparsedistancematrix.h | 15 ---
source/datastructures/sparsematrix.cpp | 2 +-
source/datastructures/sparsematrix.hpp | 12 ---
source/datastructures/tree.cpp | 6 +-
source/libshuff.cpp | 2 +-
source/linearalgebra.cpp | 4 +-
source/metastats/mothurmetastats.cpp | 2 +-
source/mothur.h | 33 ++++++
source/mothurout.cpp | 139 ++++++++++++++++++++++++-
source/mothurout.h | 8 ++
source/opticluster.cpp | 4 +-
source/randomforest/abstractdecisiontree.cpp | 4 +-
source/randomforest/decisiontree.cpp | 5 +-
source/sharedutilities.cpp | 2 +-
source/subsample.cpp | 17 +--
source/subsample.h | 8 --
48 files changed, 369 insertions(+), 207 deletions(-)
diff --git a/Makefile b/Makefile
index a805276..27fc1e3 100644
--- a/Makefile
+++ b/Makefile
@@ -15,8 +15,8 @@ USEBOOST ?= yes
BOOST_LIBRARY_DIR="\"Enter_your_boost_library_path_here\""
BOOST_INCLUDE_DIR="\"Enter_your_boost_include_path_here\""
MOTHUR_FILES="\"Enter_your_default_path_here\""
-RELEASE_DATE = "\"2/2/2017\""
-VERSION = "\"1.39.1\""
+RELEASE_DATE = "\"3/6/2017\""
+VERSION = "\"1.39.4\""
ifeq ($(strip $(64BIT_VERSION)),yes)
CXXFLAGS += -DBIT_VERSION
diff --git a/Mothur.xcodeproj/project.pbxproj b/Mothur.xcodeproj/project.pbxproj
index 612d786..644a293 100644
--- a/Mothur.xcodeproj/project.pbxproj
+++ b/Mothur.xcodeproj/project.pbxproj
@@ -3370,8 +3370,8 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
- CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
- CLANG_CXX_LIBRARY = "libstdc++";
+ CLANG_CXX_LANGUAGE_STANDARD = "c++14";
+ CLANG_CXX_LIBRARY = "compiler-default";
CLANG_WARN_CXX0X_EXTENSIONS = YES;
"CLANG_WARN_CXX0X_EXTENSIONS[arch=*]" = NO;
CLANG_WARN_UNREACHABLE_CODE = YES;
@@ -3380,12 +3380,13 @@
DSTROOT = TARGET_BUILD_DIR;
"DSTROOT[sdk=*]" = TARGET_BUILD_DIR;
"DYLIB_CURRENT_VERSION[sdk=*]" = "";
+ GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_DYNAMIC_NO_PIC = NO;
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 3;
GCC_PREPROCESSOR_DEFINITIONS = (
- "VERSION=\"\\\"1.39.2\\\"\"",
- "RELEASE_DATE=\"\\\"2/16/2017\\\"\"",
+ "VERSION=\"\\\"1.39.3\\\"\"",
+ "RELEASE_DATE=\"\\\"2/23/2017\\\"\"",
"MOTHUR_FILES=\"\\\"/Users/sarahwestcott/desktop/release\\\"\"",
);
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
@@ -3393,10 +3394,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
"INSTALL_PATH[sdk=*]" = TARGET_BUILD_DIR;
LIBRARY_SEARCH_PATHS = "";
- "LIBRARY_SEARCH_PATHS[arch=*]" = (
- /usr/local/lib/,
- /usr/local/include/,
- );
+ "LIBRARY_SEARCH_PATHS[arch=*]" = /usr/local/lib/;
ONLY_ACTIVE_ARCH = YES;
PRELINK_LIBS = "";
PRODUCT_NAME = mothur;
@@ -3409,27 +3407,25 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
- CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
- CLANG_CXX_LIBRARY = "libstdc++";
+ CLANG_CXX_LANGUAGE_STANDARD = "c++14";
+ CLANG_CXX_LIBRARY = "compiler-default";
CLANG_WARN_CXX0X_EXTENSIONS = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
DEPLOYMENT_LOCATION = YES;
DSTROOT = TARGET_BUILD_DIR;
+ GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_MODEL_TUNING = G5;
GCC_OPTIMIZATION_LEVEL = 3;
GCC_PREPROCESSOR_DEFINITIONS = (
- "VERSION=\"\\\"1.39.2\\\"\"",
- "RELEASE_DATE=\"\\\"2/16/2017\\\"\"",
+ "VERSION=\"\\\"1.39.3\\\"\"",
+ "RELEASE_DATE=\"\\\"2/23/2017\\\"\"",
"MOTHUR_FILES=\"\\\"/Users/sarahwestcott/desktop/release\\\"\"",
);
GCC_WARN_ABOUT_MISSING_PROTOTYPES = NO;
GCC_WARN_UNINITIALIZED_AUTOS = NO;
GCC_WARN_UNUSED_VALUE = YES;
- LIBRARY_SEARCH_PATHS = (
- /usr/local/include/,
- /usr/local/lib/,
- );
+ LIBRARY_SEARCH_PATHS = /usr/local/lib/;
"LIBRARY_SEARCH_PATHS[arch=*]" = "";
ONLY_ACTIVE_ARCH = YES;
PRELINK_LIBS = "";
@@ -3443,12 +3439,12 @@
1DEB928A08733DD80010E9CD /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
- CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
- CLANG_CXX_LIBRARY = "libstdc++";
+ CLANG_CXX_LANGUAGE_STANDARD = "c++14";
+ CLANG_CXX_LIBRARY = "compiler-default";
CLANG_WARN_UNREACHABLE_CODE = YES;
DEPLOYMENT_LOCATION = NO;
ENABLE_TESTABILITY = YES;
- GCC_C_LANGUAGE_STANDARD = c11;
+ GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_ENABLE_SSE3_EXTENSIONS = NO;
GCC_ENABLE_SSE41_EXTENSIONS = NO;
GCC_ENABLE_SSE42_EXTENSIONS = NO;
@@ -3465,8 +3461,11 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- HEADER_SEARCH_PATHS = /usr/local/include/;
- "HEADER_SEARCH_PATHS[arch=*]" = "";
+ HEADER_SEARCH_PATHS = "";
+ "HEADER_SEARCH_PATHS[arch=*]" = (
+ "$(inherited)",
+ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include,
+ );
INSTALL_PATH = TARGET_BUILD_DIR;
LIBRARY_SEARCH_PATHS = "";
"LIBRARY_SEARCH_PATHS[arch=*]" = /usr/local/lib/;
@@ -3475,12 +3474,10 @@
ONLY_ACTIVE_ARCH = YES;
OTHER_CPLUSPLUSFLAGS = (
"-DBIT_VERSION",
- "-DUSE_BOOST",
"-DUNIT_TEST",
- "-stdlib=libstdc++",
- "-std=c++11",
"-DUSE_READLINE",
"$(OTHER_CFLAGS)",
+ "-DUSE_BOOST",
);
OTHER_LDFLAGS = (
"-lreadline",
@@ -3496,17 +3493,17 @@
1DEB928B08733DD80010E9CD /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
- CLANG_CXX_LANGUAGE_STANDARD = "c++0x";
- CLANG_CXX_LIBRARY = "libstdc++";
+ CLANG_CXX_LANGUAGE_STANDARD = "c++14";
+ CLANG_CXX_LIBRARY = "compiler-default";
CLANG_WARN_UNREACHABLE_CODE = YES;
DEPLOYMENT_LOCATION = NO;
- GCC_C_LANGUAGE_STANDARD = c11;
+ GCC_C_LANGUAGE_STANDARD = "compiler-default";
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_MODEL_TUNING = "";
GCC_OPTIMIZATION_LEVEL = 3;
GCC_PREPROCESSOR_DEFINITIONS = (
- "VERSION=\"\\\"1.39.2\\\"\"",
- "RELEASE_DATE=\"\\\"2/16/2017\\\"\"",
+ "VERSION=\"\\\"1.39.3\\\"\"",
+ "RELEASE_DATE=\"\\\"2/23/2017\\\"\"",
"MOTHUR_FILES=\"\\\"/Users/sarahwestcott/desktop/release\\\"\"",
);
GCC_VERSION = "";
@@ -3530,12 +3527,10 @@
MACOSX_DEPLOYMENT_TARGET = 10.12;
OTHER_CPLUSPLUSFLAGS = (
"-DUSE_READLINE",
- "-DUSE_BOOST",
"-DUNIT_TEST",
- "-std=c++11",
- "-stdlib=libstdc++",
"-DBIT_VERSION",
"$(OTHER_CFLAGS)",
+ "-DUSE_BOOST",
);
OTHER_LDFLAGS = (
"-lreadline",
diff --git a/makefile-internal b/makefile-internal
index 3e017db..284898a 100644
--- a/makefile-internal
+++ b/makefile-internal
@@ -1,8 +1,8 @@
64BIT_VERSION ?= yes
USEREADLINE ?= no
USEBOOST ?= no
-RELEASE_DATE = "\"2/7/2017\""
-VERSION = "\"1.39.1\""
+RELEASE_DATE = "\"3/6/2017\""
+VERSION = "\"1.39.4\""
# Optimize to level 3:
CXXFLAGS += -O3
diff --git a/source/chimera/chimeracheckrdp.cpp b/source/chimera/chimeracheckrdp.cpp
index 72b4a79..3772fb1 100644
--- a/source/chimera/chimeracheckrdp.cpp
+++ b/source/chimera/chimeracheckrdp.cpp
@@ -20,7 +20,7 @@ ChimeraCheckRDP::ChimeraCheckRDP(string filename, string temp, string n, bool s,
kmerSize = k;
outputDir = o;
- templateDB = new AlignmentDB(templateFileName, "kmer", kmerSize, 0.0,0.0,0.0,0.0, rand(), true);
+ templateDB = new AlignmentDB(templateFileName, "kmer", kmerSize, 0.0,0.0,0.0,0.0, m->getRandomNumber(), true);
m->mothurOutEndLine();
kmer = new Kmer(kmerSize);
diff --git a/source/chimera/slayer.cpp b/source/chimera/slayer.cpp
index a787f27..437f074 100644
--- a/source/chimera/slayer.cpp
+++ b/source/chimera/slayer.cpp
@@ -299,13 +299,13 @@ int Slayer::bootstrapSNPS(vector<snps> left, vector<snps> right, float& BSA, flo
vector<snps> selectedLeft;
for (int j = 0; j < numLeft; j++) {
- int index = int(rand() % left.size());
+ int index = m->getRandomIndex(left.size()-1);
selectedLeft.push_back(left[index]);
}
vector<snps> selectedRight;
for (int j = 0; j < numRight; j++) {
- int index = int(rand() % right.size());
+ int index = m->getRandomIndex(right.size()-1);
selectedRight.push_back(right[index]);
}
diff --git a/source/classifier/bayesian.cpp b/source/classifier/bayesian.cpp
index 55589f4..03f098f 100644
--- a/source/classifier/bayesian.cpp
+++ b/source/classifier/bayesian.cpp
@@ -269,7 +269,7 @@ string Bayesian::bootstrapResults(vector<int> kmers, int tax, int numToSelect) {
vector<int> temp;
for (int j = 0; j < numToSelect; j++) {
- int index = int(rand() % kmers.size());
+ int index = m->getRandomIndex(kmers.size()-1);
//add word to temp
temp.push_back(kmers[index]);
diff --git a/source/clusterclassic.cpp b/source/clusterclassic.cpp
index 32a9341..b2f30b0 100644
--- a/source/clusterclassic.cpp
+++ b/source/clusterclassic.cpp
@@ -461,7 +461,7 @@ double ClusterClassic::getSmallCell() {
int zrand = 0;
if (mins.size() > 1) {
//pick random number between 0 and mins.size()
- zrand = (int)((float)(rand()) / (RAND_MAX / (mins.size()-1) + 1));
+ zrand = m->getRandomIndex(mins.size()-1);
}
smallRow = mins[zrand].row;
diff --git a/source/commands/aligncommand.cpp b/source/commands/aligncommand.cpp
index 6e4f6dd..aa3d871 100644
--- a/source/commands/aligncommand.cpp
+++ b/source/commands/aligncommand.cpp
@@ -295,7 +295,7 @@ int AlignCommand::execute(){
try {
if (abort == true) { if (calledHelp) { return 0; } return 2; }
- templateDB = new AlignmentDB(templateFileName, search, kmerSize, gapOpen, gapExtend, match, misMatch, rand(), true);
+ templateDB = new AlignmentDB(templateFileName, search, kmerSize, gapOpen, gapExtend, match, misMatch, m->getRandomNumber(), true);
for (int s = 0; s < candidateFileNames.size(); s++) {
if (m->control_pressed) { outputTypes.clear(); return 0; }
diff --git a/source/commands/amovacommand.cpp b/source/commands/amovacommand.cpp
index 080fcdd..695a518 100644
--- a/source/commands/amovacommand.cpp
+++ b/source/commands/amovacommand.cpp
@@ -377,7 +377,7 @@ map<string, vector<int> > AmovaCommand::getRandomizedGroups(map<string, vector<i
sampleIndices.insert(sampleIndices.end(), indices.begin(), indices.end());
}
- random_shuffle(sampleIndices.begin(), sampleIndices.end());
+ m->mothurRandomShuffle(sampleIndices);
int index = 0;
map<string, vector<int> > randomizedGroups = origMapping;
diff --git a/source/commands/anosimcommand.cpp b/source/commands/anosimcommand.cpp
index 24e70d7..9538ef1 100644
--- a/source/commands/anosimcommand.cpp
+++ b/source/commands/anosimcommand.cpp
@@ -460,7 +460,7 @@ map<string, vector<int> > AnosimCommand::getRandomizedGroups(map<string, vector<
sampleIndices.insert(sampleIndices.end(), indices.begin(), indices.end());
}
- random_shuffle(sampleIndices.begin(), sampleIndices.end());
+ m->mothurRandomShuffle(sampleIndices);
int index = 0;
map<string, vector<int> > randomizedGroups = origMapping;
diff --git a/source/commands/chimeraslayercommand.cpp b/source/commands/chimeraslayercommand.cpp
index 99358db..ae65ba3 100644
--- a/source/commands/chimeraslayercommand.cpp
+++ b/source/commands/chimeraslayercommand.cpp
@@ -1471,9 +1471,9 @@ int ChimeraSlayerCommand::driver(linePair filePos, string outputFName, string fi
MothurChimera* chimera;
if (templatefile != "self") { //you want to run slayer with a reference template
- chimera = new ChimeraSlayer(filename, templatefile, trim, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign, blastlocation, rand());
+ chimera = new ChimeraSlayer(filename, templatefile, trim, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign, blastlocation, m->getRandomNumber());
}else {
- chimera = new ChimeraSlayer(filename, templatefile, trim, priority, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign, blastlocation, rand());
+ chimera = new ChimeraSlayer(filename, templatefile, trim, priority, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign, blastlocation, m->getRandomNumber());
}
if (m->control_pressed) { delete chimera; return 0; }
diff --git a/source/commands/classifyseqscommand.cpp b/source/commands/classifyseqscommand.cpp
index 5a0025a..705e420 100644
--- a/source/commands/classifyseqscommand.cpp
+++ b/source/commands/classifyseqscommand.cpp
@@ -595,8 +595,8 @@ int ClassifySeqsCommand::execute(){
if (abort == true) { if (calledHelp) { return 0; } return 2; }
string outputMethodTag = method;
- if(method == "wang"){ classify = new Bayesian(taxonomyFileName, templateFileName, search, kmerSize, cutoff, iters, rand(), flip, writeShortcuts); }
- else if(method == "knn"){ classify = new Knn(taxonomyFileName, templateFileName, search, kmerSize, gapOpen, gapExtend, match, misMatch, numWanted, rand()); }
+ if(method == "wang"){ classify = new Bayesian(taxonomyFileName, templateFileName, search, kmerSize, cutoff, iters, m->getRandomNumber(), flip, writeShortcuts); }
+ else if(method == "knn"){ classify = new Knn(taxonomyFileName, templateFileName, search, kmerSize, gapOpen, gapExtend, match, misMatch, numWanted, m->getRandomNumber()); }
else if(method == "zap"){
outputMethodTag = search + "_" + outputMethodTag;
if (search == "kmer") { classify = new KmerTree(templateFileName, taxonomyFileName, kmerSize, cutoff); }
@@ -605,7 +605,7 @@ int ClassifySeqsCommand::execute(){
else {
m->mothurOut(search + " is not a valid method option. I will run the command using wang.");
m->mothurOutEndLine();
- classify = new Bayesian(taxonomyFileName, templateFileName, search, kmerSize, cutoff, iters, rand(), flip, writeShortcuts);
+ classify = new Bayesian(taxonomyFileName, templateFileName, search, kmerSize, cutoff, iters, m->getRandomNumber(), flip, writeShortcuts);
}
if (m->control_pressed) { delete classify; return 0; }
diff --git a/source/commands/cooccurrencecommand.cpp b/source/commands/cooccurrencecommand.cpp
index db73da7..0315304 100644
--- a/source/commands/cooccurrencecommand.cpp
+++ b/source/commands/cooccurrencecommand.cpp
@@ -447,7 +447,7 @@ int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp
if (m->control_pressed) { return 0; }
nextnum2:
previous = 0.0;
- randnum = rand() / double(RAND_MAX);
+ randnum = m->getRandomDouble0to1();
for(int i=0;i<nrows;i++) {
for(int j=0;j<ncols;j++) {
current = probabilityMatrix[ncols * i + j];
@@ -466,7 +466,7 @@ int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp
else if (matrix == "sim2") {
for(int i=0;i<nrows;i++) {
- random_shuffle( co_matrix[i].begin(), co_matrix[i].end() );
+ m->mothurRandomShuffle(co_matrix[i]);
}
//do this for the scoring since those all have nullmatrix as a parameter
//nullmatrix gets cleared at the begining of each run
@@ -479,7 +479,7 @@ int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp
while(count < rowtotal[i]) {
previous = 0.0;
if (m->control_pressed) { return 0; }
- randnum = rand() / double(RAND_MAX);
+ randnum = m->getRandomDouble0to1();
for(int j=0;j<ncols;j++) {
current = probabilityMatrix[ncols * i + j];
if(randnum <= current && randnum > previous && nullmatrix[i][j] != 1) {
@@ -500,7 +500,7 @@ int CooccurrenceCommand::getCooccurrence(vector<SharedRAbundVector*>& thisLookUp
count = 0;
while(count < columntotal[j]) {
if (m->control_pressed) { return 0; }
- randnum = rand() / double(RAND_MAX);
+ randnum = m->getRandomDouble0to1();
for(int i=0;i<nrows;i++) {
current = probabilityMatrix[ncols * i + j];
if(randnum <= current && randnum > previous && nullmatrix[i][j] != 1) {
diff --git a/source/commands/homovacommand.cpp b/source/commands/homovacommand.cpp
index 1a1cd66..7707d70 100644
--- a/source/commands/homovacommand.cpp
+++ b/source/commands/homovacommand.cpp
@@ -438,7 +438,7 @@ map<string, vector<int> > HomovaCommand::getRandomizedGroups(map<string, vector<
sampleIndices.insert(sampleIndices.end(), indices.begin(), indices.end());
}
- random_shuffle(sampleIndices.begin(), sampleIndices.end());
+ m->mothurRandomShuffle(sampleIndices);
int index = 0;
map<string, vector<int> > randomizedGroups = origMapping;
diff --git a/source/commands/lefsecommand.cpp b/source/commands/lefsecommand.cpp
index a49db1e..7caba42 100644
--- a/source/commands/lefsecommand.cpp
+++ b/source/commands/lefsecommand.cpp
@@ -801,11 +801,11 @@ map<int, double> LefseCommand::testLDA(vector<SharedRAbundFloatVector*>& lookup,
for (int h = 0; h < 1000; h++) { //generate a vector of length fractionNumGroups with range 0 to numGroups-1
save = h;
rand_s.clear();
- for (int k = 0; k < fractionNumGroups; k++) { int index = m->getRandomIndex(numGroups-1); rand_s.push_back(index);
- //if (m->debug) { m->mothurOut("[DEBUG]: index = " + toString(index) + "\n."); }
- }
+
+ for (int k = 0; k < fractionNumGroups; k++) { int index = m->getRandomIndex(numGroups-1); rand_s.push_back(index); }
if (!contastWithinClassesOrFewPerClass(adjustedLookup, rand_s, minCl, class2GroupIndex, indexToClass)) { h+=1000; save += 1000; } //break out of loop
}
+
if (m->control_pressed) { return sigOTUS; }
if (m->debug) { m->mothurOut("[DEBUG]: after 1000. \n."); }
diff --git a/source/commands/makecontigscommand.cpp b/source/commands/makecontigscommand.cpp
index 4226ca3..e394ff0 100644
--- a/source/commands/makecontigscommand.cpp
+++ b/source/commands/makecontigscommand.cpp
@@ -2098,6 +2098,7 @@ unsigned long long MakeContigsCommand::driver(vector<string> inputFiles, vector<
outScrapQual << ">" << fSeq.getName() << " | " << trashCode << '\t' << commentString << endl;
for (int i = 0; i < contigScores.size(); i++) { outScrapQual << contigScores[i] << " "; } outScrapQual << endl;
}
+
}
}
num++;
@@ -2302,17 +2303,18 @@ vector<int> MakeContigsCommand::assembleFragments(vector< vector<double> >&qual_
for (int i = overlapEnd; i < length; i++) { contig += seq1[i]; if (hasQuality) { if (((seq1[i] != '-') && (seq1[i] != '.'))) { contigScores.push_back(scores1[ABaseMap[i]]); } }
}
}
- //cout << contig << endl;
+ //cout << "contig = " << contig << endl;
if (trimOverlap) {
contig = contig.substr(overlapStart, oend-oStart);
- if (contig.length() == 0) { trashCode += "l"; }
if (hasQuality) {
vector<int> newContigScores;
for (int i = overlapStart; i < oend; i++) { newContigScores.push_back(contigScores[i]); }
contigScores = newContigScores;
}
}
+
+ if (contig == "") { trashCode += "l"; contig = "NNNN"; contigScores.push_back(0); contigScores.push_back(0); contigScores.push_back(0); contigScores.push_back(0); }
return contigScores;
}
diff --git a/source/commands/makecontigscommand.h b/source/commands/makecontigscommand.h
index d0c99be..8e8744e 100644
--- a/source/commands/makecontigscommand.h
+++ b/source/commands/makecontigscommand.h
@@ -1939,6 +1939,8 @@ static DWORD WINAPI MyGroupContigsThreadFunction(LPVOID lpParam){
}
}
+ if (contig == "") { trashCode += "l"; contig = "NNNN"; contigScores.push_back(0); contigScores.push_back(0); contigScores.push_back(0); contigScores.push_back(0); }
+
if(trashCode.length() == 0){
bool ignore = false;
@@ -3281,6 +3283,8 @@ static DWORD WINAPI MyContigsThreadFunction(LPVOID lpParam){
}
}
+ if (contig == "") { trashCode += "l"; contig = "NNNN"; contigScores.push_back(0); contigScores.push_back(0); contigScores.push_back(0); contigScores.push_back(0); }
+
if(trashCode.length() == 0){
bool ignore = false;
diff --git a/source/commands/makefilecommand.cpp b/source/commands/makefilecommand.cpp
index 18fa5f7..9e109af 100644
--- a/source/commands/makefilecommand.cpp
+++ b/source/commands/makefilecommand.cpp
@@ -17,6 +17,7 @@ vector<string> MakeFileCommand::setParameters(){
CommandParameter pprefix("prefix", "String", "", "", "", "", "","",false,false); parameters.push_back(pprefix);
CommandParameter pinputdir("inputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(pinputdir);
CommandParameter poutputdir("outputdir", "String", "", "", "", "", "","",false,false); parameters.push_back(poutputdir);
+ CommandParameter pdelim("delim", "String", "", "_", "", "", "","",false,false); parameters.push_back(pdelim);
vector<string> myArray;
for (int i = 0; i < parameters.size(); i++) { myArray.push_back(parameters[i].name); }
@@ -37,6 +38,7 @@ string MakeFileCommand::getHelpString(){
helpString += "The type parameter allows you to set the type of files to look for. Options are fastq or gz. Default=fastq. \n";
helpString += "The numcols parameter allows you to set number of columns you mothur to make in the file. Default=3, meaning groupName forwardFastq reverseFastq. The groupName is made from the beginning part of the forwardFastq file. Everything up to the first '_' or if no '_' is found then the root of the forwardFastq filename.\n";
helpString += "The prefix parameter allows you to enter your own prefix for the output filename. Default=stability.";
+ helpString += "The delim parameter allow you to enter the character you would like to use to create the sample name. Default='_'. For example, M6D7_S163_L001_R2_001.fastq.gz would produce the sample name M6D7. Set delim=* to indicate you want mothur to create unique names for each file pair. (no pooling)\n";
helpString += "The make.file command should be in the following format: \n";
helpString += "make.file(inputdir=yourInputDirectory). \n";
helpString += "Example make.group(inputdir=fastqFiles)\n";
@@ -130,6 +132,8 @@ MakeFileCommand::MakeFileCommand(string option) {
prefix = validParameter.validFile(parameters, "prefix", false); if (prefix == "not found") { prefix = "stability"; }
+ delim = validParameter.validFile(parameters, "delim", false); if (delim == "not found") { delim = "_"; }
+
}
}
catch(exception& e) {
@@ -248,80 +252,94 @@ int MakeFileCommand::execute(){
//groupName defaults to "noGroup"+toString(i);
vector< vector<string> > MakeFileCommand::findGroupNames(vector< vector<string> > paired){
try {
+ vector< vector<string> > results;
- //remove any "words" in filenames that is the same in all filenames separated by delim(_ .)
- //MI.M00833_0261.001.FLD0207.TRIN-META_16S_R2.fastq
- //MI.M00833_0261.001.FLD0223.ERIFF-META_16S_R2.fastq
- //would become...
- //FLD0207.TRIN-META
- //FLD0223.ERIFF-META
-
- //split all forward names into pieces
- vector<vector<string> > words; words.resize(paired.size());
- map<int, set<string> > posToWord;
-
- for (int i = 0; i < paired.size(); i++) {
- if (m->control_pressed) { break; }
+ if (delim == "*") {
+ //remove any "words" in filenames that is the same in all filenames separated by delim(_ .)
+ //MI.M00833_0261.001.FLD0207.TRIN-META_16S_R2.fastq
+ //MI.M00833_0261.001.FLD0223.ERIFF-META_16S_R2.fastq
+ //would become...
+ //FLD0207.TRIN-META
+ //FLD0223.ERIFF-META
- string filename = m->getRootName(m->getSimpleName(paired[i][0]));
+ //split all forward names into pieces
+ vector<vector<string> > words; words.resize(paired.size());
+ map<int, set<string> > posToWord;
- int pos = 0;
- string individual = "";
- for(int j=0;j<filename.length();j++){
- if((filename[j] == '.') || (filename[j] == '_')){
+ for (int i = 0; i < paired.size(); i++) {
+ if (m->control_pressed) { break; }
+
+ string filename = m->getRootName(m->getSimpleName(paired[i][0]));
+
+ int pos = 0;
+ string individual = "";
+ for(int j=0;j<filename.length();j++){
+ if((filename[j] == '.') || (filename[j] == '_')){
+ words[i].push_back(individual);
+
+ map<int, set<string> >::iterator it = posToWord.find(pos);
+ if (it != posToWord.end()) { posToWord[pos].insert(individual); }
+ else {
+ set<string> temp; temp.insert(individual);
+ posToWord[pos] = temp;
+ }
+ individual = "";
+ pos++;
+ }
+ else{
+ individual += filename[j];
+ }
+ }
+ if (!m->allSpaces(individual)) {
words[i].push_back(individual);
-
map<int, set<string> >::iterator it = posToWord.find(pos);
if (it != posToWord.end()) { posToWord[pos].insert(individual); }
else {
set<string> temp; temp.insert(individual);
posToWord[pos] = temp;
}
- individual = "";
- pos++;
- }
- else{
- individual += filename[j];
}
}
- if (!m->allSpaces(individual)) {
- words[i].push_back(individual);
- map<int, set<string> >::iterator it = posToWord.find(pos);
- if (it != posToWord.end()) { posToWord[pos].insert(individual); }
- else {
- set<string> temp; temp.insert(individual);
- posToWord[pos] = temp;
- }
- }
- }
-
- //remove duplicate pieces
- set<int> goodIndexes;
- for (map<int, set<string> >::iterator it = posToWord.begin(); it != posToWord.end(); it++) {
- set<string> w = it->second;;
- if (w.size() != 1) { goodIndexes.insert(it->first); }
- }
-
- set<string> groups;
- vector< vector<string> > results; results.resize(paired.size());
- for (int i = 0; i < words.size(); i++) {
- //assemble groupNames
- string groupName = "";
- for (int j = 0; j < words[i].size(); j++) {
- //include word
- if (goodIndexes.count(j) != 0) { groupName += words[i][j] + "_"; }
+ //remove duplicate pieces
+ set<int> goodIndexes;
+ for (map<int, set<string> >::iterator it = posToWord.begin(); it != posToWord.end(); it++) {
+ set<string> w = it->second;;
+ if (w.size() != 1) { goodIndexes.insert(it->first); }
}
- if (groupName != "") { groupName = groupName.substr(0, groupName.length()-1); }
+ set<string> groups;
+ results.resize(paired.size());
+ for (int i = 0; i < words.size(); i++) {
+
+ //assemble groupNames
+ string groupName = "";
+ for (int j = 0; j < words[i].size(); j++) {
+ //include word
+ if (goodIndexes.count(j) != 0) { groupName += words[i][j] + "_"; }
+ }
+
+ if (groupName != "") { groupName = groupName.substr(0, groupName.length()-1); }
+
+ //is this name unique
+ if (groups.count(groupName) == 0) { groups.insert(groupName); }
+ else { groupName = "Group_"+ toString(i); groups.insert(groupName); }
+
+ results[i].push_back(groupName); results[i].push_back(paired[i][0]); results[i].push_back(paired[i][1]);
+ }
- //is this name unique
- if (groups.count(groupName) == 0) { groups.insert(groupName); }
- else { groupName = "Group_"+ toString(i); groups.insert(groupName); }
+ }else { //separate by the user selected deliminator. default='_'
- results[i].push_back(groupName); results[i].push_back(paired[i][0]); results[i].push_back(paired[i][1]);
+ for (int i = 0; i < paired.size(); i++) {
+
+ string groupName = "Group_" + toString(i);
+
+ int pos = paired[i][0].find_first_of(delim);
+ if (pos != string::npos) { groupName = paired[i][0].substr(0, pos); }
+
+ results[i].push_back(groupName); results[i].push_back(paired[i][0]); results[i].push_back(paired[i][1]);
+ }
}
-
return results;
}
catch(exception& e) {
diff --git a/source/commands/makefilecommand.h b/source/commands/makefilecommand.h
index fcdd2a6..c693559 100644
--- a/source/commands/makefilecommand.h
+++ b/source/commands/makefilecommand.h
@@ -32,7 +32,7 @@ public:
private:
- string inputDir, outputDir, typeFile, prefix;
+ string inputDir, outputDir, typeFile, prefix, delim;
vector<string> outputNames;
int numCols;
bool abort;
diff --git a/source/commands/mantelcommand.cpp b/source/commands/mantelcommand.cpp
index a09e83c..bf1d364 100644
--- a/source/commands/mantelcommand.cpp
+++ b/source/commands/mantelcommand.cpp
@@ -207,7 +207,7 @@ int MantelCommand::execute(){
//randomize matrix2
vector< vector<double> > matrix2Copy = matrix2;
- random_shuffle(matrix2Copy.begin(), matrix2Copy.end());
+ m->mothurRandomShuffle(matrix2Copy);
//calc random mantel
double randomMantel = 0.0;
diff --git a/source/commands/nmdscommand.cpp b/source/commands/nmdscommand.cpp
index c57cfe5..33b7e0b 100644
--- a/source/commands/nmdscommand.cpp
+++ b/source/commands/nmdscommand.cpp
@@ -388,10 +388,10 @@ vector< vector<double> > NMDSCommand::generateStartingConfiguration(int numNames
if (m->control_pressed) { return axes; }
//generate random int between 0 and 99999
- int myrand = (int)((float)(rand()) / ((RAND_MAX / 99998) + 1));
+ int myrand = m->getRandomIndex(99999);
//generate random sign
- int mysign = (int)((float)(rand()) / ((RAND_MAX / 99998) + 1));
+ int mysign = m->getRandomIndex(99999);
//if mysign is even then sign = positive, else sign = negative
if ((mysign % 2) == 0) { mysign = 1.0; }
diff --git a/source/commands/phylodiversitycommand.cpp b/source/commands/phylodiversitycommand.cpp
index e7dca03..d2468b8 100644
--- a/source/commands/phylodiversitycommand.cpp
+++ b/source/commands/phylodiversitycommand.cpp
@@ -600,7 +600,7 @@ int PhyloDiversityCommand::driver(Tree* t, map< string, vector<float> >& div, ma
for (int l = 0; l < numIters; l++) {
- random_shuffle(randomLeaf.begin(), randomLeaf.end());
+ m->mothurRandomShuffle(randomLeaf);
//initialize counts
map<string, int> counts;
diff --git a/source/commands/phylodiversitycommand.h b/source/commands/phylodiversitycommand.h
index e78ea4d..1585042 100644
--- a/source/commands/phylodiversitycommand.h
+++ b/source/commands/phylodiversitycommand.h
@@ -95,7 +95,7 @@ static DWORD WINAPI MyPhyloDivThreadFunction(LPVOID lpParam){
vector<string> mGroups = pDataArray->m->getGroups();
for (int l = 0; l < pDataArray->numIters; l++) {
- random_shuffle(pDataArray->randomLeaf.begin(), pDataArray->randomLeaf.end());
+ pDataArray->m->mothurRandomShuffle(pDataArray->randomLeaf);
//initialize counts
map<string, int> counts;
diff --git a/source/commands/sparcccommand.cpp b/source/commands/sparcccommand.cpp
index 3175d6a..81bb5d6 100644
--- a/source/commands/sparcccommand.cpp
+++ b/source/commands/sparcccommand.cpp
@@ -303,7 +303,7 @@ vector<vector<float> > SparccCommand::shuffleSharedVector(vector<vector<float> >
for(int i=0;i<numGroups;i++){
for(int j=0;j<numOTUs;j++){
- shuffledVector[i][j] = sharedVector[rand()%numGroups][j];
+ shuffledVector[i][j] = sharedVector[m->getRandomIndex(numGroups-1)][j];
}
}
diff --git a/source/commands/sparcccommand.h b/source/commands/sparcccommand.h
index 73e9f8a..123c426 100644
--- a/source/commands/sparcccommand.h
+++ b/source/commands/sparcccommand.h
@@ -95,7 +95,7 @@ static DWORD WINAPI MySparccThreadFunction(LPVOID lpParam){
for(int k=0;k<numGroups;k++){
for(int j=0;j<numOTUs;j++){
- sharedShuffled[k][j] = pDataArray->sharedVector[rand()%numGroups][j];
+ sharedShuffled[k][j] = pDataArray->sharedVector[pDataArray->m->getRandomIndex(numGroups-1)][j];
}
}
/////////////////////////////////////////////////////////
diff --git a/source/commands/subsamplecommand.cpp b/source/commands/subsamplecommand.cpp
index 1bab26e..3bc3741 100644
--- a/source/commands/subsamplecommand.cpp
+++ b/source/commands/subsamplecommand.cpp
@@ -534,7 +534,7 @@ int SubSampleCommand::getSubSampleFasta() {
if (!pickedGroups) { m->mothurOut("Sampling " + toString(size) + " from " + toString(thisSize) + "."); m->mothurOutEndLine(); }
}
- random_shuffle(names.begin(), names.end());
+ m->mothurRandomShuffle(names);
set<string> subset; //dont want repeat sequence names added
if (persample) {
@@ -1124,7 +1124,7 @@ int SubSampleCommand::getSubSampleList() {
}
}
- random_shuffle(names.begin(), names.end());
+ m->mothurRandomShuffle(names);
//randomly select a subset of those names to include in the subsample
if (persample) {
@@ -1499,13 +1499,13 @@ int SubSampleCommand::processRabund(RAbundVector*& rabund, ofstream& out) {
if (thisSize != size) {
- OrderVector* order = new OrderVector();
+ vector<int> order;
for(int p=0;p<numBins;p++){
for(int j=0;j<rabund->get(p);j++){
- order->push_back(p);
+ order.push_back(p);
}
}
- random_shuffle(order->begin(), order->end());
+ m->mothurRandomShuffle(order);
RAbundVector* temp = new RAbundVector(numBins);
temp->setLabel(rabund->getLabel());
@@ -1515,15 +1515,13 @@ int SubSampleCommand::processRabund(RAbundVector*& rabund, ofstream& out) {
for (int j = 0; j < size; j++) {
- if (m->control_pressed) { delete order; return 0; }
+ if (m->control_pressed) { return 0; }
- int bin = order->get(j);
+ int bin = order[j];
int abund = rabund->get(bin);
rabund->set(bin, (abund+1));
}
-
- delete order;
}
if (m->control_pressed) { return 0; }
@@ -1660,13 +1658,13 @@ int SubSampleCommand::processSabund(SAbundVector*& sabund, ofstream& out) {
if (thisSize != size) {
- OrderVector* order = new OrderVector();
+ vector<int> order;
for(int p=0;p<numBins;p++){
for(int j=0;j<rabund->get(p);j++){
- order->push_back(p);
+ order.push_back(p);
}
}
- random_shuffle(order->begin(), order->end());
+ m->mothurRandomShuffle(order);
RAbundVector* temp = new RAbundVector(numBins);
temp->setLabel(rabund->getLabel());
@@ -1676,15 +1674,13 @@ int SubSampleCommand::processSabund(SAbundVector*& sabund, ofstream& out) {
for (int j = 0; j < size; j++) {
- if (m->control_pressed) { delete order; return 0; }
+ if (m->control_pressed) { return 0; }
- int bin = order->get(j);
+ int bin = order[j];
int abund = rabund->get(bin);
rabund->set(bin, (abund+1));
}
-
- delete order;
}
if (m->control_pressed) { return 0; }
diff --git a/source/commands/summarytaxcommand.cpp b/source/commands/summarytaxcommand.cpp
index 18efb98..acc6b93 100644
--- a/source/commands/summarytaxcommand.cpp
+++ b/source/commands/summarytaxcommand.cpp
@@ -271,12 +271,14 @@ int SummaryTaxCommand::execute(){
}else{
for (int i = 0; i < itNames->second.size(); i++) {
taxaSum->addSeqToTree(itNames->second[i], newTax); //add it as many times as there are identical seqs
+ numSeqs++;
}
itNames->second.clear();
nameMap.erase(itNames->first);
}
}else {
taxaSum->addSeqToTree(name, newTax);
+ numSeqs++;
}
}
@@ -295,7 +297,7 @@ int SummaryTaxCommand::execute(){
outTaxTree.close();
delete taxaSum;
- if (groupMap != NULL) { delete groupMap; } if (ct != NULL) { delete ct; }
+ if (groupMap != NULL) { delete groupMap; } if (ct != NULL) { numSeqs = ct->getNumSeqs(); delete ct; }
if (m->control_pressed) { m->mothurRemove(summaryFile); return 0; }
diff --git a/source/communitytype/communitytype.cpp b/source/communitytype/communitytype.cpp
index cf289d0..4f77628 100644
--- a/source/communitytype/communitytype.cpp
+++ b/source/communitytype/communitytype.cpp
@@ -407,7 +407,7 @@ int CommunityTypeFinder::findkMeans(){
//randomize samples
vector<int> temp;
for (int i = 0; i < numSamples; i++) { temp.push_back(i); }
- random_shuffle(temp.begin(), temp.end());
+ m->mothurRandomShuffle(temp);
//assign each partition at least one random sample
int numAssignedSamples = 0;
diff --git a/source/datastructures/blastalign.cpp b/source/datastructures/blastalign.cpp
index 8109a3b..6ee7639 100644
--- a/source/datastructures/blastalign.cpp
+++ b/source/datastructures/blastalign.cpp
@@ -27,7 +27,7 @@ BlastAlignment::BlastAlignment(float go, float ge, float ma, float mm) :
gapOpen = abs(go); // This is the penalty to assess for opening a gap (gapOpen >= 0)
gapExtend = abs(ge); // This is the penalty to assess for extending a gap (gapExtend >= 0)
- int randNumber = rand();
+ int randNumber = m->getRandomNumber();
candidateFileName = toString(randNumber) + ".candidate";
templateFileName = toString(randNumber) + ".template";
blastFileName = toString(randNumber) + ".pairwise";
diff --git a/source/datastructures/blastdb.cpp b/source/datastructures/blastdb.cpp
index 9a7de16..e9153e8 100644
--- a/source/datastructures/blastdb.cpp
+++ b/source/datastructures/blastdb.cpp
@@ -21,7 +21,7 @@ gapOpen(gO), gapExtend(gE), match(mm), misMatch(mM) {
path = b;
threadID = tid;
- int randNumber = rand();
+ int randNumber = m->getRandomNumber();;
//int randNumber = 12345;
string pid = m->mothurGetpid(threadID);
@@ -117,7 +117,7 @@ BlastDB::BlastDB(string b, int tid) : Database() {
#endif
}
- int randNumber = rand();
+ int randNumber = m->getRandomNumber();;
string pid = m->mothurGetpid(threadID);
dbFileName = pid + toString(randNumber) + ".template.unaligned.fasta";
queryFileName = pid + toString(randNumber) + ".candidate.unaligned.fasta";
@@ -202,7 +202,7 @@ vector<int> BlastDB::findClosestSequences(Sequence* seq, int n) {
vector<int> topMatches;
ofstream queryFile;
- int randNumber = rand();
+ int randNumber = m->getRandomNumber();;
string pid = scrubName(seq->getName());
m->openOutputFile((queryFileName+pid+toString(randNumber)), queryFile);
@@ -266,7 +266,7 @@ vector<int> BlastDB::findClosestMegaBlast(Sequence* seq, int n, int minPerID) {
Scores.clear();
ofstream queryFile;
- int randNumber = rand();
+ int randNumber = m->getRandomNumber();
string pid = scrubName(seq->getName());
m->openOutputFile((queryFileName+pid+toString(randNumber)), queryFile);
diff --git a/source/datastructures/oligos.cpp b/source/datastructures/oligos.cpp
index ef57452..434e805 100644
--- a/source/datastructures/oligos.cpp
+++ b/source/datastructures/oligos.cpp
@@ -16,6 +16,7 @@ Oligos::Oligos(string o){
hasPPrimers = false; hasPBarcodes = false; pairedOligos = false; reversePairs = true;
indexBarcode = 0; indexPairedBarcode = 0; indexPrimer = 0; indexPairedPrimer = 0;
oligosfile = o;
+ reversePairs = true;
readOligos();
if (pairedOligos) {
numBarcodes = pairedBarcodes.size();
@@ -35,6 +36,7 @@ Oligos::Oligos(string o){
Oligos::Oligos(){
try {
m = MothurOut::getInstance();
+ reversePairs = true;
hasPPrimers = false; hasPBarcodes = false; pairedOligos = false; reversePairs = true;
indexBarcode = 0; indexPairedBarcode = 0; indexPrimer = 0; indexPairedPrimer = 0;
numFPrimers = 0; numBarcodes = 0;
diff --git a/source/datastructures/sparsedistancematrix.cpp b/source/datastructures/sparsedistancematrix.cpp
index d161d44..4503e30 100644
--- a/source/datastructures/sparsedistancematrix.cpp
+++ b/source/datastructures/sparsedistancematrix.cpp
@@ -146,7 +146,7 @@ ull SparseDistanceMatrix::getSmallestCell(ull& row){
}
}
- random_shuffle(mins.begin(), mins.end()); //randomize the order of the iterators in the mins vector
+ m->mothurRandomShuffle(mins); //randomize the order of the iterators in the mins vector
row = mins[0].row;
ull col = mins[0].col;
diff --git a/source/datastructures/sparsedistancematrix.h b/source/datastructures/sparsedistancematrix.h
index 6c6bbe5..8519282 100644
--- a/source/datastructures/sparsedistancematrix.h
+++ b/source/datastructures/sparsedistancematrix.h
@@ -15,23 +15,8 @@
class ListVector;
-
-/* For each distance in a sparse matrix we have a row, column and distance.
- The PDistCell consists of the column and distance.
- We know the row by the distances row in the seqVec matrix.
- SeqVec is square and each row is sorted so the column values are ascending to save time in the search for the smallest distance. */
-
-/***********************************************************************/
-struct PDistCellMin{
- ull row;
- ull col;
- //PDistCell* cell;
- PDistCellMin(ull r, ull c) : col(c), row(r) {}
-};
/***********************************************************************/
-
-
class SparseDistanceMatrix {
public:
diff --git a/source/datastructures/sparsematrix.cpp b/source/datastructures/sparsematrix.cpp
index 3a0ec65..6952004 100644
--- a/source/datastructures/sparsematrix.cpp
+++ b/source/datastructures/sparsematrix.cpp
@@ -153,7 +153,7 @@ PCell* SparseMatrix::getSmallestCell(){
}
}
- random_shuffle(mins.begin(), mins.end()); //randomize the order of the iterators in the mins vector
+ m->mothurRandomShuffle(mins); //randomize the order of the iterators in the mins vector
for(int i=0;i<mins.size();i++){
mins[i]->vectorMap = &mins[i]; //assign vectorMap to the address for the container
diff --git a/source/datastructures/sparsematrix.hpp b/source/datastructures/sparsematrix.hpp
index c8a11d7..db9f4ae 100644
--- a/source/datastructures/sparsematrix.hpp
+++ b/source/datastructures/sparsematrix.hpp
@@ -9,18 +9,6 @@ class ListVector;
/***********************************************************************/
-
- struct PCell{
- ull row;
- ull column;
- float dist;
- PCell** vectorMap;
- PCell() : row(0), column(0), dist(0), vectorMap(NULL) {};
- PCell(ull r, ull c, float d) : row(r), column(c), dist(d), vectorMap(NULL) {};
-};
-
-/***********************************************************************/
-
typedef list<PCell>::iterator MatData;
class SparseMatrix {
diff --git a/source/datastructures/tree.cpp b/source/datastructures/tree.cpp
index 675d544..d092c80 100644
--- a/source/datastructures/tree.cpp
+++ b/source/datastructures/tree.cpp
@@ -837,7 +837,7 @@ void Tree::randomLabels(vector<string> g) {
for(int i = 0; i < numLeaves; i++){
int z;
//get random index to switch with
- z = int((float)(i+1) * (float)(rand()) / ((float)RAND_MAX+1.0));
+ z = m->getRandomIndex(i);
//you only want to randomize the nodes that are from a group the user wants analyzed, so
//if either of the leaf nodes you are about to switch are not in the users groups then you don't want to switch them.
@@ -878,7 +878,7 @@ void Tree::randomLabels(vector<string> g) {
void Tree::randomBlengths() {
try {
for(int i=numNodes-1;i>=0;i--){
- int z = int((float)(i+1) * (float)(rand()) / ((float)RAND_MAX+1.0));
+ int z = m->getRandomIndex(i);
float bl_hold = tree[z].getBranchLength();
tree[z].setBranchLength(tree[i].getBranchLength());
@@ -923,7 +923,7 @@ void Tree::randomTopology() {
int escape =0;
int rnd_index1, rnd_index2;
while(escape == 0){
- rnd_index1 = (int)(((double)rand() / (double) RAND_MAX)*i);
+ rnd_index1 = m->getRandomIndex(i);
if(tree[rnd_index1].getParent() == -1){escape = 1;}
}
diff --git a/source/libshuff.cpp b/source/libshuff.cpp
index 5f1bdef..5105475 100644
--- a/source/libshuff.cpp
+++ b/source/libshuff.cpp
@@ -117,7 +117,7 @@ void Libshuff::randomizeGroups(int x, int y){
for(int k=0;k<groupSizes[y];k++) { v[index++] = groups[y][k]; }
for(int k=nv-1;k>0;k--){
- int z = (int)(rand() % k);
+ int z = m->getRandomIndex(k);
swap(v[z],v[k]);
}
diff --git a/source/linearalgebra.cpp b/source/linearalgebra.cpp
index 0219493..275e965 100644
--- a/source/linearalgebra.cpp
+++ b/source/linearalgebra.cpp
@@ -1326,8 +1326,8 @@ double LinearAlgebra::calcKruskalWallis(vector<spearmanRank>& values, double& pV
/*********************************************************************************************************************************/
double LinearAlgebra::normalvariate(double mean, double standardDeviation) {
try {
- double u1 = ((double)(rand()) + 1.0 )/( (double)(RAND_MAX) + 1.0);
- double u2 = ((double)(rand()) + 1.0 )/( (double)(RAND_MAX) + 1.0);
+ double u1 = m->getRandomDouble0to1();
+ double u2 = m->getRandomDouble0to1();
//double r = sqrt( -2.0*log(u1) );
//double theta = 2.0*PI*u2;
//cout << cos(8.*atan(1.)*u2)*sqrt(-2.*log(u1)) << endl;
diff --git a/source/metastats/mothurmetastats.cpp b/source/metastats/mothurmetastats.cpp
index c4cf5eb..b11048b 100644
--- a/source/metastats/mothurmetastats.cpp
+++ b/source/metastats/mothurmetastats.cpp
@@ -309,7 +309,7 @@ vector<double> MothurMetastats::permute_and_calc_ts(vector< vector<double> >& Im
map<int, int> randomMap;
vector<int> randoms;
for (int i = 0; i < column; i++) { randoms.push_back(i); }
- random_shuffle(randoms.begin(), randoms.end());
+ m->mothurRandomShuffle(randoms);
for (int i = 0; i < randoms.size(); i++) { randomMap[i] = randoms[i]; }
//calc ts
diff --git a/source/mothur.h b/source/mothur.h
index a214fac..fae675e 100644
--- a/source/mothur.h
+++ b/source/mothur.h
@@ -49,6 +49,8 @@
#include <math.h>
#include <algorithm>
#include <numeric>
+#include <random>
+#include <chrono>
//misc
#include <cerrno>
@@ -127,6 +129,37 @@ struct diffPair {
}
};
+struct item {
+ string name;
+ string group;
+
+ item() {}
+ item(string n, string g) : name(n), group(g) {}
+ ~item() {}
+};
+
+struct PCell{
+ ull row;
+ ull column;
+ float dist;
+ PCell** vectorMap;
+ PCell() : row(0), column(0), dist(0), vectorMap(NULL) {};
+ PCell(ull r, ull c, float d) : row(r), column(c), dist(d), vectorMap(NULL) {};
+};
+
+/* For each distance in a sparse matrix we have a row, column and distance.
+ The PDistCell consists of the column and distance.
+ We know the row by the distances row in the seqVec matrix.
+ SeqVec is square and each row is sorted so the column values are ascending to save time in the search for the smallest distance. */
+
+/***********************************************************************/
+struct PDistCellMin{
+ ull row;
+ ull col;
+ //PDistCell* cell;
+ PDistCellMin(ull r, ull c) : col(c), row(r) {}
+};
+
/**********************************************************/
struct CommonHeader {
unsigned int magicNumber;
diff --git a/source/mothurout.cpp b/source/mothurout.cpp
index d26064a..d95b03b 100644
--- a/source/mothurout.cpp
+++ b/source/mothurout.cpp
@@ -831,14 +831,115 @@ string MothurOut::getSimpleName(string longName){
exit(1);
}
}
-
+/***********************************************************************/
+int MothurOut::mothurRandomShuffle(vector<int>& randomize){
+ try {
+ unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
+ mt19937_64 mersenne_twister_engine(seed);
+
+ shuffle (randomize.begin(), randomize.end(), mersenne_twister_engine);
+
+ return 0;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getRandomNumber");
+ exit(1);
+ }
+
+}
+/***********************************************************************/
+int MothurOut::mothurRandomShuffle(vector<string>& randomize){
+ try {
+ unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
+ mt19937_64 mersenne_twister_engine(seed);
+
+ shuffle (randomize.begin(), randomize.end(), mersenne_twister_engine);
+
+ return 0;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getRandomNumber");
+ exit(1);
+ }
+
+}
+/***********************************************************************/
+int MothurOut::mothurRandomShuffle(vector<item>& randomize){
+ try {
+ unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
+ mt19937_64 mersenne_twister_engine(seed);
+
+ shuffle (randomize.begin(), randomize.end(), mersenne_twister_engine);
+
+ return 0;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getRandomNumber");
+ exit(1);
+ }
+
+}
+/***********************************************************************/
+int MothurOut::mothurRandomShuffle(vector<PCell*>& randomize){
+ try {
+ unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
+ mt19937_64 mersenne_twister_engine(seed);
+
+ shuffle (randomize.begin(), randomize.end(), mersenne_twister_engine);
+
+ return 0;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getRandomNumber");
+ exit(1);
+ }
+
+}
+/***********************************************************************/
+int MothurOut::mothurRandomShuffle(vector<PDistCellMin>& randomize){
+ try {
+ unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
+ mt19937_64 mersenne_twister_engine(seed);
+
+ shuffle (randomize.begin(), randomize.end(), mersenne_twister_engine);
+
+ return 0;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getRandomNumber");
+ exit(1);
+ }
+
+}
+/***********************************************************************/
+int MothurOut::mothurRandomShuffle(vector< vector<double> >& randomize){
+ try {
+ unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
+ mt19937_64 mersenne_twister_engine(seed);
+
+ shuffle (randomize.begin(), randomize.end(), mersenne_twister_engine);
+
+ return 0;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getRandomNumber");
+ exit(1);
+ }
+
+}
/***********************************************************************/
int MothurOut::getRandomIndex(int highest){
try {
if (highest == 0) { return 0; }
- int random = (int) ((float)(highest+1) * (float)(rand()) / ((float)RAND_MAX+1.0));
+ //int random = (int) ((float)(highest+1) * (float)(rand()) / ((float)RAND_MAX+1.0));
+
+ unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
+ mt19937_64 mersenne_twister_engine(seed);
+ uniform_int_distribution<int> dis(0, highest);
+
+ int random = dis(mersenne_twister_engine);
return random;
}
@@ -848,6 +949,40 @@ int MothurOut::getRandomIndex(int highest){
}
}
+/***********************************************************************/
+int MothurOut::getRandomNumber(){
+ try {
+ unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
+ mt19937_64 mersenne_twister_engine(seed);
+ uniform_int_distribution<int> dis;
+
+ int random = dis(mersenne_twister_engine);
+
+ return random;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getRandomNumber");
+ exit(1);
+ }
+
+}
+/***********************************************************************/
+double MothurOut::getRandomDouble0to1(){
+ try {
+ unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
+ mt19937_64 mersenne_twister_engine(seed);
+ uniform_real_distribution<double> dis(0, 1);
+
+ double random = dis(mersenne_twister_engine);
+
+ return random;
+ }
+ catch(exception& e) {
+ errorOut(e, "MothurOut", "getRandomNumber");
+ exit(1);
+ }
+
+}
/**********************************************************************/
string MothurOut::getPathName(string longName){
diff --git a/source/mothurout.h b/source/mothurout.h
index 2315810..936cf15 100644
--- a/source/mothurout.h
+++ b/source/mothurout.h
@@ -202,6 +202,12 @@ class MothurOut {
bool checkGroupName(string name);
map<string, vector<string> > parseClasses(string);
string addUnclassifieds(string tax, int maxlevel, bool probs);
+ int mothurRandomShuffle(vector<int>&);
+ int mothurRandomShuffle(vector< vector<double> >&);
+ int mothurRandomShuffle(vector<string>&);
+ int mothurRandomShuffle(vector<item>&);
+ int mothurRandomShuffle(vector<PCell*>&);
+ int mothurRandomShuffle(vector<PDistCellMin>&);
//math operation
@@ -220,6 +226,8 @@ class MothurOut {
int sum(vector<int>);
double sum(vector<double>);
int getRandomIndex(int); //highest
+ int getRandomNumber();
+ double getRandomDouble0to1();
double getStandardDeviation(vector<int>&);
vector<double> getStandardDeviation(vector< vector<double> >&);
vector<double> getStandardDeviation(vector< vector<double> >&, vector<double>&);
diff --git a/source/opticluster.cpp b/source/opticluster.cpp
index 4bbb797..0b90d68 100644
--- a/source/opticluster.cpp
+++ b/source/opticluster.cpp
@@ -36,7 +36,7 @@ int OptiCluster::initialize(double& value, bool randomize, string initialize) {
randomizeSeqs.push_back(i);
}
- if (randomize) { random_shuffle(randomizeSeqs.begin(), randomizeSeqs.end()); }
+ if (randomize) { m->mothurRandomShuffle(randomizeSeqs); }
//for each sequence (singletons removed on read)
for (map<int, int>::iterator it = seqBin.begin(); it != seqBin.end(); it++) {
@@ -58,7 +58,7 @@ int OptiCluster::initialize(double& value, bool randomize, string initialize) {
randomizeSeqs.push_back(i);
}
- if (randomize) { random_shuffle(randomizeSeqs.begin(), randomizeSeqs.end()); }
+ if (randomize) { m->mothurRandomShuffle(randomizeSeqs); }
//for each sequence (singletons removed on read)
for (map<int, int>::iterator it = seqBin.begin(); it != seqBin.end(); it++) {
diff --git a/source/randomforest/abstractdecisiontree.cpp b/source/randomforest/abstractdecisiontree.cpp
index e7f1c5e..e7e98b6 100644
--- a/source/randomforest/abstractdecisiontree.cpp
+++ b/source/randomforest/abstractdecisiontree.cpp
@@ -57,8 +57,8 @@ int AbstractDecisionTree::createBootStrappedSamples(){
for (int i = 0; i < numSamples; i++) {
if (m->control_pressed) { return 0; }
- // TODO: optimize the rand() function call + double check if it's working properly
- int randomIndex = rand() % numSamples;
+
+ int randomIndex = m->getRandomIndex(numSamples-1);
bootstrappedTrainingSamples.push_back(baseDataSet[randomIndex]);
isInTrainingSamples[randomIndex] = true;
}
diff --git a/source/randomforest/decisiontree.cpp b/source/randomforest/decisiontree.cpp
index 1fd2924..7440e3f 100644
--- a/source/randomforest/decisiontree.cpp
+++ b/source/randomforest/decisiontree.cpp
@@ -176,7 +176,7 @@ void DecisionTree::randomlyShuffleAttribute(const vector< vector<int> >& samples
if (m->control_pressed) { return; }
featureVectors[j] = samples[j][featureIndex];
}
- random_shuffle(featureVectors.begin(), featureVectors.end());
+ m->mothurRandomShuffle(featureVectors);
for (int j = 0; j < samples.size(); j++) {
if (m->control_pressed) { return; }
shuffledSample[j][featureIndex] = featureVectors[j];
@@ -386,8 +386,7 @@ vector<int> DecisionTree::selectFeatureSubsetRandomly(vector<int> globalDiscarde
if (m->control_pressed) { return featureSubsetIndices; }
- // TODO: optimize rand() call here
- int randomIndex = rand() % numFeatures;
+ int randomIndex = m->getRandomIndex(numFeatures-1);
vector<int>::iterator it = find(featureSubsetIndices.begin(), featureSubsetIndices.end(), randomIndex);
if (it == featureSubsetIndices.end()){ // NOT FOUND
vector<int>::iterator it2 = find(combinedDiscardedFeatureIndices.begin(), combinedDiscardedFeatureIndices.end(), randomIndex);
diff --git a/source/sharedutilities.cpp b/source/sharedutilities.cpp
index d9891db..df75eb2 100644
--- a/source/sharedutilities.cpp
+++ b/source/sharedutilities.cpp
@@ -79,7 +79,7 @@ void SharedUtil::getSharedVectorswithReplacement(vector<string> Groups, vector<S
//sample all the members
for(int i=0;i<numSeqs;i++){
//get random number
- int random = int((float)(i+1) * (float)(rand()) / ((float)RAND_MAX+1.0));
+ int random = m->getRandomIndex(i);
individual chosen = order->get(random);
int abundance;
diff --git a/source/subsample.cpp b/source/subsample.cpp
index 538d5c3..cb4072f 100644
--- a/source/subsample.cpp
+++ b/source/subsample.cpp
@@ -35,7 +35,7 @@ Tree* SubSample::getSample(Tree* T, CountTable* ct, CountTable* newCt, int size)
int num = ct->getGroupCount(names[j], Groups[i]);
for (int k = 0; k < num; k++) { random.push_back(j); }
}
- random_shuffle(random.begin(), random.end());
+ m->mothurRandomShuffle(random);
vector<int> sampleRandoms; sampleRandoms.resize(names.size(), 0);
for (int j = 0; j < size; j++) { sampleRandoms[random[j]]++; }
@@ -110,6 +110,8 @@ vector<string> SubSample::getSample(vector<SharedRAbundVector*>& thislookup, int
//save mothurOut's binLabels to restore for next label
vector<string> saveBinLabels = m->currentSharedBinLabels;
+ //unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
+ //mt19937_64 mersenne_twister_engine(seed);
int numBins = thislookup[0]->getNumBins();
for (int i = 0; i < thislookup.size(); i++) {
@@ -119,13 +121,14 @@ vector<string> SubSample::getSample(vector<SharedRAbundVector*>& thislookup, int
string thisgroup = thislookup[i]->getGroup();
- OrderVector order;
+ vector<int> order;
for(int p=0;p<numBins;p++){
for(int j=0;j<thislookup[i]->getAbundance(p);j++){
order.push_back(p);
}
}
- random_shuffle(order.begin(), order.end());
+
+ m->mothurRandomShuffle(order);
SharedRAbundVector* temp = new SharedRAbundVector(numBins);
temp->setLabel(thislookup[i]->getLabel());
@@ -139,7 +142,7 @@ vector<string> SubSample::getSample(vector<SharedRAbundVector*>& thislookup, int
if (m->control_pressed) { return m->currentSharedBinLabels; }
- int bin = order.get(j);
+ int bin = order[j];
int abund = thislookup[i]->getAbundance(bin);
thislookup[i]->set(bin, (abund+1), thisgroup);
@@ -286,7 +289,7 @@ CountTable SubSample::getSample(CountTable& ct, int size, vector<string> Groups)
for (int k = 0; k < num; k++) { allNames.push_back(names[j]); }
}
- random_shuffle(allNames.begin(), allNames.end());
+ m->mothurRandomShuffle(allNames);
if (allNames.size() < size) { m->mothurOut("[ERROR]: You have selected a size that is larger than "+Groups[i]+" number of sequences.\n"); m->control_pressed = true; }
else{
@@ -352,7 +355,7 @@ CountTable SubSample::getSample(CountTable& ct, int size, vector<string> Groups,
}
}
- random_shuffle(allNames.begin(), allNames.end());
+ m->mothurRandomShuffle(allNames);
if (allNames.size() < size) {
if (pickedGroups) { m->mothurOut("[ERROR]: You have selected a size that is larger than the number of sequences.\n"); }
@@ -396,7 +399,7 @@ CountTable SubSample::getSample(CountTable& ct, int size, vector<string> Groups,
if (allNames.size() < size) { m->mothurOut("[ERROR]: You have selected a size that is larger than the number of sequences.\n"); m->control_pressed = true; return sampledCt; }
else {
- random_shuffle(allNames.begin(), allNames.end());
+ m->mothurRandomShuffle(allNames);
for (int j = 0; j < size; j++) {
if (m->control_pressed) { return sampledCt; }
diff --git a/source/subsample.h b/source/subsample.h
index fdf8576..ebb5dc1 100644
--- a/source/subsample.h
+++ b/source/subsample.h
@@ -15,14 +15,6 @@
#include "tree.h"
#include "counttable.h"
-struct item {
- string name;
- string group;
-
- item() {}
- item(string n, string g) : name(n), group(g) {}
- ~item() {}
-};
//subsampling overwrites the sharedRabunds. If you need to reuse the original use the getSamplePreserve function.
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/mothur.git
More information about the debian-med-commit
mailing list