NCBI C++ ToolKit
intron.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /*
2 * $Id: intron.hpp 101425 2023-12-12 18:03:47Z dicuccio $
3 *
4 * =========================================================================
5 *
6 * PUBLIC DOMAIN NOTICE
7 * National Center for Biotechnology Information
8 *
9 * This software/database is a "United States Government Work" under the
10 * terms of the United States Copyright Act. It was written as part of
11 * the author's official duties as a United States Government employee and
12 * thus cannot be copyrighted. This software/database is freely available
13 * to the public for use. The National Library of Medicine and the U.S.
14 * Government have not placed any restriction on its use or reproduction.
15 *
16 * Although all reasonable efforts have been taken to ensure the accuracy
17 * and reliability of the software and data, the NLM and the U.S.
18 * Government do not and cannt warrant the performance or results that
19 * may be obtained by using this software or data. The NLM and the U.S.
20 * Government disclaim all warranties, express or implied, including
21 * warranties of performance, merchantability or fitness for any particular
22 * purpose.
23 *
24 * Please cite the author in any work or product based on this material.
25 *
26 * =========================================================================
27 *
28 * Author: Boris Kiryutin
29 *
30 * =========================================================================
31 */
32 
33 
34 #ifndef INTRON_HPP
35 #define INTRON_HPP
36 
37 #include <corelib/ncbistl.hpp>
38 #include <corelib/ncbidbg.hpp>
39 
40 #include <utility>
41 #include <vector>
42 #include <fstream>
43 
44 #include "AlignInfo.hpp"
45 #include "nucprot.hpp"
46 #include "NSeq.hpp"
47 
49 BEGIN_SCOPE(prosplign)
50 
51 extern const int infinity;
52 
53 class CHIntronScore : public pair<int, int> { //score, length / donor position
54 public:
55  CHIntronScore(int score = infinity) {
56  first = score;
57  }
58 };
59 
60 class CAnyIntron {
61 protected:
62  class CSIntronScore : public CHIntronScore {
63  int jsc;//where count score
64  const int *sc;
65  public:
66  void Init(const vector<int>& sco, int j, const CProSplignScaledScoring& scoring, int shl = 0, int shr = 0) {
67  sc = &sco.front();
68  jsc = j - shl - shr - scoring.lmin;
69  }
70 
72  jsc++;
73  first -= scoring.ie;
74  return *this;
75  }
76 
77  inline void AddDon(const CProSplignScaledScoring& scoring) {
78  if(jsc >= scoring.ini_nuc_margin) {//require at least ini_nuc_margin nuc. before splice in this version
79 // if(jsc >=0) {
80  int score = sc[jsc];
81  if(score > first) {
82  first = score;
83  second = jsc;
84  }
85  }
86  }
87  };
88 
91  const int *esc;//where to get score for swa-sen
92  int /*i, */j;//current position
93  char amin;//should be pseq[i-1];
94  const CNSeq& nseq;
95 
96 public:
97  //same coord for donor and acceptor in one group
98  //group 2
100  //group 1
102  //group 0
104 
105 #define GET0(fn,sn) \
106  inline CHIntronScore fn() { \
107  CHIntronScore res(sn); \
108  res.second = j - res.second; \
109  return res; \
110  }
111 
117 
118 #define GETANY(fn,sn, st) \
119  inline CHIntronScore fn() { \
120  CHIntronScore res(sn); \
121  res.second = j - res.second - st; \
122  return res; \
123  }
124 
131 
132 
133 
134 
135  CAnyIntron(/*int i1, */int j1, char amin1, const CAlignInfo& prev, const CAlignInfo& cur, const CNSeq& nseq_ori, const CProSplignScaledScoring& scoring)
136  : nseq(nseq_ori)
137  {
138  //i=i1;
139  j=j1;
140  amin=amin1;
141 
142  esc = &prev.w[0];
143 
144  sw111.Init(prev.w,j,scoring,1,1);
145  sfv111.Init(prev.fv,j,scoring,1,1);
146  sw000.Init(cur.w,j,scoring);
147  sh000.Init(cur.h,j,scoring);
148  sv000.Init(cur.v,j,scoring);
149  sfh000.Init(cur.fh,j,scoring);
150  sfv000.Init(cur.fv,j,scoring);
151  sw012.Init(cur.w,j,scoring,1,2);
152  sh012.Init(cur.h,j,scoring,1,2);
153  sw021.Init(cur.w,j,scoring,2,1);
154  sh021.Init(cur.h,j,scoring,2,1);
155  }
156 
157  void SimpleNucStep(const CProSplignScaledScoring scoring);
158  void NucStep(const CProSplignScaledScoring scoring, const CSubstMatrix& matrix);
159  void AddW1(const CProSplignScaledScoring scoring);
160  void AddW2(const CProSplignScaledScoring scoring, const CSubstMatrix& matrix);
161 
162  inline CHIntronScore GetW1(const CSubstMatrix& matrix) {
163  CHIntronScore res(swa);
164  res.first += matrix.MultScore(nA, nseq[j-2], nseq[j-1], amin);
166  tmp.first += matrix.MultScore(nC, nseq[j-2], nseq[j-1], amin);
167  if(tmp.first > res.first) res = tmp;
168  tmp = swg;
169  tmp.first += matrix.MultScore(nG, nseq[j-2], nseq[j-1], amin);
170  if(tmp.first > res.first) res = tmp;
171  tmp = swt;
172  tmp.first += matrix.MultScore(nT, nseq[j-2], nseq[j-1], amin);
173  if(tmp.first > res.first) res = tmp;
174  tmp = swn;
175  tmp.first += matrix.MultScore(nN, nseq[j-2], nseq[j-1], amin);
176  if(tmp.first > res.first) res = tmp;
177 
178  res.second = j - 2 - res.second;
179  return res;
180  }
181 
182  inline CHIntronScore GetW2() {
183  switch (nseq[j-1]) {
184  case nA:
185  {
186  CHIntronScore res(sea);
187  res.second = j - 1 - res.second;
188  return res;
189  }
190  break;
191  case nC:
192  {
193  CHIntronScore res(sec);
194  res.second = j - 1 - res.second;
195  return res;
196  }
197  break;
198  case nG:
199  {
200  CHIntronScore res(seg);
201  res.second = j - 1 - res.second;
202  return res;
203  }
204  break;
205  case nT:
206  {
207  CHIntronScore res(set);
208  res.second = j - 1 - res.second;
209  return res;
210  }
211  break;
212  default:
213  break;
214  }
215  // default:
216  CHIntronScore res(sen);
217  res.second = j - 1 - res.second;
218  return res;
219  }
220 
221 };
222 
223 
224 class CIntron : public CAnyIntron {
225 public:
226  //group 2
227  int donj2;//where to check if donor
228  int acsj2;//where to check if acseptor
229  //group 1
230  int donj1;//where to check if donor
231  int acsj1;//where to check if acseptor
232 
233  //group 0
234  int donj0;//where to check if donor
235  int acsj0;//where to check if acseptor
236 
237 char don1, don2;//donor letters
238 char acs1, acs2;//acsessor letters
239 
240 inline bool IsDon(int jn/*nucleotide pos*/) {
241  if(jn<0) return false;
242  if(nseq[jn] == don1 && nseq[jn+1] == don2) return true;
243  return false;
244 }
245 
246 inline bool NotAcs(int jn/*first nucl after intron*/) {
247  if(jn<2) return true;
248  if(nseq[jn-2] == acs1 && nseq[jn-1] == acs2) return false;
249  return true;
250 }
251 
252 inline void SimpleNucStep(const CProSplignScaledScoring scoring) {
253  CAnyIntron::SimpleNucStep(scoring);
254  donj0++;
255  acsj0++;
256  donj1++;
257  acsj1++;
258  donj2++;
259  acsj2++;
260 }
261 inline void NucStep(const CProSplignScaledScoring scoring, const CSubstMatrix& matrix)
262 {
263  SimpleNucStep(scoring);
264  if(j - scoring.lmin - 3 >= scoring.ini_nuc_margin) {
265  if(IsDon(j-scoring.lmin-2)) {//new donor
266  AddW1(scoring);
267  }
268  if(IsDon(j-scoring.lmin-1)) {//new donor
269  AddW2(scoring, matrix);
270  }
271  }//end j > lmin +3
272  if(IsDon(donj0)) {
273  sw000.AddDon(scoring);
274  sh000.AddDon(scoring);
275  sv000.AddDon(scoring);
276  sfh000.AddDon(scoring);
277  sfv000.AddDon(scoring);
278  }
279  if(IsDon(donj1)) {
280  sw111.AddDon(scoring);
281  sfv111.AddDon(scoring);
282  sw021.AddDon(scoring);
283  sh021.AddDon(scoring);
284  }
285  if(IsDon(donj2)) {
286  sw012.AddDon(scoring);
287  sh012.AddDon(scoring);
288  }
289 
290 }
291 
292 #define MGET(fn,acs) \
293  inline CHIntronScore fn() { \
294  if(NotAcs(acs)) return CHIntronScore(); \
295  return CAnyIntron::fn(); \
296  }
297 
309 //MGET(GetW1,j-2)
311  if(NotAcs(j-2)) return CHIntronScore();
312  return CAnyIntron::GetW1(matrix);
313 }
314 
316 
317  CIntron(/*int i,*/ int j_in, char amin_in, char don11, char don21, char acs11, char acs21, const CAlignInfo& prev, const CAlignInfo& cur, const CNSeq& nseq_in, const CProSplignScaledScoring& scoring)
318  : CAnyIntron(/*i, */j_in, amin_in, prev, cur, nseq_in, scoring) {
323  donj0 = j-scoring.lmin;
324  donj1 = donj0 - 1;
325  donj2 = donj1 - 1;
326  acsj0 = j;
327  acsj1 = acsj0 - 1;
328  acsj2 = acsj1 - 1;
329  }
330 };
331 
332 class CBestIntron {
333 public:
336  int gtcost, gccost, atcost, anycost;//cost of intron of minimum length
337 
338  CBestIntron(/*int i, */int j, char amin, const CAlignInfo& prev, const CAlignInfo& cur, const CNSeq& nseq, const CProSplignScaledScoring& scoring) :
339  gt(/*i, */j, amin, 'G', 'T', 'A', 'G', prev, cur, nseq, scoring),
340  gc(/*i, */j, amin, 'G', 'C', 'A', 'G', prev, cur, nseq, scoring),
341  at(/*i, */j, amin, 'A', 'T', 'A', 'C', prev, cur, nseq, scoring),
342  an(/*i, */j, amin, prev, cur, nseq, scoring) {
343  gtcost = scoring.sm_ICGT + scoring.lmin*scoring.ie;
344  gccost = scoring.sm_ICGC + scoring.lmin*scoring.ie;
345  atcost = scoring.sm_ICAT + scoring.lmin*scoring.ie;
346  anycost = scoring.sm_ICANY + scoring.lmin*scoring.ie;
347  }
348 
349  inline void NucStep(const CProSplignScaledScoring scoring, const CSubstMatrix& matrix) {
350  gt.NucStep(scoring, matrix);
351  gc.NucStep(scoring, matrix);
352  at.NucStep(scoring, matrix);
353  an.NucStep(scoring, matrix);
354  }
355 
357  sgt.first -= gtcost;
358  sgc.first -= gccost;
359  sat.first -= atcost;
360  sany.first -= anycost;
361  if(sgt.first > sgc.first) {
362  if(sat.first > sany.first) {
363  if(sgt.first > sat.first) return sgt;
364  else return sat;
365  }
366  if(sgt.first > sany.first) return sgt;
367  return sany;
368  }
369  if(sat.first > sany.first) {
370  if(sgc.first > sat.first) return sgc;
371  return sat;
372  }
373  if(sgc.first > sany.first) return sgc;
374  return sany;
375  }
376 
377 #define FUNC(name) \
378  inline CHIntronScore name() { return GetBest(gt.name(), gc.name(), at.name(), an.name()); }
379 
380 //FUNC(GetW1)
381  inline CHIntronScore GetW1(const CSubstMatrix& matrix) { return GetBest(gt.GetW1(matrix), gc.GetW1(matrix), at.GetW1(matrix), an.GetW1(matrix)); }
382 
395 };
396 
397 
398 // *** FAST INTRON IMPLEMENTATION
399 
400 /*
401 struct CBestI
402 {
403  int m_v, m_h1, m_h2, m_h3, m_w1, m_w2, m_w;
404 };
405 */
406 
407 struct CBestI
408 {
409  int v, h1, h2, h3, w1, w2, w;
410 };
411 
413 {
417  eANY
418 };
419 
421 {
424  eANYa
425 };
426 
428 {
429 public:
430  EDonType m_dt, m_dt1, m_dt2;
431  EAccType m_at, m_at1, m_at2;
433  //int m_w1s[5];//match scores for w1-splice
434  //int m_w2s[5];//match scores for w2-splice
435 };
436 
438 {
439 public:
440  CHIntronScore m_v, m_h1, m_h2, m_h3, m_w;
441  CHIntronScore m_w1[5];//in Nucleotides order, i.e m_w1[nA] - score for A
442  CHIntronScore m_w2[5];//same order
443 
444  void Reset(void);
445 };
446 
447 class CFIntron
448 {
449 private:
451  CFIntronDon m_gt, m_gc, m_at, m_any;
452  int m_w1s[5], m_w2s[5];//match scores
453  vector<CFIntornData> m_data;
454  CFIntornData *m_cd;//current pointer inside m_data
455  int *m_v, *m_h1, *m_h2, *m_h3, *m_w, *m_w12;//where to get score
456  const CNSeq& m_nseq;
457 
460 
461  //initialization methods
462  inline static EDonType GetDonType(char nuc1, char nuc2) {
463  if(nuc1 == nG) {
464  if(nuc2 == nT) return eGT;
465  if(nuc2 == nC) return eGC;
466  } else if(nuc1 == nA && nuc2 == nT) return eAT;
467  return eANY;
468  }
469  inline static EAccType GetAccType(char nuc1, char nuc2) {
470  if(nuc1 == nA) {
471  if(nuc2 == nG) return eAG;
472  if(nuc2 == nC) return eAC;
473  }
474  return eANYa;
475  }
476  inline void InitW12s(int j, const CProSplignScaledScoring& scoring, const CFastIScore& fiscore) {
477  j -= scoring.lmin + 3;
478  if(j<0) return;
479  char nuc1 = m_nseq[j];
480  char nuc2 = m_nseq[++j];
481  m_w2s[nA] = fiscore.GetScore(nuc1, nuc2, nA);
482  m_w2s[nT] = fiscore.GetScore(nuc1, nuc2, nT);
483  m_w2s[nG] = fiscore.GetScore(nuc1, nuc2, nG);
484  m_w2s[nC] = fiscore.GetScore(nuc1, nuc2, nC);
485  m_w2s[nN] = fiscore.GetScore(nuc1, nuc2, nN);
486  nuc1 = m_nseq[j+=scoring.lmin];
487  nuc2 = m_nseq[++j];
488  m_w1s[nA] = fiscore.GetScore(nA, nuc1, nuc2);
489  m_w1s[nT] = fiscore.GetScore(nT, nuc1, nuc2);
490  m_w1s[nG] = fiscore.GetScore(nG, nuc1, nuc2);
491  m_w1s[nC] = fiscore.GetScore(nC, nuc1, nuc2);
492  m_w1s[nN] = fiscore.GetScore(nN, nuc1, nuc2);
493  }
494  // Acceptor methods
495  inline void BestScAny(const CProSplignScaledScoring& scoring) {
496  m_bei.w = m_any.m_w.first - scoring.sm_ICANY;
497  m_bei.v = m_any.m_v.first - scoring.sm_ICANY;
498  m_bei.h1 = m_any.m_h1.first - scoring.sm_ICANY;
499  m_bei.h2 = m_any.m_h2.first - scoring.sm_ICANY;
500  m_bei.h3 = m_any.m_h3.first - scoring.sm_ICANY;
501  }
502  inline void BestScCon(const CFIntronDon& don, int cost, int j, const CProSplignScaledScoring& scoring) {
503  int tmp = don.m_w.first - cost - scoring.ie*(j - don.m_w.second);
504  if(tmp > m_bei.w) m_bei.w = tmp;
505  tmp = don.m_v.first - cost - scoring.ie*(j - don.m_v.second);
506  if(tmp > m_bei.v) m_bei.v = tmp;
507  tmp = don.m_h1.first - cost - scoring.ie*(j - don.m_h1.second);
508  if(tmp > m_bei.h1) m_bei.h1 = tmp;
509  tmp = don.m_h2.first - cost - scoring.ie*(j - don.m_h2.second);
510  if(tmp > m_bei.h2) m_bei.h2 = tmp;
511  tmp = don.m_h3.first - cost - scoring.ie*(j - don.m_h3.second);
512  if(tmp > m_bei.h3) m_bei.h3 = tmp;
513  }
514  inline int BestSc1(const CFIntronDon& don, int j, const CProSplignScaledScoring& scoring) const {
515  const CHIntronScore *sp = don.m_w1;
516  const int *ap = m_w1s;
517  //int res = don.m_w1[nA].first + m_w1s[nA] - ie*(j - don.m_w1[nA].second);
518  int res = sp->first + *(ap++) - scoring.ie*(j - sp->second);
519  ++sp;
520  int tmp = sp->first + *(ap++) - scoring.ie*(j - sp->second);
521  if(tmp > res) res = tmp;
522  ++sp;
523  tmp = sp->first + *(ap++) - scoring.ie*(j - sp->second);
524  if(tmp > res) res = tmp;
525  ++sp;
526  tmp = sp->first + *(ap++) - scoring.ie*(j - sp->second);
527  if(tmp > res) res = tmp;
528  ++sp;
529  tmp = sp->first + *(ap++) - scoring.ie*(j - sp->second);
530  if(tmp > res) res = tmp;
531  return res;
532  }
533  inline int GetLen1(int sc, const CFIntronDon& don, int j, const CProSplignScaledScoring& scoring) const {
534  const CHIntronScore *sp = don.m_w1;
535  const int *ap = m_w1s;
536  if(sc == sp->first + *(ap++) - scoring.ie*(j - sp->second + scoring.lmin)) return j - sp->second + scoring.lmin;
537  ++sp;
538  if(sc == sp->first + *(ap++) - scoring.ie*(j - sp->second + scoring.lmin)) return j - sp->second + scoring.lmin;
539  ++sp;
540  if(sc == sp->first + *(ap++) - scoring.ie*(j - sp->second + scoring.lmin)) return j - sp->second + scoring.lmin;
541  ++sp;
542  if(sc == sp->first + *(ap++) - scoring.ie*(j - sp->second + scoring.lmin)) return j - sp->second + scoring.lmin;
543  ++sp;
544  if(sc == sp->first + *(ap++) - scoring.ie*(j - sp->second + scoring.lmin)) return j - sp->second + scoring.lmin;
545  return 0;
546  }
547  //Donor methods
548  inline static void AddDonAny(int sc, CHIntronScore& bsc, int j, const CProSplignScaledScoring& scoring) {
549  if(sc > (bsc.first -= scoring.ie)) {
550  bsc.first = sc;
551  bsc.second = j;
552  }
553  }
554  inline static void AddDonCon(int sc, CHIntronScore& bsc, int j, const CProSplignScaledScoring& scoring) {
555  if(sc > (bsc.first - scoring.ie*(j-bsc.second))) {
556  bsc.first = sc;
557  bsc.second = j;
558  }
559  }
560  inline void AddDon1(CFIntronDon& don, Nucleotides& nuc, int j, const CProSplignScaledScoring& scoring) {
561  AddDonCon(*++m_w12, m_any.m_w1[nuc], j, scoring);
562  AddDonCon(*m_w12, don.m_w1[nuc], j, scoring);
563  }
564  inline void AddDon1(Nucleotides& nuc, int j, const CProSplignScaledScoring& scoring) {
565  AddDonCon(*++m_w12, m_any.m_w1[nuc], j, scoring);
566  }
567  inline void AddDon2(int j, const CProSplignScaledScoring& scoring) {
568  int sc = *m_w12;
569  AddDonAny(sc + m_w2s[nA], m_any.m_w2[nA], j, scoring);
570  AddDonAny(sc + m_w2s[nC], m_any.m_w2[nC], j, scoring);
571  AddDonAny(sc + m_w2s[nG], m_any.m_w2[nG], j, scoring);
572  AddDonAny(sc + m_w2s[nT], m_any.m_w2[nT], j, scoring);
573  AddDonAny(sc + m_w2s[nN], m_any.m_w2[nN], j, scoring);
574  }
575  inline void AddDon2(CFIntronDon& don, int j, const CProSplignScaledScoring& scoring) {
576  int sc = *m_w12;
577  AddDonAny(sc + m_w2s[nA], m_any.m_w2[nA], j, scoring);
578  AddDonAny(sc + m_w2s[nC], m_any.m_w2[nC], j, scoring);
579  AddDonAny(sc + m_w2s[nG], m_any.m_w2[nG], j, scoring);
580  AddDonAny(sc + m_w2s[nT], m_any.m_w2[nT], j, scoring);
581  AddDonAny(sc + m_w2s[nN], m_any.m_w2[nN], j, scoring);
582  AddDonCon(sc + m_w2s[nA], don.m_w2[nA], j, scoring);
583  AddDonCon(sc + m_w2s[nC], don.m_w2[nC], j, scoring);
584  AddDonCon(sc + m_w2s[nG], don.m_w2[nG], j, scoring);
585  AddDonCon(sc + m_w2s[nT], don.m_w2[nT], j, scoring);
586  AddDonCon(sc + m_w2s[nN], don.m_w2[nN], j, scoring);
587  }
588  inline void AddDon(int j, const CProSplignScaledScoring& scoring) {
589  AddDonAny(*++m_w, m_any.m_w, j, scoring);
590  AddDonAny(*++m_v, m_any.m_v, j, scoring);
591  AddDonAny(*++m_h1, m_any.m_h1, j, scoring);
592  AddDonAny(*++m_h2, m_any.m_h2, j, scoring);
593  AddDonAny(*++m_h3, m_any.m_h3, j, scoring);
594  }
595  inline void AddDon(CFIntronDon& don, int j, const CProSplignScaledScoring& scoring) {
596  AddDonAny(*++m_w, m_any.m_w, j, scoring);
597  AddDonAny(*++m_v, m_any.m_v, j, scoring);
598  AddDonAny(*++m_h1, m_any.m_h1, j, scoring);
599  AddDonAny(*++m_h2, m_any.m_h2, j, scoring);
600  AddDonAny(*++m_h3, m_any.m_h3, j, scoring);
601  AddDonCon(*m_w, don.m_w, j, scoring);
602  AddDonCon(*m_v, don.m_v, j, scoring);
603  AddDonCon(*m_h1, don.m_h1, j, scoring);
604  AddDonCon(*m_h2, don.m_h2, j, scoring);
605  AddDonCon(*m_h3, don.m_h3, j, scoring);
606  }
607 
608 public:
609 // static int lmin;//minimum intron length
610 // static int ie;//intron extention cost (scaled)
611 
612  void InitRowScores(CAlignRow *row, vector<int>& prevw, int j);
613  CFIntron(const CNSeq& nseq, const CProSplignScaledScoring scoring);
614 
615  inline const CBestI& Step(int j, const CProSplignScaledScoring& scoring, const CFastIScore& fiscore)
616  {
617  InitW12s(j, scoring, fiscore);
618  switch((++m_cd)->m_dt2) {
619  case eGT :
620  AddDon(j, scoring);
621  AddDon1(m_cd->m_1nuc, j, scoring);
622  AddDon2(m_gt, j, scoring);
623  break;
624  case eGC :
625  AddDon(j, scoring);
626  AddDon1(m_cd->m_1nuc, j, scoring);
627  AddDon2(m_gc, j, scoring);
628  break;
629  case eAT :
630  AddDon(j, scoring);
631  AddDon1(m_cd->m_1nuc, j, scoring);
632  AddDon2(m_at, j, scoring);
633  break;
634  default:
635  switch(m_cd->m_dt) {
636  case eGT :
637  AddDon(m_gt, j, scoring);
638  break;
639  case eGC :
640  AddDon(m_gc, j, scoring);
641  break;
642  case eAT :
643  AddDon(m_at, j, scoring);
644  break;
645  default:
646  AddDon(j, scoring);
647  break;
648  }
649  switch(m_cd->m_dt1) {
650  case eGT :
651  AddDon1(m_gt, m_cd->m_1nuc, j, scoring);
652  break;
653  case eGC :
654  AddDon1(m_gc, m_cd->m_1nuc, j, scoring);
655  break;
656  case eAT :
657  AddDon1(m_at, m_cd->m_1nuc, j, scoring);
658  break;
659  default:
660  AddDon1(m_cd->m_1nuc, j, scoring);
661  break;
662  }
663  AddDon2(j, scoring);
664  break;
665  }
666  //acceptor
667  BestScAny(scoring);
668  m_bei.w1 = BestSc1(m_any, j, scoring) - scoring.sm_ICANY;
669  m_bei.w2 = m_any.m_w2[m_cd->m_2nuc].first - scoring.sm_ICANY;
670  int tmp;
671  switch(m_cd->m_at2) {
672  case eAC:
673  tmp = m_at.m_w2[m_cd->m_2nuc].first - scoring.ie*(j - m_at.m_w2[m_cd->m_2nuc].second) - scoring.sm_ICAT;
674  if(tmp > m_bei.w2) m_bei.w2 = tmp;
675  break;
676  case eAG:
677  tmp = m_gt.m_w2[m_cd->m_2nuc].first - scoring.ie*(j - m_gt.m_w2[m_cd->m_2nuc].second) - scoring.sm_ICGT;
678  if(tmp > m_bei.w2) m_bei.w2 = tmp;
679  tmp = m_gc.m_w2[m_cd->m_2nuc].first - scoring.ie*(j - m_gc.m_w2[m_cd->m_2nuc].second) - scoring.sm_ICGC;
680  if(tmp > m_bei.w2) m_bei.w2 = tmp;
681  break;
682  default:
683  switch(m_cd->m_at) {
684  case eAC:
685  BestScCon(m_at, scoring.sm_ICAT, j, scoring);
686  break;
687  case eAG:
688  BestScCon(m_gt, scoring.sm_ICGT, j, scoring);
689  BestScCon(m_gc, scoring.sm_ICGC, j, scoring);
690  break;
691  default:
692  break;
693  }
694  switch(m_cd->m_at1) {
695  case eAC :
696  tmp = BestSc1(m_at, j, scoring) - scoring.sm_ICAT;
697  if(tmp > m_bei.w1) m_bei.w1 = tmp;
698  break;
699  case eAG :
700  tmp = BestSc1(m_gt, j, scoring) - scoring.sm_ICGT;
701  if(tmp > m_bei.w1) m_bei.w1 = tmp;
702  tmp = BestSc1(m_gc, j, scoring) - scoring.sm_ICGC;
703  if(tmp > m_bei.w1) m_bei.w1 = tmp;
704  break;
705  default:
706  break;
707  }
708  break;
709  }
710  m_bei.h1 -= scoring.ie_x_lmin;
711  m_bei.h2 -= scoring.ie_x_lmin;
712  m_bei.h3 -= scoring.ie_x_lmin;
713  m_bei.w1 -= scoring.ie_x_lmin;
714  m_bei.w2 -= scoring.ie_x_lmin;
715  m_bei.w -= scoring.ie_x_lmin;
716  m_bei.v -= scoring.ie_x_lmin;
717  return m_bei;
718  }
719  inline static int Getlen(const EAccType& at, int sc, const CHIntronScore& sc_any, const CHIntronScore& sc_at,
720  const CHIntronScore& sc_gt, const CHIntronScore& sc_gc, int j, const CProSplignScaledScoring& scoring) {
721  if(sc == sc_any.first - scoring.sm_ICANY - scoring.ie_x_lmin) return j - sc_any.second + scoring.lmin;
722  _ASSERT(at == eAC || at == eAG);
723  if(at == eAC) {
724  _ASSERT(sc == sc_at.first - scoring.sm_ICAT - scoring.ie*(j - sc_at.second + scoring.lmin));
725  return j - sc_at.second + scoring.lmin;
726  }
727  _ASSERT(at == eAG);
728  if(sc == sc_gt.first - scoring.sm_ICGT - scoring.ie*(j - sc_gt.second + scoring.lmin)) return j - sc_gt.second + scoring.lmin;
729  _ASSERT(sc == sc_gc.first - scoring.sm_ICGC - scoring.ie*(j - sc_gc.second + scoring.lmin));
730  return j - sc_gc.second + scoring.lmin;
731  }
732  inline int GetWlen(int j, const CProSplignScaledScoring& scoring) const { return Getlen(m_cd->m_at, m_bei.w, m_any.m_w, m_at.m_w, m_gt.m_w, m_gc.m_w, j, scoring); }
733  inline int GetVlen(int j, const CProSplignScaledScoring& scoring) const { return Getlen(m_cd->m_at, m_bei.v, m_any.m_v, m_at.m_v, m_gt.m_v, m_gc.m_v, j, scoring); }
734  inline int GetH1len(int j, const CProSplignScaledScoring& scoring) const { return Getlen(m_cd->m_at, m_bei.h1, m_any.m_h1, m_at.m_h1, m_gt.m_h1, m_gc.m_h1, j, scoring); }
735  inline int GetH2len(int j, const CProSplignScaledScoring& scoring) const { return Getlen(m_cd->m_at, m_bei.h2, m_any.m_h2, m_at.m_h2, m_gt.m_h2, m_gc.m_h2, j, scoring); }
736  inline int GetH3len(int j, const CProSplignScaledScoring& scoring) const { return Getlen(m_cd->m_at, m_bei.h3, m_any.m_h3, m_at.m_h3, m_gt.m_h3, m_gc.m_h3, j, scoring); }
737  inline int GetW2len(int j, const CProSplignScaledScoring& scoring) const {
738  int m_2nuc = m_cd->m_2nuc;
739  if(m_bei.w2 == m_any.m_w2[m_2nuc].first - scoring.sm_ICANY - scoring.ie_x_lmin)
740  return j - m_any.m_w2[m_2nuc].second + scoring.lmin;
741  _ASSERT(m_cd->m_at2 == eAC || m_cd->m_at2 == eAG);
742 
743  int w2len;
744 
745  if(m_cd->m_at2 == eAC) {
746  w2len = j - m_at.m_w2[m_2nuc].second + scoring.lmin;
747  _ASSERT(m_bei.w2 == m_at.m_w2[m_2nuc].first - scoring.sm_ICAT - scoring.ie*w2len);
748  return w2len;
749  }
750  _ASSERT(m_cd->m_at2 == eAG);
751  w2len = j - m_gt.m_w2[m_2nuc].second + scoring.lmin;
752  if(m_bei.w2 == m_gt.m_w2[m_2nuc].first - scoring.sm_ICGT - scoring.ie*w2len)
753  return w2len;
754  w2len = j - m_gc.m_w2[m_2nuc].second + scoring.lmin;
755  _ASSERT(m_bei.w2 == m_gc.m_w2[m_2nuc].first - scoring.sm_ICGC - scoring.ie*w2len);
756  return w2len;
757  }
758  inline int GetW1len(int j, const CProSplignScaledScoring& scoring) const {
759  int len = GetLen1(m_bei.w1 + scoring.sm_ICANY, m_any, j, scoring);
760  if(len) return len;
761  _ASSERT(m_cd->m_at1 == eAC || m_cd->m_at1 == eAG);
762  if(m_cd->m_at1 == eAC) {
763  len = GetLen1(m_bei.w1 + scoring.sm_ICAT, m_at, j, scoring);
764  _ASSERT(len);
765  return len;
766  }
767  _ASSERT(m_cd->m_at1 == eAG);
768  len = GetLen1(m_bei.w1 + scoring.sm_ICGT, m_gt, j, scoring);
769  if(len) return len;
770  len = GetLen1(m_bei.w1 + scoring.sm_ICGC, m_gc, j, scoring);
771  _ASSERT(len);
772  return len;
773  }
774 };
775 
776 // *** END OF FAST INTRON IMPLEMENTATION
777 
778 
779 END_SCOPE(prosplign)
781 
782 #endif //INTRON_HPP
Nucleotides
Definition: NSeq.hpp:47
@ nA
Definition: NSeq.hpp:47
@ nG
Definition: NSeq.hpp:47
@ nT
Definition: NSeq.hpp:47
@ nN
Definition: NSeq.hpp:47
@ nC
Definition: NSeq.hpp:47
void AddDon(const CProSplignScaledScoring &scoring)
Definition: intron.hpp:77
CSIntronScore & increment(const CProSplignScaledScoring &scoring)
Definition: intron.hpp:71
void Init(const vector< int > &sco, int j, const CProSplignScaledScoring &scoring, int shl=0, int shr=0)
Definition: intron.hpp:66
CSIntronScore sw012
Definition: intron.hpp:99
CHIntronScore Getw111()
Definition: intron.hpp:125
CHIntronScore sec
Definition: intron.hpp:90
CHIntronScore Getw012()
Definition: intron.hpp:127
CSIntronScore sv000
Definition: intron.hpp:103
CSIntronScore sw021
Definition: intron.hpp:101
CHIntronScore Getfv000()
Definition: intron.hpp:116
CHIntronScore set
Definition: intron.hpp:90
CHIntronScore Getfv111()
Definition: intron.hpp:126
CHIntronScore Geth021()
Definition: intron.hpp:130
CSIntronScore sfh000
Definition: intron.hpp:103
const CNSeq & nseq
Definition: intron.hpp:94
void AddW2(const CProSplignScaledScoring scoring, const CSubstMatrix &matrix)
Definition: intron.cpp:111
CSIntronScore sfv111
Definition: intron.hpp:101
CHIntronScore Getfh000()
Definition: intron.hpp:115
CHIntronScore swg
Definition: intron.hpp:89
CHIntronScore Getw000()
Definition: intron.hpp:112
CHIntronScore Geth000()
Definition: intron.hpp:114
CHIntronScore swt
Definition: intron.hpp:89
CHIntronScore GetW1(const CSubstMatrix &matrix)
Definition: intron.hpp:162
CHIntronScore seg
Definition: intron.hpp:90
CHIntronScore Geth012()
Definition: intron.hpp:128
void AddW1(const CProSplignScaledScoring scoring)
Definition: intron.cpp:74
CSIntronScore sh012
Definition: intron.hpp:99
char amin
Definition: intron.hpp:93
CHIntronScore swc
Definition: intron.hpp:89
CHIntronScore Getv000()
Definition: intron.hpp:113
void SimpleNucStep(const CProSplignScaledScoring scoring)
Definition: intron.cpp:47
CHIntronScore swn
Definition: intron.hpp:89
CSIntronScore sh021
Definition: intron.hpp:101
CHIntronScore sea
Definition: intron.hpp:90
void NucStep(const CProSplignScaledScoring scoring, const CSubstMatrix &matrix)
Definition: intron.cpp:140
CHIntronScore swa
Definition: intron.hpp:89
CHIntronScore sen
Definition: intron.hpp:90
CHIntronScore GetW2()
Definition: intron.hpp:182
CSIntronScore sfv000
Definition: intron.hpp:103
CSIntronScore sh000
Definition: intron.hpp:103
CSIntronScore sw000
Definition: intron.hpp:103
CHIntronScore Getw021()
Definition: intron.hpp:129
CSIntronScore sw111
Definition: intron.hpp:101
const int * esc
Definition: intron.hpp:91
CHIntronScore GetBest(CHIntronScore sgt, CHIntronScore sgc, CHIntronScore sat, CHIntronScore sany)
Definition: intron.hpp:356
CHIntronScore Getw111()
Definition: intron.hpp:384
CHIntronScore Getw012()
Definition: intron.hpp:386
CHIntronScore GetW2()
Definition: intron.hpp:383
CHIntronScore Getw021()
Definition: intron.hpp:388
CBestIntron(int j, char amin, const CAlignInfo &prev, const CAlignInfo &cur, const CNSeq &nseq, const CProSplignScaledScoring &scoring)
Definition: intron.hpp:338
int atcost
Definition: intron.hpp:336
CHIntronScore Getfv111()
Definition: intron.hpp:385
CIntron at
Definition: intron.hpp:334
int gccost
Definition: intron.hpp:336
CHIntronScore Getfv000()
Definition: intron.hpp:394
CHIntronScore Geth021()
Definition: intron.hpp:389
int gtcost
Definition: intron.hpp:336
CIntron gc
Definition: intron.hpp:334
CHIntronScore Geth012()
Definition: intron.hpp:387
CHIntronScore Getfh000()
Definition: intron.hpp:393
CHIntronScore Geth000()
Definition: intron.hpp:390
void NucStep(const CProSplignScaledScoring scoring, const CSubstMatrix &matrix)
Definition: intron.hpp:349
CHIntronScore Getw000()
Definition: intron.hpp:392
CIntron gt
Definition: intron.hpp:334
CHIntronScore Getv000()
Definition: intron.hpp:391
CHIntronScore GetW1(const CSubstMatrix &matrix)
Definition: intron.hpp:381
int anycost
Definition: intron.hpp:336
CAnyIntron an
Definition: intron.hpp:335
EDonType m_dt1
Definition: intron.hpp:430
Nucleotides m_2nuc
Definition: intron.hpp:432
EAccType m_at
Definition: intron.hpp:431
EDonType m_dt
Definition: intron.hpp:430
Nucleotides m_1nuc
Definition: intron.hpp:432
EAccType m_at1
Definition: intron.hpp:431
EAccType m_at2
Definition: intron.hpp:431
EDonType m_dt2
Definition: intron.hpp:430
CHIntronScore m_h2
Definition: intron.hpp:440
CHIntronScore m_v
Definition: intron.hpp:440
CHIntronScore m_h1
Definition: intron.hpp:440
CHIntronScore m_w2[5]
Definition: intron.hpp:442
CHIntronScore m_w1[5]
Definition: intron.hpp:441
CHIntronScore m_h3
Definition: intron.hpp:440
CHIntronScore m_w
Definition: intron.hpp:440
const CBestI & Step(int j, const CProSplignScaledScoring &scoring, const CFastIScore &fiscore)
Definition: intron.hpp:615
vector< CFIntornData > m_data
Definition: intron.hpp:453
void AddDon2(int j, const CProSplignScaledScoring &scoring)
Definition: intron.hpp:567
void AddDon1(Nucleotides &nuc, int j, const CProSplignScaledScoring &scoring)
Definition: intron.hpp:564
static void AddDonAny(int sc, CHIntronScore &bsc, int j, const CProSplignScaledScoring &scoring)
Definition: intron.hpp:548
CBestI m_bei
Definition: intron.hpp:450
int GetLen1(int sc, const CFIntronDon &don, int j, const CProSplignScaledScoring &scoring) const
Definition: intron.hpp:533
CFIntronDon m_gt
Definition: intron.hpp:451
static void AddDonCon(int sc, CHIntronScore &bsc, int j, const CProSplignScaledScoring &scoring)
Definition: intron.hpp:554
void AddDon(int j, const CProSplignScaledScoring &scoring)
Definition: intron.hpp:588
int BestSc1(const CFIntronDon &don, int j, const CProSplignScaledScoring &scoring) const
Definition: intron.hpp:514
int GetH1len(int j, const CProSplignScaledScoring &scoring) const
Definition: intron.hpp:734
static EDonType GetDonType(char nuc1, char nuc2)
Definition: intron.hpp:462
int * m_w12
Definition: intron.hpp:455
CFIntornData * m_cd
Definition: intron.hpp:454
int GetWlen(int j, const CProSplignScaledScoring &scoring) const
Definition: intron.hpp:732
int GetH2len(int j, const CProSplignScaledScoring &scoring) const
Definition: intron.hpp:735
CFIntron & operator=(const CFIntron &)
void AddDon(CFIntronDon &don, int j, const CProSplignScaledScoring &scoring)
Definition: intron.hpp:595
const CNSeq & m_nseq
Definition: intron.hpp:456
static int Getlen(const EAccType &at, int sc, const CHIntronScore &sc_any, const CHIntronScore &sc_at, const CHIntronScore &sc_gt, const CHIntronScore &sc_gc, int j, const CProSplignScaledScoring &scoring)
Definition: intron.hpp:719
void AddDon1(CFIntronDon &don, Nucleotides &nuc, int j, const CProSplignScaledScoring &scoring)
Definition: intron.hpp:560
static EAccType GetAccType(char nuc1, char nuc2)
Definition: intron.hpp:469
void BestScCon(const CFIntronDon &don, int cost, int j, const CProSplignScaledScoring &scoring)
Definition: intron.hpp:502
void AddDon2(CFIntronDon &don, int j, const CProSplignScaledScoring &scoring)
Definition: intron.hpp:575
void BestScAny(const CProSplignScaledScoring &scoring)
Definition: intron.hpp:495
int GetVlen(int j, const CProSplignScaledScoring &scoring) const
Definition: intron.hpp:733
CFIntron(const CFIntron &)
void InitW12s(int j, const CProSplignScaledScoring &scoring, const CFastIScore &fiscore)
Definition: intron.hpp:476
int GetH3len(int j, const CProSplignScaledScoring &scoring) const
Definition: intron.hpp:736
int GetW2len(int j, const CProSplignScaledScoring &scoring) const
Definition: intron.hpp:737
int GetW1len(int j, const CProSplignScaledScoring &scoring) const
Definition: intron.hpp:758
int GetScore()
Definition: nucprot.hpp:148
CHIntronScore(int score=infinity)
Definition: intron.hpp:55
CHIntronScore Getw012()
Definition: intron.hpp:307
int acsj2
Definition: intron.hpp:228
bool IsDon(int jn)
Definition: intron.hpp:240
CHIntronScore Getfh000()
Definition: intron.hpp:302
CHIntronScore Geth021()
Definition: intron.hpp:306
CHIntronScore Geth000()
Definition: intron.hpp:299
bool NotAcs(int jn)
Definition: intron.hpp:246
CHIntronScore Geth012()
Definition: intron.hpp:308
char acs2
Definition: intron.hpp:238
char acs1
Definition: intron.hpp:238
CHIntronScore Getw000()
Definition: intron.hpp:298
CHIntronScore Getw021()
Definition: intron.hpp:305
int donj0
Definition: intron.hpp:234
void NucStep(const CProSplignScaledScoring scoring, const CSubstMatrix &matrix)
Definition: intron.hpp:261
char don1
Definition: intron.hpp:237
char don2
Definition: intron.hpp:237
int acsj0
Definition: intron.hpp:235
int donj2
Definition: intron.hpp:227
int acsj1
Definition: intron.hpp:231
CHIntronScore Getfv111()
Definition: intron.hpp:304
CHIntronScore Getv000()
Definition: intron.hpp:300
int donj1
Definition: intron.hpp:230
CHIntronScore Getw111()
Definition: intron.hpp:303
void SimpleNucStep(const CProSplignScaledScoring scoring)
Definition: intron.hpp:252
CHIntronScore GetW2()
Definition: intron.hpp:315
CHIntronScore Getfv000()
Definition: intron.hpp:301
CHIntronScore GetW1(const CSubstMatrix &matrix)
Definition: intron.hpp:310
Definition: NSeq.hpp:52
Substitution Matrix for Scoring Amino-Acid Alignments.
Definition: nucprot.hpp:123
int MultScore(int nuc1, int nuc2, int nuc3, char amin) const
Definition: nucprot.hpp:129
static int CharToNuc(char c)
Definition: nucprot.cpp:106
Definition: set.hpp:45
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
Definition: dlist.tmpl.h:46
static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
Definition: dlist.tmpl.h:61
static char tmp[3200]
Definition: utf8.c:42
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
#define GET0(fn, sn)
Definition: intron.hpp:105
#define GETANY(fn, sn, st)
Definition: intron.hpp:118
const int infinity
Definition: nucprot.cpp:52
#define FUNC(name)
Definition: intron.hpp:377
EAccType
Definition: intron.hpp:421
@ eANYa
Definition: intron.hpp:424
@ eAG
Definition: intron.hpp:422
@ eAC
Definition: intron.hpp:423
#define MGET(fn, acs)
Definition: intron.hpp:292
EDonType
Definition: intron.hpp:413
@ eAT
Definition: intron.hpp:416
@ eGC
Definition: intron.hpp:415
@ eANY
Definition: intron.hpp:417
@ eGT
Definition: intron.hpp:414
int len
NCBI C++ auxiliary debug macros.
The NCBI C++/STL use hints.
#define row(bind, expected)
Definition: string_bind.c:73
int h2
Definition: intron.hpp:409
int h1
Definition: intron.hpp:409
int w
Definition: intron.hpp:409
int h3
Definition: intron.hpp:409
int w1
Definition: intron.hpp:409
int v
Definition: intron.hpp:409
int w2
Definition: intron.hpp:409
#define _ASSERT
#define const
Definition: zconf.h:232
Modified on Fri May 24 14:57:26 2024 by modify_doxy.py rev. 669887