pair<objects::ENa_strand, objects::ENa_strand> TStrands;
53TStrands RetrieveStdStrands(
constobjects::CSeq_align& seq_align)
58 const CStd_seg& stdseg (*(std_list.front()));
69 if(seq_align.CheckNumRows() != 2) {
71 "Pairwise seq-align required to init align-shadow");
74 const boolis_denseg (seq_align.GetSegs().IsDenseg());
75 const boolis_stdseg (seq_align.GetSegs().IsStd());
76 if(!is_denseg && !is_stdseg) {
78 "Must be a dense-seg or std_seg to init align-shadow");
81 m_Id.first.Reset(&seq_align.GetSeq_id(0));
82 m_Id.second.Reset(&seq_align.GetSeq_id(1));
88qstrand = seq_align.GetSeqStrand(0);
89sstrand = seq_align.GetSeqStrand(1);
92 constTStrands strands (RetrieveStdStrands(seq_align));
93qstrand = strands.first;
94sstrand = strands.second;
98 m_Box[1] = seq_align.GetSeqStart(0);
99 m_Box[0] = seq_align.GetSeqStop(0);
102 m_Box[0] = seq_align.GetSeqStart(0);
103 m_Box[1] = seq_align.GetSeqStop(0);
107 m_Box[3] = seq_align.GetSeqStart(1);
108 m_Box[2] = seq_align.GetSeqStop(1);
111 m_Box[2] = seq_align.GetSeqStart(1);
112 m_Box[3] = seq_align.GetSeqStop(1);
120 const CDense_seg& ds (seq_align.GetSegs().GetDenseg());
125 const charindel[2] = {
'D',
'I'};
128 for(
size_tj: {0,1}) {
130 while(
i< starts.size() && starts[
i]==-1)
i+= 2;
131 next[j] = starts[
i];
133 next[j] += lens[
i/2];
139 for(
size_tii_lens = 0; ii_lens < lens.size(); ++ii_lens) {
142 for(
size_tj: {0,1}) {
143 if(starts[
i+j] != -1) {
146 if(
next[j] != end) {
150 next[j] = starts[
i+j];
152 if(
next[j] != starts[
i+j]) {
156 next[j] = starts[
i+j] + lens[ii_lens];
161 if(starts[
i] < 0) {
164 else if(starts[
i+1] < 0) {
171 if(lens[ii_lens] > 1) {
180 "CAlignShadow(): save_xcript mode not supported " 181 "for seq-align segments other than dense-seg.");
194 const TId& idsubj,
TCoordsstart,
boolsstrand,
195 const string& xcript)
197 m_Id.first = idquery;
198 m_Id.second = idsubj;
203 TCoordq = qstart, q0 = q, s = sstart, s0 = s;
204 const intqinc (qstrand? 1: -1), sinc (sstrand? 1: -1);
206 ITERATE(
string, ii, xcript) {
210 case 'M':
case 'R':
229 "CAlignShadow()::CAlignShadow(): " 230 "Unexpected transcript symbol found");
245os << align_shadow.
GetId(0)->AsFastaString() <<
'\t' 246<< align_shadow.
GetId(1)->AsFastaString() <<
'\t';
261 case0:
return m_Id.first;
262 case1:
return m_Id.second;
265 "CAlignShadow::GetId() - argument out of range");
286 case0:
m_Id.first = id;
break;
287 case1:
m_Id.second = id;
break;
290 "CAlignShadow::SetId() - argument out of range");
311 if(0 != where && where != 1) {
313 "CAlignShadow::GetStrand() - argument out of range");
337 if(0 != where && where != 1) {
339 "CAlignShadow::SetStrand() - argument out of range");
343 const Uint1i1 (where << 1), i2 (i1 + 1);
345 if(
m_Box[i1] == g_UndefCoord ||
m_Box[i2] == g_UndefCoord) {
347 "CAlignShadow::SetStrand() -start and/or stop not yet set");
350 const boolcur_strand (
GetStrand(where));
351 if(strand != cur_strand) {
409 if(0 != where && where != 1) {
411 "CAlignShadow::GetStart() - argument out of range");
415 return m_Box[where << 1];
422 if(0 != where && where != 1) {
424 "CAlignShadow::GetStop() - argument out of range");
428 return m_Box[(where << 1) | 1];
459 if(0 != where && where != 1) {
461 "CAlignShadow::GetStart() - argument out of range");
472 if(0 != where && where != 1) {
474 "CAlignShadow::GetStop() - argument out of range");
512 if(0 != where && where != 1) {
514 "CAlignShadow::GetMin() - argument out of range");
518 Uint1i1 = where << 1, i2 = i1 + 1;
526 if(0 != where && where != 1) {
528 "CAlignShadow::GetMax() - argument out of range");
532 Uint1i1 = where << 1, i2 = i1 + 1;
540 if(0 != where && where != 1) {
542 "CAlignShadow::SetMin() - argument out of range");
546 const Uint1i1 (where << 1), i2 (i1 + 1);
548 if(
m_Box[i1] == g_UndefCoord ||
m_Box[i2] == g_UndefCoord) {
550 "CAlignShadow::SetMin() - start and/or stop not yet set");
562 "CAlignShadow::SetMin() - new position is invalid");
572 if(0 != where && where != 1) {
574 "CAlignShadow::SetMax() - argument out of range");
578 const Uint1i1 (where << 1), i2 (i1 + 1);
580 if(
m_Box[i1] == g_UndefCoord ||
m_Box[i2] == g_UndefCoord) {
582 "CAlignShadow::SetMax() - start and/or stop not yet set");
594 "CAlignShadow::SetMax() - new position is invalid");
681 m_Box[0] += shift_query;
682 m_Box[1] += shift_query;
683 m_Box[2] += shift_subj;
684 m_Box[3] += shift_subj;
716 boolnewpos_invalid =
false;
718 if(new_pos < qmin || new_pos > qmax) {
719newpos_invalid =
true;
723 if(new_pos < smin || new_pos > smax) {
724newpos_invalid =
true;
728 if(newpos_invalid) {
730 "CAlignShadow::Modify(): requested new position invalid");
733 const boolsame_strands = qstrand == sstrand;
741 Int1dq = (qstrand? +1: -1), ds = (sstrand? +1: -1);
745 boolneed_trace =
true;
747 if(q == new_pos) need_trace =
false;
750 if(s == new_pos) need_trace =
false;
753 const boolpoint_is_start((point%2) ^ (
GetStrand(point/2)? 1: 0));
761 case 'M':
case 'R': q += dq; s += ds;
break;
762 case 'D': q += dq;
break;
763 case 'I': s += ds;
break;
766 "CAlignShadow::Modify(): unexpected transcript symbol");
770 if(point_is_start) {
772 if(q == new_pos)
break;
775 if(s == new_pos)
break;
780 if(q == new_pos + dq)
break;
783 if(s == new_pos + ds)
break;
788 if(!point_is_start && n1 > 0) {
790 case 'M':
case 'R': q -= dq; s -= ds;
break;
791 case 'D': q -= dq;
break;
792 case 'I': s -= ds;
break;
817 "CAlignShadow::Modify(): Invalid end point requested.");
821 if( point_is_start ) {
822xcript = xcript.substr(n1, xcript.size() - n1);
837 TCoordqlen = 1 + qmax - qmin, slen = 1 + smax - smin;
838 doublek = double(qlen) / slen;
839 Int4delta_q, delta_s;
844delta_q = new_pos - qmin;
846 if( smin + delta_s > smax ) {
847delta_s = smax - smin;
862delta_q = qmax - new_pos;
864 if( smin + delta_s > smax ) {
865delta_s = smax - smin;
880delta_s = new_pos - smin;
882 if( qmin + delta_q > qmax ) {
883delta_q = qmax - qmin;
898delta_s = smax - new_pos;
900 if( qmin + delta_q > qmax ) {
901delta_q = qmax - qmin;
916 "CAlignShadow::Modify(): invalid end requested");
925 const size_tdim (
in.size());
930 const char* p (
in.data());
934 for(
size_tk (1); k < dim; ++k) {
970 if(
'0'<= c && c <=
'9') {
971 N=
N* 10 + c -
'0';
975 out.append(
N- 1,
C);
978 out.push_back(
C= c);
982 out.append(
N- 1,
C);
CNcbiOstream & operator<<(CNcbiOstream &os, const CAlignShadow &align_shadow)
void SetId(Uint1 where, const TId &id)
bool GetQueryStrand(void) const
void SetQueryMax(TCoord pos)
TCoord GetQueryStart(void) const
void SetQueryMin(TCoord pos)
TCoord GetSubjStop(void) const
void SetStop(Uint1 where, TCoord pos)
std::pair< TId, TId > m_Id
const TCoord * GetBox(void) const
static string s_RunLengthDecode(const string &in)
TCoord GetMin(Uint1 where) const
virtual void Modify(Uint1 point, TCoord new_pos)
const TId & GetSubjId(void) const
void SetMax(Uint1 where, TCoord pos)
void SetSubjStrand(bool strand)
void SetQueryStrand(bool strand)
void Shift(Int4 shift_query, Int4 shift_subj)
TCoord GetQueryMin(void) const
void SetSubjId(const TId &id)
TCoord GetSubjStart(void) const
bool GetSubjStrand(void) const
void SetSubjStart(TCoord pos)
void SetSubjMin(TCoord pos)
void SetMin(Uint1 where, TCoord pos)
TCoord GetMax(Uint1 where) const
void SetStart(Uint1 where, TCoord pos)
TCoord GetStop(Uint1 where) const
const TId & GetId(Uint1 where) const
TCoord GetQueryStop(void) const
void SetQueryStart(TCoord pos)
virtual void x_PartialSerialize(CNcbiOstream &os) const
const TId & GetQueryId(void) const
TCoord GetSubjMin(void) const
static string s_RunLengthEncode(const string &in)
void SetSubjStop(TCoord pos)
TCoord GetQueryMax(void) const
TCoord GetQuerySpan(void) const
void SetBox(const TCoord box[4])
void SetQueryId(const TId &id)
void SetStrand(Uint1 where, bool strand)
void SetSubjMax(TCoord pos)
TCoord GetSubjMax(void) const
const TTranscript & GetTranscript(void) const
TCoord GetSubjSpan(void) const
TCoord GetStart(Uint1 where) const
void SetQueryStop(TCoord pos)
bool GetStrand(Uint1 where) const
std::ofstream out("events_result.xml")
main entry point for tests
static DLIST_TYPE *DLIST_NAME() next(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
int TSignedSeqPos
Type for signed sequence position.
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
ENa_strand GetStrand(const CSeq_loc &loc, CScope *scope=0)
Returns eNa_strand_unknown if multiple Bioseqs in loc Returns eNa_strand_other if multiple strands in...
uint8_t Uint1
1-byte (8-bit) unsigned integer
int32_t Int4
4-byte (32-bit) signed integer
uint32_t Uint4
4-byte (32-bit) unsigned integer
int8_t Int1
1-byte (8-bit) signed integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define USING_SCOPE(ns)
Use the specified namespace.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
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.
vector< CRef< CSeq_loc > > TLoc
list< CRef< CStd_seg > > TStd
const TStarts & GetStarts(void) const
Get the Starts member data.
vector< ENa_strand > TStrands
const TLens & GetLens(void) const
Get the Lens member data.
vector< TSignedSeqPos > TStarts
const TStrands & GetStrands(void) const
Get the Strands member data.
ENa_strand
strand of nucleic acid
std::istream & in(std::istream &in_, double &x_)
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4