]> git.donarmstrong.com Git - mothur.git/blob - unifracweightedcommand.h
added subsample and consensus parameters to unifrac.weighted command
[mothur.git] / unifracweightedcommand.h
1 #ifndef UNIFRACWEIGHTEDCOMMAND_H
2 #define UNIFRACWEIGHTEDCOMMAND_H
3
4 /*
5  *  unifracweightedcommand.h
6  *  Mothur
7  *
8  *  Created by Sarah Westcott on 2/9/09.
9  *  Copyright 2009 Schloss Lab UMASS Amherst. All rights reserved.
10  *
11  */
12
13 #include "command.hpp"
14 #include "weighted.h"
15 #include "treemap.h"
16 #include "progress.hpp"
17 #include "sharedutilities.h"
18 #include "fileoutput.h"
19 #include "readtree.h"
20
21 class UnifracWeightedCommand : public Command {
22         
23         public:
24                 UnifracWeightedCommand(string);
25                 UnifracWeightedCommand();
26                 ~UnifracWeightedCommand() {}
27         
28                 vector<string> setParameters();
29                 string getCommandName()                 { return "unifrac.weighted";            }
30                 string getCommandCategory()             { return "Hypothesis Testing";          }
31                 string getHelpString(); 
32                 string getCitation() { return "Lozupone CA, Hamady M, Kelley ST, Knight R (2007). Quantitative and qualitative beta diversity measures lead to different insights into factors that structure microbial communities. Appl Environ Microbiol 73: 1576-85. \nhttp://www.mothur.org/wiki/Unifrac.weighted"; }
33                 string getDescription()         { return "generic tests that describes whether two or more communities have the same structure"; }
34
35                 int execute();
36                 void help() { m->mothurOut(getHelpString()); }
37         
38         private:
39                 struct linePair {
40                         int start;
41                         int num;
42                         linePair(int i, int j) : start(i), num(j) {}
43                 };
44                 vector<linePair> lines;
45                 
46                 ReadTree* read;
47                 SharedUtil* util;
48                 FileOutput* output;
49                 vector<Tree*> T;           //user trees
50                 vector<double> utreeScores;  //user tree unweighted scores
51                 vector<double> WScoreSig;  //tree weighted score signifigance when compared to random trees - percentage of random trees with that score or lower.
52                 vector<string> groupComb; // AB. AC, BC...
53                 TreeMap* tmap;
54                 string sumFile, outputDir;
55                 int iters, numGroups, numComp, counter;
56                 vector< vector<double> > rScores;  //vector<weighted scores for random trees.> each group comb has an entry
57                 vector< vector<double> > uScores;  //vector<weighted scores for user trees.> each group comb has an entry
58                 vector< map<float, float> > rScoreFreq;  //map <weighted score, number of random trees with that score.> -vector entry for each combination.
59                 vector< map<float, float> > rCumul;  //map <weighted score, cumulative percentage of number of random trees with that score or higher.> -vector entry for each c                                                                
60                 map<float, float>  validScores;  //map contains scores from random
61                 
62                 bool abort, phylip, random, includeRoot, subsample, consensus;
63                 string groups, itersString, outputForm, treefile, groupfile, namefile;
64                 vector<string> Groups, outputNames; //holds groups to be used
65                 int processors, numUniquesInName, subsampleSize, subsampleIters;
66                 ofstream outSum;
67                 map<string, string> nameMap;
68                 
69                 void printWSummaryFile();
70                 void printWeightedFile();  
71                 void createPhylipFile();
72                 //void removeValidScoresDuplicates();
73                 int findIndex(float, int);
74                 void calculateFreqsCumuls();
75                 int createProcesses(Tree*,  vector< vector<string> >,  vector< vector<double> >&);
76                 int driver(Tree*, vector< vector<string> >, int, int,  vector< vector<double> >&);
77                 int readNamesFile();
78         int runRandomCalcs(Tree*, vector<double>);
79         int readTrees();
80         vector<Tree*> buildTrees(vector< vector<double> >&, int, TreeMap*);
81         int getConsensusTrees(vector< vector<double> >&, int);
82         int getAverageSTDMatrices(vector< vector<double> >&, int);
83                 
84 };
85
86
87
88 #endif