A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/hit__filter_8hpp_source.html below:

NCBI C++ ToolKit: include/algo/align/util/hit_filter.hpp Source File

1 #ifndef ALGO_ALIGN_UTIL_HITFILTER__HPP 2 #define ALGO_ALIGN_UTIL_HITFILTER__HPP 54 template

<

class

THit>

88  const TCoord

box [] = { ph->GetQueryMin(), ph->GetQueryMax(),

89

ph->GetSubjMin(), ph->GetSubjMax() };

96  return

(box[

m_i2

] > Finish0)?

119 template

<

class

THit>

140  typename

THitRefs::const_iterator from,

141  typename

THitRefs::const_iterator to)

145  typedef typename

THitRefs::const_iterator TCI;

146  typedef typename

THitRefs::iterator TI;

148

TI jj = hitrefs.begin();

155  typename

THitComparator::ESortCriterion sort_type (

157

THitComparator::eQueryMin:

158

THitComparator::eSubjMin);

160

THitComparator sorter (sort_type);

161

stable_sort(hitrefs.begin(), hitrefs.end(), sorter);

164  return

accumulate(hitrefs.begin(), hitrefs.end(),

178

span[1] = span[3] = 0;

180  for

(

typename

THitRefs::const_iterator ii = hitrefs.begin(),

181

ii_end = hitrefs.end(); ii != ii_end; ++ii) {

183  TCoord

x = (*ii)->GetQueryMin();

187

x = (*ii)->GetSubjMin();

191

x = (*ii)->GetQueryMax();

195

x = (*ii)->GetSubjMax();

206  const int n

= minmax - maxmin + 1;

235  typename

THitRefs::iterator hri_end,

238  double

min_hit_idty = .9,

240  TCoord

retain_overlap = 0,

246  switch

(unique_type) {

257  if

(hri_beg > hri_end) {

259  "Invalid input iterator order"

);

262  const size_t

dim0 = hri_end - hri_beg;

265  size_t

dim_factor = 2;

266  bool

restart =

true

;

275  copy

(hri_beg, hri_end,

all

.begin());

276  all

.reserve(dim_factor * dim0);

278  const typename

THitRefs::iterator all_beg =

all

.begin();

283  typename

THitRefs::iterator ii = all_beg;

284  for

(

size_t i

= 0;

i

< dim0; ++

i

, ++ii) {

287  for

(

Uint1

point = 0; point < 4; ++point) {

291

he.

m_X

= h->GetBox()[point];

306  const Uint1

where = ii->m_Point/2;

307  THitRef

* hitrefptr = ii->m_Ptr;

308  if

((*hitrefptr)->GetId(where)->CompareOrdered(*

id

) != 0) {

311

open_hits.insert(hitrefptr);

312  id

= (*hitrefptr)->GetId(where);

315  auto

iis = open_hits.find(hitrefptr);

316  if

(iis == open_hits.end()) {

318

open_hits.insert(hitrefptr);

321

open_hits.erase(iis);

322  const float

curscore = (*hitrefptr)->GetScore();

323  for

(

auto

& open_hit: open_hits) {

333

vector<bool> skip (dim0,

false

);

334

skip.reserve(dim_factor * dim0);

335

del.assign(dim0,

false

);

336

del.reserve(dim_factor * dim0);

338  const THitRef

* hitref_firstptr = &(*all_beg);

340  while

(restart ==

false

) {

343  double

score_best = 0;

344  typename

THitRefs::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 double

score = (*ii)->GetScore();

348  if

(score > score_best) {

355  if

(ii_best ==

all

.end()) {

363  for

(

Uint1

where = min_idx; where < max_idx; ++where) {

367  const TCoord

cmin = hc->GetMin(where);

368  const TCoord

cmax = hc->GetMax(where);

370  for

(

auto

ii_lcl=iters.first; ii_lcl != iters.second; ++ii_lcl) {

372  const THitEnd

& he_lcl = *ii_lcl;

374  const size_t

hitrefidx = he_lcl.

m_Ptr

- hitref_firstptr;

375  const bool

alive = skip[hitrefidx] ==

false

;

376  const bool self

= he_lcl.

m_Ptr

== &hc;

378  if

(alive && !

self

) {

386

tie(newpos, newpoint)

388

cmin, cmax, min_hit_len,

389

min_hit_idty, & hit_new,

393

del[hitrefidx] = skip[hitrefidx] =

true

;

415  if

(++dim > 2 * dim0) {

421  all

.push_back(hit_new);

423

del.push_back(

false

);

424

skip.push_back(

false

);

426

box = hit_new->GetBox();

433

he2_lcl.

m_Ptr

= ptr;

435

hit_ends.

insert

(he2_lcl);

439

he3_lcl.

m_Ptr

= ptr;

441

hit_ends.

insert

(he3_lcl);

443  sx_AddMidPoints

(*ptr, saved_box, margin, hit_ends, skip, hitref_firstptr);

451

skip[&hc - hitref_firstptr] =

true

;

456  typename

THitRefs::iterator all_beg =

all

.begin(), ii = all_beg;

457  const size_t

dim =

all

.size();

458  for

(

size_t i

= 0;

i

< dim; ++

i

, ++ii) {

466  typename

THitRefs::iterator idst = hri_beg, isrc = all_beg,

467

isrc_end =

all

.end();

468  while

(isrc != isrc_end && idst != hri_end) {

469  if

(isrc->NotEmpty()) {

476  while

(idst != hri_end) {

477

idst++ -> Reset(

NULL

);

481

phits_new->resize(0);

482  while

(isrc != isrc_end) {

483  if

(isrc->NotEmpty()) {

484

phits_new->push_back(*isrc);

495  typename

THitRefs::iterator hri_end,

496  const double

& maxlenfr,

499  if

(hri_beg > hri_end) {

501  "Invalid input iterator order"

);

505  const size_t

dim0 = hri_end - hri_beg;

508  for

(

typename

THitRefs::iterator hri = hri_beg; hri != hri_end; ++hri) {

509  if

((*hri)->GetQueryStrand() ==

false

) {

510

(*hri)->FlipStrands();

512  all

.push_back(*hri);

517  typename

THitRefs::iterator ii1 =

all

.begin();

518  typename

THitRefs::iterator ii2 =

all

.end(); --ii2;

524  for

(

Uint1

point = 0; point < 4; ++point) {

529

he1.

m_X

= h1->GetBox()[point];

535

he2.

m_X

= h2->GetBox()[point];

548  for

(

Uint1

point = 0; point < 4; ++point) {

552

he.

m_X

= h->GetBox()[point];

559  typename

THitComparator::ESortCriterion sort_type

560

(THitComparator::eQueryIdSubjIdSubjStrand);

561

THitComparator sorter (sort_type);

562

stable_sort(

all

.begin(),

all

.end(), sorter);

568  typename

THitRefs::iterator ib =

all

.begin();

571  if

( ! (*ii)->GetQueryId()->Match(*(h0->GetQueryId())) ||

572

! (*ii)->GetSubjId()->Match(*(h0->GetSubjId())) ||

573

(*ii)->GetSubjStrand() != h0->GetSubjStrand() )

603  return

c < 0?

true

: (c > 0?

false

:

609

ostr <<

"(Point,Coord) = (" 624  bool

hd_score (((*(container_candidate))->GetScore() < curscore));

631  bool

hd_xl (margin + (*(container_candidate))->GetMin(where)

632

< (*hit)->GetMin(where));

633  bool

hd_xr (margin + (*hit)->GetMax(where)

634

< (*(container_candidate))->GetMax(where));

635  if

(hd_score && hd_xl && hd_xr) {

639

hm.

m_Ptr

= container_candidate;

640

hm.

m_X

= ( (*hit)->GetStart(where)

641

+ (*hit)->GetStop(where) ) / 2;

647  const bool

is_constraint = hc->GetScore() > 1e20;

649  for

(

Uint1

point = 0; point < 4; ++point) {

653  if

(is_constraint ==

false

) {

654

he[point].

m_X

= box[point];

657  const bool

is_start = (point & 1) == 0;

658  const bool

is_plus = hc->GetStrand(point / 2);

659

he[point].

m_X

= (is_start ^ is_plus)?

b

:

a

;

664  const Uint1

i1 = where << 1, i2 = i1 | 1;

665  if

(he[i1].m_X <= he[i2].m_X) {

678  auto

prev_X = phe_lo->

m_X

;

680  if

(phe_lo->

m_X

>= margin +1) {

681

phe_lo->

m_X

-= margin +1;

686

phe_hi->

m_X

+= margin;

691  while

( ii0 != ii1 && ii0->m_X+margin < prev_X ) ++ii0;

694  if

(phe_lo->

m_X

== 0) {

695  THitRef

hitref (*(ii0->m_Ptr));

696  const typename THit::TId

& id_lcl (hitref->GetId(ii0->m_Point/2));

698

ii0 != ii_start; --ii0) {

700  const typename THit::TId

& id2 (hr->GetId(ii0->m_Point/2));

701  if

(0 != id_lcl->CompareOrdered(*id2)) {

707  return

make_pair(ii0, ii1);

710

vector<bool>& skip,

const THitRef

* hitref_firstptr)

714  const float

score = h->GetScore();

715  for

(

Uint1

where: {0, 1}) {

717  for

(

auto

it = iters.first; it != iters.second; ++it) {

718  const size_t

hitrefidx = it->m_Ptr - hitref_firstptr;

719  const bool

alive = 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  TCoord

min_hit_len,

double

& min_idty,

744  TCoord

lmin = h->GetMin(where), lmax = h->GetMax(where);

746  if

(retain_overlap > 0) {

748  if

(overlap >= retain_overlap) {

749  return

make_pair(-1, 0);

753  if

(cmin <= lmin && lmax <= cmax) {

754  return

make_pair(-2, 0);

757  int

ldif = cmin - lmin, rdif = lmax - cmax;

758

reverse = 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);

766

h->Modify(rp = 2*where + 1, lmax = cmin - 1);

769  if

((*pnew_hit)->GetIdentity() < min_idty) {

771  return

make_pair((h->GetIdentity() < min_idty)? -2: rv, rp ^ reverse);

774  if

(h->GetIdentity() < min_idty) {

776  return

make_pair(cmax + 1, (2*where) ^ reverse);

778  return

make_pair(0, rp ^ reverse);

780  else if

(ldif > rdif) {

782  if

(lmin <= cmin && cmin <= lmax) {

783  if

(cmin == 0)

return

make_pair(-2, 0);

784

h->Modify(rp = 2*where + 1, lmax = cmin - 1);

787  if

(lmin <= cmax && cmax <= lmax) {

788

h->Modify(rp = 2*where, lmin = cmax + 1);

794  if

(lmin <= cmax && cmax <= lmax) {

795

h->Modify(rp = 2*where, lmin = cmax + 1);

798  if

(lmin <= cmin && cmin <= lmax) {

799  if

(cmin == 0)

return

make_pair(-2, 0);

800

h->Modify(rp = 2*where + 1, lmax = cmin - 1);

806  if

(1 + lmax - lmin < min_hit_len || h->GetIdentity() < min_idty) {

807  return

make_pair(-2, 0);

813  return

make_pair(rv, rp ^ reverse);

821  const bool

sstrand (lhs->GetSubjStrand());

822  if

(sstrand != rhs->GetSubjStrand()) {

825  "Cannot merge hits: different strands"

);

828  const int

qgap ((!sstrand && where == 1)?

829

(

int

(lhs->GetQueryMin()) -

int

(rhs->GetQueryMax())):

830

(

int

(rhs->GetQueryMin()) -

int

(lhs->GetQueryMax())));

832  const int

sgap ((!sstrand && where == 0)?

833

(

int

(lhs->GetSubjMin()) -

int

(rhs->GetSubjMax())):

834

(

int

(rhs->GetSubjMin()) -

int

(lhs->GetSubjMax())));

836  const bool

bv1 (

abs

(qgap) == 1 &&

abs

(sgap) > 0);

837  const bool

bv2 (

abs

(sgap) == 1 &&

abs

(qgap) > 0);

848  if

(x_lhs.size() && x_rhs.size()) {

852

x_gap.assign(

abs

(sgap) - 1,

'I'

);

855

x_gap.assign(

abs

(qgap) - 1,

'D'

);

860  if

(where == 0 || sstrand) {

861

xcript = x_lhs + x_gap + x_rhs;

865

xcript = x_rhs + x_gap + x_lhs;

869

rv.

Reset

(

new THit

(h->GetId(0), h->GetStart(0), h->GetStrand(0),

870

h->GetId(1), h->GetStart(1), h->GetStrand(1),

876

rv->SetId(0, lhs->GetId(0));

877

rv->SetId(1, lhs->GetId(1));

879

lhs->GetQueryStart(), rhs->GetQueryStop(),

880

lhs->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  typename

THitRefs::iterator ii_beg,

921  typename

THitRefs::iterator ii_end,

923  const double

& maxlenfr,

927  typename

THitComparator::ESortCriterion sort_type (

929

THitComparator::eQueryMinScore:

930

THitComparator::eSubjMinScore);

931

THitComparator sorter (sort_type);

932

stable_sort(ii_beg, ii_end, sorter);

934  typedef typename

THitRefs::iterator TIter;

936  for

(TIter ii = ii_beg; ii != ii_end; ++ii) {

939  const TCoord

cmax = (*ii)->GetMax(where);

941  for

(++jj; jj != ii_end && cmax >= cmin; ++jj) {

942

cmin = (*jj)->GetMin(where);

945  if

(cmax + 1 == cmin) {

948  bool

can_merge =

true

;

949  const Uint1

where2 (where ^ 1);

950  const bool

subj_strand ((*ii)->GetSubjStrand());

952

can_merge = (*ii)->GetMax(where2) < (*jj)->GetMin(where2);

955

can_merge = (*jj)->GetMax(where2) < (*ii)->GetMin(where2);

967

he_ii.

m_Ptr

= &(*ii);

968

he_ii.

m_X

= (*ii)->GetStop(where2) + 1;

971

he_jj.

m_Ptr

= &(*jj);

972

he_jj.

m_X

= (*jj)->GetStart(where2) - 1;

977

he_jj.

m_Ptr

= &(*ii);

978

he_jj.

m_X

= (*ii)->GetStop(where2) - 1;

981

he_ii.

m_Ptr

= &(*jj);

982

he_ii.

m_X

= (*jj)->GetStart(where2) + 1;

989

= size_t(maxlenfr *

min

((*ii)->GetLength(),

993  for

(

THitEndsIter

ii_lcl = ii0; ii_lcl != ii1; ++ii_lcl) {

995  const THitRef

& h = *(ii_lcl->m_Ptr);

997  TCoord

cmin_lcl (h->GetMin(where2));

998  if

(cmin_lcl < he_ii.

m_X

) cmin_lcl = he_ii.

m_X

;

1000  TCoord

cmax_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  typename

TIterMap::iterator imi = m.

find

(ii);

1015  THitRef

lhs (imi == m.

end

()? *ii: imi->second);

1033  typename

THitRefs::iterator ii_end,

1035  const double

& maxlenfr,

1038  typedef typename

THitRefs::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  typename

TIterMap::iterator imi = m.find(ii);

1048  THitRef

hr (imi == m.end()? *ii: imi->second);

1050

pout->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