X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=mothur.h;h=2c143e8667786c5740f0aa6324ea4062eab66b76;hb=a6cf29fa4dac0909c7582cb1094151d34093ee76;hp=337e5b33a6b1d8100effe484c230d42c7fd93f58;hpb=173a1a82a4e4aa6bef8e4ba77bce342fb9c6563e;p=mothur.git diff --git a/mothur.h b/mothur.h index 337e5b3..2c143e8 100644 --- a/mothur.h +++ b/mothur.h @@ -36,11 +36,13 @@ #include #include #include +#include //math #include #include #include +#include //misc #include @@ -52,10 +54,12 @@ #endif /***********************************************************************/ -#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) +#if defined (__APPLE__) || (__MACH__) || (linux) || (__linux) || (__linux__) || (__unix__) || (__unix) #include #include #include + #include + #include #include #ifdef USE_READLINE @@ -68,6 +72,8 @@ #include //get cwd #include #include + #include + #include #endif @@ -80,6 +86,7 @@ using namespace std; #define isnan(x) ((x) != (x)) #define isinf(x) (fabs(x) == std::numeric_limits::infinity()) + typedef unsigned long ull; struct IntNode { @@ -100,6 +107,19 @@ struct ThreadNode { IntNode* right; }; +struct diffPair { + float prob; + float reverseProb; + + diffPair() { + prob = 0; reverseProb = 0; + } + diffPair(float p, float rp) { + prob = p; + reverseProb = rp; + } +}; + /************************************************************/ struct clusterNode { int numSeq; @@ -111,9 +131,9 @@ struct clusterNode { struct seqDist { int seq1; int seq2; - float dist; + double dist; seqDist() {} - seqDist(int s1, int s2, float d) : seq1(s1), seq2(s2), dist(d) {} + seqDist(int s1, int s2, double d) : seq1(s1), seq2(s2), dist(d) {} ~seqDist() {} }; /************************************************************/ @@ -123,6 +143,37 @@ struct distlinePair { }; /************************************************************/ +struct seqPriorityNode { + int numIdentical; + string seq; + string name; + seqPriorityNode() {} + seqPriorityNode(int n, string s, string nm) : numIdentical(n), seq(s), name(nm) {} + ~seqPriorityNode() {} +}; +/***************************************************************/ +struct spearmanRank { + string name; + float score; + + spearmanRank(string n, float s) : name(n), score(s) {} +}; +//******************************************************************************************************************** +//sorts highest to lowest +inline bool compareSpearman(spearmanRank left, spearmanRank right){ + return (left.score > right.score); +} +//******************************************************************************************************************** +//sorts highest to lowest +inline bool compareSeqPriorityNodes(seqPriorityNode left, seqPriorityNode right){ + return (left.numIdentical > right.numIdentical); +} +//******************************************************************************************************************** +//sorts lowest to highest +inline bool compareSpearmanReverse(spearmanRank left, spearmanRank right){ + return (left.score < right.score); +} +/************************************************************/ //sorts lowest to highest inline bool compareDistLinePairs(distlinePair left, distlinePair right){ return (left.end < right.end); @@ -152,7 +203,8 @@ void convert(const string& s, T& x, bool failIfLeftoverChars = true){ throw BadConversion(s); } - +//********************************************************************************************************************** +template int sgn(T val){ return (val > T(0)) - (val < T(0)); } //********************************************************************************************************************** template @@ -219,5 +271,15 @@ string toString(const T&x, int i){ } //********************************************************************************************************************** +template +T fromString(const string& s){ + istringstream stream (s); + T t; + stream >> t; + return t; +} + +//********************************************************************************************************************** + #endif