From 5e7c1cf6a6dd289a90d27c0eef7eb4675b5e17b7 Mon Sep 17 00:00:00 2001 From: ryabin Date: Wed, 18 Feb 2009 19:42:11 +0000 Subject: [PATCH] Added get.line command. Added get.label command. Added get.group command. Added parameter and parameter value error checking. Modified ace to allow changing the abund variable. Made it so you don't need a space after the comma when entering parameters. Added error checking for invalid labels. Added a new convert method that tests if a given string can be converted into an int. --- Mothur.xcodeproj/project.pbxproj | 4 - collect.cpp | 297 +++++++++++++++---------------- collect.h | 2 +- collectcommand.cpp | 2 +- errorchecking.cpp | 11 -- getgroupcommand.cpp | 57 ++++++ getgroupcommand.h | 31 ++++ getlabelcommand.cpp | 71 ++++++++ getlabelcommand.h | 31 ++++ getlinecommand.cpp | 75 ++++++++ getlinecommand.h | 31 ++++ globaldata.hpp | 1 - rarefactcommand.cpp | 2 +- summarycommand.cpp | 2 +- 14 files changed, 441 insertions(+), 176 deletions(-) create mode 100644 getgroupcommand.cpp create mode 100644 getgroupcommand.h create mode 100644 getlabelcommand.cpp create mode 100644 getlabelcommand.h create mode 100644 getlinecommand.cpp create mode 100644 getlinecommand.h diff --git a/Mothur.xcodeproj/project.pbxproj b/Mothur.xcodeproj/project.pbxproj index d3716c7..68b44f5 100644 --- a/Mothur.xcodeproj/project.pbxproj +++ b/Mothur.xcodeproj/project.pbxproj @@ -85,7 +85,6 @@ 37D9289F0F21331F001D4494 /* validparameter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37D928530F21331F001D4494 /* validparameter.cpp */; }; 37E5F3E30F29FD4200F8D827 /* treenode.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37E5F3E20F29FD4200F8D827 /* treenode.cpp */; }; 37E5F4920F2A3DA800F8D827 /* readtreecommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37E5F4910F2A3DA800F8D827 /* readtreecommand.cpp */; }; - 7E44EBD10F3235D900B0D45D /* makefile in Sources */ = {isa = PBXBuildFile; fileRef = 7E44EBD00F32358B00B0D45D /* makefile */; }; 8DD76F6A0486A84900D96B5E /* Mothur.1 in CopyFiles */ = {isa = PBXBuildFile; fileRef = C6859E8B029090EE04C91782 /* Mothur.1 */; }; EBA52D2C0F378B0F00122C15 /* getgroupcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EBA52D2B0F378B0F00122C15 /* getgroupcommand.cpp */; }; EBFD67840F33876C00883537 /* getlabelcommand.cpp in Sources */ = {isa = PBXBuildFile; fileRef = EBFD67830F33876C00883537 /* getlabelcommand.cpp */; }; @@ -269,7 +268,6 @@ 37E5F3E20F29FD4200F8D827 /* treenode.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = treenode.cpp; sourceTree = SOURCE_ROOT; }; 37E5F4900F2A3DA800F8D827 /* readtreecommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = readtreecommand.h; sourceTree = SOURCE_ROOT; }; 37E5F4910F2A3DA800F8D827 /* readtreecommand.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = readtreecommand.cpp; sourceTree = SOURCE_ROOT; }; - 7E44EBD00F32358B00B0D45D /* makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = makefile; sourceTree = ""; }; 8DD76F6C0486A84900D96B5E /* mothur */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = mothur; sourceTree = BUILT_PRODUCTS_DIR; }; C6859E8B029090EE04C91782 /* Mothur.1 */ = {isa = PBXFileReference; lastKnownFileType = text.man; path = Mothur.1; sourceTree = ""; }; EBA52D2A0F378B0F00122C15 /* getgroupcommand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = getgroupcommand.h; sourceTree = ""; }; @@ -324,7 +322,6 @@ 37D927D60F21331F001D4494 /* display.h */, 37D927D80F21331F001D4494 /* engine.hpp */, 37D927D70F21331F001D4494 /* engine.cpp */, - 7E44EBD00F32358B00B0D45D /* makefile */, 37D928B10F213472001D4494 /* errorcheckor */, 37D927DE0F21331F001D4494 /* fileoutput.h */, 37D927DD0F21331F001D4494 /* fileoutput.cpp */, @@ -647,7 +644,6 @@ 37E5F3E30F29FD4200F8D827 /* treenode.cpp in Sources */, 37E5F4920F2A3DA800F8D827 /* readtreecommand.cpp in Sources */, 379293C30F2DE73400B9034A /* treemap.cpp in Sources */, - 7E44EBD10F3235D900B0D45D /* makefile in Sources */, EBFD67840F33876C00883537 /* getlabelcommand.cpp in Sources */, EBFD67E80F339AAA00883537 /* getlinecommand.cpp in Sources */, EBA52D2C0F378B0F00122C15 /* getgroupcommand.cpp in Sources */, diff --git a/collect.cpp b/collect.cpp index 1c8128a..80ad918 100644 --- a/collect.cpp +++ b/collect.cpp @@ -13,173 +13,158 @@ /***********************************************************************/ void Collect::getCurve(int increment = 1){ - try { - RAbundVector* lookup = new RAbundVector(order->getNumBins()); - SAbundVector* rank = new SAbundVector(order->getMaxRank()+1); - - CollectorsCurveData* ccd = new CollectorsCurveData(); - - for(int i=0;iregisterDisplay(displays[i]); //adds a display[i] to cdd - displays[i]->init(label); //sets displays label - } - for(int i=0;iget(i); - int abundance = lookup->get(binNumber); - - rank->set(abundance, rank->get(abundance)-1); - - abundance++; - - lookup->set(binNumber, abundance); - rank->set(abundance, rank->get(abundance)+1); //increment rank(abundance) - - if((i == 0) || (i+1) % increment == 0){ - ccd->updateRankData(rank); - } - } - - if(numSeqs % increment != 0){ - ccd->updateRankData(rank); - } - - for(int i=0;ireset(); - } - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the Collect class Function getCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the Collect class function getCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } + try { + RAbundVector* lookup = new RAbundVector(order->getNumBins()); + SAbundVector* rank = new SAbundVector(order->getMaxRank()+1); + + CollectorsCurveData* ccd = new CollectorsCurveData(); + + for(int i=0;iregisterDisplay(displays[i]); //adds a display[i] to cdd + displays[i]->init(label); //sets displays label + } + for(int i=0;iget(i); + int abundance = lookup->get(binNumber); + + rank->set(abundance, rank->get(abundance)-1); + + abundance++; + + lookup->set(binNumber, abundance); + rank->set(abundance, rank->get(abundance)+1); //increment rank(abundance) + + if((i == 0) || (i+1) % increment == 0){ + ccd->updateRankData(rank); + } + } + + if(numSeqs % increment != 0){ + ccd->updateRankData(rank); + } + + for(int i=0;ireset(); + } + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the Collect class Function getCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the Collect class function getCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } } /***********************************************************************/ void Collect::getSharedCurve(int increment = 1){ try { - globaldata = GlobalData::getInstance(); - vector lookup; - vector chosenGroups = globaldata->sharedGroups; - - //create and initialize vector of sharedvectors, one for each group - for (int i = 0; i < globaldata->gGroupmap->getNumGroups(); i++) { - SharedRAbundVector* temp = new SharedRAbundVector(sharedorder->getNumBins()); - temp->setLabel(sharedorder->getLabel()); - temp->setGroup(globaldata->gGroupmap->namesOfGroups[i]); - temp->setGroupIndex(globaldata->gGroupmap->groupIndex[globaldata->gGroupmap->namesOfGroups[i]]); - lookup.push_back(temp); - } - - SharedCollectorsCurveData* ccd = new SharedCollectorsCurveData(); - - //initialize labels for output - //makes 'uniqueAB uniqueAC uniqueBC' if your groups are A, B, C - getGroupComb(chosenGroups); - groupLabel = ""; - for (int s = 0; s < groupComb.size(); s++) { - groupLabel = groupLabel + label + groupComb[s] + "\t"; - } - - for(int i=0;iregisterDisplay(displays[i]); //adds a display[i] to cdd - displays[i]->init(groupLabel); - } - - //sample all the members - for(int i=0;iget(i); - int abundance; - //set info for sharedvector in chosens group - for (int j = 0; j < lookup.size(); j++) { - if (chosen.group == lookup[j]->getGroup()) { - abundance = lookup[j]->getAbundance(chosen.bin); - lookup[j]->set(chosen.bin, (abundance + 1), chosen.group); - break; - } - } - - //calculate at 0 and the given increment - if((i == 0) || (i+1) % increment == 0){ - //randomize group order - if (globaldata->getJumble() == "1") { random_shuffle(lookup.begin(), lookup.end()); } - //how many comparisons to make i.e. for group a, b, c = ab, ac, bc. - int n = 1; - for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare - for (int l = n; l < lookup.size(); l++) { - ccd->updateSharedData(lookup[k], lookup[l], i+1, globaldata->gGroupmap->namesOfGroups.size()); - } - n++; - } - totalNumSeq = i+1; - } - } - - //calculate last line if you haven't already - if(numSeqs % increment != 0){ - //how many comparisons to make i.e. for group a, b, c = ab, ac, bc. - int n = 1; - for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare - for (int l = n; l < lookup.size(); l++) { - ccd->updateSharedData(lookup[k], lookup[l], totalNumSeq, globaldata->gGroupmap->namesOfGroups.size()); - } - n++; - } - } - - //resets output files - for(int i=0;ireset(); - } - } - catch(exception& e) { - cout << "Standard Error: " << e.what() << " has occurred in the Collect class Function getSharedCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } - catch(...) { - cout << "An unknown error has occurred in the Collect class function getSharedCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; - exit(1); - } + globaldata = GlobalData::getInstance(); + vector lookup; + + //create and initialize vector of sharedvectors, one for each group + for (int i = 0; i < globaldata->gGroupmap->getNumGroups(); i++) { + SharedRAbundVector* temp = new SharedRAbundVector(sharedorder->getNumBins()); + temp->setLabel(sharedorder->getLabel()); + temp->setGroup(globaldata->gGroupmap->namesOfGroups[i]); + temp->setGroupIndex(globaldata->gGroupmap->groupIndex[globaldata->gGroupmap->namesOfGroups[i]]); + lookup.push_back(temp); + } + + SharedCollectorsCurveData* ccd = new SharedCollectorsCurveData(); + + //initialize labels for output + //makes 'uniqueAB uniqueAC uniqueBC' if your groups are A, B, C + getGroupComb(); + groupLabel = ""; + for (int s = 0; s < groupComb.size(); s++) { + groupLabel = groupLabel + label + groupComb[s] + "\t"; + } + + for(int i=0;iregisterDisplay(displays[i]); //adds a display[i] to cdd + displays[i]->init(groupLabel); + } + + //sample all the members + for(int i=0;iget(i); + int abundance; + + //set info for sharedvector in chosens group + for (int j = 0; j < lookup.size(); j++) { + if (chosen.group == lookup[j]->getGroup()) { + abundance = lookup[j]->getAbundance(chosen.bin); + lookup[j]->set(chosen.bin, (abundance + 1), chosen.group); + break; + } + } + + //calculate at 0 and the given increment + if((i == 0) || (i+1) % increment == 0){ + //randomize group order + if (globaldata->getJumble() == "1") { random_shuffle(lookup.begin(), lookup.end()); } + //how many comparisons to make i.e. for group a, b, c = ab, ac, bc. + int n = 1; + for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare + for (int l = n; l < lookup.size(); l++) { + ccd->updateSharedData(lookup[k], lookup[l], i+1, globaldata->gGroupmap->namesOfGroups.size()); + } + n++; + } + } + totalNumSeq = i+1; + } + + //calculate last line if you haven't already + if(numSeqs % increment != 0){ + //how many comparisons to make i.e. for group a, b, c = ab, ac, bc. + int n = 1; + for (int k = 0; k < (lookup.size() - 1); k++) { // pass cdd each set of groups to commpare + for (int l = n; l < lookup.size(); l++) { + ccd->updateSharedData(lookup[k], lookup[l], totalNumSeq, globaldata->gGroupmap->namesOfGroups.size()); + } + n++; + } + } + + //resets output files + for(int i=0;ireset(); + } + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the Collect class Function getSharedCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the Collect class function getSharedCurve. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } } /**************************************************************************************/ -void Collect::getGroupComb(vector chosen) { - string group; - - numGroupComb = 0; - - int n = 1; - for (int i = 0; i < (globaldata->gGroupmap->getNumGroups() - 1); i++) { - for (int l = n; l < globaldata->gGroupmap->getNumGroups(); l++) { - string g1 = globaldata->gGroupmap->namesOfGroups[i]; - string g2 = globaldata->gGroupmap->namesOfGroups[l]; - if(validGroup(chosen, g1) && validGroup(chosen, g2)) { - group = g1 + g2; - groupComb.push_back(group); - numGroupComb++; - } - } - n++; - } -} - -/**************************************************************************************/ +void Collect::getGroupComb() { + string group; + + numGroupComb = 0; + + int n = 1; + for (int i = 0; i < (globaldata->gGroupmap->getNumGroups() - 1); i++) { + for (int l = n; l < globaldata->gGroupmap->getNumGroups(); l++) { + group = globaldata->gGroupmap->namesOfGroups[i] + globaldata->gGroupmap->namesOfGroups[l]; + groupComb.push_back(group); + numGroupComb++; + } + n++; + } -bool Collect::validGroup(vector chosen, string group) { - if(chosen.size() == 0) - return true; - for(int i = 0; i < chosen.size(); i++) - if(chosen.at(i).compare(group) == 0) - return true; - return false; } - - +/**************************************************************************************/ \ No newline at end of file diff --git a/collect.h b/collect.h index 3f6a094..aca4ccd 100644 --- a/collect.h +++ b/collect.h @@ -34,7 +34,7 @@ private: vector displays; int numSeqs, numGroupComb, totalNumSeq; string label, groupLabel; - void getGroupComb(vector); + void getGroupComb(); vector groupComb; bool validGroup(vector, string); }; diff --git a/collectcommand.cpp b/collectcommand.cpp index f012ba1..c716732 100644 --- a/collectcommand.cpp +++ b/collectcommand.cpp @@ -37,7 +37,7 @@ CollectCommand::CollectCommand(){ cDisplays.push_back(new CollectDisplay(new Chao1(), new ThreeColumnFile(fileNameRoot+"chao"))); }else if (globaldata->Estimators[i] == "ace") { convert(globaldata->getAbund(), abund); - cDisplays.push_back(new CollectDisplay(new Ace(), new ThreeColumnFile(fileNameRoot+"ace"))); + cDisplays.push_back(new CollectDisplay(new Ace(abund), new ThreeColumnFile(fileNameRoot+"ace"))); }else if (globaldata->Estimators[i] == "jack") { cDisplays.push_back(new CollectDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"jack"))); }else if (globaldata->Estimators[i] == "shannon") { diff --git a/errorchecking.cpp b/errorchecking.cpp index cc6cbf9..ddcfc32 100644 --- a/errorchecking.cpp +++ b/errorchecking.cpp @@ -268,12 +268,6 @@ bool ErrorCheck::checkInput(string input) { if (parameter == "label" ) { label = value; } if (parameter == "abund" ) { abund = value; } if (parameter == "random" ) { randomtree = value; } - - if (parameter == "comparegroups") { //stores groups to be compared - sharedGroups.clear(); //clears out old values - globaldata->splitAtDash(value, sharedGroups); - } - } //gets the last parameter and value @@ -345,11 +339,6 @@ bool ErrorCheck::checkInput(string input) { if (parameter == "label" ) { label = value; } if (parameter == "random" ) { randomtree = value; } if (parameter == "abund" ) { abund = value; } - - if (parameter == "comparegroups") { //stores groups to be compared - sharedGroups.clear(); //clears out old values - globaldata->splitAtDash(value, sharedGroups); - } } } diff --git a/getgroupcommand.cpp b/getgroupcommand.cpp new file mode 100644 index 0000000..393be4e --- /dev/null +++ b/getgroupcommand.cpp @@ -0,0 +1,57 @@ +/* + * getgroupcommand.cpp + * Mothur + * + * Created by Thomas Ryabin on 2/2/09. + * Copyright 2009 __MyCompanyName__. All rights reserved. + * + */ + +#include "getgroupcommand.h" + + + + + +GetgroupCommand::GetgroupCommand(){ + try { + globaldata = GlobalData::getInstance(); + groupMap = globaldata->gGroupmap; + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the GetgroupCommand class Function GetgroupCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the GetgroupCommand class function GetgroupCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + +} + +//********************************************************************************************************************** + +GetgroupCommand::~GetgroupCommand(){ +} + +//********************************************************************************************************************** + +int GetgroupCommand::execute(){ + try { + vector groupNames = groupMap->namesOfGroups; + for(int i = 0; i < groupNames.size(); i++) + cout << groupNames[i] << "\n"; + return 0; + } + + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the GetgroupCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the GetgroupCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} + + diff --git a/getgroupcommand.h b/getgroupcommand.h new file mode 100644 index 0000000..00c1b51 --- /dev/null +++ b/getgroupcommand.h @@ -0,0 +1,31 @@ +#ifndef GETGROUPCOMMAND_H +#define GETGROUPCOMMAND_H + +/* + * getgroupcommand.h + * Mothur + * + * Created by Thomas Ryabin on 2/2/09. + * Copyright 2009 __MyCompanyName__. All rights reserved. + * + */ + +#include +#include +#include "command.hpp" +#include "readmatrix.hpp" + +class GlobalData; + +class GetgroupCommand : public Command { +public: + GetgroupCommand(); + ~GetgroupCommand(); + int execute(); + +private: + GlobalData* globaldata; + GroupMap* groupMap; +}; + +#endif diff --git a/getlabelcommand.cpp b/getlabelcommand.cpp new file mode 100644 index 0000000..baabc21 --- /dev/null +++ b/getlabelcommand.cpp @@ -0,0 +1,71 @@ +/* + * GetlabelCommand.cpp + * Mothur + * + * Created by Thomas Ryabin on 1/30/09. + * Copyright 2009 __MyCompanyName__. All rights reserved. + * + */ + +#include "getlabelcommand.h" + + + + + + +GetlabelCommand::GetlabelCommand(){ + try { + globaldata = GlobalData::getInstance(); + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the GetlabelCommand class Function GetlabelCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the GetlabelCommand class function GetlabelCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + +} + +//********************************************************************************************************************** + +GetlabelCommand::~GetlabelCommand(){ +} + +//********************************************************************************************************************** + +int GetlabelCommand::execute(){ + try { + filename = globaldata->inputFileName; + ifstream in; + openInputFile(filename, in); + string label; + int numBins = 0; + int count = -1; + while(in.good()) + { + if(count > numBins) + count = 0; + if(count == 0) + { + cout << label << "\n"; + in >> numBins; + } + in >> label; + count++; + } + return 0; + } + + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the GetlabelCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the GetlabelCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} + diff --git a/getlabelcommand.h b/getlabelcommand.h new file mode 100644 index 0000000..ae4c4db --- /dev/null +++ b/getlabelcommand.h @@ -0,0 +1,31 @@ +#ifndef GETLABELCOMMAND_H +#define GETLABELCOMMAND_H + +/* + * getlabelcommand.h + * Mothur + * + * Created by Thomas Ryabin on 1/30/09. + * Copyright 2009 __MyCompanyName__. All rights reserved. + * + */ + +#include +#include +#include "command.hpp" +#include "readmatrix.hpp" + +class GlobalData; + +class GetlabelCommand : public Command { +public: + GetlabelCommand(); + ~GetlabelCommand(); + int execute(); + +private: + GlobalData* globaldata; + string filename; +}; + +#endif \ No newline at end of file diff --git a/getlinecommand.cpp b/getlinecommand.cpp new file mode 100644 index 0000000..63dde60 --- /dev/null +++ b/getlinecommand.cpp @@ -0,0 +1,75 @@ +/* + * GetlineCommand.cpp + * Mothur + * + * Created by Thomas Ryabin on 1/30/09. + * Copyright 2009 __MyCompanyName__. All rights reserved. + * + */ + +#include "getlinecommand.h" + + + + + + +GetlineCommand::GetlineCommand(){ + try { + globaldata = GlobalData::getInstance(); + } + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the GetlineCommand class Function GetlineCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the GetlineCommand class function GetlineCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + +} + +//********************************************************************************************************************** + +GetlineCommand::~GetlineCommand(){ +} + +//********************************************************************************************************************** + +int GetlineCommand::execute(){ + try { + filename = globaldata->inputFileName; + ifstream in; + openInputFile(filename, in); + string label; + int numBins = 0; + int count = -1; + int line = 1; + while(in.good()) + { + if(count > numBins) + count = 0; + if(count == 0) + { + cout << line << "\n"; + in >> numBins; + line++; + } + in >> label; + count++; + } + return 0; + } + + catch(exception& e) { + cout << "Standard Error: " << e.what() << " has occurred in the GetlineCommand class Function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } + catch(...) { + cout << "An unknown error has occurred in the GetlineCommand class function execute. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n"; + exit(1); + } +} + + + diff --git a/getlinecommand.h b/getlinecommand.h new file mode 100644 index 0000000..295fe99 --- /dev/null +++ b/getlinecommand.h @@ -0,0 +1,31 @@ +#ifndef GETLINECOMMAND_H +#define GETLINECOMMAND_H + +/* + * getlinecommand.h + * Mothur + * + * Created by Thomas Ryabin on 1/30/09. + * Copyright 2009 __MyCompanyName__. All rights reserved. + * + */ + +#include +#include +#include "command.hpp" +#include "readmatrix.hpp" + +class GlobalData; + +class GetlineCommand : public Command { +public: + GetlineCommand(); + ~GetlineCommand(); + int execute(); + +private: + GlobalData* globaldata; + string filename; +}; + +#endif diff --git a/globaldata.hpp b/globaldata.hpp index b36545e..31a63b6 100644 --- a/globaldata.hpp +++ b/globaldata.hpp @@ -97,7 +97,6 @@ private: ~GlobalData(); ListVector* gListVector; SparseMatrix* gSparseMatrix; - void clear(); //clears all parameters void reset(); //clears all non filename parameters diff --git a/rarefactcommand.cpp b/rarefactcommand.cpp index df33e5d..594b1dd 100644 --- a/rarefactcommand.cpp +++ b/rarefactcommand.cpp @@ -38,7 +38,7 @@ RareFactCommand::RareFactCommand(){ convert(globaldata->getAbund(), abund); if(abund < 5) abund = 10; - rDisplays.push_back(new RareDisplay(new Ace(), new ThreeColumnFile(fileNameRoot+"r_ace"))); + rDisplays.push_back(new RareDisplay(new Ace(abund), new ThreeColumnFile(fileNameRoot+"r_ace"))); }else if (globaldata->Estimators[i] == "jack") { rDisplays.push_back(new RareDisplay(new Jackknife(), new ThreeColumnFile(fileNameRoot+"r_jack"))); }else if (globaldata->Estimators[i] == "shannon") { diff --git a/summarycommand.cpp b/summarycommand.cpp index 06cc9b0..36a4e0e 100644 --- a/summarycommand.cpp +++ b/summarycommand.cpp @@ -35,7 +35,7 @@ SummaryCommand::SummaryCommand(){ convert(globaldata->getAbund(), abund); if(abund < 5) abund = 10; - sumCalculators.push_back(new Ace()); + sumCalculators.push_back(new Ace(abund)); }else if(globaldata->Estimators[i] == "jack"){ sumCalculators.push_back(new Jackknife()); }else if(globaldata->Estimators[i] == "shannon"){ -- 2.39.2