37D928A90F2133E5001D4494 /* commands */ = {
isa = PBXGroup;
children = (
- 7E5A17AE0FE57292003C6A03 /* mergefilecommand.cpp */,
- 7E5A17AD0FE57292003C6A03 /* mergefilecommand.h */,
37D927CD0F21331F001D4494 /* command.hpp */,
378DC5CD0FBDE1C8003B8607 /* aligncommand.h */,
378DC5CE0FBDE1C8003B8607 /* aligncommand.cpp */,
375873F30F7D648F0040F377 /* libshuffcommand.cpp */,
21E859D60FC4632E005E1A48 /* matrixoutputcommand.h */,
21E859D70FC4632E005E1A48 /* matrixoutputcommand.cpp */,
+ 7E5A17AD0FE57292003C6A03 /* mergefilecommand.h */,
+ 7E5A17AE0FE57292003C6A03 /* mergefilecommand.cpp */,
375873F70F7D649C0040F377 /* nocommands.h */,
375873F60F7D649C0040F377 /* nocommands.cpp */,
37D927FA0F21331F001D4494 /* parselistcommand.h */,
if (abort == false) {
//get matrix, list and rabund for execute
- if(globaldata->gSparseMatrix != NULL) { matrix = new SparseMatrix(*globaldata->gSparseMatrix); }
+ if(globaldata->gSparseMatrix != NULL) { matrix = globaldata->gSparseMatrix; }
if(globaldata->gListVector != NULL){
- list = new ListVector(*globaldata->gListVector);
+ list = globaldata->gListVector;
rabund = new RAbundVector(list->getRAbundVector());
}
ClusterCommand::~ClusterCommand(){
delete cluster;
- delete matrix;
- delete list;
delete rabund;
}
lines.clear();
labels.clear();
Estimators.clear();
+ Groups.clear();
//allow user to run help
if(option == "help") { validCalculator = new ValidCalculators(); help(); abort = true; }
if (groups == "not found") { groups = ""; }
else {
splitAtDash(groups, Groups);
- globaldata->Groups = Groups;
}
+ globaldata->Groups = Groups;
string temp;
temp = validParameter.validFile(parameters, "freq", false); if (temp == "not found") { temp = "100"; }
//if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
set<string> processedLabels;
- set<string> userLabels = globaldata->labels;
- set<int> userLines = globaldata->lines;
+ set<string> userLabels = labels;
+ set<int> userLines = lines;
//set users groups
util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups, "collect");
util->updateGroupIndex(globaldata->Groups, globaldata->gGroupmap->groupIndex);
- while((order != NULL) && ((globaldata->allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) {
+ while((order != NULL) && ((allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) {
- if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(order->getLabel()) == 1){
+ if(allLines == 1 || lines.count(count) == 1 || labels.count(order->getLabel()) == 1){
//create collectors curve
cCurve = new Collect(order, cDisplays);
}else { cout << "Invalid." << endl; }
}
+ gobble(inputBatchFile);
}
return 1;
}
if (abort == false) {
- if(globaldata->gSparseMatrix != NULL) { matrix = new SparseMatrix(*globaldata->gSparseMatrix); }
+ if(globaldata->gSparseMatrix != NULL) { matrix = globaldata->gSparseMatrix; }
//globaldata->gListVector bin 0 = first name read in distance matrix, globaldata->gListVector bin 1 = second name read in distance matrix
if(globaldata->gListVector != NULL) {
//**********************************************************************************************************************
HeatMapCommand::~HeatMapCommand(){
- delete input;
+
delete read;
delete heatmap;
}
}
+ delete input;
return 0;
}
catch(exception& e) {
InputData::~InputData(){
-
+ fileHandle.close();
// delete output;
}
globaldata = GlobalData::getInstance();
//read in group map info.
- groupMap = new GroupMap(globaldata->getGroupFile());
- groupMap->readMap();
+ groupMap = globaldata->gGroupmap;
-
//fill filehandles with neccessary ofstreams
int i;
ofstream* temp;
int ParseListCommand::execute(){
try{
- globaldata = GlobalData::getInstance();
int count = 1;
//read in listfile
set<string> processedLabels;
set<string> userLabels = globaldata->labels;
set<int> userLines = globaldata->lines;
-
- //read in group map info.
- groupMap = new GroupMap(globaldata->getGroupFile());
- groupMap->readMap();
//create new list vectors to fill with parsed data
for (int i=0; i<groupMap->getNumGroups(); i++) {
if (globaldata->gGroupmap != NULL) { delete globaldata->gGroupmap; }
globaldata->gGroupmap = groupMap;
+ //close files
+ for (it3 = filehandles.begin(); it3 != filehandles.end(); it3++) {
+ ofstream* temp = it3->second;
+ (*temp).close();
+ delete it3->second;
+ }
+
+ //delete list vectors to fill with parsed data
+ for (it2 = groupOfLists.begin(); it2 != groupOfLists.end(); it2++) {
+ delete it2->second;
+ }
+
return 0;
}
catch(exception& e) {
SharedListVector* list;
map<string, string> listGroups; //maps group name to sequences from that group in a specific OTU
map<string, string>::iterator it;
+ map<string, SharedListVector*>::iterator it2;
map<string, ofstream*>::iterator it3;
void parse(int, SharedListVector*);
void process(SharedListVector*);
RareFactSharedCommand::RareFactSharedCommand(string option){
try {
globaldata = GlobalData::getInstance();
+
abort = false;
allLines = 1;
lines.clear();
labels.clear();
Estimators.clear();
-
+ Groups.clear();
+
//allow user to run help
if(option == "help") { validCalculator = new ValidCalculators(); help(); abort = true; }
if (groups == "not found") { groups = ""; }
else {
splitAtDash(groups, Groups);
- globaldata->Groups = Groups;
}
+ globaldata->Groups = Groups;
string temp;
temp = validParameter.validFile(parameters, "iters", false); if (temp == "not found") { temp = "1000"; }
input = globaldata->ginput;
lookup = input->getSharedRAbundVectors();
vector<SharedRAbundVector*> lastLookup = lookup;
-
+
if (lookup.size() < 2) {
cout << "I cannot run the command without at least 2 valid groups.";
for (int i = 0; i < lookup.size(); i++) { delete lookup[i]; }
}else {//there is an orderfile
input = new InputData(philFile, globaldata->getOrderFile(), globaldata->getFormat());
}
-
+//cout << "made it here" << endl;
//memory leak prevention
//if (globaldata->ginput != NULL) { delete globaldata->ginput; }
globaldata->ginput = input; //saving to be used by collector and rarefact commands.
-
+//cout << "after input" << endl;
if ((globaldata->getFormat() == "list") || (globaldata->getFormat() == "rabund") || (globaldata->getFormat() == "sabund")) {//you are reading a list, rabund or sabund file for collect, rarefaction or summary.
order = input->getOrderVector();
//memory leak prevention
//if (globaldata->gorder != NULL) { delete globaldata->gorder; }
globaldata->gorder = order; //saving to be used by collect and rarefact commands.
sabund = inputSabund->getSAbundVector();
+ //if (globaldata->sabund != NULL) { delete globaldata->sabund; }
globaldata->sabund = sabund; //saving to be used by summary command.
rabund = inputRabund->getRAbundVector();
+ //if (globaldata->rabund != NULL) { delete globaldata->rabund; }
globaldata->rabund = rabund; //saving to be used by heatmap.bin command.
list = inputList->getListVector();
+ //if (globaldata->gListVector != NULL) { delete globaldata->gListVector; }
globaldata->gListVector = list;
}else if (globaldata->getFormat() == "shared") {
if (abort == false) {
//gets whichever one of the above is set
filename = globaldata->inputFileName;
- read = new ReadOTUFile(filename);
+ //read = new ReadOTUFile(filename);
}
}
//**********************************************************************************************************************
ReadOtuCommand::~ReadOtuCommand(){
- if (abort == false) { delete read; }
+ if (abort == false) { //delete read;
+ }
}
//**********************************************************************************************************************
if (abort == true) { return 0; }
- read->read(&*globaldata);
+ //read->read(&*globaldata);
if (globaldata->getFormat() == "shared") {
groupMap->readMap();
//if (globaldata->gGroupmap != NULL) { delete globaldata->gGroupmap; }
- globaldata->gGroupmap = groupMap;
- shared = new SharedCommand();
- shared->execute();
-
+ globaldata->gGroupmap = groupMap;
+
parselist = new ParseListCommand();
parselist->execute();
+ delete parselist;
+
+ shared = new SharedCommand();
+ shared->execute();
+ delete shared;
//change format to shared to speed up commands
globaldata->setFormat("sharedfile");
private:
GlobalData* globaldata;
- ReadOTUFile* read;
+ //ReadOTUFile* read;
InputData* input;
Command* shared;
Command* parselist;
int i,j;
label = list->getLabel();
+ for (it = sharedGroups.begin(); it != sharedGroups.end(); it++) { delete it->second; }
sharedGroups.clear(); //removes old info.
//initalize sharedGroups
private:
GlobalData* globaldata;
+ map<string, SharedRAbundVector*>::iterator it;
void parse(int, SharedListVector*);
vector< map<string, SharedRAbundVector*> > sharedRAbund; //contains all the info needed to create the .shared file not sure if we will need
};
int SharedCommand::execute(){
try {
globaldata = GlobalData::getInstance();
+ //lookup.clear();
int count = 1;
string errorOff = "no error";
//read in listfile
read = new ReadOTUFile(globaldata->inputFileName);
read->read(&*globaldata);
+
input = globaldata->ginput;
SharedList = globaldata->gSharedList;
SharedListVector* lastList = SharedList;
+ //lookup = SharedList->getSharedRAbundVector();
+ //vector<SharedRAbundVector*> lastLookup = lookup;
//if the users enters label "0.06" and there is no "0.06" in their file use the next lowest label.
set<string> processedLabels;
while((SharedList != NULL) && ((globaldata->allLines == 1) || (userLabels.size() != 0) || (userLines.size() != 0))) {
-
+
if(globaldata->allLines == 1 || globaldata->lines.count(count) == 1 || globaldata->labels.count(SharedList->getLabel()) == 1){
-
+
shared->getSharedVectors(SharedList); //fills sharedGroups with new info and updates sharedVector
printSharedData(); //prints info to the .shared file
if (count != 1) { delete lastList; }
lastList = SharedList;
-
SharedList = input->getSharedListVector(); //get new list vector to process
+
+ //if (count != 1) { for (int i = 0; i < lastLookup.size(); i++) { delete lastLookup[i]; } }
+ //lastLookup = lookup;
+ //if (SharedList != NULL) { lookup = SharedList->getSharedRAbundVector(); }
}
//output error messages about any remaining user labels
delete lastList;
delete shared;
+ out.close();
return 0;
}
//**********************************************************************************************************************
void SharedCommand::printSharedData() {
try {
+
+ ///for (int i = 0; i < thislookup.size(); i++) {
+ // out << thislookup[i]->getLabel() << '\t' << thislookup[i]->getGroup() << '\t';
+//cout << thislookup[i]->getLabel() << '\t' << thislookup[i]->getGroup() << endl;
+ // thislookup[i]->print(out);
+ // }
//prints out horizontally
for (it = shared->sharedGroups.begin(); it != shared->sharedGroups.end(); it++) {
out << it->second->getLabel() << "\t" << it->first << "\t"; //prints out label and groupname
InputData* input;
Shared* shared;
map<string, SharedRAbundVector*>::iterator it;
+ //vector<SharedRAbundVector*> lookup;
ofstream out;
string filename;
/***********************************************************************/
-SharedListVector::SharedListVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0){}
+SharedListVector::SharedListVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0){globaldata = GlobalData::getInstance();}
/***********************************************************************/
-SharedListVector::SharedListVector(int n): DataVector(), data(n, "") , maxRank(0), numBins(0), numSeqs(0){}
+SharedListVector::SharedListVector(int n): DataVector(), data(n, "") , maxRank(0), numBins(0), numSeqs(0){globaldata = GlobalData::getInstance();}
/***********************************************************************/
SharedListVector::SharedListVector(ifstream& f) : DataVector(), maxRank(0), numBins(0), numSeqs(0) {
rav.setLabel(label);
rav.setGroup(groupName);
+
return rav;
}
vector<SharedRAbundVector*> lookup;
util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups);
+
+ delete util;
for (int i = 0; i < globaldata->Groups.size(); i++) {
SharedRAbundVector* temp = new SharedRAbundVector();
SharedListVector();
SharedListVector(int);
SharedListVector(ifstream&);
- SharedListVector(const SharedListVector& lv) : DataVector(lv.label), data(lv.data), maxRank(lv.maxRank), numBins(lv.numBins), numSeqs(lv.numSeqs){};
+ SharedListVector(const SharedListVector& lv) : DataVector(lv.label), data(lv.data), maxRank(lv.maxRank), numBins(lv.numBins), numSeqs(lv.numSeqs){globaldata = GlobalData::getInstance();};
~SharedListVector(){};
int getNumBins() { return numBins; }
/***********************************************************************/
-SharedRAbundVector::SharedRAbundVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0) {}
+SharedRAbundVector::SharedRAbundVector() : DataVector(), maxRank(0), numBins(0), numSeqs(0) {globaldata = GlobalData::getInstance();}
/***********************************************************************/
SharedRAbundVector::SharedRAbundVector(int n) : DataVector(), maxRank(0), numBins(n), numSeqs(0) {
+ globaldata = GlobalData::getInstance();
individual newGuy;
//initialize data
for (int i=0; i< n; i++) {
for (int j = 0; j < lookup.size(); j++) {
delete lookup[j];
}
-
lookup.clear();
//create and initialize vector of sharedvectors, one for each group
//need to have mode because different commands require different number of valid groups
void SharedUtil::setGroups(vector<string>& userGroups, vector<string>& allGroups) {
try {
-//cout << "groups size" << userGroups.size() << endl;
if (userGroups.size() != 0) {
if (userGroups[0] != "all") {
//check that groups are valid
//make sure the user has already run the read.otu command
if (globaldata->getSharedFile() == "") {
- if (globaldata->getListFile() == "") { cout << "You must read a list and a group, or a shared before you can use the summary.shared command." << endl; abort = true; }
- else if (globaldata->getGroupFile() == "") { cout << "You must read a list and a group, or a shared before you can use the summary.shared command." << endl; abort = true; }
+ cout << "You must read a list and a group, or a shared before you can use the summary.shared command." << endl; abort = true;
}
-
//check for optional parameter and set defaults
// ...at some point should added some additional type checking...
outputFileName = ((getRootName(globaldata->inputFileName)) + "shared.summary");
openOutputFile(outputFileName, outputFileHandle);
-// format = globaldata->getFormat();
mult = false;
}
}
-
}
catch(exception& e) {
cout << "Standard Error: " << e.what() << " has occurred in the SummarySharedCommand class Function SummarySharedCommand. Please contact Pat Schloss at pschloss@microbio.umass.edu." << "\n";
//**********************************************************************************************************************
SummarySharedCommand::~SummarySharedCommand(){
- delete input;
delete read;
delete validCalculator;
}
//close files
outputFileHandle.close();
if (mult == true) { outAll.close(); }
+
+ for(int i=0;i<sumCalculators.size();i++){ delete sumCalculators[i]; }
+
+ delete input;
return 0;
}