NCBI C++ ToolKit
Functions | Variables
showalign.cpp File Reference
#include <ncbi_pch.hpp>
#include <objtools/align_format/align_format_util.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 <objtools/blast/seqdb_reader/seqdb.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 <stdio.h>
#include <objtools/readers/getfeature.hpp>
#include <objtools/alnmgr/score_builder_base.hpp>
#include <html/htmlhelper.hpp>
#include <cgi/cgictx.hpp>
+ Include dependency graph for showalign.cpp:

Go to the source code of this file.

Go to the SVN repository for 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. More...
 
static void s_WrapOutputLine (CNcbiOstream &out, const string &str)
 wrap line More...
 
static bool s_ProcessStyledContent (string &seq, int currIndex, bool startStyledOutput, bool stopStyledOutput, string tmpl, string &styledSeqStr, CNcbiOstream &out)
 To add style to bases for some conditions. More...
 
static void s_ColorDifferentBases (string &seq, char identity_char, CNcbiOstream &out)
 To add color to bases other than identityChar. More...
 
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. More...
 
static int s_GetStdsegMasterFrame (const CStd_seg &ss, CScope &scope)
 reture the frame for master seq in stdseg More...
 
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 More...
 
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 More...
 
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 More...
 
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) More...
 
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 More...
 
static void s_OutputFeature (string &reference_feat_line, string &feat_line, bool color_feat_mismatch, int start, int len, CNcbiOstream &out, bool is_html)
 
static string s_GetFinalTranslatedString (const CSeq_loc &loc, CScope &scope, int first_encoding_base, int align_length, const string &translation, const string &sequence, char gap_char)
 
void s_CalculateIdentity (const string &sequence_standard, const string &sequence, char gap_char, int &match, int &align_length)
 
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. More...
 
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. More...
 
static string s_MapFeatureURL (string viewerURL, string textSeqID, string db, int fromRange, int toRange, string rid)
 
static void s_MakeDomainString (int aln_from, int aln_to, const string &domain_name, string &final_domain)
 

Variables

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% More...
 
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 int k_AlignStatsMargin = 2
 
static const int k_SequencePropertyLabelMargin = 2
 
const string k_DefaultAnchorTempl = "<a name=<@id_lbl@>></a>"
 
const string k_DefaultAnchorWithPosTempl = "<a name=#_<@resultPositionIndex@>_<@id_lbl@>></a>"
 
static const string k_DefaultSpaceMaintainerTempl = "<span class=\"smn\"><@chkbox@></span>"
 
static const string k_DefaultCheckboxTempl = "<input type=\"checkbox\" name=\"getSeqGi\" value=\"<@id_lbl@>\" onClick=\"synchronizeCheck(this.value, 'getSeqAlignment<@queryNumber@>', 'getSeqGi', this.checked)\">"
 
static const string k_DefaultCheckboxExTempl = "<input type=\"checkbox\" name=\"getSeqGi\" value=\"<@id_lbl@>\" checked=\"checked\" onClick=\"synchAl(this);\">"
 
const string k_DefaultPairwiseWithIdntTempl = "<font color=\"#FF0000\"><b><@alndata@></b></font>"
 
const string k_DefaultFeaturesTempl = "<font color=\"#F805F5\"><b><@alndata@></b></font>"
 
const string k_DefaultMaskSeqLocTempl = "<font color=\"<@color@>\"><@alndata@></font>"
 
static const int k_MaxDeflinesToShow = 8
 
static const int k_MinDeflinesToShow = 3
 

Function Documentation

◆ s_AdjustInsert()

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_insertthe current insert string
new_insertthe new insert string
insert_alnposinsert position
aln_startalnment start
Returns
: the updated insert end position

Definition at line 2992 of file showalign.cpp.

References _ASSERT, and int.

Referenced by CDisplaySeqalign::x_DoFills().

◆ s_CalculateIdentity()

void s_CalculateIdentity ( const string sequence_standard,
const string sequence,
char  gap_char,
int match,
int align_length 
)

Definition at line 1170 of file showalign.cpp.

References i, int, and match().

Referenced by CDisplaySeqalign::x_PrepareRowData().

◆ s_ColorDifferentBases()

static void s_ColorDifferentBases ( string seq,
char  identity_char,
CNcbiOstream out 
)
static

To add color to bases other than identityChar.

Parameters
seqsequence
identity_charidentity character
outoutput stream

Definition at line 399 of file showalign.cpp.

References i, int, k_DefaultPairwiseWithIdntTempl, out(), s_ProcessStyledContent(), and string.

Referenced by CDisplaySeqalign::x_OutputSeq().

◆ s_DisplayIdentityInfo()

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
outoutput stream
aln_stopstop in aln coords
identityidentity
positivepositives
matchmatch
gapgap
master_strandplus strand = 1 and minus strand = -1
slave_strandplus strand = 1 and minus strand = -1
master_frameframe for master
slave_frameframe for slave
aln_is_protis protein alignment?

Definition at line 309 of file showalign.cpp.

References CAlignFormatUtil::GetPercentMatch(), match(), out(), and positive().

Referenced by CDisplaySeqalign::x_DisplaySingleAlignParams().

◆ s_FillCdsStartPosition()

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
linethe input cds line
concat_exonexon only string
length_per_linealignment length per line
feat_aln_start_totalexonfeature aln pos in concat_exon
strandthe alignment strand
startstart list to be filled

Definition at line 717 of file showalign.cpp.

References eNa_strand_minus, eNa_strand_plus, i, isalpha(), and k_IntronChar.

Referenced by CDisplaySeqalign::x_GetFeatureInfo().

◆ s_GetCdsSequence()

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_codethe genetic code
featthe feature containing this cds
scopescope to fetch sequence
rangethe range list of seqloc
handlethe bioseq handle
feat_strandthe feature strand
feat_idthe feature id to be filled
frame_adjframe adjustment
mix_locis this seqloc mixed with other seqid?
Returns
: the encoded protein sequence

Definition at line 658 of file showalign.cpp.

References CGenetic_code_Base::C_E::e_Id, CBioseq_Handle::eCoding_Iupac, eExtreme_Biological, eNa_strand_plus, CDeflineGenerator::GenerateDefline(), CScope::GetBioseqHandle(), CMappedFeat::GetProduct(), CBioseq_Handle::GetRangeSeq_loc(), CBioseq_Handle::GetScope(), GetSeqData(), CSeq_loc_Base::GetWhole(), CSeq_feat_Handle::IsSetProduct(), CSeq_loc_Base::IsWhole(), ITERATE, k_FeatureIdLen, NcbiEmptyString, compile_time_bits::range(), CGenetic_code_Base::Set(), CSeq_loc::SetPartialStart(), CSeq_loc::SetPartialStop(), and CSeqTranslator::Translate().

Referenced by CDisplaySeqalign::x_GetFeatureInfo().

◆ s_GetConcatenatedExon()

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
featthe feature containing this cds
feat_strandthe feature strand
rangethe range list of seqloc
total_coding_lenthe total exon length excluding intron
raw_cdr_productthe raw protein sequence
Returns
: the concatenated exon sequences with amino acid aligned to to the second base of a codon

Definition at line 457 of file showalign.cpp.

References eNa_strand_minus, CSeqFeatData_Base::GetCdregion(), CSeq_feat_Handle::GetData(), CCdregion_Base::GetFrame(), i, CCdregion_Base::IsSetFrame(), ITERATE, and compile_time_bits::range().

Referenced by CDisplaySeqalign::x_GetFeatureInfo().

◆ s_GetFinalTranslatedString()

static string s_GetFinalTranslatedString ( const CSeq_loc loc,
CScope scope,
int  first_encoding_base,
int  align_length,
const string translation,
const string sequence,
char  gap_char 
)
static

Definition at line 1060 of file showalign.cpp.

References i, and int.

Referenced by CDisplaySeqalign::x_AddTranslationForLocalSeq().

◆ s_GetFrame()

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
startsequence start position
strandstrand
idthe seqid
scopethe scope
Returns
: the frame

Definition at line 416 of file showalign.cpp.

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

Referenced by s_GetStdsegMasterFrame(), and CDisplaySeqalign::x_PrepareRowData().

◆ s_GetStdsegMasterFrame()

static int s_GetStdsegMasterFrame ( const CStd_seg ss,
CScope scope 
)
static

reture the frame for master seq in stdseg

Parameters
ssthe input stdseg
scopethe scope
Returns
: the frame

Definition at line 435 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().

Referenced by CDisplaySeqalign::DisplaySeqalign().

◆ s_MakeDomainString()

static void s_MakeDomainString ( int  aln_from,
int  aln_to,
const string domain_name,
string final_domain 
)
static

Definition at line 4457 of file showalign.cpp.

References i, int, and max().

Referenced by CDisplaySeqalign::x_GetDomainInfo().

◆ s_MakeNewMasterSeq()

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

◆ s_MapFeatureURL()

static string s_MapFeatureURL ( string  viewerURL,
string  textSeqID,
string  db,
int  fromRange,
int  toRange,
string  rid 
)
static

◆ s_MapSlaveFeatureToMaster()

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_rangemaster feature seqloc to be filled
featthe feature in concern
slave_feat_rangefeature info for slave
avthe alignment vector for master-slave seqalign
rowthe row
frame_adjframe adjustment

Definition at line 540 of file showalign.cpp.

References IAlnExplorer::eLeft, COpenRange< Position >::Empty(), eNa_strand_minus, eNa_strand_plus, IAlnExplorer::eRight, CAlnMap::GetAlnPosFromSeqPos(), CSeqFeatData_Base::GetCdregion(), CSeq_feat_Handle::GetData(), CCdregion_Base::GetFrame(), CRange_Base::GetFrom(), CAlnMap::GetSeqPosFromAlnPos(), CAlnMap::GetSeqRange(), CRange_Base::GetTo(), CAlnMap::IsNegativeStrand(), CAlnMap::IsPositiveStrand(), CCdregion_Base::IsSetFrame(), and ITERATE.

Referenced by CDisplaySeqalign::x_GetFeatureInfo().

◆ s_OutputFeature()

static void s_OutputFeature ( string reference_feat_line,
string feat_line,
bool  color_feat_mismatch,
int  start,
int  len,
CNcbiOstream out,
bool  is_html 
)
static

◆ s_ProcessStyledContent()

static bool s_ProcessStyledContent ( string seq,
int  currIndex,
bool  startStyledOutput,
bool  stopStyledOutput,
string  tmpl,
string styledSeqStr,
CNcbiOstream out 
)
static

To add style to bases for some conditions.

Parameters
seqsequence
currIndexcurrent seq index @startStyledOutput: condition for starting output into the string to be styled @stopStyledOutput: condition for stopping output into the string to be styled @tmpl: template used for output of styled string @styledSeqStr: the string to be styled by appling template
outoutput stream

Definition at line 379 of file showalign.cpp.

References CAlignFormatUtil::MapTemplate(), and out().

Referenced by s_ColorDifferentBases(), s_OutputFeature(), and CDisplaySeqalign::x_OutputSeq().

◆ s_WrapOutputLine()

static void s_WrapOutputLine ( CNcbiOstream out,
const string str 
)
static

wrap line

Parameters
outoutput stream
strstring to wrap

Definition at line 345 of file showalign.cpp.

References i, int, isspace(), out(), and str().

Referenced by CDisplaySeqalign::x_PrintDefLine().

◆ USING_SCOPE() [1/2]

USING_SCOPE ( objects  )

◆ USING_SCOPE() [2/2]

USING_SCOPE ( sequence  )

◆ x_AddBar()

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
seqthe seq string
insert_aln_posthe position of insert
aln_startalnment start position
Returns
: the insert end position

Definition at line 2969 of file showalign.cpp.

Referenced by CDisplaySeqalign::x_DoFills().

Variable Documentation

◆ color

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

Definition at line 95 of file showalign.cpp.

Referenced by CDisplaySeqalign::x_OutputSeq().

◆ k_AlignStatsMargin

const int k_AlignStatsMargin = 2
static

◆ k_ColorMismatchIdentity

const int k_ColorMismatchIdentity = 0
static

threshhold to color mismatch. 98 means 98%

Definition at line 91 of file showalign.cpp.

Referenced by CDisplaySeqalign::x_PrepareIdentityInfo().

◆ k_ColorPink

const string k_ColorPink = "#F805F5"

Definition at line 97 of file showalign.cpp.

◆ k_ColorRed

const string k_ColorRed = "#FF0000"

Definition at line 96 of file showalign.cpp.

◆ k_DefaultAnchorTempl

const string k_DefaultAnchorTempl = "<a name=<@id_lbl@>></a>"

◆ k_DefaultAnchorWithPosTempl

const string k_DefaultAnchorWithPosTempl = "<a name=#_<@resultPositionIndex@>_<@id_lbl@>></a>"

◆ k_DefaultCheckboxExTempl

const string k_DefaultCheckboxExTempl = "<input type=\"checkbox\" name=\"getSeqGi\" value=\"<@id_lbl@>\" checked=\"checked\" onClick=\"synchAl(this);\">"
static

◆ k_DefaultCheckboxTempl

const string k_DefaultCheckboxTempl = "<input type=\"checkbox\" name=\"getSeqGi\" value=\"<@id_lbl@>\" onClick=\"synchronizeCheck(this.value, 'getSeqAlignment<@queryNumber@>', 'getSeqGi', this.checked)\">"
static

◆ k_DefaultFeaturesTempl

const string k_DefaultFeaturesTempl = "<font color=\"#F805F5\"><b><@alndata@></b></font>"

Definition at line 114 of file showalign.cpp.

Referenced by s_OutputFeature().

◆ k_DefaultMaskSeqLocTempl

const string k_DefaultMaskSeqLocTempl = "<font color=\"<@color@>\"><@alndata@></font>"

Definition at line 115 of file showalign.cpp.

Referenced by CDisplaySeqalign::x_OutputSeq().

◆ k_DefaultPairwiseWithIdntTempl

const string k_DefaultPairwiseWithIdntTempl = "<font color=\"#FF0000\"><b><@alndata@></b></font>"

◆ k_DefaultSpaceMaintainerTempl

const string k_DefaultSpaceMaintainerTempl = "<span class=\"smn\"><@chkbox@></span>"
static

◆ k_DumpGnlUrl

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

Definition at line 93 of file showalign.cpp.

◆ k_FeatureIdLen

const int k_FeatureIdLen = 16
static

Definition at line 94 of file showalign.cpp.

Referenced by s_GetCdsSequence(), and CDisplaySeqalign::x_GetFeatureInfo().

◆ k_FrameConversion

const string k_FrameConversion[k_NumFrame]
static
Initial value:
= {"+1", "+2", "+3", "-1",
"-2", "-3"}

Definition at line 86 of file showalign.cpp.

Referenced by CDisplaySeqalign::DisplaySeqalign().

◆ k_GetDynamicFeatureSeqLength

const int k_GetDynamicFeatureSeqLength = 200000
static

Definition at line 92 of file showalign.cpp.

Referenced by CDisplaySeqalign::x_PrepareDynamicFeatureInfo().

◆ k_GetSubseqThreshhold

const int k_GetSubseqThreshhold = 10000
static

Definition at line 88 of file showalign.cpp.

Referenced by CDisplaySeqalign::x_InitDefLinesHeader().

◆ k_IdentityChar

const char k_IdentityChar = '.'
static

◆ k_IdStartMargin

const int k_IdStartMargin = 2
static

◆ k_IntronChar

const char k_IntronChar = '~'
static

◆ k_MaxDeflinesToShow

const int k_MaxDeflinesToShow = 8
static

◆ k_MinDeflinesToShow

const int k_MinDeflinesToShow = 3
static

◆ k_NumFrame

const int k_NumFrame = 6
static

Definition at line 85 of file showalign.cpp.

Referenced by CDisplaySeqalign::DisplaySeqalign().

◆ k_SeqStopMargin

const int k_SeqStopMargin = 2
static

Definition at line 101 of file showalign.cpp.

Referenced by CDisplaySeqalign::x_DisplaySequenceLine().

◆ k_SequencePropertyLabelMargin

const int k_SequencePropertyLabelMargin = 2
static

◆ k_StartSequenceMargin

const int k_StartSequenceMargin = 2
static
Modified on Fri Jan 05 07:25:15 2024 by modify_doxy.py rev. 669887