File: dp.h

package info (click to toggle)
mothur 1.48.5-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 13,684 kB
  • sloc: cpp: 161,854; makefile: 122; sh: 31
file content (164 lines) | stat: -rwxr-xr-x 5,094 bytes parent folder | download | duplicates (9)
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#ifndef dp_h
#define dp_h

#define SAVE_FAST	0

#include "myutils.h"
#include "mx.h"
#include "seqdb.h"
#include "diagbox.h"
#include "path.h"
#include "alnparams.h"
#include "alnheuristics.h"
#include "hspfinder.h"

typedef void (*OnPathFn)(const string &Path, bool Full);

enum XType
	{
	XType_Full=1,
	XType_Fwd=2,
	XType_Bwd=3,
	};

// public
float ViterbiBrute(const byte *A, unsigned LA, const byte *B, unsigned LB, 
  unsigned DiagLo, unsigned DiagHi, const AlnParams &AP, PathData &PD);

float ViterbiSimple(const byte *A, unsigned LA, const byte *B, unsigned LB,
  const AlnParams &AP, PathData &PD);

float ViterbiSimpleBand(const byte *A, unsigned LA, const byte *B, unsigned LB,
  const AlnParams &AP, unsigned DiagLo, unsigned DiagHi, PathData &PD);

float ViterbiFast(const byte *A, unsigned LA, const byte *B, unsigned LB,
  const AlnParams &AP, PathData &PD);

float ViterbiFastBand(const byte *A, unsigned LA, const byte *B, unsigned LB,
  unsigned DiagLo, unsigned DiagHi, const AlnParams &AP, PathData &PD);

float ViterbiFastMainDiag(const byte *A, unsigned LA, const byte *B, unsigned LB,
  unsigned BandRadius, const AlnParams &AP, PathData &PD);

float XDropFwdSimple(const byte *A, unsigned LA, const byte *B, unsigned LB,
  const AlnParams &AP, float XDrop, unsigned &Leni, unsigned &Lenj, PathData &PD);

float XDropBwdSimple(const byte *A, unsigned LA, const byte *B, unsigned LB,
  const AlnParams &AP, float XDrop, unsigned &Leni, unsigned &Lenj, PathData &PD);

float XDropFwdFast(const byte *A, unsigned LA, const byte *B, unsigned LB,
  const AlnParams &AP, float XDrop, unsigned &Leni, unsigned &Lenj, PathData &PD);

float XDropBwdFast(const byte *A, unsigned LA, const byte *B, unsigned LB,
  const AlnParams &AP, float XDrop, unsigned &Leni, unsigned &Lenj, PathData &PD);

void XDropAlign(const byte *A, unsigned LA, const byte *B, unsigned LB,
  unsigned AncLoi, unsigned AncLoj, unsigned AncLen, const AlnParams &AP,
  float XDrop, HSPData &HSP, PathData &PD);

float SWSimple(const byte *A, unsigned LA, const byte *B, unsigned LB,
  const AlnParams &AP, unsigned &Loi, unsigned &Leni, unsigned &Lenj,
  unsigned &Hij, PathData &PD);

float SWFast(const byte *A, unsigned LA, const byte *B, unsigned LB,
  const AlnParams &AP, unsigned &Loi, unsigned &Leni, unsigned &Lenj,
  unsigned &Hij, PathData &PD);

void SWFast2(const SeqData &SA, const SeqData &SB, const AlnParams &AP,
  HSPData &HSP, PathData &PD);

void SWSimple2(const SeqData &SA, const SeqData &SB, const AlnParams &AP,
  HSPData &HSP, PathData &PD);

float SWUngapped(const byte *A, unsigned LA, const byte *B, unsigned LB,
  const float * const *SubstMx, unsigned &LoA, unsigned &LoB, unsigned &Len);

void SWUngapped2(const SeqData &SA, const SeqData &SB, const AlnParams &AP,
  HSPData &HSP);

float SWFastNTB(const byte *A, unsigned LA, const byte *B, unsigned LB,
  const AlnParams &AP);

void GlobalAlignBand(const byte *A, unsigned LA, const byte *B, unsigned LB,
  const AlnParams &AP, unsigned BandRadius, PathData &PD);

bool GlobalAlign(const SeqData &Query, const SeqData &Target, const AlnParams &AP,
  const AlnHeuristics &AH, HSPFinder &HF, float MinFractId, float &HSPFractId,
  PathData &PD);

bool GlobalAlign(const SeqData &Query, const SeqData &Target, string &Path);

void GetBruteMxs(Mx<float> **M, Mx<float> **D, Mx<float> **I);
void GetSimpleDPMxs(Mx<float> **M, Mx<float> **D, Mx<float> **I);
void GetSimpleBandMxs(Mx<float> **M, Mx<float> **D, Mx<float> **I);
void GetXDropFwdSimpleDPMxs(Mx<float> **M, Mx<float> **D, Mx<float> **I);
#if	SAVE_FAST
void GetFastMxs(Mx<float> **M, Mx<float> **D, Mx<float> **I);
void GetFastBandMxs(Mx<float> **M, Mx<float> **D, Mx<float> **I);
#endif

// private
void TraceBackBit(unsigned LA, unsigned LB, char State, PathData &PD);
void TraceBackBitSW(unsigned LA, unsigned LB, unsigned Besti, unsigned Bestj,
  unsigned &Leni, unsigned &Lenj, PathData &PD);
void EnumPaths(unsigned L1, unsigned L2, bool SubPaths, OnPathFn OnPath);
void AllocBit(unsigned LA, unsigned LB);

const byte TRACEBITS_DM = 0x01;
const byte TRACEBITS_IM = 0x02;
const byte TRACEBITS_MD = 0x04;
const byte TRACEBITS_MI = 0x08;
const byte TRACEBITS_SM = 0x10;
const byte TRACEBITS_UNINIT = ~0x1f;

extern Mx<byte> g_Mx_TBBit;
extern float *g_DPRow1;
extern float *g_DPRow2;
extern byte **g_TBBit;

static inline void Max_xM(float &Score, float MM, float DM, float IM, byte &State)
	{
	Score = MM;
	State = 'M';

	if (DM > Score)
		{
		Score = DM;
		State = 'D';
		}
	if (IM > Score)
		{
		Score = IM;
		State = 'I';
		}
	}

static inline void Max_xD(float &Score, float MD, float DD, byte &State)
	{
	if (MD >= DD)
		{
		Score = MD;
		State = 'M';
		}
	else
		{
		Score = DD;
		State = 'D';
		}
	}

static inline void Max_xI(float &Score, float MI, float II, byte &State)
	{
	if (MI >= II)
		{
		Score = MI;
		State = 'M';
		}
	else
		{
		Score = II;
		State = 'I';
		}
	}

#endif // dp_h