1 #ifndef MOTHURPERSEUS
2 #define MOTHURPERSEUS
3 
4 /*
5  *  myPerseus.h
6  *
7  *
8  *  Created by Pat Schloss on 9/5/11.
9  *  Copyright 2011 Patrick D. Schloss. All rights reserved.
10  *
11  */
12 
13 
14 #include "mothurout.h"
15 
16 /**************************************************************************************************/
17 struct seqData {
18 
seqDataseqData19 	seqData(string name, string seq, int freq) : seqName(name), sequence(seq), frequency(freq) {	}
20 
21 	bool operator<( seqData const& rhs ) const {
22 
23 		bool verdict = 0;
24 
25 		if(frequency < rhs.frequency){
26 			verdict = 1;
27 		}
28 		else if(frequency == rhs.frequency){
29 			verdict = (seqName > rhs.seqName);
30 		}
31 
32 		return verdict;
33 	}
34 
35 	string seqName;
36 	string sequence;
37 	int frequency;
38 };
39 /**************************************************************************************************/
40 struct pwModel {
pwModelpwModel41 	pwModel(double m, double mm, double g): MATCH(m), MISMATCH(mm), GAP_OPEN(g) {;}
42 	double MATCH;
43 	double MISMATCH;
44 	double GAP_OPEN;
45 };
46 /**************************************************************************************************/
47 struct pwAlign {
pwAlignpwAlign48 	pwAlign(): query(""), reference(""){}
pwAlignpwAlign49 	pwAlign(string q, string r): query(q), reference(r){}
50 	string query;
51 	string reference;
52 
53 };
54 /**************************************************************************************************/
55 class Perseus {
56 
57 public:
Perseus()58 	Perseus() { m = MothurOut::getInstance(); }
~Perseus()59 	~Perseus() {}
60 
61 	vector<vector<double> > binomial(int);
62 	double modeledPairwiseAlignSeqs(string, string, string&, string&, vector<vector<double> >&);
63 	int getAlignments(int, vector<seqData>, vector<pwAlign>&, vector<vector<int> >& , vector<vector<int> >&, vector<vector<int> >&, vector<vector<int> >&, int&, int&, vector<bool>&);
64 	int getChimera(vector<seqData>,vector<vector<int> >&, vector<vector<int> >&,int&, int&, int&,vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<bool>);
65 	string stitchBimera(vector<pwAlign>&, int, int, int, vector<vector<int> >&, vector<vector<int> >&);
66 	int getTrimera(vector<seqData>&, vector<vector<int> >&, int&, int&, int&, int&, int&, vector<int>&, vector<int>&, vector<int>&, vector<int>&, vector<bool>);
67 	string stitchTrimera(vector<pwAlign>, int, int, int, int, int, vector<vector<int> >&, vector<vector<int> >&);
68 	double calcLoonIndex(string, string, string, int, vector<vector<double> >&);
69 	double classifyChimera(double, double, double, double, double);
70 
71 private:
72 	MothurOut* m;
73 	int toInt(char);
74 	double basicPairwiseAlignSeqs(string, string, string&, string&, pwModel);
75 	int getDiffs(string, string, vector<int>&, vector<int>&, vector<int>&, vector<int>&);
76 	int getLastMatch(char, vector<vector<char> >&, int, int, string&, string&);
77 	int threeWayAlign(string, string, string, string&, string&, string&);
78 	double calcBestDistance(string, string);
79 
80 
81 };
82 /**************************************************************************************************/
83 #endif
84 
85 
86