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

Go to the SVN repository for this file.

1 #ifndef ALNGRAPHIC_HPP
2 #define ALNGRAPHIC_HPP
3 /* $Id: alngraphic.hpp 87229 2019-08-08 18:57:07Z jianye $
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 cannot 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: Jian Ye
29  *
30  * File Description:
31  * Alignment graphic overview (using HTML table)
32  *
33  */
34 
35 #include <html/html.hpp>
36 #include <corelib/ncbiobj.hpp>
38 #include <objmgr/scope.hpp>
39 #include <util/range.hpp>
40 
43 
45 public:
46  //view options
47  enum ViewOption {
48  eCompactView = (1 << 0), //put as many seq as possible on one line
49  //default sequence with same id on one line
50  eMouseOverInfo = (1 << 1), //show info when mouse over alignment graph
51  eAnchorLink = (1 << 2), //quick link in blast resutl html page
52  eAnchorLinkDynamic = (1 << 3) //quick link in blast resutl html page for new design
53  };
54 
55  //graph bar height
56  enum BarPixel {
57  e_Height3 = 3,
58  e_Height4 = 4, //default
59  e_Height5 = 5,
60  e_Height6 = 6,
61  e_Height7 = 7
62  };
63 
64  // Constructors
65  CAlnGraphic(const CSeq_align_set& seqalign,
66  CScope& scope,
67  CRange<TSeqPos>* master_range = NULL);
68 
69  // Destructor
70  ~CAlnGraphic();
71 
73  {
74  string graphScale;
75  string graphDigit;
76  string graphImage;// m_Img_template
77  string graphSeq;
78  string graphPos;
79  string graphSeqPopup;
80  };
81 
82  //view in ViewOption. default eCompactView
83  void SetViewOption(int option) {
84  m_View = option;
85  }
86 
87  void SetImagePath(string path) { //i.e. "mypath/". defaul "./"
88  m_ImagePath = path;
89  }
90 
91  void SetGraphBarHeight(BarPixel height) {
92  m_BarHeight = height;
93  }
94 
95  //form name that include the text input area to show
96  //info, i.e. "document.forms[0]"
97  void SetMouseOverFormName(string form_name) {
98  m_MouseOverFormName = form_name;
99  }
100 
101 
102  void SetOnClickFunctionName(string onClickFunction) {
103  m_onClickFunction = onClickFunction;
104  }
105  // Display top num seqalign
106  void SetNumAlignToShow(int num) { //internal default = 1000
107  m_NumAlignToShow = num;
108  }
109 
110  /*Number of maximal line to show. Note this is different than
111  alignment number as each line may contains > 1 alignment, especially
112  when using eCompactView */
113  void SetNumLineToShow(int num) { //internal default = 50
114  m_NumLine = num;
115  }
116 
118  m_AlignGraphTemplates = graphTemplates;
119  }
120  void Init(void);
121  //show alignment graphic view
122  void AlnGraphicDisplay(CNcbiOstream& out);
123  void Display(CNcbiOstream& out);
124 
125 private:
126  struct SAlignInfo {
129  double bits;
130  string info;
131  string accession;
132  string score;
133  string eval;
136  };
137  //callback for sorting range
138 
139  inline static bool FromRangeAscendingSort(SAlignInfo* const& info1,
140  SAlignInfo* const& info2)
141  {
142  return info1->range->GetFrom() < info2->range->GetFrom();
143  }
144 
145  typedef list<SAlignInfo*> TAlnInfoList;
146  typedef list<TAlnInfoList*> TAlnInfoListList;
150  int m_View;
152  string m_ImagePath;
153  string m_MouseOverFormName; //the text input window to show mouseover info
156 
161 
162  //blast sub-sequence query
164 
166  void x_DisplayMaster(int master_len, CNCBINode* center,
167  CHTML_table* tbl_box, CHTML_tc*& tbl_box_tc);
168  void x_GetAlnInfo(const CSeq_align& aln, const CSeq_id& id,
169  SAlignInfo* aln_info);
170  void x_GetAlnInfo(SAlignInfo* aln_info);
171  void x_BuildHtmlTable(int master_len, CHTML_table* tbl_box,
172  CHTML_tc*& tbl_box_tc);
173  CRange<TSeqPos>* x_GetEffectiveRange(TAlnInfoList& alninfo_list);
174  void x_MergeDifferentSeq(double pixel_factor);
175  void x_MergeSameSeq(TAlnInfoList& alninfo_list);
176  void x_PrintTop (CNCBINode* center, CHTML_table* tbl_box,
177  CHTML_tc*& tbl_box_tc);
178 
179  string x_FormatScale(void);
180  string x_FormatScaleDigit(string digitString,int spacer_length);
181  void x_FormatGraphOverview(CNcbiOstream & out);
182 };
183 
184 
187 
188 #endif
int m_NumAlignToShow
Definition: alngraphic.hpp:149
void SetNumLineToShow(int num)
Definition: alngraphic.hpp:113
static bool FromRangeAscendingSort(SAlignInfo *const &info1, SAlignInfo *const &info2)
Definition: alngraphic.hpp:139
CRange< TSeqPos > * m_MasterRange
Definition: alngraphic.hpp:163
CRef< CScope > m_Scope
Definition: alngraphic.hpp:148
CConstRef< CSeq_align_set > m_AlnSet
Definition: alngraphic.hpp:147
TAlnInfoListList m_AlninfoListList
Definition: alngraphic.hpp:165
string m_onClickFunction
Definition: alngraphic.hpp:154
void SetOnClickFunctionName(string onClickFunction)
Definition: alngraphic.hpp:102
void SetGraphBarHeight(BarPixel height)
Definition: alngraphic.hpp:91
void SetImagePath(string path)
Definition: alngraphic.hpp:87
string m_MouseOverFormName
Definition: alngraphic.hpp:153
void SetViewOption(int option)
Definition: alngraphic.hpp:83
void SetNumAlignToShow(int num)
Definition: alngraphic.hpp:106
void SetGraphOverviewTemplates(SAlignGraphTemplates *graphTemplates)
Definition: alngraphic.hpp:117
string m_ImagePath
Definition: alngraphic.hpp:152
list< SAlignInfo * > TAlnInfoList
Definition: alngraphic.hpp:145
void SetMouseOverFormName(string form_name)
Definition: alngraphic.hpp:97
SAlignGraphTemplates * m_AlignGraphTemplates
Definition: alngraphic.hpp:160
list< TAlnInfoList * > TAlnInfoListList
Definition: alngraphic.hpp:146
double m_Pixel_factor
Definition: alngraphic.hpp:158
int m_Round_number
Definition: alngraphic.hpp:159
CScope –.
Definition: scope.hpp:92
std::ofstream out("events_result.xml")
main entry point for tests
static void Init(void)
Definition: cursor6.c:76
#define option
#define NULL
Definition: ncbistd.hpp:225
#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
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
#define NCBI_XALNTOOL_EXPORT
Definition: ncbi_export.h:1555
TFrom GetFrom(void) const
Get the From member data.
Definition: Range_.hpp:222
HTML classes.
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
CRange< TSeqPos > * range
Definition: alngraphic.hpp:134
CConstRef< CSeq_id > id
Definition: alngraphic.hpp:127
Modified on Fri Sep 20 14:58:27 2024 by modify_doxy.py rev. 669887