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

Go to the SVN repository for this file.

1 /* $Id: alngraphic.cpp 100790 2023-09-13 12:41:47Z zaretska $
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  * Author: Jian Ye
27  *
28  * File Description:
29  * Alignment graphic overview (using HTML table)
30  *
31  */
32 
33 #include <ncbi_pch.hpp>
36 #include <util/range.hpp>
37 #include <serial/iterator.hpp>
38 #include <objects/seq/Bioseq.hpp>
49 #include <objmgr/util/sequence.hpp>
51 #include <html/html.hpp>
52 
55 USING_SCOPE (sequence);
56 USING_SCOPE(align_format);
57 
58 
59 const char* kDigitGif[] = {"0.gif", "1.gif", "2.gif", "3.gif", "4.gif",
60  "5.gif", "6.gif", "7.gif", "8.gif", "9.gif"};
61 
62 const TSeqPos kScoreMargin = 50;
63 const TSeqPos kScoreLength = 500;
64 const TSeqPos kScoreHeight = 40;
65 
67 
71 
73 const TSeqPos kScaleWidth = 2;
74 const TSeqPos kScaleHeight = 10;
75 
76 const TSeqPos kDigitWidth = 10;
77 const TSeqPos kDigitHeight = 13;
78 
79 const TSeqPos kGapHeight = 1;
81 const TSeqPos kNumMark = 6;
82 
83 const int kDeflineLength = 55;
84 
85 /*two ranges are considered overlapping even if they do not overlap but
86  they differ only by this number*/
87 static const int kOverlapDiff = 5;
88 
89 //gif images
90 const char* kGifWhite = "white.gif";
91 const char* kGifMaster ="query_no_scale.gif";
92 const char* kGifScore = "score.gif";
93 const char* kGifGrey = "grey.gif";
94 const char* kGifScale = "scale.gif";
95 const char* kGifBlack = "black.gif";
96 
97 static string s_GetGif(int bits){
98  string gif = NcbiEmptyString;
99  if(bits < 40){
100  gif = "black.gif";
101  } else if (bits < 50) {
102  gif = "blue.gif";
103  } else if (bits < 80) {
104  gif = "green.gif";
105  } else if (bits < 200) {
106  gif = "purple.gif";
107  } else {
108  gif = "red.gif";
109  }
110  //for alignment with no bits info
111  if(bits == 0){
112  gif = "red.gif";
113  }
114  return gif;
115 }
116 
117 const char* kWhite = "white";
118 const char* kGrey = "grey";
119 const char* kBlack = "black";
120 
121 static string s_GetScoreColor(int bits){
122  string gif = NcbiEmptyString;
123  if(bits < 40){
124  gif = "black";
125  } else if (bits < 50) {
126  gif = "blue";
127  } else if (bits < 80) {
128  gif = "green";
129  } else if (bits < 200) {
130  gif = "purple";
131  } else {
132  gif = "red";
133  }
134  //for alignment with no bits info
135  if(bits == 0){
136  gif = "red";
137  }
138  return gif;
139 }
140 
141 //Round the number. i.e., 290 => 250, 735 => 700.
142 static int s_GetRoundNumber (int number){
143  int round = 0;
144 
145  if (number > 10) {
146  string num_str = NStr::IntToString(number);
147  int trail_num = NStr::StringToInt(num_str.substr(1, num_str.size() - 1));
148  round = number - trail_num;
149  string mid_num_str;
150  int mid_num = 0;
151  if(num_str.size() > 2) {
152  string trail_zero (num_str.size() - 2, '0');
153  mid_num_str = "5" + trail_zero;
154  mid_num = NStr::StringToInt(mid_num_str);
155  }
156 
157  if (number >= round + mid_num) {
158  round += mid_num;
159  }
160  } else {
161  round = number;
162  if(round < 1){
163  round = 1;
164  }
165  }
166  return round;
167 }
168 
171  if(!alninfo_list.empty()){
172  range = new CRange<TSeqPos>(alninfo_list.front()->range->GetFrom(),
173  alninfo_list.back()->range->GetTo());
174  }
175  return range;
176 }
177 
178 void CAlnGraphic::x_MergeDifferentSeq(double pixel_factor){
179 
180  TAlnInfoListList::iterator iter_temp;
181  list<CRange<TSeqPos>* > effective_range_list;
182  CRange<TSeqPos> *effective_range = NULL, *temp_range = NULL;
183 
185  iter_temp = iter; //current list
186  iter_temp ++; //the next list
187 
188  if(!(*iter)->empty() && iter_temp != m_AlninfoListList.end()){
189  /*effective ranges means the range covering all ranges for
190  alignment from the same seq*/
191  temp_range = x_GetEffectiveRange(**iter);
192  if(temp_range){
193  effective_range_list.push_back(temp_range);
194  }
195 
196  /*compare the range in current list to range in all other lists.
197  If the latter does not overlap with the ranges in the current
198  list, move it to the current one*/
199  while(iter_temp != m_AlninfoListList.end()){
200  /* Get effective range. Note that, except the current list,
201  all other list contains only one effective range. The
202  current list may have more than one because the range
203  from other list may be moved to it*/
204  effective_range = x_GetEffectiveRange(**iter_temp);
205  bool overlap = false;
206  if(effective_range){
208  iter2,
209  effective_range_list){
210  CRange<TSeqPos>* temp_range2 = *iter2;
211  int min_to = min(effective_range->GetTo(),
212  temp_range2->GetTo());
213  int max_from = max(effective_range->GetFrom(),
214  temp_range2->GetFrom());
215  //iter2 = ranges in current list
216  if((int)((max_from - min_to)*pixel_factor) <= kOverlapDiff){
217  //Not overlap but has only overlap_diff is still
218  //considered overlap as it's difficult to see the
219  //difference of only 1 pixel
220 
221  overlap = true;
222  break; //overlaps, do nothing
223  }
224  }
225  //if no overlap, move this list to the current list
226  if(!overlap){
227  (*iter)->merge(**iter_temp);
228  effective_range_list.push_back(effective_range);
229  }
230  if(overlap){
231  delete effective_range;
232  }
233  }
234  iter_temp ++;
235  }
236  ITERATE(list<CRange<TSeqPos>* >, iter4, effective_range_list){
237  delete *iter4;
238  }
239  effective_range_list.clear();
240  }
241  (*iter)->sort(FromRangeAscendingSort);
242  }
243 }
245  TAlnInfoList::iterator prev_iter;
246  int i = 0;
247 
248  NON_CONST_ITERATE (TAlnInfoList, iter, alninfo_list){
249  if(i > 0 && (*prev_iter)->range->IntersectingWith(*((*iter)->range))){
250  //merge range
251  (*iter)->range->Set(min((*prev_iter)->range->GetFrom(),
252  (*iter)->range->GetFrom()),
253  max((*prev_iter)->range->GetTo(),
254  (*iter)->range->GetTo()));
255  //take the maximal score and evalue
256  if((*iter)->bits < (*prev_iter)->bits){
257  (*iter)->bits = (*prev_iter)->bits;
258  (*iter)->info = (*prev_iter)->info;
259  }
260  delete (*prev_iter)->range;
261  delete *prev_iter;
262  alninfo_list.erase(prev_iter);
263  }
264  i ++;
265  prev_iter = iter;
266  }
267 }
268 
269 template<class container>
270 static bool s_GetBlastScore(const container& scoreList,
271  int& score,
272  double& bits,
273  double& evalue){
274  bool hasScore = false;
275  ITERATE (typename container, iter, scoreList) {
276  const CObject_id& id=(*iter)->GetId();
277  if (id.IsStr()) {
278  hasScore = true;
279  if (id.GetStr()=="score"){
280  score = (*iter)->GetValue().GetInt();
281 
282  } else if (id.GetStr()=="bit_score"){
283  bits = (*iter)->GetValue().GetReal();
284 
285  } else if (id.GetStr()=="e_value" || id.GetStr()=="sum_e") {
286  evalue = (*iter)->GetValue().GetReal();
287  }
288  }
289  }
290  return hasScore;
291 }
292 
293 static void s_GetAlnScores(const CSeq_align& aln,
294  int& score,
295  double& bits,
296  double& evalue){
297  bool hasScore = false;
298  //look for scores at seqalign level first
299  hasScore = s_GetBlastScore(aln.GetScore(), score, bits, evalue);
300 
301  //look at the seg level
302  if(!hasScore){
303  const CSeq_align::TSegs& seg = aln.GetSegs();
304  if(seg.Which() == CSeq_align::C_Segs::e_Std){
305  s_GetBlastScore(seg.GetStd().front()->GetScores(),
306  score, bits, evalue);
307  } else if (seg.Which() == CSeq_align::C_Segs::e_Dendiag){
308  s_GetBlastScore(seg.GetDendiag().front()->GetScores(),
309  score, bits, evalue);
310  } else if (seg.Which() == CSeq_align::C_Segs::e_Denseg){
311  s_GetBlastScore(seg.GetDenseg().GetScores(), score, bits, evalue);
312  }
313  }
314 }
315 
316 
317 void CAlnGraphic::x_GetAlnInfo(const CSeq_align& aln, const CSeq_id& id,
318  SAlignInfo* aln_info){
319  string info;
320  int score = 0;
321  double evalue = 0;
322  double bits = 0;
323  string bit_str, evalue_str;
324  string title;
325  aln_info->id = &id;
326  if(aln_info->getSeqInfo) {
327  try{
328  const CBioseq_Handle& handle = m_Scope->GetBioseqHandle(id);
329  if(handle){
330  const CBioseq::TId& ids = handle.GetBioseqCore()->GetId();
332  aln_info->id = wid;
333  aln_info->gi = FindGi(ids);
334  wid->GetLabel(&info, CSeq_id::eContent, 0);
335  CDeflineGenerator defline_gen;
336  title = defline_gen.GenerateDefline(*(handle.GetObjectCore()), *m_Scope);
337 
338  if ((int)title.size() > kDeflineLength){
339  title = title.substr(0, kDeflineLength) + "..";
340  }
341  info += " " + title;
342  } else {
343  aln_info->gi = ZERO_GI;
344  //aln_info->id = &id;
345  aln_info->id->GetLabel(&info, CSeq_id::eContent, 0);
346  }
347  } catch (const CException&){
348  aln_info->gi = ZERO_GI;
349  //aln_info->id = &id;
350  aln_info->id->GetLabel(&info, CSeq_id::eContent, 0);
351  }
352  }
353  s_GetAlnScores(aln, score, bits, evalue);
354  NStr::DoubleToString(bit_str, (int)bits);
355  NStr::DoubleToString(evalue_str, evalue);
356 
357  CNcbiOstrstream ostream;
358  ostream << setprecision (2) << evalue;
359  string formatted_evalue = CNcbiOstrstreamToString(ostream);
360  info += " S=" + bit_str + " E=" + formatted_evalue;
361  aln_info->info = info;
362  aln_info->bits = bits;
363  aln_info->score = bit_str;
364  aln_info->eval = formatted_evalue;
365 
366 }
368 {
369 
370  try{
371  string info;
372  const CBioseq_Handle& handle = m_Scope->GetBioseqHandle(*aln_info->id);
373  if(handle){
374  const CBioseq::TId& ids = handle.GetBioseqCore()->GetId();
376  aln_info->id = wid;
377  aln_info->gi = FindGi(ids);
378  wid->GetLabel(&aln_info->accession, CSeq_id::eContent);
379  CDeflineGenerator defline_gen;
380  string title = defline_gen.GenerateDefline(*(handle.GetObjectCore()), *m_Scope);
381 
382  if ((int)title.size() > kDeflineLength){
383  title = title.substr(0, kDeflineLength) + "..";
384  }
385  info = title;
386  } else {
387  aln_info->gi = ZERO_GI;
388  //aln_info->id = &id;
389  aln_info->id->GetLabel(&info, CSeq_id::eContent);
390  }
391  aln_info->info = info;
392  } catch (const CException&){
393  aln_info->gi = ZERO_GI;
394  //aln_info->id = &id;
395  aln_info->id->GetLabel(&aln_info->info, CSeq_id::eContent);
396  }
397 }
398 
400  CScope& scope,
401  CRange<TSeqPos>* master_range)
402  :m_AlnSet(&seqalign), m_Scope(&scope), m_MasterRange(master_range) {
403  m_NumAlignToShow = 1200;
406  m_ImagePath = "./";
407  m_MouseOverFormName = "document.forms[0]";
408  m_NumLine = 55;
409  m_onClickFunction= "DisplayAlignFromGraphics";
410 
411  if (m_MasterRange) {
412  if (m_MasterRange->GetFrom() >= m_MasterRange->GetTo()) {
414  }
415  }
416 }
417 
419  //deallocate memory
421  ITERATE(TAlnInfoList, iter2, **iter){
422  delete (*iter2)->range;
423  delete *iter2;
424  }
425  (*iter)->clear();
426  }
427  m_AlninfoListList.clear();
428 }
429 
430 
432  /*Note we can't just show each alnment as we go because we will
433  need to put all hsp's with the same id on one line*/
434 
435  TAlnInfoList* alninfo_list = NULL;
436  bool is_first_aln = true;
437  int num_align = 0;
438  int master_len = 0;
439  CNodeRef center;
440  CRef<CHTML_table> tbl_box;
441  CHTML_tc* tbl_box_tc;
442 
443  tbl_box = new CHTML_table; //draw a box around the graphics
444  center = new CHTML_center; //align all graphic in center
445 
446  tbl_box->SetCellSpacing(0)->SetCellPadding(10)->SetAttribute("border", "1");
447  tbl_box->SetAttribute("bordercolorlight", "#0000FF");
448  tbl_box->SetAttribute("bordercolordark", "#0000FF");
449 
450  CConstRef<CSeq_id> previous_id, subid, master_id;
451  for (CSeq_align_set::Tdata::const_iterator iter = m_AlnSet->Get().begin();
452  iter != m_AlnSet->Get().end() && num_align < m_NumAlignToShow;
453  iter++, num_align++){
454  if(!alninfo_list){
455  alninfo_list = new TAlnInfoList;
456  }
457  //get start and end seq position for master sequence
458  CRange<TSeqPos>* seq_range = new CRange<TSeqPos>((*iter)->GetSeqRange(0));;
459  if (m_MasterRange) {
460  seq_range->Set(seq_range->GetFrom() - m_MasterRange->GetFrom(),
461  seq_range->GetTo() - m_MasterRange->GetFrom());
462  }
463 
464  //for minus strand
465  if(seq_range->GetFrom() > seq_range->GetTo()){
466  seq_range->Set(seq_range->GetTo(), seq_range->GetFrom());
467  }
468  subid = &((*iter)->GetSeq_id(1));
469  if(is_first_aln) {
470  master_id = &((*iter)->GetSeq_id(0));
471  const CBioseq_Handle& handle = m_Scope->GetBioseqHandle(*master_id);
472  if(!handle){
473  NCBI_THROW(CException, eUnknown, "Master sequence is not found!");
474  }
475  if (m_MasterRange) {
476  master_len = m_MasterRange->GetLength();
477  } else {
478  master_len = handle.GetBioseqLength();
479  }
480  x_DisplayMaster(master_len, &(*center), &(*tbl_box), tbl_box_tc);
481  }
482  if(!is_first_aln && !subid->Match(*previous_id)) {
483  //this aln is a new id, show result for previous id
484  //save ranges for the same seqid
485  m_AlninfoListList.push_back(alninfo_list);
486  alninfo_list = new TAlnInfoList;
487  }
488  SAlignInfo* alninfo = new SAlignInfo;
489  alninfo->range = seq_range;
490  alninfo->getSeqInfo = true;
491  //get aln info
492  x_GetAlnInfo(**iter, *subid, alninfo);
493  alninfo_list->push_back(alninfo);
494  is_first_aln = false;
495  previous_id = subid;
496  }
497 
498  //save last set of seqs with the same id
499  if(alninfo_list){
500  m_AlninfoListList.push_back(alninfo_list);
501  }
502  //merge range for seq with the same id
504  (*iter)->sort(FromRangeAscendingSort);
505  // x_MergeSameSeq(**iter);
506  }
507 
508  //merge non-overlapping range list so that they can be put on
509  //the same line to compress the results
510  if(m_View & eCompactView){
511  double pixel_factor = ((double)kMasterPixel)/master_len;
512 
513  x_MergeDifferentSeq(pixel_factor);
514  }
515  //display the graphic
516  x_BuildHtmlTable(master_len, &(*tbl_box), tbl_box_tc);
517  center->AppendChild(&(*tbl_box));
518  center->Print(out);
519  CHTML_hr hr;
520  hr.Print(out);
521 }
522 
523 //print score legend, master label
524 void CAlnGraphic::x_PrintTop (CNCBINode* center, CHTML_table* tbl_box, CHTML_tc*& tbl_box_tc){
525  if(m_View & eMouseOverInfo){
526 
527  CRef<CHTMLBlockElement> textbox(new CHTMLBlockElement("div","Mouse over to see the defline, click to show alignments"));
528  CNodeRef centered_text;
529  textbox->SetAttribute("id", "df");
530  textbox->SetAttribute("style","width:60em;background-color: white; border: 1px solid");
531  center->AppendChild(&(*textbox));
532 
533  }
534 
535  //score legend graph
537  CHTML_tc* tc;
538  tbl->SetCellSpacing(1)->SetCellPadding(0)->SetAttribute("border", "0");
539  CRef<CHTML_img> score_margin_img(new CHTML_img(m_ImagePath + kGifWhite,
541  score_margin_img->SetAttribute("alt","");
542 
543  tc = tbl->InsertAt(0, 0, score_margin_img);
544  tc->SetAttribute("align", "LEFT");
545  tc->SetAttribute("valign", "CENTER");
546 
548  kScoreHeight));
549  score->SetAttribute("alt","");
550  tc = tbl->InsertAt(0, 1, score);
551  tc->SetAttribute("align", "LEFT");
552  tc->SetAttribute("valign", "CENTER");
553 
554  tbl_box_tc = tbl_box->InsertAt(0, 0, tbl);
555  tbl_box_tc->SetAttribute("align", "LEFT");
556  tbl_box_tc->SetAttribute("valign", "CENTER");
557  //master graph
558 
559  tbl = new CHTML_table;
560  tbl->SetCellSpacing(1)->SetCellPadding(0)->SetAttribute("border", "0");
561 
564 
565  master->SetAttribute("alt","");
566  tc = tbl->InsertAt(0, 0, master);
567  tc->SetAttribute("align", "LEFT");
568  tc->SetAttribute("valign", "CENTER");
569  tbl_box_tc->AppendChild(&(*tbl));
570 
571 }
572 
573 void CAlnGraphic::x_DisplayMaster(int master_len, CNCBINode* center, CHTML_table* tbl_box, CHTML_tc*& tbl_box_tc){
574  x_PrintTop(&(*center), &(*tbl_box), tbl_box_tc);
575 
576  //scale
578  CHTML_tc* tc;
579  CRef<CHTML_img> image;
580  int column = 0;
581  tbl->SetCellSpacing(0)->SetCellPadding(0)->SetAttribute("border", "0");
583  image->SetAttribute("alt","");
584  tc = tbl->InsertAt(0, column, image);
585  tc->SetAttribute("align", "LEFT");
586  tc->SetAttribute("valign", "CENTER");
587  column ++;
588  //first scale
590  image->SetAttribute("alt","");
591  tc = tbl->InsertAt(0, column, image);
592  tc->SetAttribute("align", "LEFT");
593  tc->SetAttribute("valign", "CENTER");
594  column ++;
595 
596  //second scale mark and on
597  float scale_unit = ((float)(master_len))/(kNumMark - 1);
598  int round_number = s_GetRoundNumber((int)scale_unit);
599  int spacer_length;
600  double pixel_factor = ((double)kMasterPixel)/master_len;
601 
602  for (int i = 1; i*round_number <= master_len; i++) {
603  spacer_length = (int)(pixel_factor*round_number) - kScaleWidth;
604  image = new CHTML_img(m_ImagePath + kGifWhite, spacer_length, m_BarHeight);
605  image->SetAttribute("alt","");
606  tc = tbl->InsertAt(0, column, image);
607  tc->SetAttribute("align", "LEFT");
608  tc->SetAttribute("valign", "CENTER");
609  column ++;
611  image->SetAttribute("alt","");
612  tc = tbl->InsertAt(0, column, image);
613  tc->SetAttribute("align", "LEFT");
614  tc->SetAttribute("valign", "CENTER");
615  column ++;
616  }
617  tbl_box_tc->AppendChild(&(*tbl));
618 
619  //digits
620  //first scale digit
621  string digit_str, previous_digitstr, first_digit_str;
622 
623  int first_digit = 0;
624  column = 0;
625  first_digit = m_MasterRange ? m_MasterRange->GetFrom() : 0;
626  first_digit_str = NStr::IntToString(first_digit + 1);
627 
628  image = new CHTML_img(m_ImagePath + kGifWhite,
629  kScoreMargin -
630  kDigitWidth*((int)(first_digit_str.size()/2)),
631  m_BarHeight);
632  image->SetAttribute("alt","");
633  tbl = new CHTML_table;
634  tbl->SetCellSpacing(0)->SetCellPadding(0)->SetAttribute("border", "0");
635  tc = tbl->InsertAt(0, column, image);
636  tc->SetAttribute("align", "LEFT");
637  tc->SetAttribute("valign", "CENTER");
638  column ++;
639 
640  //inserting actual digits
641  for(size_t j = 0; j < first_digit_str.size(); j ++){
642  string one_digit(1, first_digit_str[j]);
643  int digit = NStr::StringToInt(one_digit);
644  image = new CHTML_img(m_ImagePath + kDigitGif[digit], kDigitWidth,
646  image->SetAttribute("alt","");
647  tc = tbl->InsertAt(0, column, image);
648  tc->SetAttribute("align", "LEFT");
649  tc->SetAttribute("valign", "CENTER");
650  column ++;
651  }
652 
653 
654  previous_digitstr = first_digit_str;
655 
656  //print scale digits from second mark and on
657  for (TSeqPos i = 1; (int)i*round_number <= master_len; i++) {
658 
659  digit_str = NStr::IntToString(i*round_number +
660  (m_MasterRange ?
661  m_MasterRange->GetFrom() : 0));
662 
663  spacer_length = (int)(pixel_factor*round_number)
664  - int(kDigitWidth*(previous_digitstr.size()
665  - previous_digitstr.size()/2))
666  - int(kDigitWidth*(digit_str.size()/2));
667  previous_digitstr = digit_str;
668 
669  image = new CHTML_img(m_ImagePath + kGifWhite, spacer_length, m_BarHeight);
670  image->SetAttribute("alt","");
671  tc = tbl->InsertAt(0, column, image);
672  tc->SetAttribute("align", "LEFT");
673  tc->SetAttribute("valign", "CENTER");
674  column ++;
675  //digits
676  for(size_t j = 0; j < digit_str.size(); j ++){
677  string one_digit(1, digit_str[j]);
678  int digit = NStr::StringToInt(one_digit);
679  image = new CHTML_img(m_ImagePath + kDigitGif[digit], kDigitWidth,
681  image->SetAttribute("alt","");
682  tc = tbl->InsertAt(0, column, image);
683  tc->SetAttribute("align", "LEFT");
684  tc->SetAttribute("valign", "CENTER");
685  column ++;
686  }
687  }
688 
689  tbl_box_tc->AppendChild(&(*tbl));
690  CRef<CHTML_br> br(new CHTML_br);
691  tbl_box_tc->AppendChild(br);
692 }
693 
694 //alignment bar graph
695 void CAlnGraphic::x_BuildHtmlTable(int master_len, CHTML_table* tbl_box, CHTML_tc*& tbl_box_tc) {
696  CHTML_tc* tc;
697  double pixel_factor = ((double)kMasterPixel)/master_len;
698  int count = 0;
699  //print out each alignment
700  ITERATE(TAlnInfoListList, iter, m_AlninfoListList){ //iter = each line
701  if(count > m_NumLine){
702  break;
703  }
704  CRef<CHTML_table> tbl; //each table represents one line
705  CRef<CHTML_img> image;
706  CConstRef<CSeq_id> previous_id, current_id;
707  CRef<CHTML_a> ad;
708  double temp_value, temp_value2 ;
709  int previous_end = -1;
710  int front_margin = 0;
711  int bar_length = 0;
712  int column = 0;
713  double prev_round = 0;
714 
715 
716  if(!(*iter)->empty()){ //table for starting white spacer
717  count ++;
718  tbl = new CHTML_table;
719  tbl->SetCellSpacing(0)->SetCellPadding(0)->SetAttribute("border", "0");
721  image->SetAttribute("alt","");
722  tc = tbl->InsertAt(0, column, image);
723  column ++;
724  tc->SetAttribute("align", "LEFT");
725  tc->SetAttribute("valign", "CENTER");
726  }
727 
728  bool is_first_segment = true;
729  ITERATE(TAlnInfoList, iter2, **iter){ //iter2 = each alignments on one line
730  current_id = (*iter2)->id;
731  //white space in front of this alignment
732  //need to take into account of previous round as
733  //even 1 pixel difference would show up
734  int from = (*iter2)->range->GetFrom();
735  int stop = (*iter2)->range->GetTo();
736  if (from <= previous_end) { //some hits overlap
737  if (stop > previous_end) {
738  from = previous_end + 1;
739  (*iter2)->range->SetFrom(from);
740  } else {
741  continue; //this hsp is contained in previous hsp
742  }
743  }
744 
745  int break_len = from - (previous_end + 1); //distance between two hsp
746  bool break_len_added = false;
747  temp_value = break_len*pixel_factor + prev_round;
748 
749  //rounding to int this way as round() is not portable
750  front_margin = (int)(temp_value + (temp_value < 0.0 ? -0.5 : 0.5));
751  if (front_margin > 0) {
752  prev_round = temp_value - front_margin;
753  } else {
754  prev_round = temp_value;
755  }
756 
757  //the alignment box
758  temp_value2 = (*iter2)->range->GetLength()*pixel_factor +
759  prev_round;
760  bar_length = (int)(temp_value2 + (temp_value2 < 0.0 ? -0.5 : 0.5));
761 
762  //no round if bar itself is more than 0.5 pixel
763  if(bar_length == 0 && (*iter2)->range->GetLength()*pixel_factor >= 0.50){
764  bar_length = 1;
765  }
766 
767  if (bar_length > 0) {
768  prev_round = temp_value2 - bar_length;
769  } else {
770  prev_round = temp_value2;
771  }
772 
773 
774  if (!is_first_segment && front_margin == 0 && bar_length > 1) {
775  front_margin = 1; //show break for every segment that is > 1 pixel
776  bar_length --; //minus the added break len between two segments
777  break_len_added = true;
778  }
779 
780  //Need to add white space
781  if(front_margin > 0) {
782  //connecting the alignments with the same id
783  if(m_View & eCompactView && !previous_id.Empty()
784  && previous_id->Match(*current_id)){
785  if (break_len_added) {
786  image = new CHTML_img(m_ImagePath + kGifBlack, front_margin,
787  kGreakHeight);
788  } else {
789  image = new CHTML_img(m_ImagePath + kGifGrey, front_margin,
790  kGapHeight);
791  }
792  } else {
793 
794  image = new CHTML_img(m_ImagePath + kGifWhite, front_margin,
795  m_BarHeight);
796  }
797  image->SetAttribute("alt","");
798  tc = tbl->InsertAt(0, column, image);
799  column ++;
800  tc->SetAttribute("align", "LEFT");
801  tc->SetAttribute("valign", "CENTER");
802  }
803 
804  previous_end = stop;
805  previous_id = current_id;
806 
807  if(bar_length > 0){
808  is_first_segment = false;
809  image = new CHTML_img(m_ImagePath + s_GetGif((int)(*iter2)->bits),
810  bar_length, m_BarHeight,"score " + NStr::IntToString((int)(*iter2)->bits));
811  image->SetAttribute("border", 0);
812  if(m_View & eMouseOverInfo){
813  image->SetAttribute("ONMouseOver", "document.getElementById('df').innerHTML='" +
814  NStr::JavaScriptEncode((*iter2)->info)
815  + "'");
816  image->SetAttribute("ONMOUSEOUT",
817  "document.getElementById('df').innerHTML='Mouse-over to show defline and scores, click to show alignments'");
818  }
820  string acc;
821  (*iter2)->id->GetLabel(&acc, CSeq_id::eContent, 0);
822  string seqid = (*iter2)->gi ==
823  ZERO_GI ? acc : NStr::NumericToString((*iter2)->gi);
824  ad = new CHTML_a("#" + seqid, image);
825  if(m_View & eAnchorLinkDynamic) {
826  ad->SetAttribute("onclick", m_onClickFunction + "(\"" + seqid + "\",event)");
827  }
828  tc = tbl->InsertAt(0, column, ad);
829  }
830  else {
831  tc = tbl->InsertAt(0, column, image);
832  }
833  column ++;
834  tc->SetAttribute("valign", "CENTER");
835  tc->SetAttribute("align", "LEFT");
836  }
837 
838  }
839  if(!tbl.Empty()){
840  tbl_box_tc->AppendChild(&(*tbl));
841  //table for space between bars
842  tbl = new CHTML_table;
845  image->SetAttribute("alt","");
846  tbl->SetCellSpacing(0)->SetCellPadding(0)->SetAttribute("border", "0");
847  tbl->InsertAt(0, 0, image);
848  tbl_box_tc->AppendChild(&(*tbl));
849  }
850  }
851 }
852 
853 
854 
855 static string s_MapSeqInfoTemplate(string seqTemplate,
856  string score,
857  string seq,
858  string defline,
859  string acc,
860  string eval)
861 
862 {
863  string imgstring = CAlignFormatUtil::MapTemplate(seqTemplate,"img_seq",seq);
864  imgstring = CAlignFormatUtil::MapTemplate(imgstring,"img_score",score);
865  imgstring = CAlignFormatUtil::MapTemplate(imgstring,"img_defline",CHTMLHelper::HTMLEncode(defline));
866  imgstring = CAlignFormatUtil::MapTemplate(imgstring,"img_acc",acc);
867  imgstring = CAlignFormatUtil::MapTemplate(imgstring,"img_eval",eval);
868 
869  return imgstring;
870 }
871 
872 
873 
874 
875 static string s_MapBarTemplate(string imageTemplate,
876  int width,
877  string imgType,
878  string cssClass,
879  string score = "",
880  string seq = "",
881  string defline = "",
882  string acc = "",
883  string eval = "")
884 
885 {
886  string imgstring = CAlignFormatUtil::MapTemplate(imageTemplate,"img_width",NStr::IntToString(width));
887  imgstring = CAlignFormatUtil::MapTemplate(imgstring,"img_type",imgType);
888  imgstring = CAlignFormatUtil::MapTemplate(imgstring,"img_class",cssClass);
889  if(!seq.empty()) {
890  imgstring = s_MapSeqInfoTemplate(imgstring,
891  score,
892  seq,
893  defline,
894  acc,
895  eval);
896  }
897  return imgstring;
898 }
899 
900 
901 
902 //m_AlnSet, m_MasterRange,m_Scope - move to display
904 {
905  /*Note we can't just show each alnment as we go because we will
906  need to put all hsp's with the same id on one line*/
907 
908  TAlnInfoList* alninfo_list = NULL;
909  bool is_first_aln = true;
910  int num_align = 0;
911  m_Master_len = 0;
912 
913  CConstRef<CSeq_id> previous_id, subid, master_id;
914  for (CSeq_align_set::Tdata::const_iterator iter = m_AlnSet->Get().begin();
915  iter != m_AlnSet->Get().end() && num_align < m_NumAlignToShow;
916  iter++, num_align++){
917 
918  if(!alninfo_list){
919  alninfo_list = new TAlnInfoList;
920  }
921 
922  //get start and end seq position for master sequence
923  CRange<TSeqPos>* seq_range = new CRange<TSeqPos>((*iter)->GetSeqRange(0));;
924  if (m_MasterRange) {
925  seq_range->Set(seq_range->GetFrom() - m_MasterRange->GetFrom(),
926  seq_range->GetTo() - m_MasterRange->GetFrom());
927  }
928 
929  //for minus strand
930  if(seq_range->GetFrom() > seq_range->GetTo()){
931  seq_range->Set(seq_range->GetTo(), seq_range->GetFrom());
932  }
933  subid = &((*iter)->GetSeq_id(1));
934  if(is_first_aln) {
935  master_id = &((*iter)->GetSeq_id(0));
936 
937  const CBioseq_Handle& handle = m_Scope->GetBioseqHandle(*master_id);
938  if(!handle){
939  NCBI_THROW(CException, eUnknown, "Master sequence is not found!");
940  }
941  if (m_MasterRange) {
943  } else {
944  m_Master_len = handle.GetBioseqLength();
945  }
946  //x_DisplayMaster(master_len, &(*center), &(*tbl_box), tbl_box_tc);******************
947 
948  }
949  if(!is_first_aln && !subid->Match(*previous_id)) {
950  //this aln is a new id, show result for previous id
951  //save ranges for the same seqid
952  m_AlninfoListList.push_back(alninfo_list);
953  alninfo_list = new TAlnInfoList;
954  }
955  SAlignInfo* alninfo = new SAlignInfo;
956  alninfo->range = seq_range;
957  alninfo->getSeqInfo = false;
958  //get aln info
959  x_GetAlnInfo(**iter, *subid, alninfo);
960  alninfo_list->push_back(alninfo);
961  is_first_aln = false;
962  previous_id = subid;
963  }
964 
966  float scale_unit = ((float)(m_Master_len))/(kNumMark - 1);
967  m_Round_number = s_GetRoundNumber((int)scale_unit);
968 
969  //save last set of seqs with the same id
970  if(alninfo_list){
971  m_AlninfoListList.push_back(alninfo_list);
972  }
973  //merge range for seq with the same id
975  (*iter)->sort(FromRangeAscendingSort);
976  // x_MergeSameSeq(**iter);
977  }
978 
979  //merge non-overlapping range list so that they can be put on
980  //the same line to compress the results
981  if(m_View & eCompactView){
983  }
984 }
985 
987  string scale = x_FormatScale();
988  out << scale;
989  //display the graphic
991 }
992 
993 
994 string CAlnGraphic::x_FormatScaleDigit(string digitString,int spacer_length)
995 {
996  string grScaleDigits = CAlignFormatUtil::MapTemplate(m_AlignGraphTemplates->graphDigit,"space_width",spacer_length);
997  grScaleDigits = CAlignFormatUtil::MapTemplate(grScaleDigits,"digits_width",kDigitWidth*digitString.size());
998  grScaleDigits = CAlignFormatUtil::MapTemplate(grScaleDigits,"digit",digitString);
999  return grScaleDigits;
1000 }
1001 
1002 
1004 {
1005  int spacer_length = (int)(m_Pixel_factor*m_Round_number) - kScaleWidth;
1006  string grScale;
1007 
1008  for (int i = 0; i*m_Round_number <= m_Master_len; i++) {
1009  int spacer = (i == 0) ? 0 : spacer_length;
1010  grScale += CAlignFormatUtil::MapTemplate(m_AlignGraphTemplates->graphScale,"scaleSpace",spacer);
1011  }
1012 
1013  grScale = CAlignFormatUtil::MapTemplate(m_AlignGraphTemplates->graphPos,"graph_data",grScale);//Probably should be in formatter
1014 
1015 
1016 
1017  string digit_str, previous_digitstr, first_digit_str;
1018 
1019  int first_digit = 0;
1020  first_digit = m_MasterRange ? m_MasterRange->GetFrom() : 0;
1021  first_digit_str = NStr::IntToString(first_digit + 1);
1022 
1023  string grScaleDigits = x_FormatScaleDigit(first_digit_str,0);
1024 
1025 
1026  previous_digitstr = first_digit_str;
1027 
1028  //print scale digits from second mark and on
1029  for (TSeqPos i = 1; (int)i*m_Round_number <= m_Master_len; i++) {
1030 
1031  digit_str = NStr::IntToString(i*m_Round_number +
1032  (m_MasterRange ?
1033  m_MasterRange->GetFrom() : 0));
1034 
1035  int spacer_length = (int)(m_Pixel_factor*m_Round_number)
1036  - int(kDigitWidth*(previous_digitstr.size()
1037  - previous_digitstr.size()/2))
1038  - int(kDigitWidth*(digit_str.size()/2));
1039  previous_digitstr = digit_str;
1040 
1041  grScaleDigits += x_FormatScaleDigit(digit_str,spacer_length);
1042  }
1043  grScaleDigits = CAlignFormatUtil::MapTemplate(m_AlignGraphTemplates->graphPos,"graph_data",grScaleDigits);//Probably should be in formatter
1044  return grScale + grScaleDigits;
1045 }
1046 
1047 //alignment bar graph
1049 {
1050  int count = 0;
1051  //print out each alignment
1052  ITERATE(TAlnInfoListList, iter, m_AlninfoListList){ //iter = each line
1053  if(count > m_NumLine){
1054  break;
1055  }
1056  CConstRef<CSeq_id> previous_id, current_id;
1057  double temp_value, temp_value2 ;
1058  int previous_end = -1;
1059  int front_margin = 0;
1060  int bar_length = 0;
1061  double prev_round = 0;
1062 
1063  if(!(*iter)->empty()){ //table for starting white spacer
1064  count ++;
1065  }
1066  bool is_first_segment = true;
1067  string oneAlign;
1068  ITERATE(TAlnInfoList, iter2, **iter){ //iter2 = each alignments on one line
1069  current_id = (*iter2)->id;
1070  //white space in front of this alignment
1071  //need to take into account of previous round as
1072  //even 1 pixel difference would show up
1073  int from = (*iter2)->range->GetFrom();
1074  int stop = (*iter2)->range->GetTo();
1075  if (from <= previous_end) { //some hits overlap
1076  if (stop > previous_end) {
1077  from = previous_end + 1;
1078  (*iter2)->range->SetFrom(from);
1079  } else {
1080  continue; //this hsp is contained in previous hsp
1081  }
1082  }
1083 
1084  int break_len = from - (previous_end + 1); //distance between two hsp
1085  bool break_len_added = false;
1086  temp_value = break_len*m_Pixel_factor + prev_round;
1087 
1088  //rounding to int this way as round() is not portable
1089  front_margin = (int)(temp_value + (temp_value < 0.0 ? -0.5 : 0.5));
1090  if (front_margin > 0) {
1091  prev_round = temp_value - front_margin;
1092  } else {
1093  prev_round = temp_value;
1094  }
1095 
1096  //the alignment box
1097  temp_value2 = (*iter2)->range->GetLength()*m_Pixel_factor +
1098  prev_round;
1099  bar_length = (int)(temp_value2 + (temp_value2 < 0.0 ? -0.5 : 0.5));
1100 
1101  //no round if bar itself is more than 0.5 pixel
1102  if(bar_length == 0 && (*iter2)->range->GetLength()*m_Pixel_factor >= 0.50){
1103  bar_length = 1;
1104  }
1105 
1106  if (bar_length > 0) {
1107  prev_round = temp_value2 - bar_length;
1108  } else {
1109  prev_round = temp_value2;
1110  }
1111 
1112 
1113  if (!is_first_segment && front_margin == 0 && bar_length > 1) {
1114  front_margin = 1; //show break for every segment that is > 1 pixel
1115  bar_length --; //minus the added break len between two segments
1116  break_len_added = true;
1117  }
1118 
1119 
1120  string connectingBar;
1121 
1122  //Need to add white space
1123  if(front_margin > 0) {
1124  //connecting the alignments with the same id
1125  int imgWidth = front_margin;
1126  string imgClass,imgFile;
1127  if(m_View & eCompactView && !previous_id.Empty()
1128  && previous_id->Match(*current_id)){
1129  if (break_len_added) {
1130  imgClass = "h" + NStr::IntToString(kGreakHeight);//Class h6 {height=6}
1131  imgFile = kBlack;
1132  } else {
1133  imgClass = "h" + NStr::IntToString(kGapHeight);//Class h1 {height=1}
1134  imgFile = kGrey;
1135  }
1136  } else {
1137  imgClass = "h" + NStr::IntToString(m_BarHeight);//Class h4 {height=4}
1138  imgFile = kWhite;
1139  }
1141  imgWidth,
1142  imgFile,
1143  imgClass);
1144  oneAlign += connectingBar;
1145  }
1146 
1147 
1148  previous_end = stop;
1149  previous_id = current_id;
1150 
1151  if(bar_length > 0){
1152  is_first_segment = false;
1153  string seqid,defline,eval,acc,score;
1154  x_GetAlnInfo(*iter2);
1155  if(m_View & eMouseOverInfo){
1156  defline = (*iter2)->info;
1157  acc = (*iter2)->accession;
1158  eval = (*iter2)->eval;
1159  score =(*iter2)->score;
1160  }
1162  seqid = (*iter2)->gi == ZERO_GI ? (*iter2)->accession : NStr::NumericToString((*iter2)->gi);
1163  }
1165  bar_length,
1166  s_GetScoreColor((int)(*iter2)->bits),
1167  "h" + NStr::IntToString(m_BarHeight),//Class h4 {height=4},
1168  score,
1169  seqid,
1170  defline,
1171  acc,
1172  eval);
1173  string graph_seq_popup;
1174  if(NStr::Find(oneAlign,"Accession:"+ acc) == NPOS) {
1176  score,
1177  seqid,
1178  defline,
1179  acc,
1180  eval);
1181  }
1182  oneAlign = CAlignFormatUtil::MapTemplate(oneAlign,"graph_seq_popup",graph_seq_popup);
1183  }
1184 
1185  }//end of one line
1186  string bar = CAlignFormatUtil::MapTemplate(m_AlignGraphTemplates->graphPos,"graph_data",oneAlign);
1187  out << bar;
1188  out.flush();
1189  }
1190 }
static CRef< CScope > m_Scope
User-defined methods of the data storage class.
User-defined methods of the data storage class.
T round(const T &v)
const TSeqPos kScoreLength
Definition: alngraphic.cpp:63
const TSeqPos kDigitHeight
Definition: alngraphic.cpp:77
const char * kGifGrey
Definition: alngraphic.cpp:93
const TSeqPos kScoreHeight
Definition: alngraphic.cpp:64
const int kDeflineLength
Definition: alngraphic.cpp:83
const char * kGifBlack
Definition: alngraphic.cpp:95
static string s_MapSeqInfoTemplate(string seqTemplate, string score, string seq, string defline, string acc, string eval)
Definition: alngraphic.cpp:855
const char * kGrey
Definition: alngraphic.cpp:118
const char * kGifScore
Definition: alngraphic.cpp:92
const TSeqPos kScaleWidth
Definition: alngraphic.cpp:73
const TSeqPos kScoreMargin
Definition: alngraphic.cpp:62
const TSeqPos kDigitWidth
Definition: alngraphic.cpp:76
const TSeqPos kNumMark
Definition: alngraphic.cpp:81
const char * kWhite
Definition: alngraphic.cpp:117
const char * kDigitGif[]
Definition: alngraphic.cpp:59
static bool s_GetBlastScore(const container &scoreList, int &score, double &bits, double &evalue)
Definition: alngraphic.cpp:270
static string s_GetScoreColor(int bits)
Definition: alngraphic.cpp:121
const char * kGifWhite
Definition: alngraphic.cpp:90
static string s_GetGif(int bits)
Definition: alngraphic.cpp:97
const char * kGifMaster
Definition: alngraphic.cpp:91
static const int kOverlapDiff
Definition: alngraphic.cpp:87
const TSeqPos kMasterBarLength
Definition: alngraphic.cpp:70
const TSeqPos kGapHeight
Definition: alngraphic.cpp:79
const char * kGifScale
Definition: alngraphic.cpp:94
const TSeqPos kMasterPixel
Definition: alngraphic.cpp:69
const TSeqPos kGreakHeight
Definition: alngraphic.cpp:80
USING_SCOPE(sequence)
const TSeqPos kBlankBarHeight
Definition: alngraphic.cpp:66
static void s_GetAlnScores(const CSeq_align &aln, int &score, double &bits, double &evalue)
Definition: alngraphic.cpp:293
const TSeqPos kScaleMarginAdj
Definition: alngraphic.cpp:72
static int s_GetRoundNumber(int number)
Definition: alngraphic.cpp:142
const char * kBlack
Definition: alngraphic.cpp:119
const TSeqPos kScaleHeight
Definition: alngraphic.cpp:74
static string s_MapBarTemplate(string imageTemplate, int width, string imgType, string cssClass, string score="", string seq="", string defline="", string acc="", string eval="")
Definition: alngraphic.cpp:875
const TSeqPos kMasterHeight
Definition: alngraphic.cpp:68
static string MapTemplate(string inpString, string tmplParamName, Int8 templParamVal)
Replace template tags by real data.
void x_DisplayMaster(int master_len, CNCBINode *center, CHTML_table *tbl_box, CHTML_tc *&tbl_box_tc)
Definition: alngraphic.cpp:573
string x_FormatScaleDigit(string digitString, int spacer_length)
Definition: alngraphic.cpp:994
CAlnGraphic(const CSeq_align_set &seqalign, CScope &scope, CRange< TSeqPos > *master_range=NULL)
Definition: alngraphic.cpp:399
int m_NumAlignToShow
Definition: alngraphic.hpp:149
void x_MergeDifferentSeq(double pixel_factor)
Definition: alngraphic.cpp:178
void Init(void)
Definition: alngraphic.cpp:903
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
@ eAnchorLinkDynamic
Definition: alngraphic.hpp:52
void x_MergeSameSeq(TAlnInfoList &alninfo_list)
Definition: alngraphic.cpp:244
string m_MouseOverFormName
Definition: alngraphic.hpp:153
void x_FormatGraphOverview(CNcbiOstream &out)
string m_ImagePath
Definition: alngraphic.hpp:152
void Display(CNcbiOstream &out)
Definition: alngraphic.cpp:986
list< SAlignInfo * > TAlnInfoList
Definition: alngraphic.hpp:145
CRange< TSeqPos > * x_GetEffectiveRange(TAlnInfoList &alninfo_list)
Definition: alngraphic.cpp:169
SAlignGraphTemplates * m_AlignGraphTemplates
Definition: alngraphic.hpp:160
void x_PrintTop(CNCBINode *center, CHTML_table *tbl_box, CHTML_tc *&tbl_box_tc)
Definition: alngraphic.cpp:524
list< TAlnInfoList * > TAlnInfoListList
Definition: alngraphic.hpp:146
void AlnGraphicDisplay(CNcbiOstream &out)
Definition: alngraphic.cpp:431
void x_BuildHtmlTable(int master_len, CHTML_table *tbl_box, CHTML_tc *&tbl_box_tc)
Definition: alngraphic.cpp:695
string x_FormatScale(void)
void x_GetAlnInfo(const CSeq_align &aln, const CSeq_id &id, SAlignInfo *aln_info)
Definition: alngraphic.cpp:317
double m_Pixel_factor
Definition: alngraphic.hpp:158
int m_Round_number
Definition: alngraphic.hpp:159
CBioseq_Handle –.
Class for computing sequences' titles ("definitions").
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Definition: ncbistre.hpp:802
CScope –.
Definition: scope.hpp:92
API (CDeflineGenerator) for computing sequences' titles ("definitions").
std::ofstream out("events_result.xml")
main entry point for tests
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
#define ZERO_GI
Definition: ncbimisc.hpp:1088
#define NULL
Definition: ncbistd.hpp:225
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
static string HTMLEncode(const string &str, THTMLEncodeFlags flags=fEncodeAll)
HTML encodes a string. E.g. <.
Definition: htmlhelper.cpp:146
CNCBINode * AppendChild(CNCBINode *child)
virtual CNcbiOstream & Print(CNcbiOstream &out, TMode mode=eHTML)
Definition: node.cpp:296
CHTML_tc * InsertAt(TIndex row, TIndex column, CNCBINode *node)
void SetAttribute(const string &name, const string &value)
TGi FindGi(const container &ids)
Return gi from id list if exists, return 0 otherwise.
Definition: Seq_id.hpp:1009
void GetLabel(string *label, ELabelType type=eDefault, TLabelFlags flags=fLabel_Default) const
Append a label for this Seq-id to the supplied string.
Definition: Seq_id.cpp:2039
bool Match(const CSeq_id &sid2) const
Match() - TRUE if SeqIds are equivalent.
Definition: Seq_id.hpp:1033
static int WorstRank(const CRef< CSeq_id > &id)
Definition: Seq_id.hpp:744
@ eContent
Untagged human-readable accession or the like.
Definition: Seq_id.hpp:573
string GenerateDefline(const CBioseq_Handle &bsh, TUserFlags flags=0)
Main method.
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
TBioseqCore GetBioseqCore(void) const
Get bioseq core structure.
TSeqPos GetBioseqLength(void) const
CConstRef< TObject > GetObjectCore(void) const
bool Empty(void) const THROWS_NONE
Check if CConstRef is empty – not pointing to any object which means having a null value.
Definition: ncbiobj.hpp:1385
bool Empty(void) const THROWS_NONE
Check if CRef is empty – not pointing to any object, which means having a null value.
Definition: ncbiobj.hpp:719
position_type GetLength(void) const
Definition: range.hpp:158
TThisType & Set(position_type from, position_type to)
Definition: range.hpp:188
#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
static string DoubleToString(double value, int precision=-1, TNumToStringFlags flags=0)
Convert double to string.
Definition: ncbistr.hpp:5186
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
Definition: ncbistr.cpp:630
#define NPOS
Definition: ncbistr.hpp:133
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
Definition: ncbistr.hpp:5083
static SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the string.
Definition: ncbistr.cpp:2887
#define NcbiEmptyString
Definition: ncbistr.hpp:122
static string JavaScriptEncode(const CTempString str)
Encode a string for JavaScript.
Definition: ncbistr.cpp:3955
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to string.
Definition: ncbistr.hpp:673
C::value_type FindBestChoice(const C &container, F score_func)
Find the best choice (lowest score) for values in a container.
Definition: ncbiutil.hpp:250
TTo GetTo(void) const
Get the To member data.
Definition: Range_.hpp:269
TFrom GetFrom(void) const
Get the From member data.
Definition: Range_.hpp:222
TId GetId(void) const
Get the variant data.
Definition: Object_id_.hpp:270
const TDenseg & GetDenseg(void) const
Get the variant data.
Definition: Seq_align_.cpp:153
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_align_.hpp:691
const TStd & GetStd(void) const
Get the variant data.
Definition: Seq_align_.hpp:752
const TDendiag & GetDendiag(void) const
Get the variant data.
Definition: Seq_align_.hpp:726
const TScore & GetScore(void) const
Get the Score member data.
Definition: Seq_align_.hpp:896
const TScores & GetScores(void) const
Get the Scores member data.
Definition: Dense_seg_.hpp:605
const Tdata & Get(void) const
Get the member data.
const TSegs & GetSegs(void) const
Get the Segs member data.
Definition: Seq_align_.hpp:921
const TId & GetId(void) const
Get the Id member data.
Definition: Bioseq_.hpp:290
list< CRef< CSeq_id > > TId
Definition: Bioseq_.hpp:94
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
HTML classes.
int i
static MDB_envinfo info
Definition: mdb_load.c:37
range(_Ty, _Ty) -> range< _Ty >
T max(T x_, T y_)
T min(T x_, T y_)
static BOOL number
Definition: pcregrep.c:193
static const char * column
Definition: stats.c:23
CRange< TSeqPos > * range
Definition: alngraphic.hpp:134
CConstRef< CSeq_id > id
Definition: alngraphic.hpp:127
#define const
Definition: zconf.h:230
Modified on Fri Dec 01 04:47:45 2023 by modify_doxy.py rev. 669887