54 int start = 0,
len = 0;
87 "CAlnVec::SetAnchor(): "
98 int start = 0,
len = 0, aln_seg = -1,
offset = 0;
118 "CAlnVec::SetAnchor(): "
119 "Invalid Dense-seg: No sequence on the anchor row");
128 TNumseg l_seg, r_seg, l_index, r_index, index;
129 TNumseg l_anchor_index, r_anchor_index, anchor_index;
130 TSeqPos cont_next_start = 0, cont_prev_stop = 0;
131 TSeqPos anchor_cont_next_start = 0, anchor_cont_prev_stop = 0;
146 cont_prev_stop = start;
152 anchor_start =
m_Starts[anchor_index];
153 if (anchor_start >= 0) {
156 anchor_cont_prev_stop = anchor_start;
168 if ((start =
m_Starts[r_index]) >= 0) {
184 if ((anchor_start =
m_Starts[r_anchor_index]) >= 0) {
200 while (--l_seg >= 0) {
203 if ((start =
m_Starts[l_index]) >= 0) {
217 while (--l_seg >= 0) {
219 if ((anchor_start =
m_Starts[l_anchor_index]) >= 0) {
271 int left_seq_pos = -1;
272 for (idx = l_idx, seg = 0;
284 if (left_seq_pos < 0) {
296 if (left_seq_pos > 0) {
298 start > left_seq_pos :
316 int right_seq_pos = -1;
331 if (right_seq_pos < 0) {
343 if (right_seq_pos > 0) {
346 start > right_seq_pos) {
385 mid = (top + btm) / 2;
404 TNumseg btm, top, mid, cur,
last, cur_top, cur_btm;
405 btm = cur_btm = 0; cur = top =
last = cur_top =
m_NumSegs - 1;
460 cur = mid = (top + btm) / 2;
467 if (cur <= top && start >= 0) {
468 if (sseq_pos >= start &&
472 if (sseq_pos > start) {
488 if (cur >= btm && start >= 0) {
489 if (sseq_pos >= start
493 if (sseq_pos > start) {
508 return (
plus ? cur_btm :
last - cur_btm);
510 return (
plus ? cur_top :
last - cur_top);
518 return (
plus ? cur_btm :
last - cur_btm);
520 return (
plus ? cur_top :
last - cur_top);
529 bool try_reverse_dir)
const
552 if ((
plus ? seq_pos < start : seq_pos > stop)) {
555 if ((
plus ? seq_pos > stop : seq_pos < start)) {
568 }
else if (try_reverse_dir) {
582 }
else if (try_reverse_dir) {
601 bool try_reverse_dir)
const
609 bool reverse_pass =
false;
614 while (--seg >=0 && pos == -1) {
624 while (--seg >=0 && pos == -1) {
633 if (!try_reverse_dir) {
638 }
else if (reverse_pass) {
639 string msg =
"Invalid Dense-seg: Row " +
641 " contains gaps only.";
666 bool try_reverse_dir)
const
680 }
else if (dir !=
eNone) {
691 bool try_reverse_dir)
const
729 string err_msg =
"CAlnVec::x_GetSeqLeftSeg(): "
731 " contains gaps only.";
750 string err_msg =
"CAlnVec::x_GetSeqRightSeg(): "
752 " contains gaps only.";
760 vector<TSignedSeqPos>&
result,
770 TSeqPos aln_pos = 0, next_aln_pos, l_len = 0, r_len = 0, l_delta, r_delta;
773 TSeqPos l_pos0, r_pos0, l_pos1, r_pos1;
778 next_aln_pos = aln_pos + l_len;
780 aln_start >= aln_pos && aln_start < next_aln_pos) {
784 aln_pos = next_aln_pos;
794 l_delta = aln_start - aln_pos;
811 if (aln_stop > aln_pos) {
816 next_aln_pos = aln_pos - r_len;
818 aln_stop > next_aln_pos && aln_stop <= aln_pos) {
822 aln_pos = next_aln_pos;
831 r_delta = aln_pos - aln_stop;
845 TSeqPos size = (plus0 ? r_pos0 - l_pos0 : l_pos0 - r_pos0) + 1;
849 TSeqPos pos0 = plus0 ? 0 : l_pos0 - r_pos0;
850 TSeqPos pos1 = plus1 ? 0 : l_pos1 - r_pos1;
854 TSeqPos next_l_pos0 = plus0 ? l_pos0 + l_len : l_pos0 - l_len;
855 TSeqPos next_l_pos1 = plus1 ? l_pos1 + l_len : l_pos1 - l_len;
868 next_l_pos0 =
m_Starts[l_idx0] + l_len;
880 }
else if (
delta < 0) {
882 string errstr =
string(
"CAlnMap::GetResidueIndexMap():")
883 +
" Starts are not consistent!"
896 next_l_pos1 =
m_Starts[l_idx1] + l_len;
908 }
else if (
delta < 0) {
910 string errstr =
string(
"CAlnMap::GetResidueIndexMap():")
911 +
" Starts are not consistent!"
954 }
else if (seg == r_seg) {
962 rng0.
SetFrom(plus0 ? l_pos0 : r_pos0);
963 rng0.
SetTo(plus0 ? r_pos0 : l_pos0);
964 rng1.
SetFrom(plus1 ? l_pos1 : r_pos1);
965 rng1.
SetTo(plus1 ? r_pos1 : l_pos1);
1008 if (
range.GetTo() < 0
1014 TNumseg left_seg, right_seg, aln_seg;
1016 if (
range.GetFrom() < 0) {
1117 if (
flags & fChunkSameAsSeg) {
1121 if ((left_type & fSeq) != (right_type & fSeq)) {
1124 if (!(
flags & fIgnoreUnaligned) &&
1125 (left_type & fUnalignedOnRight || right_type & fUnalignedOnLeft ||
1126 left_type & fUnalignedOnRightOnAnchor || right_type & fUnalignedOnLeftOnAnchor)) {
1129 if ((left_type & fNotAlignedToSeqOnAnchor) ==
1130 (right_type & fNotAlignedToSeqOnAnchor)) {
1133 if (left_type & fSeq) {
1134 if (!(
flags & fInsertSameAsSeq)) {
1138 if (!(
flags & fDeletionSameAsGap)) {
1152 _ASSERT(left_seg <= right_seg);
1153 if (left_seg > right_seg) {
1156 "Invalid segments range");
1162 for (
TNumseg seg = left_seg; seg <= right_seg; seg++, hint_idx +=
m_NumRows) {
1167 if (seg == left_seg) {
1169 }
else if (seg == right_seg) {
1179 int test_hint_idx =
int(hint_idx);
1180 while (test_seg < right_seg) {
1186 hint_idx = test_hint_idx;
1217 if (start_seg > stop_seg) {
1250 if (l_from != - 1) {
1265 if (aln_from != -1) {
1273 if (r_from != - 1) {
1280 chunk->SetRange().Set(l_to + 1, r_from - 1);
1282 chunk->SetRange().Set(r_to + 1, l_from - 1);
1284 chunk->SetAlnRange().Set(aln_from, aln_to);
1299 chunk->SetRange().Set(from, to);
1314 chunk->SetRange().Set(chunk->GetRange().GetFrom(),
1315 chunk->GetRange().GetTo()
1318 chunk->SetRange().Set(chunk->GetRange().GetFrom()
1320 chunk->GetRange().GetTo());
1324 chunk->SetType(chunk->GetType() |
type);
1360 chunk->SetAlnRange().Set(from, to);
1366 if (!chunk->IsGap()) {
1368 chunk->SetRange().Set
1369 (chunk->GetRange().GetFrom()
1371 chunk->GetRange().GetTo());
1373 chunk->SetRange().Set(chunk->GetRange().GetFrom(),
1374 chunk->GetRange().GetTo()
1383 if (!chunk->IsGap()) {
1385 chunk->SetRange().Set
1386 (chunk->GetRange().GetFrom(),
1387 chunk->GetRange().GetTo()
1390 chunk->SetRange().Set
1391 (chunk->GetRange().GetFrom()
1393 chunk->GetRange().GetTo());
1405 const vector<TNumrow>& selected_rows,
1415 bool have_widths = !
m_Widths.empty();
1418 size_t dim = selected_rows.size();
1422 if ( have_widths ) {
1425 for (
size_t i = 0;
i < dim;
i++) {
1429 if ( have_widths ) {
1446 for (
TNumseg seg = from_seg; seg <= to_seg; seg++) {
1452 if (seg == from_seg &&
TSeqPos(aln_from) > aln_seg_from) {
1457 from_trim = aln_from - aln_seg_from;
1462 if (seg == to_seg) {
1464 if (aln_seg_to >
TSeqPos(aln_to)) {
1469 len -= aln_seg_to - aln_to;
1477 if (row_start >= 0) {
1478 row_start += from_trim;
1480 starts.push_back(row_start);
1481 if ( have_strands ) {
CConstRef< CAlnChunk > operator[](TNumchunk i) const
vector< TNumseg > m_StartSegs
vector< TNumseg > m_StopSegs
TNumchunk size(void) const
TNumseg GetAlnSeg(void) const
int GetOffset(void) const
void x_GetChunks(CAlnChunkVec *vec, TNumrow row, TNumseg left_seg, TNumseg right_seg, TGetChunkFlags flags) const
TRawSegTypes * m_RawSegTypes
void GetResidueIndexMap(TNumrow row0, TNumrow row1, TRange aln_rng, vector< TSignedSeqPos > &result, TRange &rng0, TRange &rng1) const
bool IsSetAnchor(void) const
CRef< CSeq_align > CreateAlignFromRange(const vector< TNumrow > &selected_rows, TSignedSeqPos aln_from, TSignedSeqPos aln_to, ESegmentTrimFlag seg_flag=eSegment_Trim)
int GetWidth(TNumrow row) const
TSignedSeqPos x_FindClosestSeqPos(TNumrow row, TNumseg seg, ESearchDirection dir, bool try_reverse_dir) const
CRef< CAlnChunkVec > GetSeqChunks(TNumrow row, const TSignedRange &range, TGetChunkFlags flags=fAlnSegsOnly) const
const TNumseg & x_GetSeqLeftSeg(TNumrow row) const
bool x_SkipType(TSegTypeFlags type, TGetChunkFlags flags) const
const CDense_seg::TStarts & m_Starts
CNumSegWithOffset x_GetSegFromRawSeg(TNumseg seg) const
TSeqPos x_GetLen(TNumrow row, TNumseg seg) const
TNumseg GetRawSeg(TNumrow row, TSeqPos seq_pos, ESearchDirection dir=eNone, bool try_reverse_dir=true) const
TSignedSeqPos GetStart(TNumrow row, TNumseg seg, int offset=0) const
TSignedSeqPos GetAlnPosFromSeqPos(TNumrow row, TSeqPos seq_pos, ESearchDirection dir=eNone, bool try_reverse_dir=true) const
bool IsPositiveStrand(TNumrow row) const
TSignedSeqPos GetSeqPosFromAlnPos(TNumrow for_row, TSeqPos aln_pos, ESearchDirection dir=eNone, bool try_reverse_dir=true) const
const CDense_seg::TIds & m_Ids
TNumseg GetSeg(TSeqPos aln_pos) const
@ fUnalignedOnLeftOnAnchor
@ fUnalignedOnRightOnAnchor
@ fNotAlignedToSeqOnAnchor
TNumseg x_GetRawSegFromSeg(TNumseg seg) const
vector< CNumSegWithOffset > m_NumSegWithOffsets
TRawSegTypes & x_GetRawSegTypes() const
TSignedSeqPos GetSeqAlnStart(TNumrow row) const
bool x_CompareAdjacentSegTypes(TSegTypeFlags left_type, TSegTypeFlags right_type, TGetChunkFlags flags) const
TDim GetNumRows(void) const
TSegTypeFlags x_SetRawSegType(TNumrow row, TNumseg seg) const
TSeqPos GetAlnStop(TNumseg seg) const
void SetAnchor(TNumrow anchor)
CDense_seg::TStarts m_AlnStarts
vector< TNumseg > m_AlnSegIdx
void x_CreateAlnStarts(void)
vector< TNumseg > m_SeqLeftSegs
const CDense_seg::TStrands & m_Strands
const TNumseg & x_GetSeqRightSeg(TNumrow row) const
TSegTypeFlags x_GetRawSegType(TNumrow row, TNumseg seg, int hint_idx=-1) const
vector< TNumseg > m_SeqRightSegs
CRef< CAlnChunkVec > GetAlnChunks(TNumrow row, const TSignedRange &range, TGetChunkFlags flags=fAlnSegsOnly) const
unsigned int TSegTypeFlags
TSeqPos GetAlnStart(void) const
TSignedSeqPos x_GetRawStop(TNumrow row, TNumseg seg) const
TSeqPos GetLen(TNumseg seg, int offset=0) const
CDense_seg::TNumseg TNumseg
const CDense_seg::TWidths & m_Widths
TSeqPos GetAlnStop(void) const
TSeqPos GetSeqStop(TNumrow row) const
TSeqPos GetAlnStart(TNumseg seg) const
int StrandSign(TNumrow row) const
TSignedSeqPos GetSeqAlnStop(TNumrow row) const
TNumseg GetNumSegs(void) const
TSeqPos GetSeqStart(TNumrow row) const
void x_SetRawSegTypes(TNumrow row) const
TSignedSeqPos GetSeqPosFromSeqPos(TNumrow for_row, TNumrow row, TSeqPos seq_pos, ESearchDirection dir=eNone, bool try_reverse_dir=true) const
TSignedSeqPos x_GetRawStart(TNumrow row, TNumseg seg) const
vector< TSegTypeFlags > TRawSegTypes
const CDense_seg::TLens & m_Lens
TWidths & SetWidths(void)
ESearchDirection
Position search options.
@ eRight
Towards higher aln coord (always to the right)
@ eLeft
Towards lower aln coord (always to the left)
@ eBackwards
Towards lower seq coord (to the left if plus strand, right if minus)
@ eForward
Towards higher seq coord (to the right if plus strand, left if minus)
static void test_type(TDSSOCKET *tds, TDSCOLUMN *col)
static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)
static const struct type types[]
unsigned int TSeqPos
Type for sequence locations and lengths.
int TSignedSeqPos
Type for signed sequence position.
void Critical(CExceptionArgs_Base &args)
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
void Reset(void)
Reset reference object.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
void SetFrom(TFrom value)
Assign a value to From data member.
TTo GetTo(void) const
Get the To member data.
TFrom GetFrom(void) const
Get the From member data.
void SetTo(TTo value)
Assign a value to To data member.
TLens & SetLens(void)
Assign a value to Lens data member.
void SetSegs(TSegs &value)
Assign a value to Segs data member.
void SetDim(TDim value)
Assign a value to Dim data member.
vector< TSignedSeqPos > TStarts
void SetDim(TDim value)
Assign a value to Dim data member.
void SetType(TType value)
Assign a value to Type data member.
TStarts & SetStarts(void)
Assign a value to Starts data member.
TStrands & SetStrands(void)
Assign a value to Strands data member.
void SetNumseg(TNumseg value)
Assign a value to Numseg data member.
TIds & SetIds(void)
Assign a value to Ids data member.
@ eType_partial
mapping pieces together
unsigned int
A callback function used to compare two keys in a database.
range(_Ty, _Ty) -> range< _Ty >
const struct ncbi::grid::netcache::search::fields::SIZE size
Int4 delta(size_t dimension_, const Int4 *score_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
#define row(bind, expected)