File: Faster.hpp

package info (click to toggle)
dindel 1.01%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 940 kB
  • ctags: 1,130
  • sloc: cpp: 15,773; makefile: 40
file content (101 lines) | stat: -rw-r--r-- 2,786 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
/*    
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/
/*
 * Faster.hpp
 *
 *  Created on: Feb 24, 2009
 *      Author: caa
 */

#ifndef FASTER_HPP_
#define FASTER_HPP_
#include <string>
#include <assert.h>
#include <iostream>
#include <stdint.h>
#include <vector>
#include <list>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include "bam.h"
#include "Haplotype.hpp"
#include "Read.hpp"
#include "MLAlignment.hpp"
#include "ObservationModel.hpp"
using namespace std;

class ObservationModelS
{


protected:
	class UngappedAlignment
	{
	public:
		UngappedAlignment()
		{
			ll=-HUGE_VAL;
			relPos=-10000;
			numMismatch=10000;
		}
		UngappedAlignment(double _ll, int _relPos, int _numMismatch)
		{
			ll=_ll;
			relPos=_relPos;
			numMismatch=_numMismatch;
		}
		double ll;
		int relPos;
		int numMismatch;
	};
public:
	ObservationModelS() {};
	ObservationModelS(const Haplotype & _hap, const Read & r, uint32_t hapStart, const ObservationModelParameters & _params);
	virtual ~ObservationModelS();
	MLAlignment align(const HapHash & hash);

	//MLAlignment calcLikelihood();
	//double getLogLikelihood() { calcLikelihood(); return ml.ll; };
	// void changeHaplotype(const Haplotype & newHap);
	void printAlignment(size_t hapScrPos);
	void printStatistics();
	ObservationModelParameters params;

protected:
	void computeBMid();
	void setupReadLikelihoods();
	void Align();
	void reportVariants();
	inline void doTransition(int cs, int nr, const vector<int> & state, vector<double> & alpha, vector<double> & bt, const vector<double> & tr, const int & S);
	inline void doTransitionNF(int cs, int nr, const vector<int> & state, vector<double> & alpha, vector<double> & bt, const vector<double> & tr, const int & S);
	void SStateHMM(vector<int> & relPos);
	void AlignHash(const HapHash & hash);
	MLAlignment ml;
	vector<double> logMatch, cumLogMatch, logMismatch;
	vector<int> mapState;
	double llMatch; //log likelihood when all bases in the read match
	int bMid, hlen, rlen;
	double llOff, llOffHMQ, pOffFirst, pOffFirstHMQ;

	const Haplotype *hap_ptr;
	const Read *read_ptr;
	size_t hapStart;
	bool  likelihoodComputed, bMidError;
};


#endif /* FASTER_HPP_ */