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

Go to the SVN repository for this file.

1 /* $Id: cav_alndisplay.hpp 55121 2012-07-18 13:55:43Z ivanov $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Authors: Paul Thiessen
27 *
28 * File Description:
29 * Classes to hold alignment display
30 *
31 * ===========================================================================
32 */
33 
34 #ifndef CAV_ALIGNMENT_DISPLAY__HPP
35 #define CAV_ALIGNMENT_DISPLAY__HPP
36 
37 #include <corelib/ncbistl.hpp>
38 #include <corelib/ncbistre.hpp>
39 
40 #include <list>
41 #include <vector>
42 
44 
45 
47 
48 class Sequence;
49 class SequenceSet;
50 class AlignmentSet;
51 
52 ///// classes that go into the AlignmentDisplay /////
53 
54 class TextRow
55 {
56 private:
57  string chars;
58 
59 public:
60  TextRow(const string& str) : chars(str) { } // initialize to string
61  TextRow(int size) : chars(string(size, '-')) { } // initialize to blank (all '-')
62 
63  unsigned int Length(void) const { return chars.size(); }
64  void InsertGaps(int nGaps, int beforePos);
65  void DeleteGaps(int nGaps, int startPos);
66  char GetCharAt(int alnLoc) const { return chars[alnLoc]; }
67  void SetCharAt(int alnLoc, char ch) { chars[alnLoc] = ch; }
68  bool IsSqueezable(int alnLoc, int *nGaps, int *startPos, int maxGaps) const;
69 };
70 
72 {
73 private:
74  typedef vector < int > IntVec;
76 
77 public:
78  IndexAlnLocToSeqLocRow(const Sequence *seq, int length = 0);
79 
81 
82  unsigned int Length(void) const { return seqLocs.size(); }
83  void InsertGaps(int nGaps, int beforePos);
84  int GetSeqLocAt(int alnLoc) const { return seqLocs[alnLoc]; }
85  void SetSeqLocAt(int alnLoc, int seqLoc) { seqLocs[alnLoc] = seqLoc; }
86  void ReIndex(const TextRow& textRow);
87 };
88 
89 
90 ///// the actual AlignmentDisplay structure /////
91 
93 {
94 private:
95  typedef vector < IndexAlnLocToSeqLocRow * > IndexAlnLocToSeqLocRows;
97 
98  typedef vector < TextRow * > TextRows;
100 
102 
103  void InsertGaps(int nGaps, int beforePos);
104  void ShiftUnalignedLeft(void);
105  void Squeeze(void);
106  void SplitUnaligned(void);
107 
108  int status;
109 
110 public:
111  AlignmentDisplay(const SequenceSet *sequenceSet, const AlignmentSet *alignmentSet);
113 
114  // query functions
115  unsigned int GetWidth(void) const { return textRows[0]->Length(); }
116  unsigned int GetNRows(void) const { return textRows.size(); }
117  char GetCharAt(int alnLoc, int row) const;
118  int GetFirstAlignedLoc(void) const { return firstAlnLoc; }
119  int GetLastAlignedLoc(void) const { return lastAlnLoc; }
120 
121  static const double SHOW_IDENTITY;
122  const string GetColumnColor(int alnLoc, double conservationThreshhold) const;
123 
124  // DumpText - plain text or HTML output controlled by 'options'
125  int DumpText(CNcbiOstream& os, unsigned int options,
126  int firstCol, int lastCol, int nColumns, double conservationThreshhold = 2.0,
127  const char *titleHTML = NULL, int nFeatures = 0, const AlignmentFeature *alnFeatures = NULL) const;
128 
129  // DumpCondensed - plain text or HTML output with incompletely aligned columns not explicitly shown
130  int DumpCondensed(CNcbiOstream& os, unsigned int options,
131  int firstCol, int lastCol, int nColumns, double conservationThreshhold = 2.0,
132  const char *titleHTML = NULL, int nFeatures = 0, const AlignmentFeature *alnFeatures = NULL) const;
133 
134  // FASTA
135  int DumpFASTA(int firstCol, int lastCol, int nColumns, bool doLowercase, CNcbiOstream& outStream) const;
136 
137  int Status(void) const { return status; }
138 };
139 
140 
141 // character type utilitles
142 inline bool IsUnaligned(char ch) { return (ch >= 'a' && ch <= 'z'); }
143 inline bool IsAligned(char ch) { return (ch >= 'A' && ch <= 'Z'); }
144 inline bool IsGap(char ch) { return (ch == '-'); }
145 
147 
148 
149 #endif
bool IsUnaligned(char ch)
bool IsGap(char ch)
bool IsAligned(char ch)
C interface header for cddalignview as function call.
int Status(void) const
int DumpCondensed(CNcbiOstream &os, unsigned int options, int firstCol, int lastCol, int nColumns, double conservationThreshhold=2.0, const char *titleHTML=NULL, int nFeatures=0, const AlignmentFeature *alnFeatures=NULL) const
int GetFirstAlignedLoc(void) const
vector< TextRow * > TextRows
IndexAlnLocToSeqLocRows indexAlnLocToSeqLocRows
vector< IndexAlnLocToSeqLocRow * > IndexAlnLocToSeqLocRows
void SplitUnaligned(void)
unsigned int GetWidth(void) const
void ShiftUnalignedLeft(void)
const string GetColumnColor(int alnLoc, double conservationThreshhold) const
int DumpText(CNcbiOstream &os, unsigned int options, int firstCol, int lastCol, int nColumns, double conservationThreshhold=2.0, const char *titleHTML=NULL, int nFeatures=0, const AlignmentFeature *alnFeatures=NULL) const
unsigned int GetNRows(void) const
int GetLastAlignedLoc(void) const
AlignmentDisplay(const SequenceSet *sequenceSet, const AlignmentSet *alignmentSet)
static const double SHOW_IDENTITY
int DumpFASTA(int firstCol, int lastCol, int nColumns, bool doLowercase, CNcbiOstream &outStream) const
char GetCharAt(int alnLoc, int row) const
void InsertGaps(int nGaps, int beforePos)
unsigned int Length(void) const
void ReIndex(const TextRow &textRow)
IndexAlnLocToSeqLocRow(const Sequence *seq, int length=0)
const Sequence * sequence
int GetSeqLocAt(int alnLoc) const
void InsertGaps(int nGaps, int beforePos)
void SetSeqLocAt(int alnLoc, int seqLoc)
TextRow(const string &str)
char GetCharAt(int alnLoc) const
void DeleteGaps(int nGaps, int startPos)
string chars
TextRow(int size)
unsigned int Length(void) const
void SetCharAt(int alnLoc, char ch)
bool IsSqueezable(int alnLoc, int *nGaps, int *startPos, int maxGaps) const
void InsertGaps(int nGaps, int beforePos)
static const char * str(char *buf, int n)
Definition: stats.c:84
string
Definition: cgiapp.hpp:690
#define NULL
Definition: ncbistd.hpp:225
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
const struct ncbi::grid::netcache::search::fields::SIZE size
The NCBI C++/STL use hints.
NCBI C++ stream class wrappers for triggering between "new" and "old" C++ stream libraries.
#define row(bind, expected)
Definition: string_bind.c:73
Modified on Fri Sep 20 14:57:44 2024 by modify_doxy.py rev. 669887