- vector<string> names;
- vector<vector<double> > D;
-
- //fbase = filename;
- //if(fbase.find_last_of(".")!=string::npos){
- // fbase.erase(fbase.find_last_of(".")+1);
- //}
- //else{
- // fbase += ".";
- //}
-
- fbase = outputDir + getRootName(getSimpleName(filename));
-
- read(filename, names, D);
-
- double offset = 0.0000;
- vector<double> d;
- vector<double> e;
- vector<vector<double> > G = D;
- vector<vector<double> > copy_G;
- //int rank = D.size();
-
- cout << "\nProcessing...\n";
-
- for(int count=0;count<2;count++){
- recenter(offset, D, G);
- tred2(G, d, e);
- qtli(d, e, G);
- offset = d[d.size()-1];
- if(offset > 0.0) break;
- }
-
-
- output(fbase, names, G, d);
-
- return 0;
- }
- catch(exception& e) {
- errorOut(e, "PCACommand", "execute");
- exit(1);
- }
-}
-/*********************************************************************************************************************************/
-
-inline double SIGN(const double a, const double b)
-{
- return b>=0 ? (a>=0 ? a:-a) : (a>=0 ? -a:a);
-}
-
-/*********************************************************************************************************************************/
-
-void PCACommand::get_comment(istream& f, char begin, char end){
- try {
- char d=f.get();
- while(d != end){ d = f.get(); }
- d = f.peek();
- }
- catch(exception& e) {
- errorOut(e, "PCACommand", "get_comment");
- exit(1);
- }
-}
-
-/*********************************************************************************************************************************/
-
-void PCACommand::read_phylip(istream& f, int square_m, vector<string>& name_list, vector<vector<double> >& d){
- try {
- // int count1=0;
- // int count2=0;
-
- int rank;
- f >> rank;
-
- name_list.resize(rank);
- d.resize(rank);
- if(square_m == 1){
- for(int i=0;i<rank;i++)
- d[i].resize(rank);
- for(int i=0;i<rank;i++) {
- f >> name_list[i];
- // cout << i << "\t" << name_list[i] << endl;
- for(int j=0;j<rank;j++) {
- f >> d[i][j];
- if (d[i][j] == -0.0000)
- d[i][j] = 0.0000;
- }
- }
- }
- else if(square_m == 2){
- for(int i=0;i<rank;i++){
- d[i].resize(rank);
- }
- d[0][0] = 0.0000;
- f >> name_list[0];
- for(int i=1;i<rank;i++){
- f >> name_list[i];
- d[i][i]=0.0000;
- for(int j=0;j<i;j++){
- f >> d[i][j];
- if (d[i][j] == -0.0000)
- d[i][j] = 0.0000;
- d[j][i]=d[i][j];
- }
- }
- }
- }
- catch(exception& e) {
- errorOut(e, "PCACommand", "read_phylip");
- exit(1);
- }
-
-}
-
-/*********************************************************************************************************************************/
-
-void PCACommand::read(string fname, vector<string>& names, vector<vector<double> >& D){
- try {
- ifstream f;
- openInputFile(fname, f);
+ //get first line of shared file
+ vector< vector<double> > matrix;
+ InputData* input;
+ if (mode == "shared") {
+ input = new InputData(inputFile, "sharedfile");
+ }else if (mode == "relabund") {
+ input = new InputData(inputFile, "relabund");
+ }else { m->mothurOut("[ERROR]: filetype not recognized."); m->mothurOutEndLine(); return 0; }
+
+ vector<SharedRAbundFloatVector*> lookupFloat = input->getSharedRAbundFloatVectors();
+ string lastLabel = lookupFloat[0]->getLabel();