1 #ifndef ALGO_GNOMON___GNOMON_SEQ__HPP
2 #define ALGO_GNOMON___GNOMON_SEQ__HPP
3 
4 /*  $Id: gnomon_seq.hpp 430525 2014-03-26 19:10:31Z souvorov $
5  * ===========================================================================
6  *
7  *                            PUBLIC DOMAIN NOTICE
8  *               National Center for Biotechnology Information
9  *
10  *  This software/database is a "United States Government Work" under the
11  *  terms of the United States Copyright Act.  It was written as part of
12  *  the author's official duties as a United States Government employee and
13  *  thus cannot be copyrighted.  This software/database is freely available
14  *  to the public for use. The National Library of Medicine and the U.S.
15  *  Government have not placed any restriction on its use or reproduction.
16  *
17  *  Although all reasonable efforts have been taken to ensure the accuracy
18  *  and reliability of the software and data, the NLM and the U.S.
19  *  Government do not and cannot warrant the performance or results that
20  *  may be obtained by using this software or data. The NLM and the U.S.
21  *  Government disclaim all warranties, express or implied, including
22  *  warranties of performance, merchantability or fitness for any particular
23  *  purpose.
24  *
25  *  Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors:  Alexandre Souvorov, Vyacheslav Chetvernin
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbistd.hpp>
36 
37 #include <algo/gnomon/gnomon_model.hpp>
38 
39 BEGIN_NCBI_SCOPE
40 BEGIN_SCOPE(gnomon)
41 
42 typedef vector<double> TDVec;
43 
44 class CEResidueVec : public vector<EResidue> {};
45 
46 class CDoubleStrandSeq {
47 public:
operator [](EStrand s) const48     const CEResidueVec& operator[](EStrand s) const { return m_seq[s]; }
operator [](EStrand s)49     CEResidueVec& operator[](EStrand s) { return m_seq[s]; }
size() const50     int size() const { return m_seq[0].size(); }
51 private:
52     CEResidueVec m_seq[2];
53 };
54 
55 void Convert(const CResidueVec& src, CEResidueVec& dst);
56 void Convert(const CEResidueVec& src, CResidueVec& dst);
57 void Convert(const CResidueVec& src, CDoubleStrandSeq& dst);
58 
59 void ReverseComplement(const CEResidueVec& src, CEResidueVec& dst);
60 
fromACGT(TResidue c)61 inline EResidue fromACGT(TResidue c)
62 {
63     switch(c)
64     {
65         case 'A':
66         case 'a':
67             return enA;
68         case 'C':
69         case 'c':
70             return enC;
71         case 'G':
72         case 'g':
73             return enG;
74         case 'T':
75         case 't':
76             return enT;
77         default:
78             return enN;
79     }
80 
81 }
82 
toACGT(EResidue c)83 inline TResidue toACGT(EResidue c)
84 {
85     switch(c) {
86     case enA:
87 	return 'A';
88     case enC:
89 	return 'C';
90     case enG:
91 	return 'G';
92     case enT:
93 	return 'T';
94     case enN:
95 	return 'N';
96     default:
97 	return 'N';
98     }
99 }
100 
101 void FindAllStarts(TIVec codons[], const CEResidueVec& mrna, const CAlignMap& mrnamap, TSignedSeqRange search_region, int fixed_frame);
102 void FindAllStops(TIVec codons[], const CEResidueVec& mrna, const CAlignMap& mrnamap, TSignedSeqRange search_region, int fixed_frame);
103 void FindStartsStops(const CGeneModel& model, const CEResidueVec& contig_seq, const CEResidueVec& mrna, const CAlignMap& mrnamap,
104                      TIVec starts[3],  TIVec stops[3], int& frame, bool obeystart);
105 bool FindUpstreamStop(const vector<int>& stops, int start, int& stop);
106 
107 
108 END_SCOPE(gnomon)
109 END_NCBI_SCOPE
110 
111 #endif  // ALGO_GNOMON___GNOMON_SEQ__HPP
112