Augustus 3.4.0
Loading...
Searching...
No Matches
orthograph.hh
1/*
2 * orthograph.hh
3 *
4 * License: Artistic License, see file LICENSE.TXT or
5 * https://opensource.org/licenses/artistic-license-1.0
6 */
7
8#ifndef _ORTHOGRAPH_HH
9#define _ORTHOGRAPH_HH
10
11//project includes
12#include "speciesgraph.hh"
13#include "phylotree.hh"
14#include "orthogene.hh"
15#include "geneMSA.hh"
16
17// forward declarations
18
22class GeneMSA;
23
27enum StepRule{constant=0, harmonic, square_root, base_2, base_e, polyak, mixed};
28
35
36public:
37 OrthoGraph(){
38 graphs.resize(numSpecies);
39 ptrs_to_alltranscripts.resize(numSpecies);
40 sfcs.resize(numSpecies);
41 geneLists.resize(numSpecies);
42 }
44 for(int i = 0; i < numSpecies; i++){
45 delete graphs[i];
46 delete ptrs_to_alltranscripts[i];
47 delete sfcs[i];
48 if (geneLists[i])
49 Transcript::destroyGeneSequence(getPtr(geneLists[i]));
50 }
51 }
52
53 static size_t numSpecies; //the number of species
54 static StepRule step_rule;
55 vector<SpeciesGraph*> graphs;
56 static PhyloTree *tree;
57 vector< list<Transcript*> *> ptrs_to_alltranscripts; // stores pointers to alltranscripts until they can be deleted (destructor of OrthoGraph)
58 vector< SequenceFeatureCollection* > sfcs; // stores extrinsic evidence for each species
59 vector< list<AltGene> *> geneLists; // filtered and processed genes as they appear in the gff files (input of OrthoGene class)
60 list<OrthoGene> all_orthogenes; // to be created by Patrick Balmerths code
61
62 void linkToOEs(list<OrthoExon> &oes); // link ECs in HECTS to nodes in orthograph
63 // old code
64 // void addScoreSelectivePressure(); //const. reward for orthologous exons and const. penalty for non-orthologous exons. Only temporary until PAML is integrated.
65
66 /*
67 * optimization via dual decomposition
68 * problem is decomposed into two subproblems whith can be solved efficiently:
69 * horizontal problem: DAG longest path
70 * verical problem: MAP inference on a set of disjoint phylogenetic trees whose
71 * leaf nodes are assigned to weights.
72 */
73 double dualdecomp(list<OrthoExon> &all_orthoex, ExonEvo &evo,vector< list<Transcript*> *> &genelist, int gr_ID, int T, vector<double> &c); //main routine
74 double treeMAPInf(list<OrthoExon> &all_orthoex, ExonEvo &evo, int &numInconsistent); //vertical problem
75 double globalPathSearch(); // horizontal problem
76 double getStepSize(int r, double c,int t, int v, int numInconsistent, double current_dual, double best_primal, double best_dual); // specifies a sequence of steps
77 double makeConsistent(list<OrthoExon> &all_orthoex, ExonEvo &evo);
78 double init(list<OrthoExon> &all_orthoex, ExonEvo &evo, int &numInconsistent) ;
79
80 // transform graph labeling into list of genes + filter + output
81 void buildGeneList(vector< list<Transcript*>* > &genelist);
82 void filterGeneList(vector< list<Transcript*> *> &genelist, vector<int> &geneid);
83 void printGenelist(vector<ofstream*> &filestreams);
84 void outputGenes(vector<ofstream*> &filestreams, vector<int> &geneid){
85 vector< list<Transcript*> *> genelist(numSpecies);
86 buildGeneList(genelist);
87 filterGeneList(genelist,geneid);
88 printGenelist(filestreams);
89 }
90 void createOrthoGenes(const GeneMSA *geneRange); // creates all_orthogenes
91 void printOrthoGenes(); // ouputs all_orthogenes
92
93 static void setStepRule(const char* r);
94 /*
95 * old code: optimization by making small local changes called moves
96 */
97 //void optimize(ExonEvo &evo);// main routine, in which different moves are created
98 //void localMove(vector<Move*> &orthomove, ExonEvo &evo, int shift_size); // execution a single move
99 /*
100 * currently, only a single type of move is implemented:
101 * if # of 0's in labelpattern of an OrthoExon is smaller than # of 1's,
102 * all nodes with the labels 0 are made to 1 and vice versa
103 */
104 //vector<Move*> majorityRuleMove(OrthoExon &orthoex, int shift_size);
105 /*double pruningAlgor(ExonEvo &evo){ // pruning algor. for all OrthoExons
106 return pruningAlgor(all_orthoex, evo);
107 } */
108 //double pruningAlgor(list<OrthoExon> &orthoex, ExonEvo &evo); // pruning algor. for a list of OrthoExons
109 // list<OrthoExon> orthoExInRange(vector<Move*> &orthomove); //determine all OrthoExons in a range
110 //string getLabelpattern(OrthoExon &ex); //determines the current labelpattern of an orthoex
111 //void printHTMLgBrowse(OrthoExon &ex); //temp: html output for gBrowse
112 /*inline void printCache(){
113 printCache(all_orthoex);
114 }*/
115 //void printCache(list<OrthoExon> &ortho);
116};
117
118/*struct Score{
119 double treescore; //stores the score of a label pattern
120
121 int count; //counts the number of exon candidate tuples which have that specific pattern
122
123 Score() : treescore(0), count(0) {}
124 ~Score() {}
125 };*/
126
127/*
128 * hashfunction storing all label patterns and their score
129 * labelpattern: string over alphabet {0,1,2}^k, k = # species^k
130 * the i-th character in a label pattern is
131 * 0 if the exon in the i-th species has label 0
132 * 1 if the exon in the i-th species has label 1
133 * 2 if exon in the i-th species does not exist
134 */
135
136/*namespace cache{
137
138 extern map<string, Score> labelscore;
139 // cache functions
140 bool inHash(string labelpattern);
141 void resetCounter();
142 void addToHash(string labelpattern, double score);
143 double getScore(string labelpattern);
144 void incrementCounter(string labelpattern);
145}
146*/
147
148//functions to redirect filestreams
149vector<ofstream*> initOutputFiles(string outdir, string extension = string());
150void closeOutputFiles(vector<ofstream*> filestreams);
151
152
153#endif
Definition contTimeMC.hh:116
multiple sequence alignment of genomes for comparative gene prediction
Definition geneMSA.hh:37
orthologous graphs for comparative gene prediction
Definition orthograph.hh:34
Definition phylotree.hh:104