A7E9B80512D37EC400DA6239 /* sharedlistvector.h */,
A7E9B80E12D37EC400DA6239 /* sharedordervector.h */,
A7E9B80D12D37EC400DA6239 /* sharedordervector.cpp */,
- A7E9B80F12D37EC400DA6239 /* sharedrabundfloatvector.cpp */,
A7E9B81012D37EC400DA6239 /* sharedrabundfloatvector.h */,
+ A7E9B80F12D37EC400DA6239 /* sharedrabundfloatvector.cpp */,
A7E9B81112D37EC400DA6239 /* sharedrabundvector.cpp */,
A7E9B81212D37EC400DA6239 /* sharedrabundvector.h */,
A7E9B81312D37EC400DA6239 /* sharedsabundvector.cpp */,
try {
if (abort == true) { if (calledHelp) { return 0; } return 2; }
- templateDB = new AlignmentDB(templateFileName, search, kmerSize, gapOpen, gapExtend, match, misMatch);
+ templateDB = new AlignmentDB(templateFileName, search, kmerSize, gapOpen, gapExtend, match, misMatch, rand());
for (int s = 0; s < candidateFileNames.size(); s++) {
if (m->control_pressed) { outputTypes.clear(); return 0; }
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
- positions = m->setFilePosFasta(candidateFileNames[s], numFastaSeqs);
-
- //figure out how many sequences you have to process
- int numSeqsPerProcessor = numFastaSeqs / processors;
- for (int i = 0; i < processors; i++) {
- int startIndex = i * numSeqsPerProcessor;
- if(i == (processors - 1)){ numSeqsPerProcessor = numFastaSeqs - i * numSeqsPerProcessor; }
- lines.push_back(new linePair(positions[startIndex], numSeqsPerProcessor));
+ if (processors == 1) {
+ lines.push_back(new linePair(0, 1000));
+ }else {
+ positions = m->setFilePosFasta(candidateFileNames[s], numFastaSeqs);
+
+ //figure out how many sequences you have to process
+ int numSeqsPerProcessor = numFastaSeqs / processors;
+ for (int i = 0; i < processors; i++) {
+ int startIndex = i * numSeqsPerProcessor;
+ if(i == (processors - 1)){ numSeqsPerProcessor = numFastaSeqs - i * numSeqsPerProcessor; }
+ lines.push_back(new linePair(positions[startIndex], numSeqsPerProcessor));
+ }
}
#endif
string extension = "";
if (i != 0) { extension = toString(i) + ".temp"; }
- alignData* tempalign = new alignData((alignFileName + extension), (reportFileName + extension), (accnosFName + extension), filename, align, search, kmerSize, m, lines[i]->start, lines[i]->end, flip, match, misMatch, gapOpen, gapExtend, threshold);
+ alignData* tempalign = new alignData((alignFileName + extension), (reportFileName + extension), (accnosFName + extension), filename, align, search, kmerSize, m, lines[i]->start, lines[i]->end, flip, match, misMatch, gapOpen, gapExtend, threshold, i);
pDataArray.push_back(tempalign);
processIDS.push_back(i);
MothurOut* m;
//AlignmentDB* templateDB;
float match, misMatch, gapOpen, gapExtend, threshold;
- int count, kmerSize;
+ int count, kmerSize, threadID;
alignData(){}
- alignData(string a, string r, string ac, string f, string al, string se, int ks, MothurOut* mout, unsigned long int st, unsigned long int en, bool fl, float ma, float misMa, float gapO, float gapE, float thr) {
+ alignData(string a, string r, string ac, string f, string al, string se, int ks, MothurOut* mout, unsigned long int st, unsigned long int en, bool fl, float ma, float misMa, float gapO, float gapE, float thr, int tid) {
alignFName = a;
reportFName = r;
accnosFName = ac;
search = se;
count = 0;
kmerSize = ks;
+ threadID = tid;
}
};
pDataArray->count = pDataArray->end;
- AlignmentDB* templateDB = new AlignmentDB("saved-silent", pDataArray->search, pDataArray->kmerSize, pDataArray->gapOpen, pDataArray->gapExtend, pDataArray->match, pDataArray->misMatch);
+ AlignmentDB* templateDB = new AlignmentDB("saved-silent", pDataArray->search, pDataArray->kmerSize, pDataArray->gapOpen, pDataArray->gapExtend, pDataArray->match, pDataArray->misMatch, pDataArray->threadID);
//moved this into driver to avoid deep copies in windows paralellized version
Alignment* alignment;
/**************************************************************************************************/
//deep copy
-AlignmentDB::AlignmentDB(const AlignmentDB& adb) : numSeqs(adb.numSeqs), longest(adb.longest), method(adb.method), emptySequence(adb.emptySequence) {
+AlignmentDB::AlignmentDB(const AlignmentDB& adb) : numSeqs(adb.numSeqs), longest(adb.longest), method(adb.method), emptySequence(adb.emptySequence), threadID(adb.threadID) {
try {
m = MothurOut::getInstance();
}
/**************************************************************************************************/
-AlignmentDB::AlignmentDB(string fastaFileName, string s, int kmerSize, float gapOpen, float gapExtend, float match, float misMatch){ // This assumes that the template database is in fasta format, may
+AlignmentDB::AlignmentDB(string fastaFileName, string s, int kmerSize, float gapOpen, float gapExtend, float match, float misMatch, int tid){ // This assumes that the template database is in fasta format, may
try { // need to alter this in the future?
m = MothurOut::getInstance();
longest = 0;
bool needToGenerate = true;
ReferenceDB* rdb = ReferenceDB::getInstance();
bool silent = false;
+ threadID = tid;
if (fastaFileName == "saved-silent") {
fastaFileName = "saved"; silent = true;
#endif
}
else if(method == "suffix") { search = new SuffixDB(numSeqs); }
- else if(method == "blast") { search = new BlastDB(fastaFileName.substr(0,fastaFileName.find_last_of(".")+1), gapOpen, gapExtend, match, misMatch, ""); }
+ else if(method == "blast") { search = new BlastDB(fastaFileName.substr(0,fastaFileName.find_last_of(".")+1), gapOpen, gapExtend, match, misMatch, "", threadID); }
else {
method = "kmer";
m->mothurOut(method + " is not a valid search option. I will run the command using kmer, ksize=8.");
method = s;
if(method == "suffix") { search = new SuffixDB(); }
- else if(method == "blast") { search = new BlastDB(""); }
+ else if(method == "blast") { search = new BlastDB("", 0); }
else { search = new KmerDB(); }
public:
- AlignmentDB(string, string, int, float, float, float, float); //reads fastafile passed in and stores sequences
+ AlignmentDB(string, string, int, float, float, float, float, int); //reads fastafile passed in and stores sequences
AlignmentDB(string);
AlignmentDB(const AlignmentDB& adb);
~AlignmentDB();
int getLongestBase() { return longest; }
private:
- int numSeqs, longest;
+ int numSeqs, longest, threadID;
string method;
Database* search;
#include "phylosummary.h"
#include "referencedb.h"
/**************************************************************************************************/
-Bayesian::Bayesian(string tfile, string tempFile, string method, int ksize, int cutoff, int i) :
+Bayesian::Bayesian(string tfile, string tempFile, string method, int ksize, int cutoff, int i, int tid) :
Classify(), kmerSize(ksize), confidenceThreshold(cutoff), iters(i) {
try {
ReferenceDB* rdb = ReferenceDB::getInstance();
+ threadID = tid;
string baseName = tempFile;
if (baseName == "saved") { baseName = rdb->getSavedReference(); }
class Bayesian : public Classify {
public:
- Bayesian(string, string, string, int, int, int);
+ Bayesian(string, string, string, int, int, int, int);
~Bayesian();
string getTaxonomy(Sequence*);
/**************************************************************************************************/
-BlastDB::BlastDB(string tag, float gO, float gE, float mm, float mM, string b) : Database(),
+BlastDB::BlastDB(string tag, float gO, float gE, float mm, float mM, string b, int tid) : Database(),
gapOpen(gO), gapExtend(gE), match(mm), misMatch(mM) {
try {
count = 0;
path = b;
+ threadID = tid;
int randNumber = rand();
//int randNumber = 12345;
string pid = "";
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
- pid += toString(getpid());
+ pid += getpid();
+#else
+ pid += toString(threadID);
#endif
+
dbFileName = tag + pid + toString(randNumber) + ".template.unaligned.fasta";
queryFileName = tag + pid + toString(randNumber) + ".candidate.unaligned.fasta";
blastFileName = tag + pid + toString(randNumber) + ".blast";
}
/**************************************************************************************************/
-BlastDB::BlastDB(string b) : Database() {
+BlastDB::BlastDB(string b, int tid) : Database() {
try {
count = 0;
path = b;
+ threadID = tid;
//make sure blast exists in the write place
if (path == "") {
int randNumber = rand();
string pid = "";
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
- pid += toString(getpid());
+ pid += getpid();
+#else
+ pid += toString(threadID);
#endif
dbFileName = pid + toString(randNumber) + ".template.unaligned.fasta";
ofstream queryFile;
int randNumber = rand();
- string pid = "";
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
- pid += toString(getpid());
-#endif
+ string pid = scrubName(seq->getName());
m->openOutputFile((queryFileName+pid+toString(randNumber)), queryFile);
queryFile << '>' << seq->getName() << endl;
ofstream queryFile;
int randNumber = rand();
- string pid = "";
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
- pid += toString(getpid());
-#endif
+ string pid = scrubName(seq->getName());
m->openOutputFile((queryFileName+pid+toString(randNumber)), queryFile);
queryFile << '>' << seq->getName() << endl;
}
}
/**************************************************************************************************/
+string BlastDB::scrubName(string seqName) {
+ try {
+
+ string cleanName = "";
+
+ for (int i = 0; i < seqName.length(); i++) {
+ if (isalnum(seqName[i])) { cleanName += seqName[i]; }
+ else { cleanName += "_"; }
+ }
+
+ return cleanName;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "BlastDB", "scrubName");
+ exit(1);
+ }
+}
+/**************************************************************************************************/
/**************************************************************************************************/
class BlastDB : public Database {
public:
- BlastDB(string, float, float, float, float, string);
- BlastDB(string);
+ BlastDB(string, float, float, float, float, string, int);
+ BlastDB(string, int);
BlastDB(const BlastDB& bdb) : dbFileName(bdb.dbFileName), queryFileName(bdb.queryFileName), blastFileName(bdb.blastFileName), path(bdb.path),
count(bdb.count), gapOpen(bdb.gapOpen), gapExtend(bdb.gapExtend), match(bdb.match), misMatch(bdb.misMatch), Database(bdb) {}
~BlastDB();
vector<int> findClosestMegaBlast(Sequence*, int, int);
private:
+
+ string scrubName(string);
+
string dbFileName;
string queryFileName;
string blastFileName;
string path;
- int count;
+ int count, threadID;
float gapOpen;
float gapExtend;
float match;
if (groups == "not found") { groups = ""; }
else {
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
calc = validParameter.validFile(parameters, "calc", false);
kmerSize = k;
outputDir = o;
- templateDB = new AlignmentDB(templateFileName, "kmer", kmerSize, 0.0,0.0,0.0,0.0);
+ templateDB = new AlignmentDB(templateFileName, "kmer", kmerSize, 0.0,0.0,0.0,0.0, rand());
m->mothurOutEndLine();
kmer = new Kmer(kmerSize);
//***************************************************************************************************************
ChimeraSlayer::ChimeraSlayer(string file, string temp, bool trim, string mode, int k, int ms, int mms, int win, float div,
-int minsim, int mincov, int minbs, int minsnp, int par, int it, int inc, int numw, bool r, string blas) : Chimera() {
+int minsim, int mincov, int minbs, int minsnp, int par, int it, int inc, int numw, bool r, string blas, int tid) : Chimera() {
try {
fastafile = file;
templateFileName = temp; templateSeqs = readSeqs(temp);
trimChimera = trim;
numNoParents = 0;
blastlocation = blas;
+ threadID = tid;
doPrep();
}
//***************************************************************************************************************
//template=self
ChimeraSlayer::ChimeraSlayer(string file, string temp, bool trim, map<string, int>& prior, string mode, int k, int ms, int mms, int win, float div,
- int minsim, int mincov, int minbs, int minsnp, int par, int it, int inc, int numw, bool r, string blas) : Chimera() {
+ int minsim, int mincov, int minbs, int minsnp, int par, int it, int inc, int numw, bool r, string blas, int tid) : Chimera() {
try {
fastafile = file; templateSeqs = readSeqs(fastafile);
templateFileName = temp;
priority = prior;
numNoParents = 0;
blastlocation = blas;
+ threadID = tid;
createFilter(templateSeqs, 0.0); //just removed columns where all seqs have a gap
}else if (searchMethod == "blast") {
//generate blastdb
- databaseLeft = new BlastDB(m->getRootName(m->getSimpleName(fastafile)), -1.0, -1.0, 1, -3, blastlocation);
+ databaseLeft = new BlastDB(m->getRootName(m->getSimpleName(fastafile)), -1.0, -1.0, 1, -3, blastlocation, threadID);
if (m->control_pressed) { return 0; }
}else if (searchMethod == "blast") {
//generate blastdb
- databaseLeft = new BlastDB(m->getRootName(m->getSimpleName(templateFileName)), -1.0, -1.0, 1, -3, blastlocation);
+ databaseLeft = new BlastDB(m->getRootName(m->getSimpleName(templateFileName)), -1.0, -1.0, 1, -3, blastlocation, threadID);
if (m->control_pressed) { return userTemplate; }
class ChimeraSlayer : public Chimera {
public:
- ChimeraSlayer(string, string, bool, string, int, int, int, int, float, int, int, int, int, int, int, int, int, bool, string);
- ChimeraSlayer(string, string, bool, map<string, int>&, string, int, int, int, int, float, int, int, int, int, int, int, int, int, bool, string);
+ ChimeraSlayer(string, string, bool, string, int, int, int, int, float, int, int, int, int, int, int, int, int, bool, string, int);
+ ChimeraSlayer(string, string, bool, map<string, int>&, string, int, int, int, int, float, int, int, int, int, int, int, int, int, bool, string, int);
~ChimeraSlayer();
Database* databaseLeft;
map<string, int> priority; //for template=self, seqname, seqAligned, abundance
set<string> chimericSeqs; //for template=self, so we don't add chimeric sequences to the userTemplate set
- int numNoParents;
+ int numNoParents, threadID;
vector<data_struct> chimeraResults;
data_results printResults;
*/
#include "chimeraslayercommand.h"
-#include "chimeraslayer.h"
#include "deconvolutecommand.h"
#include "referencedb.h"
int start = time(NULL);
- if (templatefile != "self") { //you want to run slayer with a refernce template
- chimera = new ChimeraSlayer(fastaFileNames[s], templatefile, trim, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign, blastlocation);
- }else {
+ if (templatefile == "self") {
if (processors != 1) { m->mothurOut("When using template=self, mothur can only use 1 processor, continuing."); m->mothurOutEndLine(); processors = 1; }
string nameFile = "";
if (nameFileNames.size() != 0) { //you provided a namefile and we don't need to create one
string inputString = "fasta=" + fastaFileNames[s];
m->mothurOut("/******************************************/"); m->mothurOutEndLine();
m->mothurOut("Running command: unique.seqs(" + inputString + ")"); m->mothurOutEndLine();
-
+
Command* uniqueCommand = new DeconvoluteCommand(inputString);
uniqueCommand->execute();
//sort fastafile by abundance, returns new sorted fastafile name
m->mothurOut("Sorting fastafile according to abundance..."); cout.flush();
- map<string, int> priority = sortFastaFile(fastaFileNames[s], nameFile);
+ priority = sortFastaFile(fastaFileNames[s], nameFile);
m->mothurOut("Done."); m->mothurOutEndLine();
if (m->control_pressed) { for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } return 0; }
-
- chimera = new ChimeraSlayer(fastaFileNames[s], templatefile, trim, priority, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign, blastlocation);
}
-
+
if (outputDir == "") { outputDir = m->hasPath(fastaFileNames[s]); }//if user entered a file with a path then preserve it
string outputFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "slayer.chimera";
string accnosFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "slayer.accnos";
string trimFastaFileName = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "slayer.fasta";
+ //create chimera here if you are mac or linux because fork will copy for you. Create in create processes instead if you are windows.
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ if (templatefile != "self") { //you want to run slayer with a reference template
+ chimera = new ChimeraSlayer(fastaFileNames[s], templatefile, trim, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign, blastlocation, rand());
+ }else {
+ chimera = new ChimeraSlayer(fastaFileNames[s], templatefile, trim, priority, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign, blastlocation, rand());
+ }
+
if (m->control_pressed) { delete chimera; for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } return 0; }
if (chimera->getUnaligned()) {
return 0;
}
templateSeqsLength = chimera->getLength();
+ #else
+ if (processors == 1) {
+ if (templatefile != "self") { //you want to run slayer with a reference template
+ chimera = new ChimeraSlayer(fastaFileNames[s], templatefile, trim, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign, blastlocation, rand());
+ }else {
+ chimera = new ChimeraSlayer(fastaFileNames[s], templatefile, trim, priority, search, ksize, match, mismatch, window, divR, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, realign, blastlocation, rand());
+ }
+
+ if (m->control_pressed) { delete chimera; for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } return 0; }
+
+ if (chimera->getUnaligned()) {
+ m->mothurOut("Your template sequences are different lengths, please correct."); m->mothurOutEndLine();
+ delete chimera;
+ return 0;
+ }
+ templateSeqsLength = chimera->getLength();
+ }
+ #endif
#ifdef USE_MPI
int pid, numSeqsPerProcessor;
MPI_Barrier(MPI_COMM_WORLD); //make everyone wait - just in case
#else
- ofstream outHeader;
- string tempHeader = outputDir + m->getRootName(m->getSimpleName(fastaFileNames[s])) + "slayer.chimeras.tempHeader";
- m->openOutputFile(tempHeader, outHeader);
-
- chimera->printHeader(outHeader);
- outHeader.close();
-
- vector<unsigned long int> 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)]));
- }
-
//break up file
- #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
- if(processors == 1){
- numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName, trimFastaFileName);
-
- int numNoParents = chimera->getNumNoParents();
- if (numNoParents == numSeqs) { m->mothurOut("[WARNING]: megablast returned 0 potential parents for all your sequences. This could be due to formatdb.exe not being setup properly, please check formatdb.log for errors."); m->mothurOutEndLine(); }
-
- if (m->control_pressed) { outputTypes.clear(); if (trim) { m->mothurRemove(trimFastaFileName); } m->mothurRemove(outputFileName); m->mothurRemove(tempHeader); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; }
-
- }else{
- processIDS.resize(0);
-
- numSeqs = createProcesses(outputFileName, fastaFileNames[s], accnosFileName, trimFastaFileName);
+ vector<unsigned long int> positions;
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ 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
+ if (processors == 1) {
+ lines.push_back(new linePair(0, 1000));
+ }else {
+ positions = m->setFilePosFasta(fastaFileNames[s], numSeqs);
- rename((outputFileName + toString(processIDS[0]) + ".temp").c_str(), outputFileName.c_str());
- rename((accnosFileName + toString(processIDS[0]) + ".temp").c_str(), accnosFileName.c_str());
- if (trim) { rename((trimFastaFileName + toString(processIDS[0]) + ".temp").c_str(), trimFastaFileName.c_str()); }
-
- //append output files
- for(int i=1;i<processors;i++){
- m->appendFiles((outputFileName + toString(processIDS[i]) + ".temp"), outputFileName);
- m->mothurRemove((outputFileName + toString(processIDS[i]) + ".temp"));
- }
-
- //append output files
- for(int i=1;i<processors;i++){
- m->appendFiles((accnosFileName + toString(processIDS[i]) + ".temp"), accnosFileName);
- m->mothurRemove((accnosFileName + toString(processIDS[i]) + ".temp"));
- }
-
- if (trim) {
- for(int i=1;i<processors;i++){
- m->appendFiles((trimFastaFileName + toString(processIDS[i]) + ".temp"), trimFastaFileName);
- m->mothurRemove((trimFastaFileName + toString(processIDS[i]) + ".temp"));
- }
- }
-
- if (m->control_pressed) { outputTypes.clear(); if (trim) { m->mothurRemove(trimFastaFileName); } m->mothurRemove(outputFileName); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; }
+ //figure out how many sequences you have to process
+ int numSeqsPerProcessor = numSeqs / processors;
+ for (int i = 0; i < processors; i++) {
+ int startIndex = i * numSeqsPerProcessor;
+ if(i == (processors - 1)){ numSeqsPerProcessor = numSeqs - i * numSeqsPerProcessor; }
+ lines.push_back(new linePair(positions[startIndex], numSeqsPerProcessor));
}
-
- #else
+ }
+#endif
+
+ if(processors == 1){
numSeqs = driver(lines[0], outputFileName, fastaFileNames[s], accnosFileName, trimFastaFileName);
int numNoParents = chimera->getNumNoParents();
if (numNoParents == numSeqs) { m->mothurOut("[WARNING]: megablast returned 0 potential parents for all your sequences. This could be due to formatdb.exe not being setup properly, please check formatdb.log for errors."); m->mothurOutEndLine(); }
-
- if (m->control_pressed) { outputTypes.clear(); if (trim) { m->mothurRemove(trimFastaFileName); } m->mothurRemove(outputFileName); m->mothurRemove(tempHeader); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; }
+ if (m->control_pressed) { outputTypes.clear(); if (trim) { m->mothurRemove(trimFastaFileName); } m->mothurRemove(outputFileName); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; }
- #endif
+ }else{
+ processIDS.resize(0);
+
+ numSeqs = createProcesses(outputFileName, fastaFileNames[s], accnosFileName, trimFastaFileName);
- m->appendFiles(outputFileName, tempHeader);
-
- m->mothurRemove(outputFileName);
- rename(tempHeader.c_str(), outputFileName.c_str());
+ rename((outputFileName + toString(processIDS[0]) + ".temp").c_str(), outputFileName.c_str());
+ rename((accnosFileName + toString(processIDS[0]) + ".temp").c_str(), accnosFileName.c_str());
+ if (trim) { rename((trimFastaFileName + toString(processIDS[0]) + ".temp").c_str(), trimFastaFileName.c_str()); }
+
+ //append output files
+ for(int i=1;i<processIDS.size();i++){
+ m->appendFiles((outputFileName + toString(processIDS[i]) + ".temp"), outputFileName);
+ m->mothurRemove((outputFileName + toString(processIDS[i]) + ".temp"));
+
+ m->appendFiles((accnosFileName + toString(processIDS[i]) + ".temp"), accnosFileName);
+ m->mothurRemove((accnosFileName + toString(processIDS[i]) + ".temp"));
+
+ if (trim) {
+ m->appendFiles((trimFastaFileName + toString(processIDS[i]) + ".temp"), trimFastaFileName);
+ m->mothurRemove((trimFastaFileName + toString(processIDS[i]) + ".temp"));
+ }
+ }
+
+ if (m->control_pressed) { outputTypes.clear(); if (trim) { m->mothurRemove(trimFastaFileName); } m->mothurRemove(outputFileName); m->mothurRemove(accnosFileName); for (int j = 0; j < outputNames.size(); j++) { m->mothurRemove(outputNames[j]); } for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear(); delete chimera; return 0; }
+ }
+
#endif
- delete chimera;
+ #if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+ delete chimera;
+ #endif
for (int i = 0; i < lines.size(); i++) { delete lines[i]; } lines.clear();
m->openInputFile(filename, inFASTA);
inFASTA.seekg(filePos->start);
+
+ if (filePos->start == 0) { chimera->printHeader(out); }
bool done = false;
int count = 0;
int ChimeraSlayerCommand::createProcesses(string outputFileName, string filename, string accnos, string fasta) {
try {
-#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
int process = 0;
int num = 0;
+ int numNoParents = 0;
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
//loop through and create all the processes you want
while (process != processors) {
int pid = fork();
wait(&temp);
}
- int numNoParents = 0;
for (int i = 0; i < processIDS.size(); i++) {
ifstream in;
string tempFile = outputFileName + toString(processIDS[i]) + ".num.temp";
if (!in.eof()) { int tempNum = 0; int tempNumParents = 0; in >> tempNum >> tempNumParents; num += tempNum; numNoParents += tempNumParents; }
in.close(); m->mothurRemove(tempFile);
}
+#else
- if (num == numNoParents) { m->mothurOut("[WARNING]: megablast returned 0 potential parents for all your sequences. This could be due to formatdb.exe not being setup properly, please check formatdb.log for errors."); m->mothurOutEndLine(); }
+ //////////////////////////////////////////////////////////////////////////////////////////////////////
+ //Windows version shared memory, so be careful when passing variables through the slayerData struct.
+ //Above fork() will clone, so memory is separate, but that's not the case with windows,
+ //////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ vector<slayerData*> pDataArray;
+ DWORD dwThreadIdArray[processors];
+ HANDLE hThreadArray[processors];
+ //Create processor worker threads.
+ for( int i=0; i<processors; i++ ){
+ string extension = toString(i) + ".temp";
+ slayerData* tempslayer = new slayerData((outputFileName + extension), (fasta + extension), (accnos + extension), filename, templatefile, search, blastlocation, trimera, trim, realign, m, lines[i]->start, lines[i]->end, ksize, match, mismatch, window, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted, divR, priority, i);
+ pDataArray.push_back(tempslayer);
+ processIDS.push_back(i);
+
+ //MySeqSumThreadFunction is in header. It must be global or static to work with the threads.
+ //default security attributes, thread function name, argument to thread function, use default creation flags, returns the thread identifier
+ hThreadArray[i] = CreateThread(NULL, 0, MySlayerThreadFunction, pDataArray[i], 0, &dwThreadIdArray[i]);
+ }
+
+ //Wait until all threads have terminated.
+ WaitForMultipleObjects(processors, hThreadArray, TRUE, INFINITE);
+
+ //Close all thread handles and free memory allocations.
+ for(int i=0; i < pDataArray.size(); i++){
+ num += pDataArray[i]->count;
+ numNoParents += pDataArray[i]->numNoParents;
+ CloseHandle(hThreadArray[i]);
+ delete pDataArray[i];
+ }
+#endif
+ if (num == numNoParents) { m->mothurOut("[WARNING]: megablast returned 0 potential parents for all your sequences. This could be due to formatdb.exe not being setup properly, please check formatdb.log for errors."); m->mothurOutEndLine(); }
return num;
-#endif
}
catch(exception& e) {
m->errorOut(e, "ChimeraSlayerCommand", "createProcesses");
#include "mothur.h"
#include "command.hpp"
#include "chimera.h"
+#include "chimeraslayer.h"
/***********************************************************/
vector<int> processIDS; //processid
vector<linePair*> lines;
+ map<string, int> priority;
int driver(linePair*, string, string, string, string);
int createProcesses(string, string, string, string);
/***********************************************************/
+//custom data structure for threads to use.
+// This is passed by void pointer so it can be any data type
+// that can be passed using a single void pointer (LPVOID).
+typedef struct slayerData {
+ string outputFName;
+ string fasta;
+ string accnos;
+ string filename;
+ string templatefile;
+ string search;
+ string blastlocation;
+ bool trimera;
+ bool trim, realign;
+ unsigned long int start;
+ unsigned long int end;
+ int ksize, match, mismatch, window, minSimilarity, minCoverage, minBS, minSNP, parents, iters, increment, numwanted;
+ MothurOut* m;
+ float divR;
+ map<string, int> priority;
+ int count;
+ int numNoParents;
+ int threadId;
+
+ slayerData(){}
+ slayerData(string o, string fa, string ac, string f, string te, string se, string bl, bool tri, bool trm, bool re, MothurOut* mout, unsigned long int st, unsigned long int en, int ks, int ma, int mis, int win, int minS, int minC, int miBS, int minSN, int par, int it, int inc, int numw, float div, map<string, int> prior, int tid) {
+ outputFName = o;
+ fasta = fa;
+ accnos = ac;
+ filename = f;
+ templatefile = te;
+ search = se;
+ blastlocation = bl;
+ trimera = tri;
+ trim = trm;
+ realign = re;
+ m = mout;
+ start = st;
+ end = en;
+ ksize = ks;
+ match = ma;
+ mismatch = mis;
+ window = win;
+ minSimilarity = minS;
+ minCoverage = minC;
+ minBS = miBS;
+ minSNP = minSN;
+ parents = par;
+ iters = it;
+ increment = inc;
+ numwanted = numw;
+ divR = div;
+ priority = prior;
+ threadId = tid;
+ count = 0;
+ numNoParents = 0;
+ }
+};
+
+/**************************************************************************************************/
+#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
+#else
+static DWORD WINAPI MySlayerThreadFunction(LPVOID lpParam){
+ slayerData* pDataArray;
+ pDataArray = (slayerData*)lpParam;
+
+ try {
+ ofstream out;
+ pDataArray->m->openOutputFile(pDataArray->outputFName, out);
+
+ ofstream out2;
+ pDataArray->m->openOutputFile(pDataArray->accnos, out2);
+
+ ofstream out3;
+ if (pDataArray->trim) { pDataArray->m->openOutputFile(pDataArray->fasta, out3); }
+
+ ifstream inFASTA;
+ pDataArray->m->openInputFile(pDataArray->filename, inFASTA);
+
+
+
+ Chimera* chimera;
+ if (pDataArray->templatefile != "self") { //you want to run slayer with a reference template
+ chimera = new ChimeraSlayer(pDataArray->filename, pDataArray->templatefile, pDataArray->trim, pDataArray->search, pDataArray->ksize, pDataArray->match, pDataArray->mismatch, pDataArray->window, pDataArray->divR, pDataArray->minSimilarity, pDataArray->minCoverage, pDataArray->minBS, pDataArray->minSNP, pDataArray->parents, pDataArray->iters, pDataArray->increment, pDataArray->numwanted, pDataArray->realign, pDataArray->blastlocation, pDataArray->threadId);
+ }else {
+ chimera = new ChimeraSlayer(pDataArray->filename, pDataArray->templatefile, pDataArray->trim, pDataArray->priority, pDataArray->search, pDataArray->ksize, pDataArray->match, pDataArray->mismatch, pDataArray->window, pDataArray->divR, pDataArray->minSimilarity, pDataArray->minCoverage, pDataArray->minBS, pDataArray->minSNP, pDataArray->parents, pDataArray->iters, pDataArray->increment, pDataArray->numwanted, pDataArray->realign, pDataArray->blastlocation, pDataArray->threadId);
+ }
+
+ //print header if you are process 0
+ if ((pDataArray->start == 0) || (pDataArray->start == 1)) {
+ chimera->printHeader(out);
+ inFASTA.seekg(0);
+ }else { //this accounts for the difference in line endings.
+ inFASTA.seekg(pDataArray->start-1); pDataArray->m->gobble(inFASTA);
+ }
+
+ pDataArray->count = pDataArray->end;
+
+ if (pDataArray->m->control_pressed) { out.close(); out2.close(); if (pDataArray->trim) { out3.close(); } inFASTA.close(); delete chimera; return 0; }
+
+ if (chimera->getUnaligned()) {
+ pDataArray->m->mothurOut("Your template sequences are different lengths, please correct."); pDataArray->m->mothurOutEndLine();
+ out.close(); out2.close(); if (pDataArray->trim) { out3.close(); } inFASTA.close();
+ delete chimera;
+ return 0;
+ }
+ int templateSeqsLength = chimera->getLength();
+
+ if (pDataArray->start == 0) { chimera->printHeader(out); }
+
+ int count = 0;
+ for(int i = 0; i < pDataArray->end; i++){
+
+ if (pDataArray->m->control_pressed) { out.close(); out2.close(); if (pDataArray->trim) { out3.close(); } inFASTA.close(); delete chimera; return 1; }
+
+ Sequence* candidateSeq = new Sequence(inFASTA); pDataArray->m->gobble(inFASTA);
+ string candidateAligned = candidateSeq->getAligned();
+
+ if (candidateSeq->getName() != "") { //incase there is a commented sequence at the end of a file
+ if (candidateSeq->getAligned().length() != templateSeqsLength) {
+ pDataArray->m->mothurOut(candidateSeq->getName() + " is not the same length as the template sequences. Skipping."); pDataArray->m->mothurOutEndLine();
+ }else{
+ //find chimeras
+ chimera->getChimeras(candidateSeq);
+
+ if (pDataArray->m->control_pressed) { delete candidateSeq; delete chimera; return 1; }
+
+ //if you are not chimeric, then check each half
+ data_results wholeResults = chimera->getResults();
+
+ //determine if we need to split
+ bool isChimeric = false;
+
+ if (wholeResults.flag == "yes") {
+ string chimeraFlag = "no";
+ if( (wholeResults.results[0].bsa >= pDataArray->minBS && wholeResults.results[0].divr_qla_qrb >= pDataArray->divR)
+ ||
+ (wholeResults.results[0].bsb >= pDataArray->minBS && wholeResults.results[0].divr_qlb_qra >= pDataArray->divR) ) { chimeraFlag = "yes"; }
+
+
+ if (chimeraFlag == "yes") {
+ if ((wholeResults.results[0].bsa >= pDataArray->minBS) || (wholeResults.results[0].bsb >= pDataArray->minBS)) { isChimeric = true; }
+ }
+ }
+
+ if ((!isChimeric) && pDataArray->trimera) {
+
+ //split sequence in half by bases
+ string leftQuery, rightQuery;
+ Sequence tempSeq(candidateSeq->getName(), candidateAligned);
+ //divideInHalf(tempSeq, leftQuery, rightQuery);
+ string queryUnAligned = tempSeq.getUnaligned();
+ int numBases = int(queryUnAligned.length() * 0.5);
+
+ string queryAligned = tempSeq.getAligned();
+ leftQuery = tempSeq.getAligned();
+ rightQuery = tempSeq.getAligned();
+
+ int baseCount = 0;
+ int leftSpot = 0;
+ for (int i = 0; i < queryAligned.length(); i++) {
+ //if you are a base
+ if (isalpha(queryAligned[i])) {
+ baseCount++;
+ }
+
+ //if you have half
+ if (baseCount >= numBases) { leftSpot = i; break; } //first half
+ }
+
+ //blank out right side
+ for (int i = leftSpot; i < leftQuery.length(); i++) { leftQuery[i] = '.'; }
+
+ //blank out left side
+ for (int i = 0; i < leftSpot; i++) { rightQuery[i] = '.'; }
+
+ //run chimeraSlayer on each piece
+ Sequence* left = new Sequence(candidateSeq->getName(), leftQuery);
+ Sequence* right = new Sequence(candidateSeq->getName(), rightQuery);
+
+ //find chimeras
+ chimera->getChimeras(left);
+ data_results leftResults = chimera->getResults();
+
+ chimera->getChimeras(right);
+ data_results rightResults = chimera->getResults();
+
+ //if either piece is chimeric then report
+ Sequence trimmed = chimera->print(out, out2, leftResults, rightResults);
+ if (pDataArray->trim) { trimmed.printSequence(out3); }
+
+ delete left; delete right;
+
+ }else { //already chimeric
+ //print results
+ Sequence trimmed = chimera->print(out, out2);
+ if (pDataArray->trim) { trimmed.printSequence(out3); }
+ }
+
+
+ }
+ count++;
+ }
+
+ delete candidateSeq;
+ //report progress
+ if((count) % 100 == 0){ pDataArray->m->mothurOut("Processing sequence: " + toString(count)); pDataArray->m->mothurOutEndLine(); }
+ }
+ //report progress
+ if((count) % 100 != 0){ pDataArray->m->mothurOut("Processing sequence: " + toString(count)); pDataArray->m->mothurOutEndLine(); }
+
+ pDataArray->numNoParents = chimera->getNumNoParents();
+ out.close();
+ out2.close();
+ if (pDataArray->trim) { out3.close(); }
+ inFASTA.close();
+ delete chimera;
+
+ return 0;
+
+ }
+ catch(exception& e) {
+ pDataArray->m->errorOut(e, "ChimeraSlayerCommand", "MySlayerThreadFunction");
+ exit(1);
+ }
+}
+#endif
+
+/**************************************************************************************************/
+
+
#endif
}
}
else if(method == "suffix") { database = new SuffixDB(numSeqs); }
- else if(method == "blast") { database = new BlastDB(tempFile.substr(0,tempFile.find_last_of(".")+1), gapOpen, gapExtend, match, misMatch, ""); }
+ else if(method == "blast") { database = new BlastDB(tempFile.substr(0,tempFile.find_last_of(".")+1), gapOpen, gapExtend, match, misMatch, "", threadID); }
else if(method == "distance") { database = new DistanceDB(); }
else {
m->mothurOut(method + " is not a valid search option. I will run the command using kmer, ksize=8.");
}
}
else if(method == "suffix") { database = new SuffixDB(numSeqs); }
- else if(method == "blast") { database = new BlastDB(tempFile.substr(0,tempFile.find_last_of(".")+1), gapOpen, gapExtend, match, misMatch, ""); }
+ else if(method == "blast") { database = new BlastDB(tempFile.substr(0,tempFile.find_last_of(".")+1), gapOpen, gapExtend, match, misMatch, "", threadID); }
else if(method == "distance") { database = new DistanceDB(); }
else {
m->mothurOut(method + " is not a valid search option. I will run the command using kmer, ksize=8.");
string taxFile, templateFile, simpleTax;
vector<string> names;
+ int threadID;
int readTaxonomy(string);
vector<string> parseTax(string);
try {
if (abort == true) { if (calledHelp) { return 0; } return 2; }
- if(method == "bayesian"){ classify = new Bayesian(taxonomyFileName, templateFileName, search, kmerSize, cutoff, iters); }
- else if(method == "knn"){ classify = new Knn(taxonomyFileName, templateFileName, search, kmerSize, gapOpen, gapExtend, match, misMatch, numWanted); }
+ if(method == "bayesian"){ classify = new Bayesian(taxonomyFileName, templateFileName, search, kmerSize, cutoff, iters, rand()); }
+ else if(method == "knn"){ classify = new Knn(taxonomyFileName, templateFileName, search, kmerSize, gapOpen, gapExtend, match, misMatch, numWanted, rand()); }
else {
m->mothurOut(search + " is not a valid method option. I will run the command using bayesian.");
m->mothurOutEndLine();
- classify = new Bayesian(taxonomyFileName, templateFileName, search, kmerSize, cutoff, iters);
+ classify = new Bayesian(taxonomyFileName, templateFileName, search, kmerSize, cutoff, iters, rand());
}
if (m->control_pressed) { delete classify; return 0; }
MPI_Barrier(MPI_COMM_WORLD);
#else
-
+
+ //sanity check
+ if (processors > distName.size()) { processors = distName.size(); }
+
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
if(processors == 1){
listFileNames = cluster(distName, labels); //clusters individual files and returns names of list files
}else{
+
+ cout << processors << '\t' << distName.size() << endl;
vector < vector < map<string, string> > > dividedNames; //distNames[1] = vector of filenames for process 1...
dividedNames.resize(processors);
//for each file group figure out which process will complete it
//want to divide the load intelligently so the big files are spread between processes
for (int i = 0; i < distName.size(); i++) {
+ cout << i << endl;
int processToAssign = (i+1) % processors;
if (processToAssign == 0) { processToAssign = processors; }
//not lets reverse the order of ever other process, so we balance big files running with little ones
for (int i = 0; i < processors; i++) {
+ cout << i << endl;
int remainder = ((i+1) % processors);
if (remainder) { reverse(dividedNames[i].begin(), dividedNames[i].end()); }
}
vector<SharedRAbundVector*> subset;
//create and initialize vector of sharedvectors, one for each group
- for (int i = 0; i < m->Groups.size(); i++) {
+ vector<string> mGroups = m->getGroups();
+ for (int i = 0; i < mGroups.size(); i++) {
SharedRAbundVector* temp = new SharedRAbundVector(sharedorder->getNumBins());
temp->setLabel(sharedorder->getLabel());
- temp->setGroup(m->Groups[i]);
+ temp->setGroup(mGroups[i]);
lookup.push_back(temp);
}
if ((w != k) && (w != l)) { subset.push_back(lookup[w]); }
}
- ccd->updateSharedData(subset, i+1, m->Groups.size(), pair);
+ ccd->updateSharedData(subset, i+1, m->getNumGroups(), pair);
}
n++;
}
//if this is a calculator that can do multiples then do them
pair = false;
- ccd->updateSharedData(lookup, i+1, m->Groups.size(), pair);
+ ccd->updateSharedData(lookup, i+1, m->getNumGroups(), pair);
}
totalNumSeq = i+1;
if ((w != k) && (w != l)) { subset.push_back(lookup[w]); }
}
- ccd->updateSharedData(subset, totalNumSeq, m->Groups.size(), pair);
+ ccd->updateSharedData(subset, totalNumSeq, m->getNumGroups(), pair);
}
n++;
}
//if this is a calculator that can do multiples then do them
pair = false;
- ccd->updateSharedData(lookup, totalNumSeq, m->Groups.size(), pair);
+ ccd->updateSharedData(lookup, totalNumSeq, m->getNumGroups(), pair);
}
//resets output files
numGroupComb = 0;
int n = 1;
- for (int i = 0; i < (m->Groups.size() - 1); i++) {
- for (int l = n; l < m->Groups.size(); l++) {
- group = m->Groups[i] + m->Groups[l];
+ vector<string> mGroups = m->getGroups();
+ for (int i = 0; i < (m->getNumGroups() - 1); i++) {
+ for (int l = n; l < m->getNumGroups(); l++) {
+ group = mGroups[i] + mGroups[l];
groupComb.push_back(group);
numGroupComb++;
}
for (int p = 0; p < inputFileNames.size(); p++) {
- if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } m->Groups.clear(); return 0; }
+ if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } m->clearGroups(); return 0; }
if (outputDir == "") { outputDir += m->hasPath(inputFileNames[p]); }
string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p]));
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
delete input;
delete order;
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
delete input;
delete order;
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
for(int i=0;i<cDisplays.size();i++){ delete cDisplays[i]; }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
delete input;
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
delete input;
delete order;
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
delete order;
//because we randomizes the order we need to put the results in the correct column in the output file
int group1Index, group2Index, pos;
- for (int i = 0; i < m->Groups.size(); i++) {
- if (shared[0]->getGroup() == m->Groups[i]) { group1Index = i; }
- if (shared[1]->getGroup() == m->Groups[i]) { group2Index = i; }
+ vector<string> mGroups = m->getGroups();
+ for (int i = 0; i < mGroups.size(); i++) {
+ if (shared[0]->getGroup() == mGroups[i]) { group1Index = i; }
+ if (shared[1]->getGroup() == mGroups[i]) { group2Index = i; }
}
numGroupComb = 0;
else {
m->splitAtDash(groups, Groups);
}
- m->Groups = Groups;
+ m->setGroups(Groups);
string temp;
temp = validParameter.validFile(parameters, "freq", false); if (temp == "not found") { temp = "100"; }
//set users groups
SharedUtil* util = new SharedUtil();
- util->setGroups(m->Groups, m->namesOfGroups, "collect");
+ Groups = m->getGroups();
+ vector<string> allGroups = m->getAllGroups();
+ util->setGroups(Groups, allGroups, "collect");
+ m->setGroups(Groups);
+ m->setAllGroups(allGroups);
delete util;
while((order != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
for(int i=0;i<cDisplays.size();i++){ delete cDisplays[i]; }
delete order; delete input;
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
if (m->control_pressed) {
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
for(int i=0;i<cDisplays.size();i++){ delete cDisplays[i]; }
- m->Groups.clear();
+ m->clearGroups();
delete input;
return 0;
}
for(int i=0;i<cDisplays.size();i++){ delete cDisplays[i]; }
delete order;
delete input;
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
for(int i=0;i<cDisplays.size();i++){ delete cDisplays[i]; }
//reset groups parameter
- m->Groups.clear();
+ m->clearGroups();
delete input;
m->mothurOutEndLine();
pickedGroups = true;
m->splitAtDash(groups, Groups);
}
- m->Groups = Groups;
+ m->setGroups(Groups);
outputDir = validParameter.validFile(parameters, "outputdir", false); if (outputDir == "not found"){ outputDir = m->hasPath(inputFileName); }
//remove any groups the user does not want, and set globaldata->groups with only valid groups
SharedUtil* util;
util = new SharedUtil();
-
- util->setGroups(m->Groups, groupNames);
+ Groups = m->getGroups();
+ util->setGroups(Groups, groupNames);
+ m->setGroups(Groups);
for (int i = 0; i < lookupFloat.size(); i++) {
//if this sharedrabund is not from a group the user wants then delete it.
- if (util->isValidGroup(lookupFloat[i]->getGroup(), m->Groups) == false) {
+ if (util->isValidGroup(lookupFloat[i]->getGroup(), m->getGroups()) == false) {
delete lookupFloat[i]; lookupFloat[i] = NULL;
lookupFloat.erase(lookupFloat.begin()+i);
i--;
if (groups == "not found") { groups = ""; }
else {
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
sharedfile = validParameter.validFile(parameters, "shared", true);
}
}
- if ((accnosfile == "") && (Groups.size() == 0)) { Groups.push_back("all"); m->Groups = Groups; }
+ if ((accnosfile == "") && (Groups.size() == 0)) { Groups.push_back("all"); m->setGroups(Groups); }
}
}
//make sure groups are valid
//takes care of user setting groupNames that are invalid or setting groups=all
SharedUtil util;
- util.setGroups(Groups, groupMap.namesOfGroups);
+ vector<string> nameGroups = groupMap.getNamesOfGroups();
+ util.setGroups(Groups, nameGroups);
for (int i = 0; i < Groups.size(); i++) {
m->mothurOut(Groups[i] + " contains " + toString(groupMap.getNumSeqs(Groups[i])) + "."); m->mothurOutEndLine();
}
in.close();
- m->Groups = Groups;
+ m->setGroups(Groups);
}
catch(exception& e) {
//make sure groups are valid. takes care of user setting groupNames that are invalid or setting groups=all
SharedUtil* util = new SharedUtil();
- util->setGroups(Groups, groupMap->namesOfGroups);
+ vector<string> nameGroups = groupMap->getNamesOfGroups();
+ util->setGroups(Groups, nameGroups);
delete util;
//sort groupNames so that the group title match the counts below, this is needed because the map object automatically sorts
}
m->runParse = true;
- m->Groups.clear();
- m->namesOfGroups.clear();
+ m->clearGroups();
+ m->clearAllGroups();
m->Treenames.clear();
m->names.clear();
if (m->control_pressed) {
delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
#endif
//executes valid command
mout->runParse = true;
- mout->Groups.clear();
- mout->namesOfGroups.clear();
+ mout->clearGroups();
+ mout->clearAllGroups();
mout->Treenames.clear();
mout->names.clear();
mout->saveNextLabel = "";
#endif
//executes valid command
mout->runParse = true;
- mout->Groups.clear();
- mout->namesOfGroups.clear();
+ mout->clearGroups();
+ mout->clearAllGroups();
mout->Treenames.clear();
mout->names.clear();
mout->saveNextLabel = "";
#endif
//executes valid command
mout->runParse = true;
- mout->Groups.clear();
- mout->namesOfGroups.clear();
+ mout->clearGroups();
+ mout->clearAllGroups();
mout->Treenames.clear();
mout->names.clear();
mout->saveNextLabel = "";
if (groups == "not found") { groups = ""; }
else {
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
sharedfile = validParameter.validFile(parameters, "shared", true);
//make sure groups are valid
//takes care of user setting groupNames that are invalid or setting groups=all
SharedUtil* util = new SharedUtil();
- util->setGroups(Groups, groupMap->namesOfGroups);
+ vector<string> gNamesOfGroups = groupMap->getNamesOfGroups();
+ util->setGroups(Groups, gNamesOfGroups);
+ groupMap->setNamesOfGroups(gNamesOfGroups);
delete util;
//fill names with names of sequences that are from the groups we want to remove
}
in.close();
- m->Groups = Groups;
+ m->setGroups(Groups);
}
catch(exception& e) {
m->splitAtDash(groups, Groups);
}
}
- m->Groups = Groups;
+ m->setGroups(Groups);
string temp = validParameter.validFile(parameters, "large", false); if (temp == "not found") { temp = "F"; }
large = m->isTrue(temp);
if (Groups.size() != 0) {
SharedUtil* util = new SharedUtil();
- util->setGroups(Groups, groupMap->namesOfGroups, "getoturep");
+ vector<string> gNamesOfGroups = groupMap->getNamesOfGroups();
+ util->setGroups(Groups, gNamesOfGroups, "getoturep");
+ groupMap->setNamesOfGroups(gNamesOfGroups);
delete util;
}
}
//make sure groups are valid
//takes care of user setting groupNames that are invalid or setting groups=all
SharedUtil* util = new SharedUtil();
- util->setGroups(Groups, groupMap->namesOfGroups);
+ vector<string> gNamesOfGroups = groupMap->getNamesOfGroups();
+ util->setGroups(Groups, gNamesOfGroups);
+ groupMap->setNamesOfGroups(gNamesOfGroups);
delete util;
if (m->control_pressed) { delete groupMap; return 0; }
else {
pickedGroups = true;
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
scale = validParameter.validFile(parameters, "scale", false); if (scale == "not found") { scale = "totalgroup"; }
//as long as you are not at the end of the file or done wih the lines you want
while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
- if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->Groups.clear(); delete input; out.close(); m->mothurRemove(outputFileName); return 0; }
+ if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->clearGroups(); delete input; out.close(); m->mothurRemove(outputFileName); return 0; }
if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){
//prevent memory leak
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; lookup[i] = NULL; }
- if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); delete input; out.close(); m->mothurRemove(outputFileName); return 0; }
+ if (m->control_pressed) { outputTypes.clear(); m->clearGroups(); delete input; out.close(); m->mothurRemove(outputFileName); return 0; }
//get next line to process
lookup = input->getSharedRAbundVectors();
}
- if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); delete input; out.close(); m->mothurRemove(outputFileName); return 0; }
+ if (m->control_pressed) { outputTypes.clear(); m->clearGroups(); delete input; out.close(); m->mothurRemove(outputFileName); return 0; }
//output error messages about any remaining user labels
set<string>::iterator it;
}
//reset groups parameter
- m->Groups.clear();
+ m->clearGroups();
delete input;
out.close();
else {
userGroups = "unique." + groups;
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
else {
userGroups = groups;
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
unique = false;
}
if (m->control_pressed) { delete groupMap; return 0; }
if (Groups.size() == 0) {
- Groups = groupMap->namesOfGroups;
+ Groups = groupMap->getNamesOfGroups();
//make string for outputfile name
userGroups = "unique.";
}else{
//sanity check for group names
SharedUtil util;
- util.setGroups(Groups, groupMap->namesOfGroups);
+ vector<string> namesOfGroups = groupMap->getNamesOfGroups();
+ util.setGroups(Groups, namesOfGroups);
+ groupMap->setNamesOfGroups(namesOfGroups);
}
//put groups in map to find easier
//reset groups parameter
- m->Groups.clear();
+ m->clearGroups();
if (lastlist != NULL) { delete lastlist; }
m->gobble(fileHandle);
}
fileHandle.close();
- m->namesOfGroups = namesOfGroups;
+ m->setAllGroups(namesOfGroups);
return error;
}
/************************************************************/
m->gobble(fileHandle);
}
fileHandle.close();
- m->namesOfGroups = namesOfGroups;
+ m->setAllGroups(namesOfGroups);
return error;
}
/************************************************************/
void GroupMap::setGroup(string sequenceName, string groupN) {
- groupmap[sequenceName] = groupN;
+ setNamesOfGroups(groupN);
+
+ it = groupmap.find(sequenceName);
+
+ if (it != groupmap.end()) { m->mothurOut("Your groupfile contains more than 1 sequence named " + sequenceName + ", sequence names must be unique. Please correct."); m->mothurOutEndLine(); }
+ else {
+ groupmap[sequenceName] = groupN; //store data in map
+ seqsPerGroup[groupN]++; //increment number of seqs in that group
+ }
}
/************************************************************/
bool isValidGroup(string); //return true if string is a valid group
string getGroup(string);
void setGroup(string, string);
- vector<string> namesOfGroups;
+ vector<string> getNamesOfGroups() {
+ sort(namesOfGroups.begin(), namesOfGroups.end());
+ groupIndex.clear();
+ for (int i = 0; i < namesOfGroups.size(); i++) { groupIndex[namesOfGroups[i]] = i; }
+ return namesOfGroups;
+ }
+ void setNamesOfGroups(vector<string> sn) { namesOfGroups = sn; }
map<string, int> groupIndex; //groupname, vectorIndex in namesOfGroups. - used by collectdisplays and libshuff commands.
int getNumSeqs() { return groupmap.size(); }
vector<string> getNamesSeqs();
int getNumSeqs(string); //return the number of seqs in a given group
private:
+ vector<string> namesOfGroups;
MothurOut* m;
ifstream fileHandle;
string groupFileName;
if (groups == "not found") { groups = ""; }
else {
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
string temp = validParameter.validFile(parameters, "numotu", false); if (temp == "not found") { temp = "0"; }
if (m->control_pressed) {
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { m->mothurRemove(outputNames[i]); } } outputTypes.clear();
- m->Groups.clear();
+ m->clearGroups();
delete input; delete heatmap; return 0;
}
if (m->control_pressed) {
for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { m->mothurRemove(outputNames[i]); } } outputTypes.clear();
- m->Groups.clear();
+ m->clearGroups();
delete input; delete heatmap; return 0;
}
}
//reset groups parameter
- m->Groups.clear();
+ m->clearGroups();
}else if ((format == "list") || (format == "rabund") || (format == "sabund")) {
if (m->control_pressed) {
for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; }
for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { m->mothurRemove(outputNames[i]); } } outputTypes.clear();
- m->Groups.clear();
+ m->clearGroups();
delete input; delete heatmap; return 0;
}
if (m->control_pressed) {
for (int i = 0; i < outputNames.size(); i++) { if (outputNames[i] != "control") { m->mothurRemove(outputNames[i]); } } outputTypes.clear();
- m->Groups.clear();
+ m->clearGroups();
delete input; delete heatmap; return 0;
}
}
//reset groups parameter
- m->Groups.clear();
+ m->clearGroups();
}
//get similairity between groups
data = calcs[k]->getValues(subset);
- sims.push_back(data[0]);
+ sims.push_back(1.0 - data[0]);
//save biggest similairity to set relative sim
// if (data[0] > biggest) { biggest = data[0]; }
if (groups == "not found") { groups = ""; }
else {
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
set<string> processedLabels;
set<string> userLabels = labels;
- if (m->control_pressed) { delete input; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->Groups.clear(); return 0; }
+ if (m->control_pressed) { delete input; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->clearGroups(); return 0; }
//as long as you are not at the end of the file or done wih the lines you want
while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
- if (m->control_pressed) { delete input; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->Groups.clear(); return 0; }
+ if (m->control_pressed) { delete input; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->clearGroups(); return 0; }
if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){
}
- if (m->control_pressed) { delete input; m->Groups.clear(); return 0; }
+ if (m->control_pressed) { delete input; m->clearGroups(); return 0; }
//output error messages about any remaining user labels
set<string>::iterator it;
}
}
- if (m->control_pressed) { delete input; m->Groups.clear(); return 0; }
+ if (m->control_pressed) { delete input; m->clearGroups(); return 0; }
//run last label if you need to
if (needToRun == true) {
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
}
- if (m->control_pressed) { delete input; m->Groups.clear(); return 0; }
+ if (m->control_pressed) { delete input; m->clearGroups(); return 0; }
//reset groups parameter
- m->Groups.clear();
+ m->clearGroups();
delete input;
}
m->runParse = true;
- m->Groups.clear();
- m->namesOfGroups.clear();
+ m->clearGroups();
+ m->clearAllGroups();
m->Treenames.clear();
m->names.clear();
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = ""; Groups.push_back("all"); }
else { m->splitAtDash(groups, Groups); }
- m->Groups = Groups;
+ m->setGroups(Groups);
label = validParameter.validFile(parameters, "label", false);
if (label == "not found") { label = ""; m->mothurOut("You did not provide a label, I will use the first label in your inputfile."); m->mothurOutEndLine(); label=""; }
//fill Groups - checks for "all" and for any typo groups
SharedUtil* util = new SharedUtil();
- util->setGroups(Groups, designMap->namesOfGroups);
+ vector<string> nameGroups = designMap->getNamesOfGroups();
+ util->setGroups(Groups, nameGroups);
+ designMap->setNamesOfGroups(nameGroups);
delete util;
//loop through the Groups and fill Globaldata's Groups with the design file info
- m->Groups = designMap->getNamesSeqs(Groups);
+ vector<string> namesSeqs = designMap->getNamesSeqs(Groups);
+ m->setGroups(namesSeqs);
}
/***************************************************/
}
//reset groups if needed
- if (designfile != "") { m->Groups = Groups; }
+ if (designfile != "") { m->setGroups(Groups); }
/***************************************************/
// reading tree info //
for (int i = 0; i < m->Treenames.size(); i++) {
//sanity check - is this a group that is not in the sharedfile?
if (designfile == "") {
- if (!(m->inUsersGroups(m->Treenames[i], m->namesOfGroups))) {
+ if (!(m->inUsersGroups(m->Treenames[i], m->getAllGroups()))) {
m->mothurOut("[ERROR]: " + m->Treenames[i] + " is not a group in your shared or relabund file."); m->mothurOutEndLine();
mismatch = true;
}
vector<string> myNames = designMap->getNamesSeqs(myGroups);
for(int k = 0; k < myNames.size(); k++) {
- if (!(m->inUsersGroups(myNames[k], m->namesOfGroups))) {
+ if (!(m->inUsersGroups(myNames[k], m->getAllGroups()))) {
m->mothurOut("[ERROR]: " + myNames[k] + " is not a group in your shared or relabund file."); m->mothurOutEndLine();
mismatch = true;
}
/***************************************************/
// create ouptut tree - respecting pickedGroups //
/***************************************************/
- Tree* outputTree = new Tree(m->Groups.size(), treeMap);
+ Tree* outputTree = new Tree(m->getNumGroups(), treeMap);
- outputTree->getSubTree(T[0], m->Groups);
+ outputTree->getSubTree(T[0], m->getGroups());
outputTree->assembleTree();
//no longer need original tree, we have output tree to use and label
vector<SharedRAbundVector*> subset;
//for each grouping
- for (int i = 0; i < designMap->namesOfGroups.size(); i++) {
+ for (int i = 0; i < (designMap->getNamesOfGroups()).size(); i++) {
for (int k = 0; k < lookup.size(); k++) {
//are you from this grouping?
- if (designMap->getGroup(lookup[k]->getGroup()) == designMap->namesOfGroups[i]) {
+ if (designMap->getGroup(lookup[k]->getGroup()) == (designMap->getNamesOfGroups())[i]) {
subset.push_back(lookup[k]);
groupsAlreadyAdded.insert(lookup[k]->getGroup());
}
vector<SharedRAbundFloatVector*> subset;
//for each grouping
- for (int i = 0; i < designMap->namesOfGroups.size(); i++) {
+ for (int i = 0; i < (designMap->getNamesOfGroups()).size(); i++) {
for (int k = 0; k < lookupFloat.size(); k++) {
//are you from this grouping?
- if (designMap->getGroup(lookupFloat[k]->getGroup()) == designMap->namesOfGroups[i]) {
+ if (designMap->getGroup(lookupFloat[k]->getGroup()) == (designMap->getNamesOfGroups())[i]) {
subset.push_back(lookupFloat[k]);
groupsAlreadyAdded.insert(lookupFloat[k]->getGroup());
}
#include "knn.h"
/**************************************************************************************************/
-Knn::Knn(string tfile, string tempFile, string method, int kmerSize, float gapOpen, float gapExtend, float match, float misMatch, int n)
+Knn::Knn(string tfile, string tempFile, string method, int kmerSize, float gapOpen, float gapExtend, float match, float misMatch, int n, int tid)
: Classify(), num(n), search(method) {
try {
+ threadID = tid;
+
//create search database and names vector
generateDatabaseAndNames(tfile, tempFile, method, kmerSize, gapOpen, gapExtend, match, misMatch);
}
class Knn : public Classify {
public:
- Knn(string, string, string, int, float, float, float, float, int);
+ Knn(string, string, string, int, float, float, float, float, int, int);
~Knn();
void setDistName(string s);
else {
savegroups = groups;
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
string temp;
//this is needed because when we read the matrix we sort it into groups in alphabetical order
//the rest of the command and the classes used in this command assume specific order
/********************************************************************************************/
- matrix->setGroups(groupMap->namesOfGroups);
+ matrix->setGroups(groupMap->getNamesOfGroups());
vector<int> sizes;
- for (int i = 0; i < groupMap->namesOfGroups.size(); i++) { sizes.push_back(groupMap->getNumSeqs(groupMap->namesOfGroups[i])); }
+ for (int i = 0; i < (groupMap->getNamesOfGroups()).size(); i++) { sizes.push_back(groupMap->getNumSeqs((groupMap->getNamesOfGroups())[i])); }
matrix->setSizes(sizes);
savedDXYValues = form->evaluateAll();
savedMinValues = form->getSavedMins();
- if (m->control_pressed) { delete form; m->Groups.clear(); delete matrix; delete groupMap; return 0; }
+ if (m->control_pressed) { delete form; m->clearGroups(); delete matrix; delete groupMap; return 0; }
pValueCounts.resize(numGroups);
for(int i=0;i<numGroups;i++){
pValueCounts[i].assign(numGroups, 0);
}
- if (m->control_pressed) { outputTypes.clear(); delete form; m->Groups.clear(); delete matrix; delete groupMap; return 0; }
+ if (m->control_pressed) { outputTypes.clear(); delete form; m->clearGroups(); delete matrix; delete groupMap; return 0; }
Progress* reading = new Progress();
for(int i=0;i<numGroups-1;i++) {
for(int j=i+1;j<numGroups;j++) {
- if (m->control_pressed) { outputTypes.clear(); delete form; m->Groups.clear(); delete matrix; delete groupMap; delete reading; return 0; }
+ if (m->control_pressed) { outputTypes.clear(); delete form; m->clearGroups(); delete matrix; delete groupMap; delete reading; return 0; }
reading->newLine(groupNames[i]+'-'+groupNames[j], iters);
int spoti = groupMap->groupIndex[groupNames[i]]; //neccessary in case user selects groups so you know where they are in the matrix
for(int p=0;p<iters;p++) {
- if (m->control_pressed) { outputTypes.clear(); delete form; m->Groups.clear(); delete matrix; delete groupMap; delete reading; return 0; }
+ if (m->control_pressed) { outputTypes.clear(); delete form; m->clearGroups(); delete matrix; delete groupMap; delete reading; return 0; }
form->randomizeGroups(spoti,spotj);
if(form->evaluatePair(spoti,spotj) >= savedDXYValues[spoti][spotj]) { pValueCounts[i][j]++; }
if(form->evaluatePair(spotj,spoti) >= savedDXYValues[spotj][spoti]) { pValueCounts[j][i]++; }
- if (m->control_pressed) { outputTypes.clear(); delete form; m->Groups.clear(); delete matrix; delete groupMap; delete reading; return 0; }
+ if (m->control_pressed) { outputTypes.clear(); delete form; m->clearGroups(); delete matrix; delete groupMap; delete reading; return 0; }
reading->update(p);
}
}
}
- if (m->control_pressed) { outputTypes.clear(); delete form; m->Groups.clear(); delete matrix; delete groupMap; delete reading; return 0; }
+ if (m->control_pressed) { outputTypes.clear(); delete form; m->clearGroups(); delete matrix; delete groupMap; delete reading; return 0; }
reading->finish();
delete reading;
printCoverageFile();
//clear out users groups
- m->Groups.clear();
+ m->clearGroups();
delete form;
delete matrix; delete groupMap;
void LibShuffCommand::setGroups() {
try {
+ vector<string> myGroups = m->getGroups();
//if the user has not entered specific groups to analyze then do them all
- if (m->Groups.size() == 0) {
+ if (m->getNumGroups() == 0) {
numGroups = groupMap->getNumGroups();
for (int i=0; i < numGroups; i++) {
- m->Groups.push_back(groupMap->namesOfGroups[i]);
+ myGroups.push_back((groupMap->getNamesOfGroups())[i]);
}
} else {
if (savegroups != "all") {
//check that groups are valid
- for (int i = 0; i < m->Groups.size(); i++) {
- if (groupMap->isValidGroup(m->Groups[i]) != true) {
- m->mothurOut(m->Groups[i] + " is not a valid group, and will be disregarded."); m->mothurOutEndLine();
+ for (int i = 0; i < myGroups.size(); i++) {
+ if (groupMap->isValidGroup(myGroups[i]) != true) {
+ m->mothurOut(myGroups[i] + " is not a valid group, and will be disregarded."); m->mothurOutEndLine();
// erase the invalid group from globaldata->Groups
- m->Groups.erase(m->Groups.begin()+i);
+ myGroups.erase(myGroups.begin()+i);
}
}
//if the user only entered invalid groups
- if ((m->Groups.size() == 0) || (m->Groups.size() == 1)) {
+ if ((myGroups.size() == 0) || (myGroups.size() == 1)) {
numGroups = groupMap->getNumGroups();
for (int i=0; i < numGroups; i++) {
- m->Groups.push_back(groupMap->namesOfGroups[i]);
+ myGroups.push_back((groupMap->getNamesOfGroups())[i]);
}
m->mothurOut("When using the groups parameter you must have at least 2 valid groups. I will run the command using all the groups in your groupfile."); m->mothurOutEndLine();
- } else { numGroups = m->Groups.size(); }
+ } else { numGroups = myGroups.size(); }
} else { //users wants all groups
numGroups = groupMap->getNumGroups();
- m->Groups.clear();
+ myGroups.clear();
for (int i=0; i < numGroups; i++) {
- m->Groups.push_back(groupMap->namesOfGroups[i]);
+ myGroups.push_back((groupMap->getNamesOfGroups())[i]);
}
}
}
//sort so labels match
- sort(m->Groups.begin(), m->Groups.end());
+ sort(myGroups.begin(), myGroups.end());
//sort
- sort(groupMap->namesOfGroups.begin(), groupMap->namesOfGroups.end());
+ //sort(groupMap->namesOfGroups.begin(), groupMap->namesOfGroups.end());
- for (int i = 0; i < groupMap->namesOfGroups.size(); i++) { groupMap->groupIndex[groupMap->namesOfGroups[i]] = i; }
+ for (int i = 0; i < (groupMap->getNamesOfGroups()).size(); i++) { groupMap->groupIndex[(groupMap->getNamesOfGroups())[i]] = i; }
- groupNames = m->Groups;
+ groupNames = myGroups;
+ m->setGroups(myGroups);
}
catch(exception& e) {
if (groups == "not found") { groups = ""; }
else {
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
string temp = validParameter.validFile(parameters, "processors", false); if (temp == "not found"){ temp = m->getProcessors(); }
lines[i].end = int (sqrt(float(i+1)/float(processors)) * numGroups);
}
- if (m->control_pressed) { delete input; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->Groups.clear(); return 0; }
+ if (m->control_pressed) { delete input; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->clearGroups(); return 0; }
//as long as you are not at the end of the file or done wih the lines you want
while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
- if (m->control_pressed) { outputTypes.clear(); delete input; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } m->Groups.clear(); return 0; }
+ if (m->control_pressed) { outputTypes.clear(); delete input; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } m->clearGroups(); return 0; }
if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){
m->mothurOut(lookup[0]->getLabel()); m->mothurOutEndLine();
lookup = input->getSharedRAbundVectors();
}
- if (m->control_pressed) { outputTypes.clear(); delete input; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } m->Groups.clear(); return 0; }
+ if (m->control_pressed) { outputTypes.clear(); delete input; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } m->clearGroups(); return 0; }
//output error messages about any remaining user labels
set<string>::iterator it;
}
}
- if (m->control_pressed) { outputTypes.clear(); delete input; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } m->Groups.clear(); return 0; }
+ if (m->control_pressed) { outputTypes.clear(); delete input; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } m->clearGroups(); return 0; }
//run last label if you need to
if (needToRun == true) {
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
}
- if (m->control_pressed) { outputTypes.clear(); delete input; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } m->Groups.clear(); return 0; }
+ if (m->control_pressed) { outputTypes.clear(); delete input; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } m->clearGroups(); return 0; }
//reset groups parameter
- m->Groups.clear();
+ m->clearGroups();
//set phylip file as new current phylipfile
string current = "";
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = "all"; }
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
}
//as long as you are not at the end of the file or done wih the lines you want
while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
- if (m->control_pressed) { out.close(); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->Groups.clear(); delete designMap; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
+ if (m->control_pressed) { out.close(); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->clearGroups(); delete designMap; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){
//prevent memory leak
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; lookup[i] = NULL; }
- if (m->control_pressed) { out.close(); m->Groups.clear(); delete designMap; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
+ if (m->control_pressed) { out.close(); m->clearGroups(); delete designMap; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
//get next line to process
lookup = input.getSharedRAbundVectors();
}
- if (m->control_pressed) { out.close(); m->Groups.clear(); delete designMap; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
+ if (m->control_pressed) { out.close(); m->clearGroups(); delete designMap; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
//output error messages about any remaining user labels
set<string>::iterator it;
out.close();
//reset groups parameter
- m->Groups.clear();
+ m->clearGroups();
delete designMap;
if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0;}
else {
pickedGroups = true;
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
sets = validParameter.validFile(parameters, "sets", false);
//setup the pairwise comparions of sets for metastats
//calculate number of comparisons i.e. with groups A,B,C = AB, AC, BC = 3;
//make sure sets are all in designMap
- SharedUtil* util = new SharedUtil();
- util->setGroups(Sets, designMap->namesOfGroups);
+ SharedUtil* util = new SharedUtil();
+ vector<string> dGroups = designMap->getNamesOfGroups();
+ util->setGroups(Sets, dGroups);
delete util;
int numGroups = Sets.size();
//as long as you are not at the end of the file or done wih the lines you want
while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
- if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->Groups.clear(); delete input; delete designMap; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
+ if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->clearGroups(); delete input; delete designMap; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){
//prevent memory leak
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; lookup[i] = NULL; }
- if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); delete input; delete designMap; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
+ if (m->control_pressed) { outputTypes.clear(); m->clearGroups(); delete input; delete designMap; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
//get next line to process
lookup = input->getSharedRAbundVectors();
}
- if (m->control_pressed) { outputTypes.clear(); m->Groups.clear(); delete input; delete designMap; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
+ if (m->control_pressed) { outputTypes.clear(); m->clearGroups(); delete input; delete designMap; for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
//output error messages about any remaining user labels
set<string>::iterator it;
}
//reset groups parameter
- m->Groups.clear();
+ m->clearGroups();
delete input;
delete designMap;
void setReleaseDate(string r) { releaseDate = r; }
string getVersion() { return version; }
void setVersion(string r) { version = r; }
- vector<string> Groups;
+
+ void addGroup(string g) { Groups.push_back(g); }
+ void setGroups(vector<string>& g) { sort(g.begin(), g.end()); Groups = g; }
+ void clearGroups() { Groups.clear(); }
+ int getNumGroups() { return Groups.size(); }
+ vector<string> getGroups() { sort(Groups.begin(), Groups.end()); return Groups; }
+ void addAllGroup(string g) { namesOfGroups.push_back(g); }
+ void setAllGroups(vector<string>& g) { sort(g.begin(), g.end()); namesOfGroups = g; }
+ void clearAllGroups() { namesOfGroups.clear(); }
+ int getNumAllGroups() { return namesOfGroups.size(); }
+
+ vector<string> getAllGroups() { sort(namesOfGroups.begin(), namesOfGroups.end()); return namesOfGroups; }
vector<string> Treenames;
map<string, string> names;
- vector<string> namesOfGroups;
vector<string> binLabelsInFile;
vector<string> currentBinLabels;
string saveNextLabel, argv, sharedHeaderMode;
string accnosfile, phylipfile, columnfile, listfile, rabundfile, sabundfile, namefile, groupfile, designfile, taxonomyfile;
string orderfile, treefile, sharedfile, ordergroupfile, relabundfile, fastafile, qualfile, sfffile, oligosfile, processors, flowfile;
-
+ vector<string> Groups;
+ vector<string> namesOfGroups;
ofstream out;
int mem_usage(double&, double&);
else {
pickedGroups = true;
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
method = validParameter.validFile(parameters, "method", false); if (method == "not found") { method = "totalgroup"; }
//look for groups whose numseqs is below norm and remove them, warning the user
if (norm != 0) {
- m->Groups.clear();
+ m->clearGroups();
+ vector<string> mGroups;
vector<SharedRAbundVector*> temp;
for (int i = 0; i < lookup.size(); i++) {
if (lookup[i]->getNumSeqs() < norm) {
m->mothurOut(lookup[i]->getGroup() + " contains " + toString(lookup[i]->getNumSeqs()) + ". Eliminating."); m->mothurOutEndLine();
delete lookup[i];
}else {
- m->Groups.push_back(lookup[i]->getGroup());
+ mGroups.push_back(lookup[i]->getGroup());
temp.push_back(lookup[i]);
}
}
lookup = temp;
+ m->setGroups(mGroups);
}
//if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
//as long as you are not at the end of the file or done wih the lines you want
while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
- if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->Groups.clear(); return 0; }
+ if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } m->clearGroups(); return 0; }
if(allLines == 1 || labels.count(lookup[0]->getLabel()) == 1){
//prevent memory leak
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; lookup[i] = NULL; }
- if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); m->Groups.clear(); return 0; }
+ if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); m->clearGroups(); return 0; }
//get next line to process
lookup = input->getSharedRAbundVectors();
}
- if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); m->Groups.clear(); return 0; }
+ if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); m->clearGroups(); return 0; }
//output error messages about any remaining user labels
set<string>::iterator it;
//look for groups whose numseqs is below norm and remove them, warning the user
if (norm != 0) {
- m->Groups.clear();
+ m->clearGroups();
+ vector<string> mGroups;
vector<SharedRAbundFloatVector*> temp;
for (int i = 0; i < lookupFloat.size(); i++) {
if (lookupFloat[i]->getNumSeqs() < norm) {
m->mothurOut(lookupFloat[i]->getGroup() + " contains " + toString(lookupFloat[i]->getNumSeqs()) + ". Eliminating."); m->mothurOutEndLine();
delete lookupFloat[i];
}else {
- m->Groups.push_back(lookupFloat[i]->getGroup());
+ mGroups.push_back(lookupFloat[i]->getGroup());
temp.push_back(lookupFloat[i]);
}
}
lookupFloat = temp;
+ m->setGroups(mGroups);
}
//set norm to smallest group number
//as long as you are not at the end of the file or done wih the lines you want
while((lookupFloat[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
- if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; } m->Groups.clear(); return 0; }
+ if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; } m->clearGroups(); return 0; }
if(allLines == 1 || labels.count(lookupFloat[0]->getLabel()) == 1){
//prevent memory leak
for (int i = 0; i < lookupFloat.size(); i++) { delete lookupFloat[i]; lookupFloat[i] = NULL; }
- if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); m->Groups.clear(); return 0; }
+ if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); m->clearGroups(); return 0; }
//get next line to process
lookupFloat = input->getSharedRAbundFloatVectors();
}
- if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); m->Groups.clear(); return 0; }
+ if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); m->clearGroups(); return 0; }
//output error messages about any remaining user labels
set<string>::iterator it;
}
//reset groups parameter
- m->Groups.clear();
+ m->clearGroups();
delete input;
if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear(); return 0;}
//fill filehandles with neccessary ofstreams
int i;
ofstream* temp;
- for (i=0; i<groupMap->namesOfGroups.size(); i++) {
+ vector<string> gGroups = groupMap->getNamesOfGroups();
+ for (i=0; i<gGroups.size(); i++) {
temp = new ofstream;
- filehandles[groupMap->namesOfGroups[i]] = temp;
+ filehandles[gGroups[i]] = temp;
- string filename = fileroot + groupMap->namesOfGroups[i] + ".list";
+ string filename = fileroot + gGroups[i] + ".list";
outputNames.push_back(filename); outputTypes["list"].push_back(filename);
m->openOutputFile(filename, *temp);
}
if (m->control_pressed) {
delete input; delete list; delete groupMap;
- for (i=0; i<groupMap->namesOfGroups.size(); i++) { (*(filehandles[groupMap->namesOfGroups[i]])).close(); delete filehandles[groupMap->namesOfGroups[i]]; }
+ vector<string> gGroups = groupMap->getNamesOfGroups();
+ for (i=0; i<gGroups.size(); i++) { (*(filehandles[gGroups[i]])).close(); delete filehandles[gGroups[i]]; }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
return 0;
}
if (m->control_pressed) {
delete input; delete list; delete groupMap;
- for (i=0; i<groupMap->namesOfGroups.size(); i++) { (*(filehandles[groupMap->namesOfGroups[i]])).close(); delete filehandles[groupMap->namesOfGroups[i]]; }
+ for (i=0; i<gGroups.size(); i++) { (*(filehandles[gGroups[i]])).close(); delete filehandles[gGroups[i]]; }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
return 0;
}
}
if (m->control_pressed) {
- delete input; delete groupMap;
- for (i=0; i<groupMap->namesOfGroups.size(); i++) { (*(filehandles[groupMap->namesOfGroups[i]])).close(); delete filehandles[groupMap->namesOfGroups[i]]; }
- for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
- return 0;
+ delete input; delete groupMap;
+ for (i=0; i<gGroups.size(); i++) { (*(filehandles[gGroups[i]])).close(); delete filehandles[gGroups[i]]; }
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
+ return 0;
}
//output error messages about any remaining user labels
}
if (m->control_pressed) {
- delete input; delete groupMap;
- for (i=0; i<groupMap->namesOfGroups.size(); i++) { (*(filehandles[groupMap->namesOfGroups[i]])).close(); delete filehandles[groupMap->namesOfGroups[i]]; }
- for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
- return 0;
+ delete input; delete groupMap;
+ for (i=0; i<gGroups.size(); i++) { (*(filehandles[gGroups[i]])).close(); delete filehandles[gGroups[i]]; }
+ for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
+ return 0;
}
//run last label if you need to
outputDir = o;
//if the users enters no groups then give them the score of all groups
- int numGroups = m->Groups.size();
+ vector<string> mGroups = m->getGroups();
+ int numGroups = mGroups.size();
//calculate number of comparsions
int numComp = 0;
vector< vector<string> > namesOfGroupCombos;
for (int r=0; r<numGroups; r++) {
- for (int l = r+1; l < numGroups; l++) {
+ for (int l = 0; l < r; l++) {
numComp++;
- vector<string> groups; groups.push_back(m->Groups[r]); groups.push_back(m->Groups[l]);
+ vector<string> groups; groups.push_back(mGroups[r]); groups.push_back(mGroups[l]);
//cout << globaldata->Groups[r] << '\t' << globaldata->Groups[l] << endl;
namesOfGroupCombos.push_back(groups);
}
vector<string> groups;
if (numGroups == 0) {
//get score for all users groups
- for (int i = 0; i < tmap->namesOfGroups.size(); i++) {
- if (tmap->namesOfGroups[i] != "xxx") {
- groups.push_back(tmap->namesOfGroups[i]);
+ vector<string> tGroups = tmap->getNamesOfGroups();
+ for (int i = 0; i < tGroups.size(); i++) {
+ if (tGroups[i] != "xxx") {
+ groups.push_back(tGroups[i]);
//cout << tmap->namesOfGroups[i] << endl;
}
}
namesOfGroupCombos.push_back(groups);
}else {
- for (int i = 0; i < m->Groups.size(); i++) {
- groups.push_back(m->Groups[i]);
+ for (int i = 0; i < mGroups.size(); i++) {
+ groups.push_back(mGroups[i]);
//cout << globaldata->Groups[i] << endl;
}
namesOfGroupCombos.push_back(groups);
}
m->runParse = true;
- m->Groups.clear();
- m->namesOfGroups.clear();
+ m->clearGroups();
+ m->clearAllGroups();
m->Treenames.clear();
m->names.clear();
//check for optional parameter and set defaults
// ...at some point should added some additional type checking...
groups = validParameter.validFile(parameters, "groups", false);
- if (groups == "not found") { groups = ""; m->Groups.clear(); }
+ if (groups == "not found") { groups = ""; m->clearGroups(); }
else {
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
itersString = validParameter.validFile(parameters, "iters", false); if (itersString == "not found") { itersString = "1000"; }
if (m->control_pressed) {
delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
//set users groups to analyze
util = new SharedUtil();
- util->setGroups(m->Groups, tmap->namesOfGroups, allGroups, numGroups, "parsimony"); //sets the groups the user wants to analyze
- util->getCombos(groupComb, m->Groups, numComp);
+ vector<string> mGroups = m->getGroups();
+ vector<string> tGroups = tmap->getNamesOfGroups();
+ util->setGroups(mGroups, tGroups, allGroups, numGroups, "parsimony"); //sets the groups the user wants to analyze
+ util->getCombos(groupComb, mGroups, numComp);
+ m->setGroups(mGroups);
delete util;
if (numGroups == 1) { numComp++; groupComb.push_back(allGroups); }
delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }
if (randomtree == "") { outSum.close(); }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }
if (randomtree == "") { outSum.close(); }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
if (randomtree == "") { outSum.close(); }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
delete reading; delete pars; delete output; delete randT;
delete tmap;
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
delete reading; delete pars; delete output; delete randT;
delete tmap;
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }
if (randomtree == "") { outSum.close(); }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
if (randomtree == "") { printUSummaryFile(); }
//reset groups parameter
- m->Groups.clear();
+ m->clearGroups();
delete pars; delete output;
delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }
count = 1;
numEachGroup.resize(numGroups, 0);
+
for (int i = 1; i <= numGroups; i++) {
m->mothurOut("Please enter the number of sequences in group " + toString(i) + ": ");
cin >> num;
//set tmaps seqsPerGroup
tmap->seqsPerGroup[toString(i)] = num;
- tmap->namesOfGroups.push_back(toString(i));
+ tmap->addGroup(toString(i));
//set tmaps namesOfSeqs
for (int j = 0; j < num; j++) {
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = ""; }
else { m->splitAtDash(groups, Groups); }
- m->Groups = Groups;
+ m->setGroups(Groups);
}
string fbase = outputDir + m->getRootName(m->getSimpleName(inputFile));
string outputFileName = fbase + lookupFloat[0]->getLabel();
- output(outputFileName, m->Groups, X, d);
+ output(outputFileName, m->getGroups(), X, d);
if (metric) {
}
m->runParse = true;
- m->Groups.clear();
- m->namesOfGroups.clear();
+ m->clearGroups();
+ m->clearAllGroups();
m->Treenames.clear();
m->names.clear();
if (groups == "not found") { groups = ""; }
else {
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
if ((!collect) && (!rarefy) && (!summary)) { m->mothurOut("No outputs selected. You must set either collect, rarefy or summary to true, summary=T by default."); m->mothurOutEndLine(); abort=true; }
if (m->control_pressed) {
delete tmap; for (int i = 0; i < trees.size(); i++) { delete trees[i]; }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
}
SharedUtil* util = new SharedUtil();
- util->setGroups(m->Groups, tmap->namesOfGroups, "phylo.diversity"); //sets the groups the user wants to analyze
+ vector<string> mGroups = m->getGroups();
+ vector<string> tGroups = tmap->getNamesOfGroups();
+ util->setGroups(mGroups, tGroups, "phylo.diversity"); //sets the groups the user wants to analyze
delete util;
//incase the user had some mismatches between the tree and group files we don't want group xxx to be analyzed
- for (int i = 0; i < m->Groups.size(); i++) { if (m->Groups[i] == "xxx") { m->Groups.erase(m->Groups.begin()+i); break; } }
+ for (int i = 0; i < mGroups.size(); i++) { if (mGroups[i] == "xxx") { mGroups.erase(mGroups.begin()+i); break; } }
+ m->setGroups(mGroups);
vector<string> outputNames;
//create a vector containing indexes of leaf nodes, randomize it, select nodes to send to calculator
vector<int> randomLeaf;
for (int j = 0; j < numLeafNodes; j++) {
- if (m->inUsersGroups(trees[i]->tree[j].getGroup(), m->Groups) == true) { //is this a node from the group the user selected.
+ if (m->inUsersGroups(trees[i]->tree[j].getGroup(), mGroups) == true) { //is this a node from the group the user selected.
randomLeaf.push_back(j);
}
}
//find largest group total
int largestGroup = 0;
- for (int j = 0; j < m->Groups.size(); j++) {
- if (tmap->seqsPerGroup[m->Groups[j]] > largestGroup) { largestGroup = tmap->seqsPerGroup[m->Groups[j]]; }
+ for (int j = 0; j < mGroups.size(); j++) {
+ if (tmap->seqsPerGroup[mGroups[j]] > largestGroup) { largestGroup = tmap->seqsPerGroup[mGroups[j]]; }
//initialize diversity
- diversity[m->Groups[j]].resize(tmap->seqsPerGroup[m->Groups[j]]+1, 0.0); //numSampled
+ diversity[mGroups[j]].resize(tmap->seqsPerGroup[mGroups[j]]+1, 0.0); //numSampled
//groupA 0.0 0.0
//initialize sumDiversity
- sumDiversity[m->Groups[j]].resize(tmap->seqsPerGroup[m->Groups[j]]+1, 0.0);
+ sumDiversity[mGroups[j]].resize(tmap->seqsPerGroup[mGroups[j]]+1, 0.0);
}
//convert freq percentage to number
if(largestGroup % increment != 0){ numSampledList.insert(largestGroup); }
//add other groups ending points
- for (int j = 0; j < m->Groups.size(); j++) {
- if (numSampledList.count(diversity[m->Groups[j]].size()-1) == 0) { numSampledList.insert(diversity[m->Groups[j]].size()-1); }
+ for (int j = 0; j < mGroups.size(); j++) {
+ if (numSampledList.count(diversity[mGroups[j]].size()-1) == 0) { numSampledList.insert(diversity[mGroups[j]].size()-1); }
}
#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux)
int PhyloDiversityCommand::driver(Tree* t, map< string, vector<float> >& div, map<string, vector<float> >& sumDiv, int numIters, int increment, vector<int>& randomLeaf, set<int>& numSampledList, ofstream& outCollect, ofstream& outSum, bool doSumCollect){
try {
int numLeafNodes = randomLeaf.size();
+ vector<string> mGroups = m->getGroups();
for (int l = 0; l < numIters; l++) {
random_shuffle(randomLeaf.begin(), randomLeaf.end());
//initialize counts
map<string, int> counts;
map< string, set<int> > countedBranch;
- for (int j = 0; j < m->Groups.size(); j++) { counts[m->Groups[j]] = 0; countedBranch[m->Groups[j]].insert(-2); } //add dummy index to initialize countedBranch sets
+ for (int j = 0; j < mGroups.size(); j++) { counts[mGroups[j]] = 0; countedBranch[mGroups[j]].insert(-2); } //add dummy index to initialize countedBranch sets
for(int k = 0; k < numLeafNodes; k++){
if (rarefy) {
//add this diversity to the sum
- for (int j = 0; j < m->Groups.size(); j++) {
- for (int g = 0; g < div[m->Groups[j]].size(); g++) {
- sumDiv[m->Groups[j]][g] += div[m->Groups[j]][g];
+ for (int j = 0; j < mGroups.size(); j++) {
+ for (int g = 0; g < div[mGroups[j]].size(); g++) {
+ sumDiv[mGroups[j]][g] += div[mGroups[j]][g];
}
}
}
out << "Groups\tnumSampled\tphyloDiversity" << endl;
out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
-
- for (int j = 0; j < m->Groups.size(); j++) {
- int numSampled = (div[m->Groups[j]].size()-1);
- out << m->Groups[j] << '\t' << numSampled << '\t';
+
+ vector<string> mGroups = m->getGroups();
+ for (int j = 0; j < mGroups.size(); j++) {
+ int numSampled = (div[mGroups[j]].size()-1);
+ out << mGroups[j] << '\t' << numSampled << '\t';
float score;
- if (scale) { score = (div[m->Groups[j]][numSampled] / (float)numIters) / (float)numSampled; }
- else { score = div[m->Groups[j]][numSampled] / (float)numIters; }
+ if (scale) { score = (div[mGroups[j]][numSampled] / (float)numIters) / (float)numSampled; }
+ else { score = div[mGroups[j]][numSampled] / (float)numIters; }
out << setprecision(4) << score << endl;
}
try {
out << "numSampled\t";
- for (int i = 0; i < m->Groups.size(); i++) { out << m->Groups[i] << '\t'; }
+ vector<string> mGroups = m->getGroups();
+ for (int i = 0; i < mGroups.size(); i++) { out << mGroups[i] << '\t'; }
out << endl;
out.setf(ios::fixed, ios::floatfield); out.setf(ios::showpoint);
int numSampled = *it;
out << numSampled << '\t';
-
- for (int j = 0; j < m->Groups.size(); j++) {
- if (numSampled < div[m->Groups[j]].size()) {
+
+ for (int j = 0; j < mGroups.size(); j++) {
+ if (numSampled < div[mGroups[j]].size()) {
float score;
- if (scale) { score = (div[m->Groups[j]][numSampled] / (float)numIters) / (float)numSampled; }
- else { score = div[m->Groups[j]][numSampled] / (float)numIters; }
+ if (scale) { score = (div[mGroups[j]][numSampled] / (float)numIters) / (float)numSampled; }
+ else { score = div[mGroups[j]][numSampled] / (float)numIters; }
out << setprecision(4) << score << '\t';
}else { out << "NA" << '\t'; }
//initialize groupcounts
if (groupmap != NULL) {
- for (int j = 0; j < groupmap->namesOfGroups.size(); j++) {
- tree[index].groupCount[groupmap->namesOfGroups[j]] = 0;
+ vector<string> mGroups = groupmap->getNamesOfGroups();
+ for (int j = 0; j < mGroups.size(); j++) {
+ tree[index].groupCount[mGroups[j]] = 0;
}
//find out the sequences group
if (groupmap != NULL) {
map<string, bool> containsGroup;
- for (int j = 0; j < groupmap->namesOfGroups.size(); j++) {
- containsGroup[groupmap->namesOfGroups[j]] = false;
+ vector<string> mGroups = groupmap->getNamesOfGroups();
+ for (int j = 0; j < mGroups.size(); j++) {
+ containsGroup[mGroups[j]] = false;
}
for (int k = 0; k < names.size(); k++) {
//initialize groupcounts
if (groupmap != NULL) {
map<string, bool> containsGroup;
- for (int j = 0; j < groupmap->namesOfGroups.size(); j++) {
- tree[index].groupCount[groupmap->namesOfGroups[j]] = 0;
- containsGroup[groupmap->namesOfGroups[j]] = false;
+ vector<string> mGroups = groupmap->getNamesOfGroups();
+ for (int j = 0; j < mGroups.size(); j++) {
+ tree[index].groupCount[mGroups[j]] = 0;
+ containsGroup[mGroups[j]] = false;
}
if (groupmap != NULL) {
//so the labels match the counts below, since the map sorts them automatically...
//sort(groupmap->namesOfGroups.begin(), groupmap->namesOfGroups.end());
-
- for (int i = 0; i < groupmap->namesOfGroups.size(); i++) {
- out << groupmap->namesOfGroups[i] << '\t';
+ vector<string> mGroups = groupmap->getNamesOfGroups();
+ for (int i = 0; i < mGroups.size(); i++) {
+ out << mGroups[i] << '\t';
}
}
//for (itGroup = tree[0].groupCount.begin(); itGroup != tree[0].groupCount.end(); itGroup++) {
// out << itGroup->second << '\t';
//}
- for (int i = 0; i < groupmap->namesOfGroups.size(); i++) { out << tree[0].groupCount[groupmap->namesOfGroups[i]] << '\t'; }
+ vector<string> mGroups = groupmap->getNamesOfGroups();
+ for (int i = 0; i < mGroups.size(); i++) { out << tree[0].groupCount[mGroups[i]] << '\t'; }
}
out << endl;
//for (itGroup = tree[it->second].groupCount.begin(); itGroup != tree[it->second].groupCount.end(); itGroup++) {
// out << itGroup->second << '\t';
//}
- for (int i = 0; i < groupmap->namesOfGroups.size(); i++) { out << tree[it->second].groupCount[groupmap->namesOfGroups[i]] << '\t'; }
+ vector<string> mGroups = groupmap->getNamesOfGroups();
+ for (int i = 0; i < mGroups.size(); i++) { out << tree[it->second].groupCount[mGroups[i]] << '\t'; }
}
out << endl;
//initialize groupcounts
if (groupmap != NULL) {
- for (int j = 0; j < groupmap->namesOfGroups.size(); j++) {
- tree[i].groupCount[groupmap->namesOfGroups[j]] = 0;
+ for (int j = 0; j < (groupmap->getNamesOfGroups()).size(); j++) {
+ tree[i].groupCount[(groupmap->getNamesOfGroups())[j]] = 0;
}
}
string fileNameRoot = outputDir + m->getRootName(m->getSimpleName(inputFileNames[p]));
- if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } m->Groups.clear(); return 0; }
+ if (m->control_pressed) { outputTypes.clear(); for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } m->clearGroups(); return 0; }
if (inputFileNames.size() > 1) {
m->mothurOutEndLine(); m->mothurOut("Processing group " + groups[p]); m->mothurOutEndLine(); m->mothurOutEndLine();
}
delete input;
- m->Groups.clear();
+ m->clearGroups();
return filenames;
}
else {
m->splitAtDash(groups, Groups);
}
- m->Groups = Groups;
+ m->setGroups(Groups);
string temp;
temp = validParameter.validFile(parameters, "freq", false); if (temp == "not found") { temp = "100"; }
string lastLabel = lookup[0]->getLabel();
if (m->control_pressed) {
- m->Groups.clear();
+ m->clearGroups();
delete input;
for(int i=0;i<rDisplays.size();i++){ delete rDisplays[i]; }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); }
//as long as you are not at the end of the file or done wih the lines you want
while((lookup[0] != NULL) && ((allLines == 1) || (userLabels.size() != 0))) {
if (m->control_pressed) {
- m->Groups.clear();
+ m->clearGroups();
delete input;
for(int i=0;i<rDisplays.size();i++){ delete rDisplays[i]; }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); }
}
if (m->control_pressed) {
- m->Groups.clear();
+ m->clearGroups();
delete input;
for(int i=0;i<rDisplays.size();i++){ delete rDisplays[i]; }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); }
}
if (m->control_pressed) {
- m->Groups.clear();
+ m->clearGroups();
delete input;
for(int i=0;i<rDisplays.size();i++){ delete rDisplays[i]; }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); }
}
for(int i=0;i<rDisplays.size();i++){ delete rDisplays[i]; }
- m->Groups.clear();
+ m->clearGroups();
delete input;
if (m->control_pressed) { for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } return 0; }
map<string, int>::iterator it;
it = tmap->seqsPerGroup.find("xxx");
if (it == tmap->seqsPerGroup.end()) { //its a new group
- tmap->namesOfGroups.push_back("xxx");
+ tmap->addGroup("xxx");
tmap->seqsPerGroup["xxx"] = 1;
}else {
tmap->seqsPerGroup["xxx"]++;
if (groups == "not found") { groups = ""; }
else {
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
sharedfile = validParameter.validFile(parameters, "shared", true);
//make sure groups are valid
//takes care of user setting groupNames that are invalid or setting groups=all
SharedUtil* util = new SharedUtil();
- util->setGroups(Groups, groupMap->namesOfGroups);
+ vector<string> namesGroups = groupMap->getNamesOfGroups();
+ util->setGroups(Groups, namesGroups);
delete util;
//fill names with names of sequences that are from the groups we want to remove
vector<SharedRAbundVector*> lookup = tempInput->getSharedRAbundVectors();
//save m->Groups
- vector<string> allGroupsNames = m->namesOfGroups;
- vector<string> mothurOutGroups = m->Groups;
+ vector<string> allGroupsNames = m->getAllGroups();
+ vector<string> mothurOutGroups = m->getGroups();
vector<string> groupsToKeep;
for (int i = 0; i < allGroupsNames.size(); i++) {
- if (!m->inUsersGroups(allGroupsNames[i], m->Groups)) {
+ if (!m->inUsersGroups(allGroupsNames[i], m->getGroups())) {
groupsToKeep.push_back(allGroupsNames[i]);
}
}
- if (allGroupsNames.size() == groupsToKeep.size()) { m->mothurOut("Your file does not contain any groups you wish to remove."); m->mothurOutEndLine(); m->Groups = mothurOutGroups; delete tempInput; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } return 0; }
+ if (allGroupsNames.size() == groupsToKeep.size()) { m->mothurOut("Your file does not contain any groups you wish to remove."); m->mothurOutEndLine(); m->setGroups(mothurOutGroups); delete tempInput; for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; } return 0; }
//reset read
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
delete tempInput;
- m->Groups = groupsToKeep;
- m->namesOfGroups.clear();
+ m->setGroups(groupsToKeep);
+ m->clearAllGroups();
m->names.clear();
m->saveNextLabel = "";
m->printedHeaders = false;
}
- m->Groups = mothurOutGroups;
+ m->setGroups(mothurOutGroups);
if (wroteSomething == false) { m->mothurOut("Your file contains only the groups you wish to remove."); m->mothurOutEndLine(); }
}
in.close();
- m->Groups = Groups;
+ m->setGroups(Groups);
}
catch(exception& e) {
//make sure groups are valid
//takes care of user setting groupNames that are invalid or setting groups=all
SharedUtil* util = new SharedUtil();
- util->setGroups(Groups, groupMap->namesOfGroups);
+ vector<string> allGroups = groupMap->getNamesOfGroups();
+ util->setGroups(Groups, allGroups);
delete util;
if (m->control_pressed) { delete groupMap; return 0; }
if (groupfile != "") {
groupMap = new GroupMap(groupfile); groupMap->readMap();
SharedUtil util;
- util.setGroups(Groups, groupMap->namesOfGroups);
+ vector<string> namesGroups = groupMap->getNamesOfGroups();
+ util.setGroups(Groups, namesGroups);
m->openOutputFile(outputGroupFileName, outGroup);
}
//**********************************************************************************************************************
int RemoveRareCommand::processShared(){
try {
- m->Groups = Groups;
+ m->setGroups(Groups);
string thisOutputDir = outputDir;
if (outputDir == "") { thisOutputDir += m->hasPath(sharedfile); }
try {
CommandParameter plist("list", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(plist);
CommandParameter pgroup("group", "InputTypes", "", "", "none", "none", "none",false,true); parameters.push_back(pgroup);
- CommandParameter pordergroup("ordergroup", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pordergroup);
+ //CommandParameter pordergroup("ordergroup", "InputTypes", "", "", "none", "none", "none",false,false); parameters.push_back(pordergroup);
CommandParameter plabel("label", "String", "", "", "", "", "",false,false); parameters.push_back(plabel);
CommandParameter pgroups("groups", "String", "", "", "", "", "",false,false); parameters.push_back(pgroups);
CommandParameter pinputdir("inputdir", "String", "", "", "", "", "",false,false); parameters.push_back(pinputdir);
helpString += "The make.shared command parameters are list, group, ordergroup, groups and label. list and group are required unless a current file is available.\n";
helpString += "The groups parameter allows you to indicate which groups you want to include, group names should be separated by dashes. ex. groups=A-B-C. Default is all groups in your groupfile.\n";
helpString += "The label parameter allows you to indicate which labels you want to include, label names should be separated by dashes. Default is all labels in your list file.\n";
- helpString += "The ordergroup parameter allows you to indicate the order of the groups in the sharedfile, by default the groups are listed alphabetically.\n";
+ //helpString += "The ordergroup parameter allows you to indicate the order of the groups in the sharedfile, by default the groups are listed alphabetically.\n";
return helpString;
}
catch(exception& e) {
int error = groupMap->readMap();
if (error == 1) { abort = true; }
- m->namesOfGroups = groupMap->namesOfGroups;
+ vector<string> allGroups = groupMap->getNamesOfGroups();
+ m->setAllGroups(allGroups);
}
else { m->mothurOut("You have no current group file and the group parameter is required."); m->mothurOutEndLine(); abort = true; }
}else {
int error = groupMap->readMap();
if (error == 1) { abort = true; }
- m->namesOfGroups = groupMap->namesOfGroups;
+ vector<string> allGroups = groupMap->getNamesOfGroups();
+ m->setAllGroups(allGroups);
m->setGroupFile(groupfile);
}
if (groups == "not found") { groups = ""; }
else {
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
//check for optional parameter and set defaults
//if hte user has not specified any groups then use them all
if (Groups.size() == 0) {
- Groups = groupMap->namesOfGroups; m->Groups = Groups;
+ Groups = groupMap->getNamesOfGroups(); m->setGroups(Groups);
}else { pickedGroups = true; }
//fill filehandles with neccessary ofstreams
for (int i=0; i<Groups.size(); i++) { m->mothurRemove((fileroot + Groups[i] + ".rabund")); }
return 0;
}
-
- if ((m->Groups.size() == 0) && (SharedList->getNumSeqs() != groupMap->getNumSeqs())) { //if the user has not specified any groups and their files don't match exit with error
+
+ //sanity check
+ int error = ListGroupSameSeqs();
+
+ if ((!pickedGroups) && (SharedList->getNumSeqs() != groupMap->getNumSeqs())) { //if the user has not specified any groups and their files don't match exit with error
m->mothurOut("Your group file contains " + toString(groupMap->getNumSeqs()) + " sequences and list file contains " + toString(SharedList->getNumSeqs()) + " sequences. Please correct."); m->mothurOutEndLine();
out.close();
return 0;
}
+ if (error == 1) { m->control_pressed = true; }
+
//if user has specified groups make new groupfile for them
if (pickedGroups) { //make new group file
string groups = "";
- if (m->Groups.size() < 4) {
- for (int i = 0; i < m->Groups.size(); i++) {
- groups += m->Groups[i] + ".";
+ if (m->getNumGroups() < 4) {
+ for (int i = 0; i < m->getNumGroups(); i++) {
+ groups += (m->getGroups())[i] + ".";
}
}else { groups = "merge"; }
string groupName;
for (int i = 0; i < names.size(); i++) {
groupName = groupMap->getGroup(names[i]);
- if (isValidGroup(groupName, m->Groups)) {
+ if (isValidGroup(groupName, m->getGroups())) {
outGroups << names[i] << '\t' << groupName << endl;
}
}
if (order.size() == 0) { //user has not specified an order so do aplabetically
sort(thislookup.begin(), thislookup.end(), compareSharedRabunds);
- m->Groups.clear();
+ m->clearGroups();
+ vector<string> Groups;
//initialize bin values
for (int i = 0; i < thislookup.size(); i++) {
out << thislookup[i]->getLabel() << '\t' << thislookup[i]->getGroup() << '\t';
thislookup[i]->print(out);
- m->Groups.push_back(thislookup[i]->getGroup());
+ Groups.push_back(thislookup[i]->getGroup());
RAbundVector rav = thislookup[i]->getRAbundVector();
m->openOutputFileAppend(fileroot + thislookup[i]->getGroup() + ".rabund", *(filehandles[thislookup[i]->getGroup()]));
rav.print(*(filehandles[thislookup[i]->getGroup()]));
(*(filehandles[thislookup[i]->getGroup()])).close();
}
+ m->setGroups(Groups);
}else{
//create a map from groupName to each sharedrabund
map<string, SharedRAbundVector*> myMap;
myMap[thislookup[i]->getGroup()] = thislookup[i];
}
- m->Groups.clear();
+ m->clearGroups();
+ vector<string> Groups;
//loop through ordered list and print the rabund
for (int i = 0; i < order.size(); i++) {
out << (myIt->second)->getLabel() << '\t' << (myIt->second)->getGroup() << '\t';
(myIt->second)->print(out);
- m->Groups.push_back((myIt->second)->getGroup());
+ Groups.push_back((myIt->second)->getGroup());
RAbundVector rav = (myIt->second)->getRAbundVector();
m->openOutputFileAppend(fileroot + (myIt->second)->getGroup() + ".rabund", *(filehandles[(myIt->second)->getGroup()]));
m->mothurOut("Can't find shared info for " + order[i] + ", skipping."); m->mothurOutEndLine();
}
}
+
+ m->setGroups(Groups);
}
exit(1);
}
}
-
+//**********************************************************************************************************************
+int SharedCommand::ListGroupSameSeqs() {
+ try {
+
+ int error = 0;
+
+ vector<string> groupMapsSeqs = groupMap->getNamesSeqs();
+
+ set<string> groupNamesSeqs;
+ for(int i = 0; i < groupMapsSeqs.size(); i++) {
+ groupNamesSeqs.insert(groupMapsSeqs[i]);
+ }
+
+
+ //go through list and if group returns "not found" output it
+ for (int i = 0; i < SharedList->getNumBins(); i++) {
+ if (m->control_pressed) { return 0; }
+
+ string names = SharedList->get(i);
+
+ vector<string> listNames;
+ m->splitAtComma(names, listNames);
+
+ for (int j = 0; j < listNames.size(); j++) {
+ int num = groupNamesSeqs.count(listNames[j]);
+
+ if (num == 0) { error = 1; m->mothurOut("[ERROR]: " + listNames[j] + " is in your listfile and not in your groupfile. Please correct."); m->mothurOutEndLine(); }
+ else { groupNamesSeqs.erase(listNames[j]); }
+ }
+ }
+
+ for (set<string>::iterator itGroupSet = groupNamesSeqs.begin(); itGroupSet != groupNamesSeqs.end(); itGroupSet++) {
+ error = 1;
+ m->mothurOut("[ERROR]: " + (*itGroupSet) + " is in your groupfile and not your listfile. Please correct."); m->mothurOutEndLine();
+ }
+
+ return error;
+ }
+ catch(exception& e) {
+ m->errorOut(e, "SharedCommand", "ListGroupSameSeqs");
+ exit(1);
+ }
+}
//**********************************************************************************************************************
SharedCommand::~SharedCommand(){
int readOrderFile();
bool isValidGroup(string, vector<string>);
int eliminateZeroOTUS(vector<SharedRAbundVector*>&);
+ int ListGroupSameSeqs();
SharedListVector* SharedList;
InputData* input;
SharedRAbundVector* shared1 = vectorShared[0];
SharedRAbundVector* shared2 = vectorShared[1];
if(numGroups == -1) {
- numGroups = m->Groups.size();
+ numGroups = m->getNumGroups();
}
if(callCount == numGroups*(numGroups-1)/2) {
vector<SharedRAbundVector*> lookup; //contains just the groups the user selected
map<string, SharedRAbundVector*> finder; //contains all groups in groupmap
string group, names, name;
-
- util->setGroups(m->Groups, groupmap->namesOfGroups);
+
+ vector<string> Groups = m->getGroups();
+ vector<string> allGroups = groupmap->getNamesOfGroups();
+ util->setGroups(Groups, allGroups);
+ m->setGroups(Groups);
delete util;
- for (int i = 0; i < groupmap->namesOfGroups.size(); i++) {
+ for (int i = 0; i < allGroups.size(); i++) {
SharedRAbundVector* temp = new SharedRAbundVector(data.size());
- finder[groupmap->namesOfGroups[i]] = temp;
- finder[groupmap->namesOfGroups[i]]->setLabel(label);
- finder[groupmap->namesOfGroups[i]]->setGroup(groupmap->namesOfGroups[i]);
- if (m->inUsersGroups(groupmap->namesOfGroups[i], m->Groups)) { //if this group is in user groups
- lookup.push_back(finder[groupmap->namesOfGroups[i]]);
+ finder[allGroups[i]] = temp;
+ finder[allGroups[i]]->setLabel(label);
+ finder[allGroups[i]]->setGroup(allGroups[i]);
+ if (m->inUsersGroups(allGroups[i], m->getGroups())) { //if this group is in user groups
+ lookup.push_back(finder[allGroups[i]]);
}
}
f >> label >> groupN >> num;
holdLabel = label;
-
+ vector<string> allGroups;
//save group in groupmap
- groupmap->namesOfGroups.push_back(groupN);
+ allGroups.push_back(groupN);
groupmap->groupIndex[groupN] = 0;
//save group in groupmap
- groupmap->namesOfGroups.push_back(groupN);
+ allGroups.push_back(groupN);
groupmap->groupIndex[groupN] = count;
//put file pointer back since you are now at a new distance label
for (int i = 0; i < nextLabel.length(); i++) { f.unget(); }
-
- m->namesOfGroups = groupmap->namesOfGroups;
+
+ groupmap->setNamesOfGroups(allGroups);
+ m->setAllGroups(allGroups);
updateStats();
util = new SharedUtil();
vector<SharedRAbundVector*> lookup;
- util->setGroups(m->Groups, m->namesOfGroups);
- util->getSharedVectors(m->Groups, lookup, this);
+ vector<string> Groups = m->getGroups();
+ vector<string> allGroups = m->getAllGroups();
+ util->setGroups(Groups, allGroups);
+ util->getSharedVectors(Groups, lookup, this);
+ m->setGroups(Groups);
+ m->setAllGroups(allGroups);
return lookup;
}
SharedRAbundFloatVector::SharedRAbundFloatVector(ifstream& f) : DataVector(), maxRank(0.0), numBins(0), numSeqs(0.0) {
try {
- m->namesOfGroups.clear();
+ m->clearAllGroups();
+ vector<string> allGroups;
int num, count;
float inputData;
lookup[0]->setLabel(label);
lookup[0]->setGroup(groupN);
- m->namesOfGroups.push_back(groupN);
+ allGroups.push_back(groupN);
//fill vector. data = first sharedrabund in file
for(int i=0;i<num;i++){
f >> groupN >> num;
count++;
- m->namesOfGroups.push_back(groupN);
+ allGroups.push_back(groupN);
//add new vector to lookup
temp = new SharedRAbundFloatVector();
}
m->saveNextLabel = nextLabel;
+ m->setAllGroups(allGroups);
}
catch(exception& e) {
SharedUtil* util;
util = new SharedUtil();
- util->setGroups(m->Groups, m->namesOfGroups);
+ vector<string> Groups = m->getGroups();
+ vector<string> allGroups = m->getAllGroups();
+ util->setGroups(Groups, allGroups);
+ m->setGroups(Groups);
bool remove = false;
for (int i = 0; i < lookup.size(); i++) {
//if this sharedrabund is not from a group the user wants then delete it.
- if (util->isValidGroup(lookup[i]->getGroup(), m->Groups) == false) {
+ if (util->isValidGroup(lookup[i]->getGroup(), m->getGroups()) == false) {
delete lookup[i]; lookup[i] = NULL;
lookup.erase(lookup.begin()+i);
i--;
//reads a shared file
SharedRAbundVector::SharedRAbundVector(ifstream& f) : DataVector(), maxRank(0), numBins(0), numSeqs(0) {
try {
- m->namesOfGroups.clear();
-
+ m->clearAllGroups();
+ vector<string> allGroups;
+
int num, inputData, count;
count = 0;
string holdLabel, nextLabel, groupN;
lookup[0]->setLabel(label);
lookup[0]->setGroup(groupN);
- m->namesOfGroups.push_back(groupN);
+ allGroups.push_back(groupN);
//fill vector. data = first sharedrabund in file
for(int i=0;i<num;i++){
f >> groupN >> num;
count++;
- m->namesOfGroups.push_back(groupN);
+ allGroups.push_back(groupN);
//add new vector to lookup
temp = new SharedRAbundVector();
if (f.eof() != true) { f >> nextLabel; }
}
- m->saveNextLabel = nextLabel;
+ m->saveNextLabel = nextLabel;
+ m->setAllGroups(allGroups);
}
catch(exception& e) {
SharedUtil* util;
util = new SharedUtil();
- util->setGroups(m->Groups, m->namesOfGroups);
+ vector<string> Groups = m->getGroups();
+ vector<string> allGroups = m->getAllGroups();
+ util->setGroups(Groups, allGroups);
bool remove = false;
for (int i = 0; i < lookup.size(); i++) {
//if this sharedrabund is not from a group the user wants then delete it.
- if (util->isValidGroup(lookup[i]->getGroup(), m->Groups) == false) {
+ if (util->isValidGroup(lookup[i]->getGroup(), m->getGroups()) == false) {
remove = true;
delete lookup[i]; lookup[i] = NULL;
lookup.erase(lookup.begin()+i);
//need to have mode because different commands require different number of valid groups
void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups) {
try {
+
+ sort(userGroups.begin(), userGroups.end());
+ sort(allGroups.begin(), allGroups.end());
+
if (userGroups.size() != 0) {
if (userGroups[0] != "all") {
//check that groups are valid
//need to have mode because different commands require different number of valid groups
void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups, string mode) {
try {
+
+ sort(userGroups.begin(), userGroups.end());
+ sort(allGroups.begin(), allGroups.end());
+
if (userGroups.size() != 0) {
if (userGroups[0] != "all") {
//check that groups are valid
//for parsimony and unifrac commands you set pairwise groups as well as an allgroups in calc
void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups, string& label, int& numGroups, string mode){ //globaldata->Groups, your tree or group map, allgroups, mode
try {
+ sort(userGroups.begin(), userGroups.end());
+ sort(allGroups.begin(), allGroups.end());
+
numGroups = 0;
label = "";
/**************************************************************************************/
void SharedUtil::getCombos(vector<string>& groupComb, vector<string> userGroups, int& numComp) { //groupcomb, globaldata->Groups, numcomb
try {
+ sort(userGroups.begin(), userGroups.end());
//calculate number of comparisons i.e. with groups A,B,C = AB, AC, BC = 3;
numComp = 0;
for (int i=0; i< userGroups.size(); i++) {
groups = validParameter.validFile(parameters, "groups", false);
if (groups == "not found") { groups = ""; }
else if (groups == "all") {
- if (groupfile != "") { Groups = groupMap->namesOfGroups; }
+ if (groupfile != "") { Groups = groupMap->getNamesOfGroups(); }
else { m->mothurOut("You cannot select groups without a valid groupfile, I will disregard your groups selection. "); m->mothurOutEndLine(); groups = ""; }
}else {
m->splitAtDash(groups, Groups);
groupMap = new GroupMap(groupfile);
groupMap->readMap();
- SharedUtil util; util.setGroups(Groups, groupMap->namesOfGroups);
+ vector<string> namesGroups = groupMap->getNamesOfGroups();
+ SharedUtil util; util.setGroups(Groups, namesGroups);
if (namefile != "") { readNames(); }
splitFasta();
else {
pickedGroups = true;
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
string temp = validParameter.validFile(parameters, "size", false); if (temp == "not found"){ temp = "0"; }
//takes care of user setting groupNames that are invalid or setting groups=all
SharedUtil* util = new SharedUtil();
- util->setGroups(Groups, groupMap->namesOfGroups);
+ vector<string> namesGroups = groupMap->getNamesOfGroups();
+ util->setGroups(Groups, namesGroups);
delete util;
//file mismatch quit
if (thisSize < size) { size = thisSize; }
}
}else {
- m->Groups.clear();
+ m->clearGroups();
+ Groups.clear();
vector<SharedRAbundVector*> temp;
for (int i = 0; i < lookup.size(); i++) {
if (lookup[i]->getNumSeqs() < size) {
m->mothurOut(lookup[i]->getGroup() + " contains " + toString(lookup[i]->getNumSeqs()) + ". Eliminating."); m->mothurOutEndLine();
delete lookup[i];
}else {
- m->Groups.push_back(lookup[i]->getGroup());
+ Groups.push_back(lookup[i]->getGroup());
temp.push_back(lookup[i]);
}
}
lookup = temp;
- Groups = m->Groups;
+ m->setGroups(Groups);
}
if (lookup.size() == 0) { m->mothurOut("The size you selected is too large, skipping shared file."); m->mothurOutEndLine(); delete input; return 0; }
//takes care of user setting groupNames that are invalid or setting groups=all
SharedUtil* util = new SharedUtil();
- util->setGroups(Groups, groupMap->namesOfGroups);
+ vector<string> namesGroups = groupMap->getNamesOfGroups();
+ util->setGroups(Groups, namesGroups);
delete util;
//create outputfiles
if (groups == "not found") { groups = ""; }
else {
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
string temp = validParameter.validFile(parameters, "all", false); if (temp == "not found") { temp = "false"; }
delete input;
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
for(int i=0;i<sumCalculators.size();i++){ delete sumCalculators[i]; }
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
/******************************************************/
/******************************************************/
//comparison breakup to be used by different processes later
- numGroups = m->Groups.size();
+ numGroups = m->getNumGroups();
lines.resize(processors);
for (int i = 0; i < processors; i++) {
lines[i].start = int (sqrt(float(i)/float(processors)) * numGroups);
delete input;
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
for(int i=0;i<sumCalculators.size();i++){ delete sumCalculators[i]; }
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
m->mothurRemove(outputFileName);
delete input;
for(int i=0;i<sumCalculators.size();i++){ delete sumCalculators[i]; }
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
//reset groups parameter
- m->Groups.clear();
+ m->clearGroups();
for(int i=0;i<sumCalculators.size();i++){ delete sumCalculators[i]; }
delete input;
tree.resize(numNodes);
//initialize groupNodeInfo
- for (int i = 0; i < tmap->namesOfGroups.size(); i++) {
- groupNodeInfo[tmap->namesOfGroups[i]].resize(0);
+ for (int i = 0; i < (tmap->getNamesOfGroups()).size(); i++) {
+ groupNodeInfo[(tmap->getNamesOfGroups())[i]].resize(0);
}
//initialize tree with correct number of nodes, name and group info.
try {
//initialize groupNodeInfo
- for (int i = 0; i < tmap->namesOfGroups.size(); i++) {
- groupNodeInfo[tmap->namesOfGroups[i]].resize(0);
+ for (int i = 0; i < (tmap->getNamesOfGroups()).size(); i++) {
+ groupNodeInfo[(tmap->getNamesOfGroups())[i]].resize(0);
}
for(int i = 0; i < numLeaves; i++){
if (groups == "not found") { groups = ""; }
else {
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
calc = validParameter.validFile(parameters, "calc", false);
//create treemap class from groupmap for tree class to use
tmap = new TreeMap();
- tmap->makeSim(m->namesOfGroups);
+ tmap->makeSim(m->getAllGroups());
//clear globaldatas old tree names if any
m->Treenames.clear();
//fills globaldatas tree names
- m->Treenames = m->Groups;
+ m->Treenames = m->getGroups();
if (m->control_pressed) { return 0; }
tmap->makeSim(list);
- m->Groups = tmap->namesOfGroups;
+ vector<string> namesGroups = tmap->getNamesOfGroups();
+ m->setGroups(namesGroups);
//clear globaldatas old tree names if any
m->Treenames.clear();
//fills globaldatas tree names
- m->Treenames = m->Groups;
+ m->Treenames = m->getGroups();
//used in tree constructor
m->runParse = false;
}
//reset groups parameter
- m->Groups.clear();
+ m->clearGroups();
//set tree file as new current treefile
string current = "";
void removeSeq(string); //removes a sequence, this is to accomadate trees that do not contain all the seqs in your groupfile
string getGroup(string);
void addSeq(string, string);
- vector<string> namesOfGroups;
+ void addGroup(string s) { setNamesOfGroups(s); }
+ vector<string> getNamesOfGroups() {
+ sort(namesOfGroups.begin(), namesOfGroups.end());
+ return namesOfGroups;
+ }
vector<string> namesOfSeqs;
map<string,int> seqsPerGroup; //groupname, number of seqs in that group.
map<string, GroupIndex> treemap; //sequence name and <groupname, vector index>
void makeSim(ListVector*); //takes listvector info and fills treemap for use by tree.shared command.
private:
+ vector<string> namesOfGroups;
ifstream fileHandle;
string groupFileName;
int numGroups;
}
m->runParse = true;
- m->Groups.clear();
- m->namesOfGroups.clear();
+ m->clearGroups();
+ m->clearAllGroups();
m->Treenames.clear();
m->names.clear();
if (groups == "not found") { groups = ""; }
else {
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
itersString = validParameter.validFile(parameters, "iters", false); if (itersString == "not found") { itersString = "1000"; }
if ((phylip) && (Groups.size() == 0)) {
groups = "all";
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
}
if (m->control_pressed) {
delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
m->openOutputFile(sumFile, outSum);
util = new SharedUtil();
- util->setGroups(m->Groups, tmap->namesOfGroups, allGroups, numGroups, "unweighted"); //sets the groups the user wants to analyze
- util->getCombos(groupComb, m->Groups, numComp);
+ vector<string> Groups = m->getGroups();
+ vector<string> namesGroups = tmap->getNamesOfGroups();
+ util->setGroups(Groups, namesGroups, allGroups, numGroups, "unweighted"); //sets the groups the user wants to analyze
+ util->getCombos(groupComb, Groups, numComp);
delete util;
if (numGroups == 1) { numComp++; groupComb.push_back(allGroups); }
outSum.close();
- m->Groups.clear();
+ m->clearGroups();
delete tmap; delete unweighted;
for (int i = 0; i < T.size(); i++) { delete T[i]; }
if ((outputForm == "lt") || (outputForm == "square")) {
//output numSeqs
- out << m->Groups.size() << endl;
+ out << m->getNumGroups() << endl;
}
//make matrix with scores in it
- vector< vector<float> > dists; dists.resize(m->Groups.size());
- for (int i = 0; i < m->Groups.size(); i++) {
- dists[i].resize(m->Groups.size(), 0.0);
+ vector< vector<float> > dists; dists.resize(m->getNumGroups());
+ for (int i = 0; i < m->getNumGroups(); i++) {
+ dists[i].resize(m->getNumGroups(), 0.0);
}
//flip it so you can print it
int count = 0;
- for (int r=0; r<m->Groups.size(); r++) {
+ for (int r=0; r<m->getNumGroups(); r++) {
for (int l = 0; l < r; l++) {
dists[r][l] = utreeScores[count][0];
dists[l][r] = utreeScores[count][0];
}
//output to file
- for (int r=0; r<m->Groups.size(); r++) {
+ for (int r=0; r<m->getNumGroups(); r++) {
//output name
- string name = m->Groups[r];
+ string name = (m->getGroups())[r];
if (name.length() < 10) { //pad with spaces to make compatible
while (name.length() < 10) { name += " "; }
}
out << name << '\t';
//output distances
- for (int l = 0; l < m->Groups.size(); l++) { out << dists[r][l] << '\t'; }
+ for (int l = 0; l < m->getNumGroups(); l++) { out << dists[r][l] << '\t'; }
out << endl;
}else{
//output distances
for (int l = 0; l < r; l++) {
- string otherName = m->Groups[l];
+ string otherName = (m->getGroups())[l];
if (otherName.length() < 10) { //pad with spaces to make compatible
while (otherName.length() < 10) { otherName += " "; }
}
}
m->runParse = true;
- m->Groups.clear();
- m->namesOfGroups.clear();
+ m->clearGroups();
+ m->clearAllGroups();
m->Treenames.clear();
m->names.clear();
if (groups == "not found") { groups = ""; }
else {
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
itersString = validParameter.validFile(parameters, "iters", false); if (itersString == "not found") { itersString = "1000"; }
if (m->control_pressed) {
delete tmap; for (int i = 0; i < T.size(); i++) { delete T[i]; }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); } outputTypes.clear();
- m->Groups.clear();
+ m->clearGroups();
return 0;
}
util = new SharedUtil();
string s; //to make work with setgroups
- util->setGroups(m->Groups, tmap->namesOfGroups, s, numGroups, "weighted"); //sets the groups the user wants to analyze
- util->getCombos(groupComb, m->Groups, numComp);
+ vector<string> Groups = m->getGroups();
+ vector<string> nameGroups = tmap->getNamesOfGroups();
+ util->setGroups(Groups, nameGroups, s, numGroups, "weighted"); //sets the groups the user wants to analyze
+ util->getCombos(groupComb, Groups, numComp);
delete util;
weighted = new Weighted(tmap, includeRoot);
vector< vector<string> > namesOfGroupCombos;
for (int a=0; a<numGroups; a++) {
for (int l = 0; l < a; l++) {
- vector<string> groups; groups.push_back(m->Groups[a]); groups.push_back(m->Groups[l]);
+ vector<string> groups; groups.push_back((m->getGroups())[a]); groups.push_back((m->getGroups())[l]);
namesOfGroupCombos.push_back(groups);
}
}
if (phylip) { createPhylipFile(); }
//clear out users groups
- m->Groups.clear();
+ m->clearGroups();
delete tmap; delete weighted;
for (int i = 0; i < T.size(); i++) { delete T[i]; }
if ((outputForm == "lt") || (outputForm == "square")) {
//output numSeqs
- out << m->Groups.size() << endl;
+ out << m->getNumGroups() << endl;
}
//make matrix with scores in it
- vector< vector<float> > dists; dists.resize(m->Groups.size());
- for (int i = 0; i < m->Groups.size(); i++) {
- dists[i].resize(m->Groups.size(), 0.0);
+ vector< vector<float> > dists; dists.resize(m->getNumGroups());
+ for (int i = 0; i < m->getNumGroups(); i++) {
+ dists[i].resize(m->getNumGroups(), 0.0);
}
//flip it so you can print it
- for (int r=0; r<m->Groups.size(); r++) {
+ for (int r=0; r<m->getNumGroups(); r++) {
for (int l = 0; l < r; l++) {
dists[r][l] = utreeScores[count];
dists[l][r] = utreeScores[count];
}
//output to file
- for (int r=0; r<m->Groups.size(); r++) {
+ for (int r=0; r<m->getNumGroups(); r++) {
//output name
- string name = m->Groups[r];
+ string name = (m->getGroups())[r];
if (name.length() < 10) { //pad with spaces to make compatible
while (name.length() < 10) { name += " "; }
}
out << name << '\t';
//output distances
- for (int l = 0; l < m->Groups.size(); l++) { out << dists[r][l] << '\t'; }
+ for (int l = 0; l < m->getNumGroups(); l++) { out << dists[r][l] << '\t'; }
out << endl;
}else{
//output distances
for (int l = 0; l < r; l++) {
- string otherName = m->Groups[l];
+ string otherName = (m->getGroups())[l];
if (otherName.length() < 10) { //pad with spaces to make compatible
while (otherName.length() < 10) { otherName += " "; }
}
outputDir = o;
//if the users enters no groups then give them the score of all groups
- int numGroups = m->Groups.size();
+ int numGroups = m->getNumGroups();
//calculate number of comparsions
int numComp = 0;
for (int r=0; r<numGroups; r++) {
for (int l = 0; l < r; l++) {
numComp++;
- vector<string> groups; groups.push_back(m->Groups[r]); groups.push_back(m->Groups[l]);
+ vector<string> groups; groups.push_back((m->getGroups())[r]); groups.push_back((m->getGroups())[l]);
namesOfGroupCombos.push_back(groups);
}
}
vector<string> groups;
if (numGroups == 0) {
//get score for all users groups
- for (int i = 0; i < tmap->namesOfGroups.size(); i++) {
- if (tmap->namesOfGroups[i] != "xxx") {
- groups.push_back(tmap->namesOfGroups[i]);
+ for (int i = 0; i < (tmap->getNamesOfGroups()).size(); i++) {
+ if ((tmap->getNamesOfGroups())[i] != "xxx") {
+ groups.push_back((tmap->getNamesOfGroups())[i]);
}
}
namesOfGroupCombos.push_back(groups);
}else {
- for (int i = 0; i < m->Groups.size(); i++) {
- groups.push_back(m->Groups[i]);
+ for (int i = 0; i < m->getNumGroups(); i++) {
+ groups.push_back((m->getGroups())[i]);
}
namesOfGroupCombos.push_back(groups);
}
outputDir = o;
//if the users enters no groups then give them the score of all groups
- int numGroups = m->Groups.size();
+ int numGroups = m->getNumGroups();
//calculate number of comparsions
int numComp = 0;
for (int r=0; r<numGroups; r++) {
for (int l = 0; l < r; l++) {
numComp++;
- vector<string> groups; groups.push_back(m->Groups[r]); groups.push_back(m->Groups[l]);
+ vector<string> groups; groups.push_back((m->getGroups())[r]); groups.push_back((m->getGroups())[l]);
namesOfGroupCombos.push_back(groups);
}
}
vector<string> groups;
if (numGroups == 0) {
//get score for all users groups
- for (int i = 0; i < tmap->namesOfGroups.size(); i++) {
- if (tmap->namesOfGroups[i] != "xxx") {
- groups.push_back(tmap->namesOfGroups[i]);
+ for (int i = 0; i < (tmap->getNamesOfGroups()).size(); i++) {
+ if ((tmap->getNamesOfGroups())[i] != "xxx") {
+ groups.push_back((tmap->getNamesOfGroups())[i]);
}
}
namesOfGroupCombos.push_back(groups);
}else {
- for (int i = 0; i < m->Groups.size(); i++) {
- groups.push_back(m->Groups[i]);
+ for (int i = 0; i < m->getNumGroups(); i++) {
+ groups.push_back((m->getGroups())[i]);
}
namesOfGroupCombos.push_back(groups);
}
if (groups == "not found") { groups = ""; }
else {
m->splitAtDash(groups, Groups);
- m->Groups = Groups;
+ m->setGroups(Groups);
}
calc = validParameter.validFile(parameters, "calc", false);
if (m->control_pressed) {
for (int i = 0; i < vennCalculators.size(); i++) { delete vennCalculators[i]; }
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
- m->Groups.clear(); delete venn; delete input;
+ m->clearGroups(); delete venn; delete input;
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); }
return 0;
}
if (m->control_pressed) {
for (int i = 0; i < vennCalculators.size(); i++) { delete vennCalculators[i]; }
- m->Groups.clear(); delete venn; delete input;
+ m->clearGroups(); delete venn; delete input;
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); }
return 0;
}
//reset groups parameter
- m->Groups.clear();
+ m->clearGroups();
if (m->control_pressed) {
- m->Groups.clear(); delete venn; delete input;
+ m->clearGroups(); delete venn; delete input;
for (int i = 0; i < vennCalculators.size(); i++) { delete vennCalculators[i]; }
for (int i = 0; i < outputNames.size(); i++) { m->mothurRemove(outputNames[i]); }
return 0;
processors = p;
outputDir = o;
- numGroups = m->Groups.size();
+ numGroups = m->getNumGroups();
if (m->control_pressed) { return data; }
for (int l = 0; l < i; l++) {
//initialize weighted scores
//WScore[globaldata->Groups[i]+globaldata->Groups[l]] = 0.0;
- vector<string> groups; groups.push_back(m->Groups[i]); groups.push_back(m->Groups[l]);
+ vector<string> groups; groups.push_back((m->getGroups())[i]); groups.push_back((m->getGroups())[l]);
namesOfGroupCombos.push_back(groups);
}
}