From ee27b6e01a979fdf832668eb87412b029f77e4d7 Mon Sep 17 00:00:00 2001 From: westcott Date: Wed, 13 May 2009 18:35:14 +0000 Subject: [PATCH] changed all shared commands so that they read the shared file generated by the read.otu instead of the list and group combo. --- bootstrapsharedcommand.cpp | 34 +++++++--------------------------- collectsharedcommand.cpp | 30 +++++------------------------- globaldata.cpp | 12 +++++++----- globaldata.hpp | 2 ++ heatmapcommand.cpp | 10 +--------- rarefactsharedcommand.cpp | 33 ++++++--------------------------- readotucommand.cpp | 6 ++++++ summarysharedcommand.cpp | 32 ++++++-------------------------- treegroupscommand.cpp | 22 ++++++---------------- venncommand.cpp | 8 -------- 10 files changed, 46 insertions(+), 143 deletions(-) diff --git a/bootstrapsharedcommand.cpp b/bootstrapsharedcommand.cpp index e88972c..6b1f338 100644 --- a/bootstrapsharedcommand.cpp +++ b/bootstrapsharedcommand.cpp @@ -95,23 +95,13 @@ int BootSharedCommand::execute(){ //if the users entered no valid calculators don't execute command if (treeCalculators.size() == 0) { return 0; } - - if (format == "sharedfile") { - read = new ReadOTUFile(globaldata->inputFileName); - read->read(&*globaldata); - - input = globaldata->ginput; - order = input->getSharedOrderVector(); - }else { - //you are using a list and a groupfile - read = new ReadOTUFile(globaldata->inputFileName); - read->read(&*globaldata); - - input = globaldata->ginput; - SharedList = globaldata->gSharedList; - order = SharedList->getSharedOrderVector(); - } + //read first line + read = new ReadOTUFile(globaldata->inputFileName); + read->read(&*globaldata); + input = globaldata->ginput; + order = input->getSharedOrderVector(); + //set users groups util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups, "treegroup"); numGroups = globaldata->Groups.size(); @@ -186,17 +176,7 @@ int BootSharedCommand::execute(){ } //get next line to process - if (format == "sharedfile") { - order = input->getSharedOrderVector(); - }else { - //you are using a list and a groupfile - SharedList = input->getSharedListVector(); //get new list vector to process - if (SharedList != NULL) { - order = SharedList->getSharedOrderVector(); //gets new order vector with group info. - }else { - break; - } - } + order = input->getSharedOrderVector(); count++; } diff --git a/collectsharedcommand.cpp b/collectsharedcommand.cpp index 96e495a..86b35a5 100644 --- a/collectsharedcommand.cpp +++ b/collectsharedcommand.cpp @@ -129,21 +129,12 @@ int CollectSharedCommand::execute(){ //if the users entered no valid calculators don't execute command if (cDisplays.size() == 0) { return 0; } - if (format == "sharedfile") { - read = new ReadOTUFile(globaldata->inputFileName); - read->read(&*globaldata); + read = new ReadOTUFile(globaldata->inputFileName); + read->read(&*globaldata); - input = globaldata->ginput; - order = input->getSharedOrderVector(); - }else { - //you are using a list and a groupfile - read = new ReadOTUFile(globaldata->inputFileName); - read->read(&*globaldata); + input = globaldata->ginput; + order = input->getSharedOrderVector(); - input = globaldata->ginput; - SharedList = globaldata->gSharedList; - order = SharedList->getSharedOrderVector(); - } set orderList; //set users groups @@ -164,18 +155,7 @@ int CollectSharedCommand::execute(){ } //get next line to process - if (format == "sharedfile") { - order = input->getSharedOrderVector(); - }else { - //you are using a list and a groupfile - SharedList = input->getSharedListVector(); //get new list vector to process - if (SharedList != NULL) { - order = SharedList->getSharedOrderVector(); //gets new order vector with group info. - }else { - break; - } - } - + order = input->getSharedOrderVector(); count++; } set::iterator i; diff --git a/globaldata.cpp b/globaldata.cpp index ae1b0e2..494b664 100644 --- a/globaldata.cpp +++ b/globaldata.cpp @@ -290,11 +290,13 @@ string GlobalData::getScale() { return scale; } string GlobalData::getEnds() { return ends; } string GlobalData::getProcessors() { return processors; } -void GlobalData::setListFile(string file) { listfile = file; inputFileName = file;} -void GlobalData::setRabundFile(string file) { rabundfile = file; inputFileName = file;} -void GlobalData::setSabundFile(string file) { sabundfile = file; inputFileName = file;} -void GlobalData::setPhylipFile(string file) { phylipfile = file; inputFileName = file;} -void GlobalData::setColumnFile(string file) { columnfile = file; inputFileName = file;} +void GlobalData::setListFile(string file) { listfile = file; inputFileName = file;} +void GlobalData::setGroupFile(string file) { groupfile = file; } +void GlobalData::setRabundFile(string file) { rabundfile = file; inputFileName = file;} +void GlobalData::setSabundFile(string file) { sabundfile = file; inputFileName = file;} +void GlobalData::setPhylipFile(string file) { phylipfile = file; inputFileName = file;} +void GlobalData::setColumnFile(string file) { columnfile = file; inputFileName = file;} +void GlobalData::setSharedFile(string file) { sharedfile = file; inputFileName = file; fileroot = file;} void GlobalData::setNameFile(string file) { namefile = file; } void GlobalData::setFormat(string Format) { format = Format; } void GlobalData::setRandomTree(string Random) { randomtree = Random; } diff --git a/globaldata.hpp b/globaldata.hpp index 801ca60..3a469f0 100644 --- a/globaldata.hpp +++ b/globaldata.hpp @@ -87,11 +87,13 @@ public: void setListFile(string); + void setGroupFile(string file); void setPhylipFile(string); void setColumnFile(string); void setNameFile(string); void setRabundFile(string); void setSabundFile(string); + void setSharedFile(string); void setFormat(string); void setRandomTree(string); void setGroups(string); diff --git a/heatmapcommand.cpp b/heatmapcommand.cpp index be25f09..fd7a827 100644 --- a/heatmapcommand.cpp +++ b/heatmapcommand.cpp @@ -40,7 +40,7 @@ HeatMapCommand::~HeatMapCommand(){ int HeatMapCommand::execute(){ try { int count = 1; - + if (format == "sharedfile") { //you have groups read = new ReadOTUFile(globaldata->inputFileName); @@ -48,14 +48,6 @@ int HeatMapCommand::execute(){ input = globaldata->ginput; lookup = input->getSharedRAbundVectors(); - }else if (format == "shared") { - //you are using a list and a groupfile - read = new ReadOTUFile(globaldata->inputFileName); - read->read(&*globaldata); - - input = globaldata->ginput; - SharedList = globaldata->gSharedList; - lookup = SharedList->getSharedRAbundVector(); }else if (format == "list") { //you are using just a list file and have only one group read = new ReadOTUFile(globaldata->inputFileName); diff --git a/rarefactsharedcommand.cpp b/rarefactsharedcommand.cpp index 89cf4e2..29dd50e 100644 --- a/rarefactsharedcommand.cpp +++ b/rarefactsharedcommand.cpp @@ -68,22 +68,12 @@ int RareFactSharedCommand::execute(){ //if the users entered no valid calculators don't execute command if (rDisplays.size() == 0) { return 0; } - if (format == "sharedfile") { - read = new ReadOTUFile(globaldata->inputFileName); - read->read(&*globaldata); + read = new ReadOTUFile(globaldata->inputFileName); + read->read(&*globaldata); - input = globaldata->ginput; - order = input->getSharedOrderVector(); - }else { - //you are using a list and a groupfile - read = new ReadOTUFile(globaldata->inputFileName); - read->read(&*globaldata); - - input = globaldata->ginput; - SharedList = globaldata->gSharedList; - order = SharedList->getSharedOrderVector(); - } - + input = globaldata->ginput; + order = input->getSharedOrderVector(); + //set users groups util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups, "rarefact"); @@ -102,18 +92,7 @@ int RareFactSharedCommand::execute(){ } //get next line to process - if (format == "sharedfile") { - order = input->getSharedOrderVector(); - }else { - //you are using a list and a groupfile - SharedList = input->getSharedListVector(); //get new list vector to process - if (SharedList != NULL) { - order = SharedList->getSharedOrderVector(); //gets new order vector with group info. - }else { - break; - } - } - + order = input->getSharedOrderVector(); count++; } diff --git a/readotucommand.cpp b/readotucommand.cpp index 1b2ec9e..c8ec791 100644 --- a/readotucommand.cpp +++ b/readotucommand.cpp @@ -51,6 +51,12 @@ int ReadOtuCommand::execute(){ parselist = new ParseListCommand(); parselist->execute(); + + //change format to shared to speed up commands + globaldata->setFormat("sharedfile"); + globaldata->setListFile(""); + globaldata->setGroupFile(""); + globaldata->setSharedFile(getRootName(filename) + "shared"); } return 0; } diff --git a/summarysharedcommand.cpp b/summarysharedcommand.cpp index a4a345e..486e6c4 100644 --- a/summarysharedcommand.cpp +++ b/summarysharedcommand.cpp @@ -129,22 +129,12 @@ int SummarySharedCommand::execute(){ } } - if (format == "sharedfile") { - read = new ReadOTUFile(globaldata->inputFileName); - read->read(&*globaldata); + read = new ReadOTUFile(globaldata->inputFileName); + read->read(&*globaldata); - input = globaldata->ginput; - order = input->getSharedOrderVector(); - }else { - //you are using a list and a groupfile - read = new ReadOTUFile(globaldata->inputFileName); - read->read(&*globaldata); - - input = globaldata->ginput; - SharedList = globaldata->gSharedList; - order = SharedList->getSharedOrderVector(); - } - + input = globaldata->ginput; + order = input->getSharedOrderVector(); + //set users groups util->setGroups(globaldata->Groups, globaldata->gGroupmap->namesOfGroups, "summary"); @@ -229,17 +219,7 @@ int SummarySharedCommand::execute(){ } //get next line to process - if (format == "sharedfile") { - order = input->getSharedOrderVector(); - }else { - //you are using a list and a groupfile - SharedList = input->getSharedListVector(); //get new list vector to process - if (SharedList != NULL) { - order = SharedList->getSharedOrderVector(); //gets new order vector with group info. - }else { - break; - } - } + order = input->getSharedOrderVector(); count++; } diff --git a/treegroupscommand.cpp b/treegroupscommand.cpp index 047ea61..ac82da5 100644 --- a/treegroupscommand.cpp +++ b/treegroupscommand.cpp @@ -88,23 +88,13 @@ int TreeGroupCommand::execute(){ //if the users entered no valid calculators don't execute command if (treeCalculators.size() == 0) { return 0; } - if (format == "sharedfile") { - //you have groups - read = new ReadOTUFile(globaldata->inputFileName); - read->read(&*globaldata); + //you have groups + read = new ReadOTUFile(globaldata->inputFileName); + read->read(&*globaldata); - input = globaldata->ginput; - lookup = input->getSharedRAbundVectors(); - }else { - //you are using a list and a groupfile - read = new ReadOTUFile(globaldata->inputFileName); - read->read(&*globaldata); - - input = globaldata->ginput; - SharedList = globaldata->gSharedList; - lookup = SharedList->getSharedRAbundVector(); - } - + input = globaldata->ginput; + lookup = input->getSharedRAbundVectors(); + if (lookup.size() < 2) { cout << "You have not provided enough valid groups. I cannot run the command." << endl; } numGroups = globaldata->Groups.size(); diff --git a/venncommand.cpp b/venncommand.cpp index e9cb47a..b2dfc89 100644 --- a/venncommand.cpp +++ b/venncommand.cpp @@ -98,14 +98,6 @@ int VennCommand::execute(){ input = globaldata->ginput; lookup = input->getSharedRAbundVectors(); - }else if (format == "shared") { - //you are using a list and a groupfile - read = new ReadOTUFile(globaldata->inputFileName); - read->read(&*globaldata); - - input = globaldata->ginput; - SharedList = globaldata->gSharedList; - lookup = SharedList->getSharedRAbundVector(); }else if (format == "list") { //you are using just a list file and have only one group read = new ReadOTUFile(globaldata->inputFileName); -- 2.39.2