src/objtools/align_format/showalign.cpp File Reference

#include <ncbi_pch.hpp>
#include <objtools/align_format/showalign.hpp>
#include <corelib/ncbiexpt.hpp>
#include <corelib/ncbiutil.hpp>
#include <corelib/ncbistre.hpp>
#include <corelib/ncbireg.hpp>
#include <util/range.hpp>
#include <util/md5.hpp>
#include <objects/general/Object_id.hpp>
#include <objects/general/User_object.hpp>
#include <objects/general/User_field.hpp>
#include <objects/general/Dbtag.hpp>
#include <serial/iterator.hpp>
#include <serial/objistr.hpp>
#include <serial/objostr.hpp>
#include <serial/serial.hpp>
#include <serial/objostrasnb.hpp>
#include <serial/objistrasnb.hpp>
#include <connect/ncbi_conn_stream.hpp>
#include <objmgr/scope.hpp>
#include <objmgr/feat_ci.hpp>
#include <objtools/data_loaders/genbank/gbloader.hpp>
#include <objmgr/util/sequence.hpp>
#include <objmgr/util/feature.hpp>
#include <objects/seqfeat/SeqFeatData.hpp>
#include <objects/seqfeat/Cdregion.hpp>
#include <objects/seqfeat/Genetic_code.hpp>
#include <objects/seq/Seq_descr.hpp>
#include <objects/seq/Seqdesc.hpp>
#include <objects/seq/Bioseq.hpp>
#include <objects/seqset/Seq_entry.hpp>
#include <objects/seqloc/Seq_id.hpp>
#include <objects/seqloc/Seq_interval.hpp>
#include <objects/seqalign/Seq_align_set.hpp>
#include <objects/seqalign/Score.hpp>
#include <objects/seqalign/Std_seg.hpp>
#include <objects/seqalign/Dense_diag.hpp>
#include <objtools/alnmgr/alnmix.hpp>
#include <objtools/alnmgr/alnvec.hpp>
#include <objects/blastdb/Blast_def_line.hpp>
#include <objects/blastdb/Blast_def_line_set.hpp>
#include <objects/blastdb/defline_extra.hpp>
#include <stdio.h>
#include <util/tables/raw_scoremat.h>
#include <objtools/readers/getfeature.hpp>
#include <html/htmlhelper.hpp>

Include dependency graph for showalign.cpp:

Go to the source code of this file.

Functions

 USING_SCOPE (objects)
 USING_SCOPE (sequence)
static void s_DisplayIdentityInfo (CNcbiOstream &out, int aln_stop, int identity, int positive, int match, int gap, int master_strand, int slave_strand, int master_frame, int slave_frame, bool aln_is_prot)
 show blast identity, positive etc.
static void s_WrapOutputLine (CNcbiOstream &out, const string &str)
 wrap line
static void s_ColorDifferentBases (string &seq, char identity_char, CNcbiOstream &out)
 To add color to bases other than identityChar.
static int s_GetFrame (int start, ENa_strand strand, const CSeq_id &id, CScope &sp)
 return the frame for a given strand Note that start is zero bases.
static int s_GetStdsegMasterFrame (const CStd_seg &ss, CScope &scope)
 reture the frame for master seq in stdseg
static string s_GetSeqForm (char *form_name, bool db_is_na, int query_number, int db_type, const string &dbName, const char *rid, const char *queryID, bool showTreeButtons)
 return the get sequence table for html display
static string s_GetQueryIDFromSeqAlign (const CSeq_align_set &actual_aln_list)
 Gets Query Seq ID from Seq Align.
static CRef< CSeq_ids_GetSeqIdByType (const list< CRef< CSeq_id > > &ids, CSeq_id::E_Choice choice)
 return id type specified or null ref
static int s_GetGiForSeqIdList (const list< CRef< CSeq_id > > &ids)
 return gi from id list
static string s_GetConcatenatedExon (CFeat_CI &feat, ENa_strand feat_strand, list< CRange< TSeqPos > > &range, TSeqPos total_coding_len, string &raw_cdr_product, TSeqPos frame_adj)
 return concatenated exon sequence
static void s_MapSlaveFeatureToMaster (list< CRange< TSeqPos > > &master_feat_range, ENa_strand &master_feat_strand, CFeat_CI &feat, list< CSeq_loc_CI::TRange > &slave_feat_range, ENa_strand slave_feat_strand, CAlnVec *av, int row, TSeqPos frame_adj)
 map slave feature info to master seq
static string s_GetCdsSequence (int genetic_code, CFeat_CI &feat, CScope &scope, list< CRange< TSeqPos > > &range, const CBioseq_Handle &handle, ENa_strand feat_strand, string &feat_id, TSeqPos frame_adj, bool mix_loc)
 return cds coded sequence and fill the id if found
static void s_FillCdsStartPosition (string &line, string &concat_exon, size_t length_per_line, TSeqPos feat_aln_start_totalexon, ENa_strand seq_strand, ENa_strand feat_strand, list< TSeqPos > &start)
 fill the cds start positions (1 based)
static CRef< CScopes_MakeNewMasterSeq (list< list< CRange< TSeqPos > > > &feat_range, list< ENa_strand > &feat_seq_strand, const CBioseq_Handle &handle)
 make a new copy of master seq with feature info and return the scope that contains this sequence
static void s_OutputFeature (string &reference_feat_line, string &feat_line, bool color_feat_mismatch, int start, int len, CNcbiOstream &out)
static int x_AddBar (string &seq, int insert_alnpos, int aln_start)
 add a "|" to the current insert for insert on next rows and return the insert end position.
static int s_AdjustInsert (string &cur_insert, string &new_insert, int insert_alnpos, int aln_start)
 Add new insert seq to the current insert seq and return the end position of the latest insert.

Variables

static char const rcsid [] = "$Id: showalign.cpp 177302 2009-11-30 14:35:11Z camacho $"
static const char k_IdentityChar = '.'
static const int k_NumFrame = 6
static const string k_FrameConversion [k_NumFrame]
static const int k_GetSubseqThreshhold = 10000
static const int k_ColorMismatchIdentity = 0
 threshhold to color mismatch. 98 means 98%
static const int k_GetDynamicFeatureSeqLength = 200000
static const string k_DumpGnlUrl = "/blast/dumpgnl.cgi"
static const int k_FeatureIdLen = 16
const string color [] = {"#000000", "#808080", "#FF0000"}
const string k_ColorRed = "#FF0000"
const string k_ColorPink = "#F805F5"
static const char k_IntronChar = '~'
static const int k_IdStartMargin = 2
static const int k_SeqStopMargin = 2
static const int k_StartSequenceMargin = 2
static const string k_UncheckabeCheckbox
static const string k_Checkbox
static const string k_CheckboxEx
static const int k_MaxDeflinesToShow = 8
static const int k_MinDeflinesToShow = 3


Function Documentation

static int s_AdjustInsert string &  cur_insert,
string &  new_insert,
int  insert_alnpos,
int  aln_start
[static]
 

Add new insert seq to the current insert seq and return the end position of the latest insert.

Parameters:
cur_insert,: the current insert string
new_insert,: the new insert string
insert_alnpos,: insert position
aln_start,: alnment start
Returns:
: the updated insert end position

Definition at line 2528 of file showalign.cpp.

References _ASSERT.

static void s_ColorDifferentBases string &  seq,
char  identity_char,
CNcbiOstream out
[static]
 

To add color to bases other than identityChar.

Parameters:
seq,: sequence
identity_char,: identity character
out,: output stream

Definition at line 314 of file showalign.cpp.

References k_ColorRed.

static void s_DisplayIdentityInfo CNcbiOstream out,
int  aln_stop,
int  identity,
int  positive,
int  match,
int  gap,
int  master_strand,
int  slave_strand,
int  master_frame,
int  slave_frame,
bool  aln_is_prot
[static]
 

show blast identity, positive etc.

Parameters:
out,: output stream
aln_stop,: stop in aln coords
identity,: identity
positive,: positives
match,: match
gap,: gap
master_strand,: plus strand = 1 and minus strand = -1
slave_strand,: plus strand = 1 and minus strand = -1
master_frame,: frame for master
slave_frame,: frame for slave
aln_is_prot,: is protein alignment?

Definition at line 252 of file showalign.cpp.

static void s_FillCdsStartPosition string &  line,
string &  concat_exon,
size_t  length_per_line,
TSeqPos  feat_aln_start_totalexon,
ENa_strand  seq_strand,
ENa_strand  feat_strand,
list< TSeqPos > &  start
[static]
 

fill the cds start positions (1 based)

Parameters:
line,: the input cds line
concat_exon,: exon only string
length_per_line,: alignment length per line
feat_aln_start_totalexon,: feature aln pos in concat_exon
strand,: the alignment strand
start,: start list to be filled

Definition at line 739 of file showalign.cpp.

References eNa_strand_minus, and pos.

static string s_GetCdsSequence int  genetic_code,
CFeat_CI feat,
CScope scope,
list< CRange< TSeqPos > > &  range,
const CBioseq_Handle handle,
ENa_strand  feat_strand,
string &  feat_id,
TSeqPos  frame_adj,
bool  mix_loc
[static]
 

return cds coded sequence and fill the id if found

Parameters:
genetic_code,: the genetic code
feat,: the feature containing this cds
scope,: scope to fetch sequence
range,: the range list of seqloc
handle,: the bioseq handle
feat_strand,: the feature strand
feat_id,: the feature id to be filled
frame_adj,: frame adjustment
mix_loc,: is this seqloc mixed with other seqid?
Returns:
: the encoded protein sequence

Definition at line 682 of file showalign.cpp.

References CBioseq_Handle::eCoding_Iupac, CScope::GetBioseqHandle(), GetTitle(), k_FeatureIdLen, and NcbiEmptyString.

static string s_GetConcatenatedExon CFeat_CI feat,
ENa_strand  feat_strand,
list< CRange< TSeqPos > > &  range,
TSeqPos  total_coding_len,
string &  raw_cdr_product,
TSeqPos  frame_adj
[static]
 

return concatenated exon sequence

Parameters:
feat,: the feature containing this cds
feat_strand,: the feature strand
range,: the range list of seqloc
total_coding_len,: the total exon length excluding intron
raw_cdr_product,: the raw protein sequence
Returns:
: the concatenated exon sequences with amino acid aligned to to the second base of a codon

Definition at line 481 of file showalign.cpp.

References CCdregion_Base::GetFrame(), and CCdregion_Base::IsSetFrame().

static int s_GetFrame int  start,
ENa_strand  strand,
const CSeq_id id,
CScope sp
[static]
 

return the frame for a given strand Note that start is zero bases.

It returns frame +/-(1-3). 0 indicates error

Parameters:
start,: sequence start position
strand,: strand
id,: the seqid
scope,: the scope
Returns:
: the frame

Definition at line 347 of file showalign.cpp.

References eNa_strand_minus, eNa_strand_plus, CScope::GetBioseqHandle(), and CBioseq_Handle::GetBioseqLength().

Referenced by s_GetStdsegMasterFrame().

static int s_GetGiForSeqIdList const list< CRef< CSeq_id > > &  ids  )  [static]
 

return gi from id list

Parameters:
ids,: the input ids
Returns:
: the gi if found

Definition at line 461 of file showalign.cpp.

References CSeq_id_Base::e_Gi, Empty(), and s_GetSeqIdByType().

Referenced by CDisplaySeqalign::x_FillSeqid().

static string s_GetQueryIDFromSeqAlign const CSeq_align_set actual_aln_list  )  [static]
 

Gets Query Seq ID from Seq Align.

Parameters:
actual_aln_list,: align set for one query
Returns:
: string query ID

Definition at line 427 of file showalign.cpp.

References CSeq_align_set_Base::Get(), and CSeq_id::GetLabel().

static string s_GetSeqForm char *  form_name,
bool  db_is_na,
int  query_number,
int  db_type,
const string &  dbName,
const char *  rid,
const char *  queryID,
bool  showTreeButtons
[static]
 

return the get sequence table for html display

Parameters:
form_name,: form name db_is_na: is the db of nucleotide type? : the query number
Returns:
: the from string

Definition at line 384 of file showalign.cpp.

References buf, CAlignFormatUtil::GetURLFromRegistry(), and NcbiEmptyString.

static CRef<CSeq_id> s_GetSeqIdByType const list< CRef< CSeq_id > > &  ids,
CSeq_id::E_Choice  choice
[static]
 

return id type specified or null ref

Parameters:
ids,: the input ids
choice,: id of choice
Returns:
: the id with specified type

Definition at line 441 of file showalign.cpp.

Referenced by s_GetGiForSeqIdList().

static int s_GetStdsegMasterFrame const CStd_seg ss,
CScope scope
[static]
 

reture the frame for master seq in stdseg

Parameters:
ss,: the input stdseg
scope,: the scope
Returns:
: the frame

Definition at line 366 of file showalign.cpp.

References eNa_strand_minus, eNa_strand_plus, CStd_seg_Base::GetIds(), CStd_seg_Base::GetLoc(), GetStart(), GetStop(), GetStrand(), and s_GetFrame().

static CRef<CScope> s_MakeNewMasterSeq list< list< CRange< TSeqPos > > > &  feat_range,
list< ENa_strand > &  feat_seq_strand,
const CBioseq_Handle handle
[static]
 

make a new copy of master seq with feature info and return the scope that contains this sequence

Parameters:
feat_range,: the feature seqlocs
feat_seq_strand,: the stand info
handle,: the seq handle for the original master seq
Returns:
: the scope containing the new master seq

Definition at line 821 of file showalign.cpp.

References CBioseq_Handle::GetCompleteBioseq(), CObjectManager::GetInstance(), CBioseq_Handle::GetRangeSeq_loc(), NStr::IntToString(), ITERATE, and CGBDataLoader::RegisterInObjectManager().

static void s_MapSlaveFeatureToMaster list< CRange< TSeqPos > > &  master_feat_range,
ENa_strand master_feat_strand,
CFeat_CI feat,
list< CSeq_loc_CI::TRange > &  slave_feat_range,
ENa_strand  slave_feat_strand,
CAlnVec av,
int  row,
TSeqPos  frame_adj
[static]
 

map slave feature info to master seq

Parameters:
master_feat_range,: master feature seqloc to be filled
feat,: the feature in concern
slave_feat_range,: feature info for slave
av,: the alignment vector for master-slave seqalign
row,: the row
frame_adj,: frame adjustment

Definition at line 564 of file showalign.cpp.

References CCdregion_Base::GetFrame(), and CCdregion_Base::IsSetFrame().

static void s_OutputFeature string &  reference_feat_line,
string &  feat_line,
bool  color_feat_mismatch,
int  start,
int  len,
CNcbiOstream out
[static]
 

Definition at line 875 of file showalign.cpp.

References NStr::IsBlank(), k_ColorPink, k_IntronChar, and NcbiEmptyString.

static void s_WrapOutputLine CNcbiOstream out,
const string &  str
[static]
 

wrap line

Parameters:
out,: output stream
str,: string to wrap

Definition at line 288 of file showalign.cpp.

USING_SCOPE sequence   ) 
 

USING_SCOPE objects   ) 
 

static int x_AddBar string &  seq,
int  insert_alnpos,
int  aln_start
[static]
 

add a "|" to the current insert for insert on next rows and return the insert end position.

Parameters:
seq,: the seq string
insert_aln_pos,: the position of insert
aln_start,: alnment start position
Returns:
: the insert end position

Definition at line 2505 of file showalign.cpp.


Variable Documentation

const string color[] = {"#000000", "#808080", "#FF0000"}
 

Definition at line 115 of file showalign.cpp.

Referenced by OpenGLRenderer::AddTransparentSphere(), CColorPanel::ContrastBG(), CColorPanel::ContrastFG(), CHistConfigDlg::CreateControls(), CRenderingContext::Draw3DFletch(), CRenderingContext::Draw3DQuad(), CRenderingContext::Draw3DTriangle(), SequenceViewerWidget_SequenceArea::DrawCell(), CRenderingContext::DrawDisk(), CRenderingContext::DrawHairLine(), CRenderingContext::DrawSquare(), CRenderingContext::DrawStrandIndicators(), CGlUtils::DumpState(), CGlFeedbackFont::EncodeText(), StyleManager::GetAtomStyle(), DisplayRowFromString::GetCharacterTraitsAt(), DisplayRowFromSequence::GetCharacterTraitsAt(), DisplayRowFromAlignment::GetCharacterTraitsAt(), BlockMultipleAlignment::GetCharacterTraitsAt(), CSeqTextConfig::GetColor(), CRgbaColorTable::GetColor(), CSGConfigUtils::GetColor(), CGuideTree::GetTreeInfo(), glColorC(), CRgbaColor::Invert(), Colors::IsLightColor(), CHistParamsManager::LoadSettings(), SequenceDisplay::MouseOver(), NcbiChooseColor(), CHistConfigDlg::OnBGColorChanged(), CGradientPanel::OnPaint(), CGradientColorPanel::OnPaint(), SequenceViewerWidget_TitleArea::OnPaint(), CWindowManager::OnSetClientColor(), CGradientColorPanel::OnSwapClick(), CPostscript::PrintObject(), CHistogramGraph::Render(), RenderRect(), s_GetBlastNameColor(), CAlnMultiRenderer::SetBackColor(), CAlnMultiPane::SetBackColor(), CLayoutAlign::SetBackgroundColor(), CTranslationConfig::SetBarColor(), CSeqGraphicConfig::SetBGCommentColor(), CSeqGraphicConfig::SetBkColor(), SetButtonColor(), CClockPanelWMClient::SetColor(), CTextSelHandler::SetColor(), CSeqTextConfig::SetColor(), CRuler::SetColor(), CLinearSelHandler::SetColor(), CColorTableMethod::SetColor(), CWidgetDisplayStyle::SetColor(), CwxGLTestView::SetColor(), CProjectViewBase::SetColor(), CSGConfigUtils::SetColor(), CRegularGridRenderer::SetColor(), CMatrixScoringMethod::SetColorForNoScore(), CColorTableMethod::SetColorForNoScore(), CSNPScoringMethod::SetColorForNoScore(), CTranslationConfig::SetEndColor(), CSeqGraphicConfig::SetFGCommentColor(), CHitMatrixRenderer::SetGraphColor(), CSeqGraphicConfig::SetHorizontalGridColor(), CRegularGridRenderer::SetHorzColor(), CAlnMultiRenderer::SetMasterBackColor(), CAlnMultiPane::SetMasterBackColor(), CTranslationConfig::SetOrfSeqColor(), CSeqGraphicConfig::SetSelectionColor(), CSeqGraphicConfig::SetSelHairlineManyColor(), CSeqGraphicConfig::SetSelHairlineOneColor(), CSeqGraphicConfig::SetSelLabelColor(), CSeqGraphicConfig::SetSelPanelColor(), CTranslationConfig::SetSeqColor(), CVisibleRangeEvent::SetSourceColor(), CTranslationConfig::SetStartColor(), CRegularGridRenderer::SetVertColor(), CSeqGraphicConfig::SetVerticalGridColor(), SequenceViewerWidget_TitleArea::ShowTitles(), CColorPanel::SwapColors(), CColorPickerValidator::TransferFromWindow(), CColorPickerValidator::TransferToWindow(), CAlignSmearGlyph::x_Draw(), CLDBlockGlyph::x_Draw(), CGwasGlyph::x_Draw(), CBinsGlyph::x_Draw(), CCrossPanelIR::x_DrawCrossedPanel(), CRnaCdsGroup::x_DrawFeatureBar(), CFeaturePanel::x_DrawHairLine(), CSelectionHelper::x_DrawSelectionArea(), CTemplateScoringMethod::x_GetColor(), CGuideTree::x_MarkCollapsedQueryNode(), CPdf::x_PrintLine(), CPdf::x_PrintPolygon(), CPdf::x_PrintText(), CAlnVecRow::x_RenderAlign(), CAlnVecRow::x_RenderAlignSegments(), CHistogramGraph::x_RenderHistogram(), CHitMatrixGraph::x_RenderHits(), IPhyloTreeRenderer::x_RenderLine(), IPhyloTreeRenderer::x_RenderNode(), IPhyloTreeRenderer::x_RenderSpline(), CHitMatrixRenderer::x_UpdateGraphColor(), CAlnMultiWidget::x_UpdateOnStylesChanged(), and CViewGraphic::x_UpdateVisRangeLayout().

const string k_Checkbox [static]
 

Initial value:

 "<input type=\"checkbox\" \
name=\"getSeqGi\" value=\"%s\" onClick=\"synchronizeCheck(this.value, \
'getSeqAlignment%d', 'getSeqGi', this.checked)\">"

Definition at line 128 of file showalign.cpp.

const string k_CheckboxEx [static]
 

Initial value:

 "<input type=\"checkbox\" name=\"getSeqGi\" value=\"%s\" \
checked=\"checked\" onClick=\"synchAl(this);\">"

Definition at line 132 of file showalign.cpp.

const int k_ColorMismatchIdentity = 0 [static]
 

threshhold to color mismatch. 98 means 98%

Definition at line 111 of file showalign.cpp.

const string k_ColorPink = "#F805F5"
 

Definition at line 117 of file showalign.cpp.

Referenced by s_OutputFeature().

const string k_ColorRed = "#FF0000"
 

Definition at line 116 of file showalign.cpp.

Referenced by s_ColorDifferentBases().

const string k_DumpGnlUrl = "/blast/dumpgnl.cgi" [static]
 

Definition at line 113 of file showalign.cpp.

const int k_FeatureIdLen = 16 [static]
 

Definition at line 114 of file showalign.cpp.

Referenced by s_GetCdsSequence().

const string k_FrameConversion[k_NumFrame] [static]
 

Initial value:

 {"+1", "+2", "+3", "-1",
                                                     "-2", "-3"}

Definition at line 106 of file showalign.cpp.

const int k_GetDynamicFeatureSeqLength = 200000 [static]
 

Definition at line 112 of file showalign.cpp.

const int k_GetSubseqThreshhold = 10000 [static]
 

Definition at line 108 of file showalign.cpp.

const char k_IdentityChar = '.' [static]
 

Definition at line 104 of file showalign.cpp.

const int k_IdStartMargin = 2 [static]
 

Definition at line 120 of file showalign.cpp.

const char k_IntronChar = '~' [static]
 

Definition at line 119 of file showalign.cpp.

Referenced by s_OutputFeature().

const int k_MaxDeflinesToShow = 8 [static]
 

Definition at line 166 of file showalign.cpp.

const int k_MinDeflinesToShow = 3 [static]
 

Definition at line 167 of file showalign.cpp.

const int k_NumFrame = 6 [static]
 

Definition at line 105 of file showalign.cpp.

const int k_SeqStopMargin = 2 [static]
 

Definition at line 121 of file showalign.cpp.

const int k_StartSequenceMargin = 2 [static]
 

Definition at line 122 of file showalign.cpp.

const string k_UncheckabeCheckbox [static]
 

Initial value:

 "<input type=\"checkbox\" \
name=\"getSeqMaster\" value=\"\" onClick=\"uncheckable('getSeqAlignment%d',\
 'getSeqMaster')\">"

Definition at line 124 of file showalign.cpp.

char const rcsid[] = "$Id: showalign.cpp 177302 2009-11-30 14:35:11Z camacho $" [static]
 

Definition at line 34 of file showalign.cpp.


Generated on Mon Dec 7 09:23:28 2009 for NCBI C++ ToolKit by  doxygen 1.4.6
Modified on Mon Dec 07 16:22:06 2009 by modify_doxy.py rev. 173732