]> git.donarmstrong.com Git - mothur.git/blobdiff - chimera.h
changes while testing
[mothur.git] / chimera.h
index f893d63ed9c57e7d53d84843cb3b647cc9dd89d6..e187bfc60d8d504d80561d4347f9a838f1ddabee 100644 (file)
--- a/chimera.h
+++ b/chimera.h
 
 #include "mothur.h"
 #include "sequence.hpp"
-
+/***********************************************************************/
+struct data_struct { 
+       float divr_qla_qrb;
+       float divr_qlb_qra;
+       float qla_qrb;
+       float qlb_qra;
+       float qla;
+       float qrb;
+       float ab; 
+       float qa;
+       float qb; 
+       float lab; 
+       float rab; 
+       float qra; 
+       float qlb; 
+       int winLStart;
+       int winLEnd; 
+       int winRStart; 
+       int winREnd; 
+       Sequence querySeq; 
+       Sequence parentA;
+       Sequence parentB;
+       float bsa;
+       float bsb;
+       float bsMax;
+       float chimeraMax;
+       
+};
+/***********************************************************************/
+struct data_results {
+       vector<data_struct> results;
+       string flag;
+       Sequence trimQuery;
+       //results malignerResults;
+       
+       data_results(vector<data_struct> d, string f, map<int, int> s, Sequence t) : results(d), flag(f), trimQuery(t) {}
+       data_results() {}
+};
+/***********************************************************************/
+//sorts lowest to highest first by bsMax, then if tie by chimeraMax
+inline bool compareDataStruct(data_struct left, data_struct right){
+       if (left.bsMax < right.bsMax) { return true; }
+       else if (left.bsMax == right.bsMax) {
+               return (left.chimeraMax < right.chimeraMax);
+       }else { return false;   }
+} 
 /***********************************************************************/
 struct Preference {
                string name;
-               vector<string> leftParent; //keep the name of closest left associated with the two scores
-               vector<string> rightParent; //keep the name of closest right associated with the two scores
-               vector<float> score;  //so you can keep last score and calc this score and keep whichever is bigger.
-               vector<float> closestLeft;  //keep the closest left associated with the two scores
-               vector<float> closestRight; //keep the closest right associated with the two scores
+               string leftParent; //keep the name of closest left 
+               string rightParent; //keep the name of closest 
+               float score;  //preference score
+               float closestLeft;  //keep the closest left 
+               float closestRight; //keep the closest right 
                int midpoint;
-
+               Preference() { name = ""; leftParent = ""; rightParent = ""; score = 0.0; closestLeft = 10000.0; closestRight = 10000.0; midpoint = 0;  }
+               ~Preference() {}
 };
 /***********************************************************************/
 struct score_struct {
@@ -31,6 +77,7 @@ struct score_struct {
        int score;
        int row;
        int col;
+//     int mismatches;
 };
 /***********************************************************************/
 struct trace_struct {
@@ -56,6 +103,12 @@ struct SeqDist {
        float dist;
        int index;
 };
+/***********************************************************************/
+struct SeqCompare {
+       Sequence seq;
+       float dist;
+       int index;
+};
 //********************************************************************************************************************
 //sorts lowest to highest
 inline bool compareRegionStart(results left, results right){
@@ -67,7 +120,11 @@ inline bool compareSeqDist(SeqDist left, SeqDist right){
        return (left.dist < right.dist);        
 } 
 //********************************************************************************************************************
-
+//sorts lowest to highest
+inline bool compareSeqCompare(SeqCompare left, SeqCompare right){
+       return (left.dist < right.dist);        
+} 
+//********************************************************************************************************************
 struct sim {
                string leftParent;
                string rightParent; 
@@ -76,69 +133,52 @@ struct sim {
 };
 
 struct linePair {
-                       int start;
-                       int end;
-                       linePair(int i, int j) : start(i), end(j) {}
+                       unsigned long long start;
+                       unsigned long long end;
+                       linePair(unsigned long long i, unsigned long long j) : start(i), end(j) {}
                        linePair(){}
 };
 
+
 /***********************************************************************/
 
 class Chimera {
 
        public:
        
-               Chimera(){};
-               Chimera(string);
-               Chimera(string, bool, string);
-               Chimera(string, string);
-               virtual ~Chimera(){};
-               virtual void setFilter(bool f)                  {       filter = f;                     }
-               virtual void setCorrection(bool c)              {       correction = c;         }
-               virtual void setProcessors(int p)               {       processors = p;         }
-               virtual void setWindow(int w)                   {       window = w;                     }
-               virtual void setIncrement(int i)                {       increment = i;          }
-               virtual void setNumWanted(int n)                {       numWanted = n;          }
-               virtual void setKmerSize(int k)                 {       kmerSize = k;           }
-               virtual void setSVG(int s)                              {       svg = s;                        }
-               virtual void setName(string n)                  {       name = n;                       }
-               virtual void setMatch(int m)                    {       match = m;                      }
-               virtual void setMisMatch(int m)                 {       misMatch = m;           }
-               virtual void setDivR(float d)                   {       divR = d;                       }
-               virtual void setParents(int p)                  {       parents = p;            }
-               virtual void setMinSim(int s)                   {       minSim = s;                     }
-               virtual void setMinCoverage(int c)              {       minCov = c;                     }
-               virtual void setMinBS(int b)                    {       minBS = b;                      }
-               virtual void setMinSNP(int s)                   {       minSNP = s;                     }
-               virtual void setIters(int i)                    {       iters = i;                      }
-               virtual void setTemplateSeqs(vector<Sequence*> t)       {       templateSeqs = t;       }
+               Chimera(){ m = MothurOut::getInstance(); length = 0; unaligned = false;  byGroup = false; }
+               virtual ~Chimera(){     for (int i = 0; i < templateSeqs.size(); i++) { delete templateSeqs[i];  } for (int i = 0; i < filteredTemplateSeqs.size(); i++) { delete filteredTemplateSeqs[i];  } };
                virtual bool getUnaligned()                             {       return unaligned;                       }
-               virtual void setTemplateFile(string t)  {   templateFileName = t;       }
                virtual int getLength()                                 {   return length;      }
-               
-               virtual void setCons(string){};
-               virtual void setQuantiles(string){};
-               virtual void doPrep(){};
                virtual vector<Sequence*> readSeqs(string);
-               virtual vector< vector<float> > readQuantiles();
                virtual void setMask(string);
                virtual map<int, int> runFilter(Sequence*);
                virtual string createFilter(vector<Sequence*>, float);
-               
                virtual void printHeader(ostream&){};
                virtual int getChimeras(Sequence*){ return 0; }
                virtual int getChimeras(){ return 0; }
-               virtual void print(ostream&, ostream&){};       
+               virtual Sequence print(ostream&, ostream&){  Sequence temp; return temp; }
+               virtual Sequence print(ostream&, ostream&, data_results, data_results) { Sequence temp; return temp; }
+               virtual int print(ostream&, ostream&, string){  return 0; }
+               virtual int getNumNoParents(){  return 0; }
+               virtual data_results getResults() { data_results results; return results; }
+               
+               #ifdef USE_MPI
+               virtual Sequence print(MPI_File&, MPI_File&){  Sequence temp; return temp; }
+               virtual Sequence print(MPI_File&, MPI_File&, data_results, data_results, bool&){  Sequence temp; return temp; }
+               virtual int print(MPI_File&, MPI_File&, string){  return 0; }
+               #endif
                
                
        protected:
                
                vector<Sequence*> templateSeqs;
-               bool filter, correction, svg, unaligned;
-               int processors, window, increment, numWanted, kmerSize, match, misMatch, minSim, minCov, minBS, minSNP, parents, iters, length;
-               float divR;
-               string seqMask, quanfile, filterString, name, outputDir, templateFileName;
+               vector<Sequence*> filteredTemplateSeqs;
+               bool filter, unaligned, byGroup; 
+               int length; 
+               string seqMask, filterString, outputDir, templateFileName; 
                Sequence* getSequence(string);  //find sequence from name       
+               MothurOut* m;
 };
 
 /***********************************************************************/