60 "5.gif",
"6.gif",
"7.gif",
"8.gif",
"9.gif"};
101 }
else if (bits < 50) {
103 }
else if (bits < 80) {
105 }
else if (bits < 200) {
125 }
else if (bits < 50) {
127 }
else if (bits < 80) {
129 }
else if (bits < 200) {
151 if(num_str.size() > 2) {
152 string trail_zero (num_str.size() - 2,
'0');
153 mid_num_str =
"5" + trail_zero;
171 if(!alninfo_list.empty()){
173 alninfo_list.back()->range->GetTo());
180 TAlnInfoListList::iterator iter_temp;
181 list<CRange<TSeqPos>* > effective_range_list;
193 effective_range_list.push_back(temp_range);
205 bool overlap =
false;
209 effective_range_list){
211 int min_to =
min(effective_range->
GetTo(),
212 temp_range2->
GetTo());
213 int max_from =
max(effective_range->
GetFrom(),
216 if((
int)((max_from - min_to)*pixel_factor) <=
kOverlapDiff){
227 (*iter)->merge(**iter_temp);
228 effective_range_list.push_back(effective_range);
231 delete effective_range;
239 effective_range_list.clear();
245 TAlnInfoList::iterator prev_iter;
249 if(
i > 0 && (*prev_iter)->range->IntersectingWith(*((*iter)->range))){
251 (*iter)->range->Set(
min((*prev_iter)->range->GetFrom(),
252 (*iter)->range->GetFrom()),
253 max((*prev_iter)->range->GetTo(),
254 (*iter)->range->GetTo()));
256 if((*iter)->bits < (*prev_iter)->bits){
257 (*iter)->bits = (*prev_iter)->bits;
258 (*iter)->info = (*prev_iter)->info;
260 delete (*prev_iter)->range;
262 alninfo_list.erase(prev_iter);
269 template<
class container>
274 bool hasScore =
false;
275 ITERATE (
typename container, iter, scoreList) {
279 if (
id.GetStr()==
"score"){
280 score = (*iter)->GetValue().GetInt();
282 }
else if (
id.GetStr()==
"bit_score"){
283 bits = (*iter)->GetValue().GetReal();
285 }
else if (
id.GetStr()==
"e_value" ||
id.GetStr()==
"sum_e") {
286 evalue = (*iter)->GetValue().GetReal();
297 bool hasScore =
false;
306 score, bits, evalue);
309 score, bits, evalue);
323 string bit_str, evalue_str;
358 ostream << setprecision (2) << evalue;
360 info +=
" S=" + bit_str +
" E=" + formatted_evalue;
362 aln_info->
bits = bits;
363 aln_info->
score = bit_str;
364 aln_info->
eval = formatted_evalue;
402 :m_AlnSet(&seqalign),
m_Scope(&scope), m_MasterRange(master_range) {
422 delete (*iter2)->range;
436 bool is_first_aln =
true;
444 center =
new CHTML_center;
446 tbl_box->SetCellSpacing(0)->SetCellPadding(10)->SetAttribute(
"border",
"1");
447 tbl_box->SetAttribute(
"bordercolorlight",
"#0000FF");
448 tbl_box->SetAttribute(
"bordercolordark",
"#0000FF");
451 for (CSeq_align_set::Tdata::const_iterator iter =
m_AlnSet->
Get().begin();
453 iter++, num_align++){
468 subid = &((*iter)->GetSeq_id(1));
470 master_id = &((*iter)->GetSeq_id(0));
482 if(!is_first_aln && !subid->
Match(*previous_id)) {
489 alninfo->
range = seq_range;
493 alninfo_list->push_back(alninfo);
494 is_first_aln =
false;
511 double pixel_factor = ((double)
kMasterPixel)/master_len;
529 textbox->SetAttribute(
"id",
"df");
530 textbox->SetAttribute(
"style",
"width:60em;background-color: white; border: 1px solid");
538 tbl->SetCellSpacing(1)->SetCellPadding(0)->SetAttribute(
"border",
"0");
541 score_margin_img->SetAttribute(
"alt",
"");
543 tc = tbl->InsertAt(0, 0, score_margin_img);
549 score->SetAttribute(
"alt",
"");
550 tc = tbl->InsertAt(0, 1, score);
554 tbl_box_tc = tbl_box->
InsertAt(0, 0, tbl);
560 tbl->SetCellSpacing(1)->SetCellPadding(0)->SetAttribute(
"border",
"0");
565 master->SetAttribute(
"alt",
"");
566 tc = tbl->InsertAt(0, 0, master);
574 x_PrintTop(&(*center), &(*tbl_box), tbl_box_tc);
581 tbl->SetCellSpacing(0)->SetCellPadding(0)->SetAttribute(
"border",
"0");
583 image->SetAttribute(
"alt",
"");
584 tc = tbl->InsertAt(0,
column, image);
590 image->SetAttribute(
"alt",
"");
591 tc = tbl->InsertAt(0,
column, image);
597 float scale_unit = ((float)(master_len))/(
kNumMark - 1);
600 double pixel_factor = ((double)
kMasterPixel)/master_len;
602 for (
int i = 1;
i*round_number <= master_len;
i++) {
605 image->SetAttribute(
"alt",
"");
606 tc = tbl->InsertAt(0,
column, image);
611 image->SetAttribute(
"alt",
"");
612 tc = tbl->InsertAt(0,
column, image);
621 string digit_str, previous_digitstr, first_digit_str;
632 image->SetAttribute(
"alt",
"");
634 tbl->SetCellSpacing(0)->SetCellPadding(0)->SetAttribute(
"border",
"0");
635 tc = tbl->InsertAt(0,
column, image);
641 for(
size_t j = 0; j < first_digit_str.size(); j ++){
642 string one_digit(1, first_digit_str[j]);
646 image->SetAttribute(
"alt",
"");
647 tc = tbl->InsertAt(0,
column, image);
654 previous_digitstr = first_digit_str;
657 for (
TSeqPos i = 1; (
int)
i*round_number <= master_len;
i++) {
663 spacer_length = (
int)(pixel_factor*round_number)
665 - previous_digitstr.size()/2))
667 previous_digitstr = digit_str;
670 image->SetAttribute(
"alt",
"");
671 tc = tbl->InsertAt(0,
column, image);
676 for(
size_t j = 0; j < digit_str.size(); j ++){
677 string one_digit(1, digit_str[j]);
681 image->SetAttribute(
"alt",
"");
682 tc = tbl->InsertAt(0,
column, image);
697 double pixel_factor = ((double)
kMasterPixel)/master_len;
708 double temp_value, temp_value2 ;
709 int previous_end = -1;
710 int front_margin = 0;
713 double prev_round = 0;
716 if(!(*iter)->empty()){
719 tbl->SetCellSpacing(0)->SetCellPadding(0)->SetAttribute(
"border",
"0");
721 image->SetAttribute(
"alt",
"");
722 tc = tbl->InsertAt(0,
column, image);
728 bool is_first_segment =
true;
730 current_id = (*iter2)->id;
734 int from = (*iter2)->range->GetFrom();
735 int stop = (*iter2)->range->GetTo();
736 if (from <= previous_end) {
737 if (stop > previous_end) {
738 from = previous_end + 1;
739 (*iter2)->range->SetFrom(from);
745 int break_len = from - (previous_end + 1);
746 bool break_len_added =
false;
747 temp_value = break_len*pixel_factor + prev_round;
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;
754 prev_round = temp_value;
758 temp_value2 = (*iter2)->range->GetLength()*pixel_factor +
760 bar_length = (
int)(temp_value2 + (temp_value2 < 0.0 ? -0.5 : 0.5));
763 if(bar_length == 0 && (*iter2)->range->GetLength()*pixel_factor >= 0.50){
767 if (bar_length > 0) {
768 prev_round = temp_value2 - bar_length;
770 prev_round = temp_value2;
774 if (!is_first_segment && front_margin == 0 && bar_length > 1) {
777 break_len_added =
true;
781 if(front_margin > 0) {
784 && previous_id->
Match(*current_id)){
785 if (break_len_added) {
797 image->SetAttribute(
"alt",
"");
798 tc = tbl->InsertAt(0,
column, image);
805 previous_id = current_id;
808 is_first_segment =
false;
811 image->SetAttribute(
"border", 0);
813 image->SetAttribute(
"ONMouseOver",
"document.getElementById('df').innerHTML='" +
816 image->SetAttribute(
"ONMOUSEOUT",
817 "document.getElementById('df').innerHTML='Mouse-over to show defline and scores, click to show alignments'");
822 string seqid = (*iter2)->gi ==
824 ad =
new CHTML_a(
"#" + seqid, image);
828 tc = tbl->InsertAt(0,
column, ad);
831 tc = tbl->InsertAt(0,
column, image);
845 image->SetAttribute(
"alt",
"");
846 tbl->SetCellSpacing(0)->SetCellPadding(0)->SetAttribute(
"border",
"0");
847 tbl->InsertAt(0, 0, image);
909 bool is_first_aln =
true;
914 for (CSeq_align_set::Tdata::const_iterator iter =
m_AlnSet->
Get().begin();
916 iter++, num_align++){
933 subid = &((*iter)->GetSeq_id(1));
935 master_id = &((*iter)->GetSeq_id(0));
949 if(!is_first_aln && !subid->
Match(*previous_id)) {
956 alninfo->
range = seq_range;
960 alninfo_list->push_back(alninfo);
961 is_first_aln =
false;
999 return grScaleDigits;
1009 int spacer = (
i == 0) ? 0 : spacer_length;
1017 string digit_str, previous_digitstr, first_digit_str;
1019 int first_digit = 0;
1026 previous_digitstr = first_digit_str;
1037 - previous_digitstr.size()/2))
1039 previous_digitstr = digit_str;
1044 return grScale + grScaleDigits;
1057 double temp_value, temp_value2 ;
1058 int previous_end = -1;
1059 int front_margin = 0;
1061 double prev_round = 0;
1063 if(!(*iter)->empty()){
1066 bool is_first_segment =
true;
1069 current_id = (*iter2)->id;
1073 int from = (*iter2)->range->GetFrom();
1074 int stop = (*iter2)->range->GetTo();
1075 if (from <= previous_end) {
1076 if (stop > previous_end) {
1077 from = previous_end + 1;
1078 (*iter2)->range->SetFrom(from);
1084 int break_len = from - (previous_end + 1);
1085 bool break_len_added =
false;
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;
1093 prev_round = temp_value;
1099 bar_length = (
int)(temp_value2 + (temp_value2 < 0.0 ? -0.5 : 0.5));
1102 if(bar_length == 0 && (*iter2)->range->GetLength()*
m_Pixel_factor >= 0.50){
1106 if (bar_length > 0) {
1107 prev_round = temp_value2 - bar_length;
1109 prev_round = temp_value2;
1113 if (!is_first_segment && front_margin == 0 && bar_length > 1) {
1116 break_len_added =
true;
1120 string connectingBar;
1123 if(front_margin > 0) {
1125 int imgWidth = front_margin;
1126 string imgClass,imgFile;
1128 && previous_id->
Match(*current_id)){
1129 if (break_len_added) {
1144 oneAlign += connectingBar;
1148 previous_end = stop;
1149 previous_id = current_id;
1152 is_first_segment =
false;
1153 string seqid,defline,eval,acc,score;
1156 defline = (*iter2)->info;
1157 acc = (*iter2)->accession;
1158 eval = (*iter2)->eval;
1159 score =(*iter2)->score;
1173 string graph_seq_popup;
static CRef< CScope > m_Scope
User-defined methods of the data storage class.
User-defined methods of the data storage class.
const TSeqPos kScoreLength
const TSeqPos kDigitHeight
const TSeqPos kScoreHeight
static string s_MapSeqInfoTemplate(string seqTemplate, string score, string seq, string defline, string acc, string eval)
const TSeqPos kScaleWidth
const TSeqPos kScoreMargin
const TSeqPos kDigitWidth
static bool s_GetBlastScore(const container &scoreList, int &score, double &bits, double &evalue)
static string s_GetScoreColor(int bits)
static string s_GetGif(int bits)
static const int kOverlapDiff
const TSeqPos kMasterBarLength
const TSeqPos kMasterPixel
const TSeqPos kGreakHeight
const TSeqPos kBlankBarHeight
static void s_GetAlnScores(const CSeq_align &aln, int &score, double &bits, double &evalue)
const TSeqPos kScaleMarginAdj
static int s_GetRoundNumber(int number)
const TSeqPos kScaleHeight
static string s_MapBarTemplate(string imageTemplate, int width, string imgType, string cssClass, string score="", string seq="", string defline="", string acc="", string eval="")
const TSeqPos kMasterHeight
void x_DisplayMaster(int master_len, CNCBINode *center, CHTML_table *tbl_box, CHTML_tc *&tbl_box_tc)
string x_FormatScaleDigit(string digitString, int spacer_length)
CAlnGraphic(const CSeq_align_set &seqalign, CScope &scope, CRange< TSeqPos > *master_range=NULL)
void x_MergeDifferentSeq(double pixel_factor)
static bool FromRangeAscendingSort(SAlignInfo *const &info1, SAlignInfo *const &info2)
CRange< TSeqPos > * m_MasterRange
CConstRef< CSeq_align_set > m_AlnSet
TAlnInfoListList m_AlninfoListList
void x_MergeSameSeq(TAlnInfoList &alninfo_list)
string m_MouseOverFormName
void x_FormatGraphOverview(CNcbiOstream &out)
void Display(CNcbiOstream &out)
list< SAlignInfo * > TAlnInfoList
CRange< TSeqPos > * x_GetEffectiveRange(TAlnInfoList &alninfo_list)
SAlignGraphTemplates * m_AlignGraphTemplates
void x_PrintTop(CNCBINode *center, CHTML_table *tbl_box, CHTML_tc *&tbl_box_tc)
list< TAlnInfoList * > TAlnInfoListList
void AlnGraphicDisplay(CNcbiOstream &out)
void x_BuildHtmlTable(int master_len, CHTML_table *tbl_box, CHTML_tc *&tbl_box_tc)
string x_FormatScale(void)
void x_GetAlnInfo(const CSeq_align &aln, const CSeq_id &id, SAlignInfo *aln_info)
Class for computing sequences' titles ("definitions").
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
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.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
static string HTMLEncode(const string &str, THTMLEncodeFlags flags=fEncodeAll)
HTML encodes a string. E.g. <.
CNCBINode * AppendChild(CNCBINode *child)
virtual CNcbiOstream & Print(CNcbiOstream &out, TMode mode=eHTML)
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.
void GetLabel(string *label, ELabelType type=eDefault, TLabelFlags flags=fLabel_Default) const
Append a label for this Seq-id to the supplied string.
bool Match(const CSeq_id &sid2) const
Match() - TRUE if SeqIds are equivalent.
static int WorstRank(const CRef< CSeq_id > &id)
@ eContent
Untagged human-readable accession or the like.
string GenerateDefline(const CBioseq_Handle &bsh, TUserFlags flags=0)
Main method.
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
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.
bool Empty(void) const THROWS_NONE
Check if CRef is empty – not pointing to any object, which means having a null value.
position_type GetLength(void) const
TThisType & Set(position_type from, position_type to)
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
static string DoubleToString(double value, int precision=-1, TNumToStringFlags flags=0)
Convert double to string.
static int StringToInt(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to int.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
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.
static string JavaScriptEncode(const CTempString str)
Encode a string for JavaScript.
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.
C::value_type FindBestChoice(const C &container, F score_func)
Find the best choice (lowest score) for values in a container.
TTo GetTo(void) const
Get the To member data.
TFrom GetFrom(void) const
Get the From member data.
TId GetId(void) const
Get the variant data.
const TDenseg & GetDenseg(void) const
Get the variant data.
E_Choice Which(void) const
Which variant is currently selected.
const TStd & GetStd(void) const
Get the variant data.
const TDendiag & GetDendiag(void) const
Get the variant data.
const TScore & GetScore(void) const
Get the Score member data.
const TScores & GetScores(void) const
Get the Scores member data.
const Tdata & Get(void) const
Get the member data.
const TSegs & GetSegs(void) const
Get the Segs member data.
const TId & GetId(void) const
Get the Id member data.
list< CRef< CSeq_id > > TId
unsigned int
A callback function used to compare two keys in a database.
range(_Ty, _Ty) -> range< _Ty >
static const char * column
CRange< TSeqPos > * range