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/density__map_8hpp_source.html below:

NCBI C++ ToolKit: include/gui/objutils/density_map.hpp Source File

1 #ifndef GUI_UTILS___DENSITY_GRAPH__HPP 2 #define GUI_UTILS___DENSITY_GRAPH__HPP 57 template

<

class

Type>

67 template

<

class

Type>

85 template

<

class

Type>

91  return

left > right ? left : right;

101 template

<

class

Type>

107  return

left < right ? left : right;

120 template

<

typename

CntType>

167 template

<

typename

CntType>

170  return TSeqPos

(GetPosition() * m_Window + 0.5) + m_Start;

173 template

<

typename

CntType>

176  return TSeqPos

((GetPosition() + GetRunLength()) * m_Window + 0.5) + m_Start;

180 template

<

typename

CntType>

183  return TSeqPos

(GetRunLength() * m_Window + 0.5);

187 template

<

typename

CntType>

191  if

(m_Pos >= 0 && m_Pos < m_Bins.size()) {

192

CntType this_value = m_Bins[m_Pos];

195  i

< m_Bins.size() && m_Bins[

i

] == this_value;

203 template

<

typename

CntType>

206

m_Pos += m_RunLength;

207

m_RunLength = x_CalcRunLength();

221 template

<

typename

CntType>

227  typedef typename

container_type::iterator

iterator

;

234  CDensityMap

(

const

objects::CBioseq_Handle& handle,

double

window = 1,

244

CntType score = 1,

bool

expand =

false

);

252

objects::SAnnotSelector sel);

256

objects::SAnnotSelector sel);

260  const

objects::CSeq_annot& seq_annot);

305

objects::SAnnotSelector sel,

306

vector<TSeqPos>& density);

352 template

<

typename

CntType>

358

: m_Range(start, stop)

363

, m_Bins(x_CalcNbins(), def)

364

, m_AccumFunc(func ? func : new

plus_func

<CntType>)

369 template

<

typename

CntType>

374

: m_Range(0, handle.GetSeqVector().

size

())

379

, m_Bins(x_CalcNbins(), def)

380

, m_AccumFunc(func ? func : new

plus_func

<CntType>)

385 template

<

typename

CntType>

387

: m_Range(

map

.m_Range)

388

, m_Window(

map

.m_Window)

389

, m_DefVal(

map

.m_DefVal)

392

, m_Bins(

map

.m_Bins)

393

, m_AccumFunc(

map

.m_AccumFunc->clone())

398 template

<

typename

CntType>

405

m_Range =

map

.m_Range;

406

m_Window =

map

.m_Window;

407

m_DefVal =

map

.m_DefVal;

410

m_Bins =

map

.m_Bins;

411

m_AccumFunc.reset(

map

.m_AccumFunc->clone());

416 template

<

typename

CntType>

421

m_Bins.resize(x_CalcNbins(), m_DefVal);

426 template

<

typename

CntType>

435

ExtendTo( range.

GetTo

());

438  TSeqRange

usable_range(m_Range.IntersectionWith(range));

439  if

(usable_range.

Empty

()) {

443

m_Max =

max

(m_Max, score);

444

m_Min =

min

(m_Min, score);

446  size_t

begin_bin = x_BinN(usable_range.

GetFrom

());

447  size_t

end_bin = begin_bin;

448  if

(m_Window > 1.0) {

449

end_bin = x_BinN(usable_range.

GetTo

()) + 1;

451

end_bin = x_BinN(usable_range.

GetToOpen

());

453

end_bin =

min

(end_bin, m_Bins.size());

455  for

(

size_t i

= begin_bin;

i

< end_bin ; ++

i

) {

456

CntType& new_val = m_Bins[

i

];

457

new_val = (*m_AccumFunc)(new_val, score);

458

m_Max =

max

(m_Max, new_val);

459

m_Min =

min

(m_Min, new_val);

464 template

<

typename

CntType>

466

CntType score,

bool

expand)

469

ExtendTo( ranges.

GetTo

());

473  if

(ranges.

Empty

()) {

476

m_Max =

max

(m_Max, score);

477

m_Min =

min

(m_Min, score);

479  size_t

previous_end_bin = 0;

481  size_t

begin_bin = x_BinN(range_it->GetFrom());

482  size_t

end_bin = begin_bin;

483  if

(m_Window > 1.0) {

484

end_bin = x_BinN(range_it->GetTo()) + 1;

486

end_bin = x_BinN(range_it->GetToOpen());

489

begin_bin =

max

(begin_bin, previous_end_bin);

490

end_bin =

min

(end_bin, m_Bins.size());

491

previous_end_bin = end_bin;

492  for

(

size_t i

= begin_bin;

i

< end_bin ; ++

i

) {

493

CntType& new_val = m_Bins[

i

];

494

new_val = (*m_AccumFunc)(new_val, score);

495

m_Max =

max

(m_Max, new_val);

496

m_Min =

min

(m_Min, new_val);

502 template

<

typename

CntType>

506  for

( objects::CSeq_loc_CI it(loc); it; ++it) {

507

ranges += it.GetRange();

509

AddRanges(ranges, 1,

false

);

514 template

<

typename

CntType>

517  return

AddLocation(feature.GetLocation());

521 template

<

typename

CntType>

523  const

objects::CBioseq_Handle& handle,

524

objects::SAnnotSelector sel)

530 

sel.SetSortOrder(objects::SAnnotSelector::eSortOrder_None);

534

objects::CFeat_CI feat_iter(handle.GetScope(), *loc, sel);

535  if

(feat_iter.GetSize() == 0) {

539  for

(; feat_iter; ++feat_iter) {

540

objects::CMappedFeat feat = *feat_iter;

543

AddLocation(feat.GetLocation());

549 template

<

typename

CntType>

551  const

objects::CBioseq_Handle& handle,

552

objects::SAnnotSelector sel)

558

objects::CAlign_CI align_iter(handle, range, sel);

560  for

(

size_t

ai = 0; align_iter; ++align_iter, ++ai) {

561  const

objects::CSeq_align& align = *align_iter;

563  if

(! align.CanGetDim()) {

564  _TRACE

(

"Dimension not set. "

<< ai);

567  int

dim = align.GetDim();

569  _TRACE

(

"Dimension not 2. "

<< ai);

582  if

(align.GetSegs().IsStd()) {

583  _TRACE

(ai <<

": Std seg"

);

585

= align.CreateDensegFromStdseg();

586

aln_map =

new

objects::CAlnMap( ds_align->GetSegs().GetDenseg());

588

}

else if

(align.GetSegs().IsDenseg()) {

589

aln_map =

new

objects::CAlnMap(align.GetSegs().GetDenseg());

590  _TRACE

(ai <<

": Dense seg"

);

595  string

all_ids =

": "

;

598

all_ids += aln_map->GetSeqId(di).AsFastaString() +

", "

;

603  TSeqRange

range_final(aln_map->GetSeqStart(0), aln_map->GetSeqStop(0));

604

AddRange(range_final, 1,

false

);

613 template

<

typename

CntType>

615  const

objects::CBioseq_Handle& handle,

616  const

objects::CSeq_annot& seq_annot)

620

objects::SAnnotSelector sel;

621

objects::CSeq_annot_Handle sah

622

= handle.GetScope().GetSeq_annotHandle(seq_annot);

623

sel.SetLimitSeqAnnot(sah)

624

.SetSortOrder(objects::SAnnotSelector::eSortOrder_None);

627

objects::CAlign_CI align_iter(handle, range, sel);

629

objects::CAlnMix mix(handle.GetScope());

630  for

(

int

ai = 0; align_iter; ++align_iter, ++ai) {

631  const

objects::CSeq_align& align = *align_iter;

634  if

(! align.CanGetDim() || align.GetDim() != 2) {

641  if

(align.GetSegs().IsStd()) {

646

align.CreateDensegFromStdseg();

648  new

objects::CAlnMap(ds_align->GetSegs().GetDenseg());

650  string

all_ids =

": "

;

652

di < aln_map->GetNumRows(); ++di) {

653

all_ids += aln_map->GetSeqId(di).AsFastaString() +

", "

;

657

}

catch

(

const

objects::CSeqalignException&

) {

661

}

else if

(align.GetSegs().IsDenseg()) {

664

aln_map =

new

objects::CAlnMap(mix.GetDenseg());

666  if

(aln_map->GetNumSegs() < 2)

668  _TRACE

(ai <<

": Dense seg"

);

673

objects::CAlnMap::TNumrow

row

= 0;

674  for

(

row

= 0;

row

!= aln_map->GetNumRows(); ++

row

) {

675  if

( handle.IsSynonym(aln_map->GetSeqId(

row

)) ) {

676

aln_map->SetAnchor(

row

);

680  if

(

row

== aln_map->GetNumRows()) {

732 template

<

typename

CntType>

736

objects::SAnnotSelector sel,

737

vector<TSeqPos>& density)

740  if

(stop == start && stop == 0) {

741

objects::CSeqVector vec = handle.GetSeqVector();

746

objects::CFeat_CI feat_iter(handle.GetScope(),

747

*handle.GetRangeSeq_loc(start, stop),

749  if

(feat_iter.GetSize() == 0) {

753  size_t

bins = (stop - start) / window;

754  if

(bins * window < stop - start) {

758

density.resize(bins, 0);

764

deque<objects::CMappedFeat> feats;

767  TSeqPos

bin_start = start + bin_count * window;

768  TSeqPos

bin_stop = bin_start + window;

772

objects::CMappedFeat feat = *feat_iter;

773  TSeqRange

range = feat.GetLocation().GetTotalRange();

775  while

(range.

GetFrom

() < bin_stop) {

776

feats.push_back(feat);

783

range = feat.GetLocation().GetTotalRange();

788  while

(feats.size()) {

789

objects::CMappedFeat& feat = feats.front();

790  TSeqRange

range = feat.GetLocation().GetTotalRange();

792  if

(range.

GetTo

() < bin_start) {

800

*bin_iter = feats.size();

801

max_val =

max

(*bin_iter, max_val);

Run iterator. iterate through runs of equal values in the bins.

class CDensityMap generates a low-resolution view of a set of features.

position_type GetTo() const

TThisType & IntersectWith(const TRange &r)

Include a standard set of the NCBI C++ Toolkit most basic headers.

unsigned int TSeqPos

Type for sequence locations and lengths.

#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.

virtual ~binary_functor()

void ExtendTo(TSeqPos stop)

extend our density map to cover the sequence position stop.

virtual Type operator()(const Type &left, const Type &right) const

void SetMin(const CntType &min)

CntType AddAlignments(const objects::CBioseq_Handle &handle, const objects::CSeq_annot &seq_annot)

All alignments in a given annotation on this bioseq within the range of this.

const accum_functor * GetAccum() const

CntType m_Min

Smallest count in a bin.

CntType m_DefVal

Default value.

vector< size_t > TDataPoints

CntType m_Max

maximum Count accumulated in the bins so far.

const_iterator end() const

TSeqPos GetSeqPosition() const

Type operator()(const Type &left, const Type &right) const

position_type m_RunLength

virtual binary_functor< Type > * clone() const

container_type::const_iterator const_iterator

CntType operator[](typename container_type::size_type n) const

TSeqRange m_Range

closed range on a sequence this covers.

const_iterator begin() const

void SetMax(const CntType &max)

container_type::iterator iterator

runlen_iterator RunLenBegin() const

size_t x_BinN(TSeqPos p)

convert from sequence coords to a bin number.

static TSeqPos GetDensityMap(const objects::CBioseq_Handle &handle, TSeqPos start, TSeqPos stop, TSeqPos window, objects::SAnnotSelector sel, vector< TSeqPos > &density)

OLD static method.

bool operator==(const CDenMapRunIterator< CntType > &rhs) const

TSeqPos GetSeqRunEndPosition() const

CntType AddAlignments(const objects::CBioseq_Handle &handle, objects::SAnnotSelector sel)

All alignments on this bioseq selected by sel in the range of this.

virtual void AddRanges(CRangeCollection< TSeqPos > ranges, CntType score=1, bool expand=false)

position_type GetRunLength() const

CDenMapRunIterator(position_type here, const container_type &bins, TSeqPos start, double window)

double m_Window

coordinates per bin.

const container_type & m_Bins

size_t x_CalcNbins()

given the range and window size, how many bins should there be?

CDensityMap< CntType > & operator=(const CDensityMap< CntType > &map)

CDenMapRunIterator< CntType > runlen_iterator

CDensityMap(TSeqPos start=0, TSeqPos stop=0, double window=1, accum_functor *func=NULL, CntType def=(CntType) 0)

vector< CntType > container_type

virtual binary_functor< Type > * clone() const =0

virtual void AddRange(TSeqRange range, CntType score=1, bool expand=false)

runlen_iterator RunLenIterator(typename container_type::size_type n) const

CntType GetDefVal() const

CDensityMap(const CDensityMap< CntType > &map)

CntType & operator[](typename container_type::size_type n)

CntType AddLocation(const objects::CSeq_loc &loc)

virtual Type operator()(const Type &left, const Type &right) const

CntType AddFeature(const objects::CSeq_feat &feature)

vector< CntType > container_type

position_type x_CalcRunLength() const

CDensityMap(const objects::CBioseq_Handle &handle, double window=1, accum_functor *func=NULL, CntType def=(CntType) 0)

CntType AddFeatures(const objects::CBioseq_Handle &handle, objects::SAnnotSelector sel)

All features on this bioseq selected by sel in the range of this.

container_type m_Bins

Where we actually keep the accumulated counts/scores/whatever.

TSeqPos GetSeqRunLength() const

TSeqRange GetRange() const

virtual binary_functor< Type > * clone() const

DECLARE_OPERATOR_BOOL(Valid())

unique_ptr< accum_functor > m_AccumFunc

position_type GetPosition() const

binary_functor< CntType > accum_functor

virtual Type operator()(const Type &left, const Type &right) const =0

virtual binary_functor< Type > * clone() const

container_type::size_type position_type

TSeqPos GetStop(const CSeq_loc &loc, CScope *scope, ESeqLocExtremes ext=eExtreme_Positional)

If only one CBioseq is represented by CSeq_loc, returns the position at the stop of the location.

TSeqPos GetStart(const CSeq_loc &loc, CScope *scope, ESeqLocExtremes ext=eExtreme_Positional)

If only one CBioseq is represented by CSeq_loc, returns the position at the start of the location.

position_type GetToOpen(void) const

CRange< TSeqPos > TSeqRange

typedefs for sequence ranges

#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.

const struct ncbi::grid::netcache::search::fields::SIZE size

#define row(bind, expected)

TEMPLATE binary functor base struct.


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