;
74 template<
classTAlnRange>
84 typedef typenameTAlignRangeVector::size_type
size_type;
179 returnstd::lower_bound(
begin(),
end(),
r.GetFirstFrom(), p);
184 if(
r.GetLength() > 0) {
202 if(
r.GetLength() > 0) {
232 if(it_ins !=
end()) {
249 if(it_ins ==
end()) {
317pair<const_iterator, bool> res =
find_2(pos);
318 returnres.second ? res.first :
m_Ranges.end();
329 boolb_contains = (it !=
end() && it->GetFirstFrom() <= pos);
330 returnmake_pair(it, b_contains);
336 returnstd::lower_bound(
begin(),
end(), pos, p);
342 returnstd::upper_bound(
begin(),
end(), pos, p);
350 return begin()->GetFirstFrom();
353 returnTAlignRange::GetEmptyFrom();
360 return rbegin()->GetFirstToOpen();
363 returnTAlignRange::GetEmptyToOpen();
370 return rbegin()->GetFirstTo();
373 returnTAlignRange::GetEmptyTo();
381 return rbegin()->GetFirstToOpen() - from;
412pair<const_iterator, bool> res =
find_2(pos);
417 if(res.first !=
end()) {
419pos = res.first->GetFirstFrom();
423 if(res.first !=
begin()) {
426pos = res.first->GetFirstTo();
430 returnres.second ? res.first->GetSecondPosByFirstPos(pos)
442 else if(dir ==
eRight) {
456 else if(dir !=
eNone) {
462res_pos =
r.GetSecondFrom();
463dist = res_pos - pos;
466res_pos = it->GetSecondTo();
467dist = pos - res_pos;
469 if(dist > 0 && (min_dist == -1 || min_dist > dist)) {
477 return(it_closest ==
end()) ? -1 : it_closest->GetFirstPosBySecondPos(min_pos);
504vector<bool>* dead =
NULL;
505 size_trange_size =
m_Ranges.size();
507 for(
size_t i= range_size - 1;
i> 0; --
i) {
510dead =
newvector<bool>(range_size,
false);
511dead->reserve(range_size);
514(*dead)[
i] =
true;
519 for(
size_t i= 0;
i< range_size;
i++ ) {
523 else if(shift > 0) {
528 m_Ranges.resize(range_size - shift);
540 for(
size_t i= 0;
i<
m_Ranges.size()-1;
i++) {
542 if(
flags== complete) {
578 swap(r_left, r_right);
667 typedef typenameTAlignRangeVector::iterator
iterator;
691rg.SetFirstFrom(rg.GetFirstFrom()*3);
692rg.SetSecondFrom(rg.GetSecondFrom()*3);
693rg.SetLength(rg.GetLength()*3);
696rg.SetFirstFrom(rg.GetFirstFrom()*3);
697rg.SetSecondFrom(rg.GetSecondFrom()*3);
698rg.SetLength(rg.GetLength()*3);
703 typenameTAlignRangeVector::iterator it = ranges.begin();
704 while(it != ranges.end()) {
705 if(!it->IntersectingWith(range)) {
706 typenameTAlignRangeVector::iterator del = it;
711 if(it->GetFirstFrom() < range.
GetFrom() || it->GetFirstTo() > range.
GetTo()) {
712it->IntersectWith(range);
719 typenameTAlignRangeVector::iterator it = ranges.begin();
720 while(it != ranges.end()) {
721 if(it->GetSecondTo() < range.
GetFrom() || it->GetSecondFrom() > range.
GetTo()) {
722 typenameTAlignRangeVector::iterator del = it;
727 if(it->GetSecondFrom() < range.
GetFrom() || it->GetSecondTo() > range.
GetTo()) {
728it->IntersectSecondWith(range);
751 template<
classTAlnRange>
789 return*
this+= -
delta;
824 return m_Iter== iter.m_Iter;
828 return!(*
this== iter);
866 return*
this+= -
delta;
965const_iterator
end()
const 995 returnk1->GetFirstFrom() < k2->GetFirstFrom();
999 returnk1->GetFirstFrom() < pos;
1003 returnpos < k2->GetFirstFrom();
1010 returnk1->GetSecondFrom() < k2->GetSecondFrom();
1014 returnk1->GetSecondFrom() < pos;
1018 returnpos < k2->GetSecondFrom();
1035 if(
r.GetLength() > 0) {
1053const_iterator it_ins =
end();
1054 if(
r.GetLength() > 0) {
1060 autoit_left =
prev(it);
1061 if(it_left->IsAbutting(
r)) {
1068 r.CombineWithAbutting(*it_left);
1078 if(it->IsAbutting(
r)) {
1083 r.CombineWithAbutting(*it);
1104const_iterator
erase(const_iterator it_del)
1106const_iterator it_res =
end();
1108 if(it_del != it_res) {
1109it_res =
next(it_del);
1162pair<const_iterator, bool> res =
find_2(pos);
1163 returnres.second ? res.first :
end();
1173 boolb_contains = (it !=
end() && it->GetFirstFrom() <= pos);
1174 returnmake_pair(it, b_contains);
1183 returnres.second? res.first.first:
end();
1206 returnstd::lower_bound(
begin(),
end(), pos, p);
1212 returnstd::upper_bound(
begin(),
end(), pos, p);
1221 returnTAlignRange::GetEmptyFrom();
1224 return begin()->GetFirstFrom();
1231 returnTAlignRange::GetEmptyToOpen();
1234 return rbegin()->GetFirstToOpen();
1241 returnTAlignRange::GetEmptyTo();
1244 return rbegin()->GetFirstTo();
1255 return rbegin()->GetFirstToOpen() - from;
1283pair<const_iterator, bool> res =
find_2(pos);
1286 if( !res.second ) {
1288 if( res.first !=
end() ) {
1290pos = res.first->GetFirstFrom();
1294 if( res.first !=
begin() ) {
1297pos = res.first->GetFirstTo();
1301 returnres.second ? res.first->GetSecondPosByFirstPos(pos)
1309 if( dir ==
eLeft) {
1313 else if( dir ==
eRight) {
1319const_iterator it_closest =
end();
1322pair<pair<const_iterator, const_iterator>,
bool> res =
find_2_by_second(pos);
1323 if( !res.second ) {
1325 if( res.first.first !=
end() ) {
1328 _ASSERT(
r.GetSecondFrom() > pos);
1331it_closest = res.first.first;
1332min_pos =
r.GetSecondFrom();
1333min_dist =
r.GetSecondFrom() - pos;
1336 if( res.first.second !=
end() ) {
1342 intdist = pos -
r.GetSecondTo();
1343 if( min_dist < 0 || dist < min_dist ) {
1344it_closest = res.first.second;
1345min_pos =
r.GetSecondTo();
1350 if( min_dist >= 0 ) {
1355it_closest = res.first.first;
1358 returnmin_dist >= 0? it_closest->GetFirstPosBySecondPos(pos): -1;
1361const_iterator it_closest =
end();
1364 for(const_iterator it =
begin(); it !=
end(); it++) {
1370 else if(dir !=
eNone) {
1376res_pos =
r.GetSecondFrom();
1377dist = res_pos - pos;
1380res_pos = it->GetSecondTo();
1381dist = pos - res_pos;
1383 if(dist > 0 && (min_dist == -1 || min_dist > dist)) {
1391 return(it_closest ==
end()) ? -1 : it_closest->GetFirstPosBySecondPos(min_pos);
1400 if(
next== where ) {
1432 i= i_next, ++i_next ) {
1433 if(
i->IsAbutting(*i_next) ) {
1435i_next->CombineWithAbutting(*
i);
1455 i= i_next, ++i_next ) {
1457 if(
flags== complete) {
1494 swap(r_left, r_right);
1518 for(
auto&
i: insertions) {
1529 for(
auto&
i: collection ) {
1612 autopos = iter->GetFirstFrom();
1614 if( *it == iter ) {
1619 _ASSERT(0&&
"Cannot find range in m_IndexByFirst");
1623 autopos = iter->GetSecondFrom();
1625 if( *it == iter ) {
1630 _ASSERT(0&&
"Cannot find range in m_IndexBySecond");
1680 autoprev_iter =
prev(iter);
1681 _ASSERT((*prev_iter)->GetFirstFrom() <= pos);
1682 if( (*prev_iter)->GetFirstToOpen() > pos ) {
1700pair<pair<const_iterator, const_iterator>,
bool>
1703pair<pair<const_iterator, const_iterator>,
bool> ret;
1707 autoprev_iter =
prev(iter);
1708 _ASSERT((*prev_iter)->GetSecondFrom() <= pos);
1709 if( (*prev_iter)->GetSecondToOpen() > pos ) {
1711ret.first.first = *prev_iter;
1712ret.first.second =
end();
1715ret.first.second = *prev_iter;
1718ret.first.second =
end();
1721ret.first.first = *iter;
1724ret.first.first =
end();
1743rg.SetFirstFrom(rg.GetFirstFrom()*3);
1744rg.SetSecondFrom(rg.GetSecondFrom()*3);
1745rg.SetLength(rg.GetLength()*3);
1748rg.SetFirstFrom(rg.GetFirstFrom()*3);
1749rg.SetSecondFrom(rg.GetSecondFrom()*3);
1750rg.SetLength(rg.GetLength()*3);
1753rg.SetFirstFrom(rg.GetFirstFrom()*3);
1754rg.SetSecondFrom(rg.GetSecondFrom()*3);
1755rg.SetLength(rg.GetLength()*3);
1759 template<
classTRanges>
1761 typenameTRanges::iterator it = ranges.begin();
1762 while(it != ranges.end()) {
1763 if(!it->IntersectingWith(range)) {
1764 typenameTRanges::iterator del = it;
1769 if(it->GetFirstFrom() < range.
GetFrom() || it->GetFirstTo() > range.
GetTo()) {
1770it->IntersectWith(range);
1776 template<
classTRanges>
1778 typenameTRanges::iterator it = ranges.begin();
1779 while(it != ranges.end()) {
1780 if(it->GetSecondTo() < range.
GetFrom() || it->GetSecondFrom() > range.
GetTo()) {
1781 typenameTRanges::iterator del = it;
1786 if(it->GetSecondFrom() < range.
GetFrom() || it->GetSecondTo() > range.
GetTo()) {
1787it->IntersectSecondWith(range);
1808 template<
classTColl>
1856(
r->GetSecondFrom(),
r));
1908 _ASSERT(
r.GetSecondTo() >= pos);
1909 return r.SecondContains(pos) ? it :
m_Ranges.
end();
1921 returnp.second->GetSecondTo() < pos;
1926 returnpos < p.second->GetSecondTo();
1931 returnp1.second->GetSecondTo() < p2.second->GetSecondTo();
1944 template<
classTAlnRange>
1949m_Ranges.assign(src.
begin(), src.
end());
vector< TRangeWithFuzz > TRanges
virtual const char * GetErrCodeString(void) const override
Get error code interpreted as text.
CAlignRangeCollException()
CAlignRangeCollExtender this is an adapter for a collection that perfroms some of the operations fast...
position_type GetSecondTo() const
position_type GetSecondToOpen() const
void Init(const TColl &coll)
CAlignRangeCollExtender(const TColl &coll)
multimap< position_type, const TAlignRange * > TFrom2Range
position_type GetSecondFrom() const
TColl::ESearchDirection TSearchDir
CRange< position_type > GetSecondRange() const
const_iterator FindOnSecond(position_type pos) const
finds a segment at logarithmic time (linear time on first call) returns an iterator to the fisrt segm...
const_iterator end() const
TFrom2Range::const_iterator const_iterator
TColl::position_type position_type
position_type GetSecondLength(void) const
TColl::TAlignRange TAlignRange
const_iterator begin() const
const_iterator operator++(int)
const_iterator & operator--()
pointer operator->() const
const_iterator operator+(int delta)
bidirectional_iterator_tag iterator_category
const_iterator(const TRawIterator &iter)
const TAlignRange * pointer
ptrdiff_t difference_type
const TAlignRange & reference
const_iterator operator-(int delta)
reference operator*() const
const_iterator & operator-=(int delta)
bool operator==(const const_iterator &iter) const
const_iterator & operator+=(int delta)
const_iterator & operator++()
const_iterator operator--(int)
bool operator!=(const const_iterator &iter) const
iterator & operator+=(int delta)
reference operator*() const
iterator operator-(int delta)
iterator(const TRawIterator &i)
iterator operator+(int delta)
pointer operator->() const
iterator & operator-=(int delta)
class CAlignRangeCollectionList<TAlignRange> represent a sorted collection of TAlignRange.
const_iterator find_insertion_point(const TAlignRange &range) const
bool IsSet(int flags) const
static int ValidateRanges(const TAlignRange &r_1, const TAlignRange &r_2)
determine conflicts between two ranges
int GetStateFlags() const
const_iterator x_FindRangeContaining(position_type pos) const
int GetPolicyFlags() const
TIndexBySecond m_IndexBySecond
CAlignRangeCollectionList(const TAlignRangeVectorImpl &v, int flags)
const_iterator begin() const
const_iterator insert(const TAlignRange &r)
ESearchDirection
adding empty ranges is considered valid, they are simply ignored
CAlignRangeCollectionList< TAlignRange > TThisType
void x_Unindex(TIndexKey iter)
const_iterator insert(const_iterator it, const TAlignRange &arg_r)
TAlignRangeVectorImpl m_RangesVector
void x_UnindexBySecond(TIndexKey iter)
const TAlignRange & operator[](size_type pos) const
Use iterator access.
void IntersectFirst(const CRange< position_type > &range)
list< TAlignRange > TAlignRangeList
pair< const_iterator, bool > find_2(position_type pos) const
returns an iterator pointing to a range containing "pos"; if such a range does not exists an iterator...
const_reverse_iterator rbegin() const
position_type GetFirstLength(void) const
TSignedSeqPos GetSecondPosByFirstPos(position_type pos, ESearchDirection dir=eNone) const
void IntersectSecond(const CRange< position_type > &range)
void Normalize()
ensures that segments are sorted, if fAllowAdjust is not set - merges adjacent segments
pair< pair< const_iterator, const_iterator >, bool > find_2_by_second(position_type pos) const
returns an iterator pointing to a range containing "pos"; if such a range does not exists an iterator...
void push_back(const TAlignRange &r)
void x_IntersectFirst(TRanges &ranges, const CRange< position_type > &range)
TAlignRangeList::size_type size_type
bool x_Equals(const TThisType &c) const
iterator x_FindInsertionPlace(const TAlignRange &r)
position_type GetFirstFrom() const
TAlignRangeList::const_reverse_iterator const_reverse_iterator
const TIndexByFirst & GetIndexByFirst() const
CRange< position_type > GetFirstRange() const
@ fMixedDir
contains at least one reversed range
@ fPolicyMask
Keep compatible with SC-8.0.
@ fNotValidated
State flags:
@ fAllowOverlap
allow segments with different orientation
@ fAllowAbutting
allow segments overlapping on the first sequence
@ fInvalid
collection was modified and not validated
@ fIgnoreInsertions
allows segments not separated by gaps
@ fAllowMixedDir
enforce all policies after any modification
@ fKeepNormalized
Policies:
@ fReversed
contains at least one direct range
@ fDefaultPolicy
do not store insertions
@ fUnsorted
one or more policies violated
TSignedSeqPos GetFirstPosBySecondPos(position_type pos, ESearchDirection dir=eNone) const
TAlignRangeList::iterator TRawIterator
CAlignRangeCollectionList(const TAlignRangeList &v, int flags)
const TIndexBySecond & GetIndexBySecond() const
const_iterator find(position_type pos) const
void x_SetFlags(int flags)
TIndexByFirst m_IndexByFirst
combination of EFlags
void CombineAbutting()
merge adjacent segments together, merging changes collection size and invalidates iterators
TAlignRangeList m_RangesList
const TInsertions & GetInsertions() const
Each insertion shows where the 'first' sequence has a gap while the 'second' sequence has the inserti...
void x_ResetFlags(int flags)
vector< TAlignRange > TInsertions
const_reverse_iterator rend() const
TRawIterator x_Insert(TRawIterator where, const TAlignRange &r)
void x_Erase(TRawIterator iter)
multiset< TIndexKey, PIndexBySecondLess > TIndexBySecond
void x_Index(TIndexKey iter)
const_iterator end() const
multiset< TIndexKey, PIndexByFirstLess > TIndexByFirst
vector< TAlignRange > TAlignRangeVector
position_type GetFirstTo() const
vector< TAlignRange > TAlignRangeVectorImpl
Use iterators on TAlignRangeList or TInsertions for insertions.
position_type GetFirstToOpen() const
void x_UnindexByFirst(TIndexKey iter)
const_iterator find_by_second(position_type pos) const
const_iterator erase(const_iterator it_del)
void x_MultiplyCoordsBy3()
void Validate()
analyses segements and updates flags
void AddInsertion(const TAlignRange &r)
TAlignRangeVectorImpl & x_GetAlignRangeVector() const
void x_IntersectSecond(TRanges &ranges, const CRange< position_type > &range)
TAlignRange::position_type position_type
void AddInsertions(const TInsertions &insertions)
void AddInsertions(const TThisType &collection)
CAlignRangeCollectionList(int flags=fDefaultPolicy)
pair< pair< const_iterator, const_iterator >, bool > x_FindRangesBySecondContaining(position_type pos) const
void SortInsertions(void)
class CAlignRangeCollection<TAlignRange> represent a sorted collection of TAlignRange.
position_type GetFirstTo() const
void Normalize()
ensures that segments are sorted, if fAllowAdjust is not set - merges adjacent segments
void x_IntersectSecond(TAlignRangeVector &ranges, const CRange< position_type > &range)
TAlignRangeVector m_Ranges
const_reverse_iterator rend() const
TAlignRangeVector::const_reverse_iterator const_reverse_iterator
TAlignRangeVector::const_iterator const_iterator
vector< TAlignRange > TAlignRangeVector
const_iterator insert(const_iterator where, const TAlignRange &r)
bool IsSet(int flags) const
CAlignRangeCollection(const TAlignRangeVector &v, int flags)
int GetPolicyFlags() const
void AddInsertions(const TThisType &collection)
TSignedSeqPos GetFirstPosBySecondPos(position_type pos, ESearchDirection dir=eNone) const
void push_back(const TAlignRange &r)
void CombineAbutting()
merge adjacent segments together, merging changes collection size and invalidates iterators
CRange< position_type > GetFirstRange() const
position_type GetFirstToOpen() const
const_iterator lower_bound(position_type pos) const
@ fAllowOverlap
allow segments with different orientation
@ fMixedDir
contains at least one reversed range
@ fPolicyMask
Keep compatible with SC-8.0.
@ fIgnoreInsertions
allows segments not separated by gaps
@ fAllowAbutting
allow segments overlapping on the first sequence
@ fAllowMixedDir
enforce all policies after any modification
@ fInvalid
collection was modified and not validated
@ fKeepNormalized
Policies:
@ fUnsorted
one or more policies violated
@ fDefaultPolicy
do not store insertions
@ fNotValidated
State flags:
@ fReversed
contains at least one direct range
void AddInsertions(const TAlignRangeVector &insertions)
position_type GetFirstFrom() const
void Validate()
analyses segements and updates flags
const_iterator insert(const TAlignRange &r)
void x_SetFlags(int flags)
const_iterator upper_bound(position_type pos) const
TSignedSeqPos GetSecondPosByFirstPos(position_type pos, ESearchDirection dir=eNone) const
const_iterator erase(const_iterator it)
bool x_Equals(const TThisType &c) const
void IntersectSecond(const CRange< position_type > &range)
const TAlignRange & operator[](size_type pos) const
position_type GetFirstLength(void) const
const_iterator find(position_type pos) const
void x_ResetFlags(int flags)
ESearchDirection
adding empty ranges is considered valid, they are simply ignored
CAlignRangeCollection(int flags=fDefaultPolicy)
void SortInsertions(void)
TAlignRange::position_type position_type
const_iterator end() const
TAlignRangeVector::iterator iterator
const_reverse_iterator rbegin() const
TAlignRangeVector m_Insertions
void AddInsertion(const TAlignRange &r)
int GetStateFlags() const
TAlignRangeVector::size_type size_type
void x_IntersectFirst(TAlignRangeVector &ranges, const CRange< position_type > &range)
void Assign(const CAlignRangeCollectionList< TAlignRange > &src)
pair< const_iterator, bool > find_2(position_type pos) const
returns an iterator pointing to a range containing "pos"; if such a range does not exists an iterator...
void x_MultiplyCoordsBy3()
CAlignRangeCollection< TAlignRange > TThisType
const TAlignRangeVector & GetInsertions() const
Each insertion shows where the 'first' sequence has a gap while the 'second' sequence has the inserti...
const_iterator begin() const
TAlignRangeVector::reverse_iterator reverse_iterator
const_iterator find_insertion_point(const TAlignRange &r)
static int ValidateRanges(const TAlignRange &r_1, const TAlignRange &r_2)
determine conflicts between two ranges
TAlignRange & operator[](size_type pos)
void IntersectFirst(const CRange< position_type > &range)
CAlignRange Represents an element of pairwise alignment of two sequences.
container_type::const_iterator const_iterator
const_iterator end() const
iterator insert(const value_type &val)
const_iterator begin() const
container_type::value_type value_type
const_iterator begin() const
const_iterator upper_bound(const key_type &key) const
iterator insert(const value_type &val)
const_iterator end() const
const_iterator lower_bound(const key_type &key) const
Include a standard set of the NCBI C++ Toolkit most basic headers.
static DLIST_TYPE *DLIST_NAME() prev(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
static DLIST_TYPE *DLIST_NAME() next(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
pair< TRange, CRef< CSeq_align > > TAlignRange
#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)
bool IsAbutting(const TThisType &r) const
position_type GetFirstToOpen(void) const
bool NotEmpty(void) const
TThisType & CombineWithAbutting(const TThisType &r)
position_type GetFirstFrom(void) const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
TTo GetTo(void) const
Get the To member data.
TFrom GetFrom(void) const
Get the From member data.
constexpr auto sort(_Init &&init)
Defines NCBI C++ exception handling.
The NCBI C++/STL use hints.
Int4 delta(size_t dimension_, const Int4 *score_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
bool operator()(const typename TFrom2Range::value_type &p1, const typename TFrom2Range::value_type &p2)
TAlignRange::position_type position_type
bool operator()(const typename TFrom2Range::value_type &p, position_type pos)
bool operator()(position_type pos, const typename TFrom2Range::value_type &p)
bool operator()(position_type pos, const TIndexKey &k2) const
bool operator()(const TIndexKey &k1, const TIndexKey &k2) const
bool operator()(const TIndexKey &k1, position_type pos) const
bool operator()(position_type pos, const TIndexKey &k2) const
bool operator()(const TIndexKey &k1, const TIndexKey &k2) const
bool operator()(const TIndexKey &k1, position_type pos) const
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