<
classTHit>
88 const TCoordbox [] = { ph->GetQueryMin(), ph->GetQueryMax(),
89ph->GetSubjMin(), ph->GetSubjMax() };
96 return(box[
m_i2] > Finish0)?
119 template<
classTHit>
140 typenameTHitRefs::const_iterator from,
141 typenameTHitRefs::const_iterator to)
145 typedef typenameTHitRefs::const_iterator TCI;
146 typedef typenameTHitRefs::iterator TI;
148TI jj = hitrefs.begin();
155 typenameTHitComparator::ESortCriterion sort_type (
157THitComparator::eQueryMin:
158THitComparator::eSubjMin);
160THitComparator sorter (sort_type);
161stable_sort(hitrefs.begin(), hitrefs.end(), sorter);
164 returnaccumulate(hitrefs.begin(), hitrefs.end(),
178span[1] = span[3] = 0;
180 for(
typenameTHitRefs::const_iterator ii = hitrefs.begin(),
181ii_end = hitrefs.end(); ii != ii_end; ++ii) {
183 TCoordx = (*ii)->GetQueryMin();
187x = (*ii)->GetSubjMin();
191x = (*ii)->GetQueryMax();
195x = (*ii)->GetSubjMax();
206 const int n= minmax - maxmin + 1;
235 typenameTHitRefs::iterator hri_end,
238 doublemin_hit_idty = .9,
240 TCoordretain_overlap = 0,
246 switch(unique_type) {
257 if(hri_beg > hri_end) {
259 "Invalid input iterator order");
262 const size_tdim0 = hri_end - hri_beg;
265 size_tdim_factor = 2;
266 boolrestart =
true;
275 copy(hri_beg, hri_end,
all.begin());
276 all.reserve(dim_factor * dim0);
278 const typenameTHitRefs::iterator all_beg =
all.begin();
283 typenameTHitRefs::iterator ii = all_beg;
284 for(
size_t i= 0;
i< dim0; ++
i, ++ii) {
287 for(
Uint1point = 0; point < 4; ++point) {
291he.
m_X= h->GetBox()[point];
306 const Uint1where = ii->m_Point/2;
307 THitRef* hitrefptr = ii->m_Ptr;
308 if((*hitrefptr)->GetId(where)->CompareOrdered(*
id) != 0) {
311open_hits.insert(hitrefptr);
312 id= (*hitrefptr)->GetId(where);
315 autoiis = open_hits.find(hitrefptr);
316 if(iis == open_hits.end()) {
318open_hits.insert(hitrefptr);
321open_hits.erase(iis);
322 const floatcurscore = (*hitrefptr)->GetScore();
323 for(
auto& open_hit: open_hits) {
333vector<bool> skip (dim0,
false);
334skip.reserve(dim_factor * dim0);
335del.assign(dim0,
false);
336del.reserve(dim_factor * dim0);
338 const THitRef* hitref_firstptr = &(*all_beg);
340 while(restart ==
false) {
343 doublescore_best = 0;
344 typenameTHitRefs::iterator ii = all_beg, ii_best =
all.end();
345 for(
size_t i= 0;
i< dim; ++
i, ++ii) {
346 if(skip[
i] ==
false) {
347 const doublescore = (*ii)->GetScore();
348 if(score > score_best) {
355 if(ii_best ==
all.end()) {
363 for(
Uint1where = min_idx; where < max_idx; ++where) {
367 const TCoordcmin = hc->GetMin(where);
368 const TCoordcmax = hc->GetMax(where);
370 for(
autoii_lcl=iters.first; ii_lcl != iters.second; ++ii_lcl) {
372 const THitEnd& he_lcl = *ii_lcl;
374 const size_thitrefidx = he_lcl.
m_Ptr- hitref_firstptr;
375 const boolalive = skip[hitrefidx] ==
false;
376 const bool self= he_lcl.
m_Ptr== &hc;
378 if(alive && !
self) {
386tie(newpos, newpoint)
388cmin, cmax, min_hit_len,
389min_hit_idty, & hit_new,
393del[hitrefidx] = skip[hitrefidx] =
true;
415 if(++dim > 2 * dim0) {
421 all.push_back(hit_new);
423del.push_back(
false);
424skip.push_back(
false);
426box = hit_new->GetBox();
433he2_lcl.
m_Ptr= ptr;
435hit_ends.
insert(he2_lcl);
439he3_lcl.
m_Ptr= ptr;
441hit_ends.
insert(he3_lcl);
443 sx_AddMidPoints(*ptr, saved_box, margin, hit_ends, skip, hitref_firstptr);
451skip[&hc - hitref_firstptr] =
true;
456 typenameTHitRefs::iterator all_beg =
all.begin(), ii = all_beg;
457 const size_tdim =
all.size();
458 for(
size_t i= 0;
i< dim; ++
i, ++ii) {
466 typenameTHitRefs::iterator idst = hri_beg, isrc = all_beg,
467isrc_end =
all.end();
468 while(isrc != isrc_end && idst != hri_end) {
469 if(isrc->NotEmpty()) {
476 while(idst != hri_end) {
477idst++ -> Reset(
NULL);
481phits_new->resize(0);
482 while(isrc != isrc_end) {
483 if(isrc->NotEmpty()) {
484phits_new->push_back(*isrc);
495 typenameTHitRefs::iterator hri_end,
496 const double& maxlenfr,
499 if(hri_beg > hri_end) {
501 "Invalid input iterator order");
505 const size_tdim0 = hri_end - hri_beg;
508 for(
typenameTHitRefs::iterator hri = hri_beg; hri != hri_end; ++hri) {
509 if((*hri)->GetQueryStrand() ==
false) {
510(*hri)->FlipStrands();
512 all.push_back(*hri);
517 typenameTHitRefs::iterator ii1 =
all.begin();
518 typenameTHitRefs::iterator ii2 =
all.end(); --ii2;
524 for(
Uint1point = 0; point < 4; ++point) {
529he1.
m_X= h1->GetBox()[point];
535he2.
m_X= h2->GetBox()[point];
548 for(
Uint1point = 0; point < 4; ++point) {
552he.
m_X= h->GetBox()[point];
559 typenameTHitComparator::ESortCriterion sort_type
560(THitComparator::eQueryIdSubjIdSubjStrand);
561THitComparator sorter (sort_type);
562stable_sort(
all.begin(),
all.end(), sorter);
568 typenameTHitRefs::iterator ib =
all.begin();
571 if( ! (*ii)->GetQueryId()->Match(*(h0->GetQueryId())) ||
572! (*ii)->GetSubjId()->Match(*(h0->GetSubjId())) ||
573(*ii)->GetSubjStrand() != h0->GetSubjStrand() )
603 returnc < 0?
true: (c > 0?
false:
609ostr <<
"(Point,Coord) = (" 624 boolhd_score (((*(container_candidate))->GetScore() < curscore));
631 boolhd_xl (margin + (*(container_candidate))->GetMin(where)
632< (*hit)->GetMin(where));
633 boolhd_xr (margin + (*hit)->GetMax(where)
634< (*(container_candidate))->GetMax(where));
635 if(hd_score && hd_xl && hd_xr) {
639hm.
m_Ptr= container_candidate;
640hm.
m_X= ( (*hit)->GetStart(where)
641+ (*hit)->GetStop(where) ) / 2;
647 const boolis_constraint = hc->GetScore() > 1e20;
649 for(
Uint1point = 0; point < 4; ++point) {
653 if(is_constraint ==
false) {
654he[point].
m_X= box[point];
657 const boolis_start = (point & 1) == 0;
658 const boolis_plus = hc->GetStrand(point / 2);
659he[point].
m_X= (is_start ^ is_plus)?
b:
a;
664 const Uint1i1 = where << 1, i2 = i1 | 1;
665 if(he[i1].m_X <= he[i2].m_X) {
678 autoprev_X = phe_lo->
m_X;
680 if(phe_lo->
m_X>= margin +1) {
681phe_lo->
m_X-= margin +1;
686phe_hi->
m_X+= margin;
691 while( ii0 != ii1 && ii0->m_X+margin < prev_X ) ++ii0;
694 if(phe_lo->
m_X== 0) {
695 THitRefhitref (*(ii0->m_Ptr));
696 const typename THit::TId& id_lcl (hitref->GetId(ii0->m_Point/2));
698ii0 != ii_start; --ii0) {
700 const typename THit::TId& id2 (hr->GetId(ii0->m_Point/2));
701 if(0 != id_lcl->CompareOrdered(*id2)) {
707 returnmake_pair(ii0, ii1);
710vector<bool>& skip,
const THitRef* hitref_firstptr)
714 const floatscore = h->GetScore();
715 for(
Uint1where: {0, 1}) {
717 for(
autoit = iters.first; it != iters.second; ++it) {
718 const size_thitrefidx = it->m_Ptr - hitref_firstptr;
719 const boolalive = skip[hitrefidx] ==
false;
720 const bool self= it->m_Ptr == &h;
722 if(alive && !
self) {
724 sx_AddMidIfNeeded(it->m_Ptr, (*it->m_Ptr)->GetScore(), &h, where, margin, hit_mids);
734 TCoordmin_hit_len,
double& min_idty,
744 TCoordlmin = h->GetMin(where), lmax = h->GetMax(where);
746 if(retain_overlap > 0) {
748 if(overlap >= retain_overlap) {
749 returnmake_pair(-1, 0);
753 if(cmin <= lmin && lmax <= cmax) {
754 returnmake_pair(-2, 0);
757 intldif = cmin - lmin, rdif = lmax - cmax;
758reverse = h->GetStrand(where) ? 0 : 1;
760 if(ldif >
int(min_hit_len) && rdif >
int(min_hit_len)) {
764(*pnew_hit)->Modify(2*where, cmax + 1);
766h->Modify(rp = 2*where + 1, lmax = cmin - 1);
769 if((*pnew_hit)->GetIdentity() < min_idty) {
771 returnmake_pair((h->GetIdentity() < min_idty)? -2: rv, rp ^ reverse);
774 if(h->GetIdentity() < min_idty) {
776 returnmake_pair(cmax + 1, (2*where) ^ reverse);
778 returnmake_pair(0, rp ^ reverse);
780 else if(ldif > rdif) {
782 if(lmin <= cmin && cmin <= lmax) {
783 if(cmin == 0)
returnmake_pair(-2, 0);
784h->Modify(rp = 2*where + 1, lmax = cmin - 1);
787 if(lmin <= cmax && cmax <= lmax) {
788h->Modify(rp = 2*where, lmin = cmax + 1);
794 if(lmin <= cmax && cmax <= lmax) {
795h->Modify(rp = 2*where, lmin = cmax + 1);
798 if(lmin <= cmin && cmin <= lmax) {
799 if(cmin == 0)
returnmake_pair(-2, 0);
800h->Modify(rp = 2*where + 1, lmax = cmin - 1);
806 if(1 + lmax - lmin < min_hit_len || h->GetIdentity() < min_idty) {
807 returnmake_pair(-2, 0);
813 returnmake_pair(rv, rp ^ reverse);
821 const boolsstrand (lhs->GetSubjStrand());
822 if(sstrand != rhs->GetSubjStrand()) {
825 "Cannot merge hits: different strands");
828 const intqgap ((!sstrand && where == 1)?
829(
int(lhs->GetQueryMin()) -
int(rhs->GetQueryMax())):
830(
int(rhs->GetQueryMin()) -
int(lhs->GetQueryMax())));
832 const intsgap ((!sstrand && where == 0)?
833(
int(lhs->GetSubjMin()) -
int(rhs->GetSubjMax())):
834(
int(rhs->GetSubjMin()) -
int(lhs->GetSubjMax())));
836 const boolbv1 (
abs(qgap) == 1 &&
abs(sgap) > 0);
837 const boolbv2 (
abs(sgap) == 1 &&
abs(qgap) > 0);
848 if(x_lhs.size() && x_rhs.size()) {
852x_gap.assign(
abs(sgap) - 1,
'I');
855x_gap.assign(
abs(qgap) - 1,
'D');
860 if(where == 0 || sstrand) {
861xcript = x_lhs + x_gap + x_rhs;
865xcript = x_rhs + x_gap + x_lhs;
869rv.
Reset(
new THit(h->GetId(0), h->GetStart(0), h->GetStrand(0),
870h->GetId(1), h->GetStart(1), h->GetStrand(1),
876rv->SetId(0, lhs->GetId(0));
877rv->SetId(1, lhs->GetId(1));
879lhs->GetQueryStart(), rhs->GetQueryStop(),
880lhs->GetSubjStart(), rhs->GetSubjStop()
899 ITERATE(
string, ii, xcript) {
901 case 'M':
case 'R': q0 = q; q += qinc; s0 = s; s += sinc;
break;
902 case 'I': s0 = s; s += sinc;
break;
903 case 'D': q0 = q; q += qinc;
break;
906 "Invalid transcript symbol");
920 typenameTHitRefs::iterator ii_beg,
921 typenameTHitRefs::iterator ii_end,
923 const double& maxlenfr,
927 typenameTHitComparator::ESortCriterion sort_type (
929THitComparator::eQueryMinScore:
930THitComparator::eSubjMinScore);
931THitComparator sorter (sort_type);
932stable_sort(ii_beg, ii_end, sorter);
934 typedef typenameTHitRefs::iterator TIter;
936 for(TIter ii = ii_beg; ii != ii_end; ++ii) {
939 const TCoordcmax = (*ii)->GetMax(where);
941 for(++jj; jj != ii_end && cmax >= cmin; ++jj) {
942cmin = (*jj)->GetMin(where);
945 if(cmax + 1 == cmin) {
948 boolcan_merge =
true;
949 const Uint1where2 (where ^ 1);
950 const boolsubj_strand ((*ii)->GetSubjStrand());
952can_merge = (*ii)->GetMax(where2) < (*jj)->GetMin(where2);
955can_merge = (*jj)->GetMax(where2) < (*ii)->GetMin(where2);
967he_ii.
m_Ptr= &(*ii);
968he_ii.
m_X= (*ii)->GetStop(where2) + 1;
971he_jj.
m_Ptr= &(*jj);
972he_jj.
m_X= (*jj)->GetStart(where2) - 1;
977he_jj.
m_Ptr= &(*ii);
978he_jj.
m_X= (*ii)->GetStop(where2) - 1;
981he_ii.
m_Ptr= &(*jj);
982he_ii.
m_X= (*jj)->GetStart(where2) + 1;
989= size_t(maxlenfr *
min((*ii)->GetLength(),
993 for(
THitEndsIterii_lcl = ii0; ii_lcl != ii1; ++ii_lcl) {
995 const THitRef& h = *(ii_lcl->m_Ptr);
997 TCoordcmin_lcl (h->GetMin(where2));
998 if(cmin_lcl < he_ii.
m_X) cmin_lcl = he_ii.
m_X;
1000 TCoordcmax_lcl (h->GetMax(where2));
1001 if(cmax_lcl < he_jj.
m_X) cmax_lcl = he_jj.
m_X;
1003 if(cmax_lcl - cmin_lcl + 1 > max_len) {
1014 typenameTIterMap::iterator imi = m.
find(ii);
1015 THitReflhs (imi == m.
end()? *ii: imi->second);
1033 typenameTHitRefs::iterator ii_end,
1035 const double& maxlenfr,
1038 typedef typenameTHitRefs::iterator TIter;
1042 sx_TM(0, ii_beg, ii_end, hit_ends, maxlenfr, m);
1043 sx_TM(1, ii_beg, ii_end, hit_ends, maxlenfr, m);
1046 for(TIter ii = ii_beg; ii != ii_end; ++ii) {
1047 typenameTIterMap::iterator imi = m.find(ii);
1048 THitRefhr (imi == m.end()? *ii: imi->second);
1050pout->push_back(hr);
bool GetQueryStrand(void) const
TCoord GetQueryStart(void) const
TCoord GetSubjStop(void) const
static string s_RunLengthDecode(const string &in)
TCoord GetSubjStart(void) const
bool GetSubjStrand(void) const
const TId & GetId(Uint1 where) const
TCoord GetQueryStop(void) const
const TTranscript & GetTranscript(void) const
float GetScore(void) const
const_iterator end() const
const_iterator find(const key_type &key) const
const_iterator begin() const
const_iterator upper_bound(const key_type &key) const
iterator insert(const value_type &val)
const_iterator end() const
parent_type::iterator iterator
const_iterator lower_bound(const key_type &key) const
TCoord operator()(TCoord iVal, const THitRef &ph)
Overloaded function call operator to be used with std::accumulate()
static void s_RunGreedy(typename THitRefs::iterator hri_beg, typename THitRefs::iterator hri_end, THitRefs *phits_new, TCoord min_hit_len=100, double min_hit_idty=.9, TCoord margin=1, TCoord retain_overlap=0, EUnique_type unique_type=e_Strict)
EUnique_type
Multiple-sequences greedy alignment uniquification algorithm.
static TCoord s_GetOverlap(TCoord L1, TCoord R1, TCoord L2, TCoord R2)
static pair< int, Uint1 > sx_Cleave(THitRef &h, Uint1 where, TCoord cmin, TCoord cmax, TCoord min_hit_len, double &min_idty, THitRef *pnew_hit, TCoord retain_overlap)
bool operator<(const SHitEnd &rhs) const
friend ostream & operator<<(ostream &ostr, const SHitEnd &he)
static void sx_AddMidIfNeeded(THitRef *hit, const float curscore, THitRef *container_candidate, const Uint1 where, TCoord margin, THitEnds &hit_mids)
static void sx_AddMidPoints(THitRef &h, const TCoord *outer_box, TCoord margin, THitEnds &hit_ends, vector< bool > &skip, const THitRef *hitref_firstptr)
THitEnds::iterator THitEndsIter
static void s_GetSpan(const THitRefs &hitrefs, TCoord span[4])
Get sequence span for a set of alignments (hits).
static TCoord s_GetCoverage(Uint1 where, typename THitRefs::const_iterator from, typename THitRefs::const_iterator to)
Collect coverage for the range of hits on the specified source sequence.
CHitCoverageAccumulator(Uint1 where)
Create the object; specify the accumulation sequence.
multiset< THitEnd > THitEnds
static bool s_TrackHit(const THit &h)
static void sx_TestAndMerge(typename THitRefs::iterator ii_beg, typename THitRefs::iterator ii_end, const THitEnds &hit_ends, const double &maxlenfr, THitRefs *pout)
static pair< THitEndsIter, THitEndsIter > sx_GetEndsInRange(const THitRef &hc, const TCoord *box, Uint1 where, TCoord margin, THitEnds &hit_ends)
static void s_MergeAbutting(typename THitRefs::iterator hri_beg, typename THitRefs::iterator hri_end, const double &maxlenfr, THitRefs *pout)
static void sx_TM(Uint1 where, typename THitRefs::iterator ii_beg, typename THitRefs::iterator ii_end, const THitEnds &hit_ends, const double &maxlenfr, map< typename THitRefs::iterator, THitRef > &m)
vector< THitRef > THitRefs
static THitRef sx_Merge(const THitRef &lhs, const THitRef &rhs, Uint1 where)
static bool s_PNullRef(const THitRef &hr)
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
bool NotNull(void) const THROWS_NONE
Check if pointer is not null â same effect as NotEmpty().
objects::CSeq_id element_type
Define alias element_type.
void Reset(void)
Reset reference object.
bool NotEmpty(void) const THROWS_NONE
Check if CRef is not empty â pointing to an object and has a non-null value.
bool IsNull(void) const THROWS_NONE
Check if pointer is null â same effect as Empty().
uint8_t Uint1
1-byte (8-bit) unsigned integer
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
unsigned int
A callback function used to compare two keys in a database.
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