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

NCBI C++ ToolKit: src/algo/cobalt/unit_test/clusterer_unit_test.cpp Source File

51 #define NCBI_BOOST_NO_AUTO_TEST_MAIN 57 #ifndef SKIP_DOXYGEN_PROCESSING 68

BOOST_CHECK_EQUAL((

int

)cluster.

size

(), 0);

84

BOOST_CHECK_EQUAL((

int

)clusterer.

GetClusters

().size(), 0);

91

BOOST_CHECK_EQUAL((

int

)clusterer.

GetClusters

().size(), 1);

97

dmat(1, 0) = dmat(0, 1);

102

BOOST_CHECK_EQUAL((

int

)clusterer.

GetClusters

().size(), 1);

106

BOOST_CHECK_EQUAL((

int

)clusterer.

GetClusters

().size(), 2);

113

dmat(0, 1) = dmat(1, 0) = 0.1;

114

dmat(0, 2) = dmat(2, 0) = 0.3;

115

dmat(0, 3) = dmat(3, 0) = 0.2;

116

dmat(1, 2) = dmat(2, 1) = 0.5;

117

dmat(1, 3) = dmat(3, 1) = 0.2;

118

dmat(2, 3) = dmat(3, 2) = 0.1;

121

BOOST_CHECK((

int

)clusterer.

GetClusters

().size() > 1);

155

vector<double> dists;

156  while

(!istr.eof()) {

157  double val

= DBL_MAX;

160  if

(

val

!= DBL_MAX) {

161

dists.push_back(

val

);

165  int

num_elements = (

int

)sqrt((

double

)dists.size());

168

BOOST_REQUIRE_EQUAL(num_elements * num_elements, (

int

)dists.size());

170

dmat.

Resize

(num_elements, num_elements, 0.0);

171  for

(

int i

=0;

i

< num_elements;

i

++) {

172  for

(

int

j=0;j < num_elements;j++) {

173

dmat(

i

, j) = dists[

i

*num_elements + j];

185  int id

= node->

GetValue

().GetId();

186

BOOST_REQUIRE(

id

< (

int

)elems.size());

189

BOOST_REQUIRE(!elems[

id

]);

206

BOOST_REQUIRE(

tree

);

207

BOOST_REQUIRE(cluster.

size

() > 0);

210  int

max_elem = cluster[0];

211  for

(

int i

=1;

i

< (

int

)cluster.

size

();

i

++) {

212  if

(cluster[

i

] > max_elem) {

213

max_elem = cluster[

i

];

219

vector<bool> elems(max_elem + 1,

true

);

221

elems[*elem] =

false

;

227  ITERATE

(vector<bool>, it, elems) {

240  const string

& ref_filename =

""

)

242

BOOST_REQUIRE(clusterer.

GetClusters

().size() > 0);

244

vector<bool> check_elems(num_elems,

false

);

247  const

vector<TPhyTreeNode*>& trees = clusterer.

GetTrees

();

250  int

num_elements = 0;

254

BOOST_REQUIRE(*elem < num_elems);

257

BOOST_REQUIRE(!check_elems[*elem]);

258

check_elems[*elem] =

true

;

265  ITERATE

(vector<bool>, it, check_elems) {

271

BOOST_REQUIRE_EQUAL(clusters.size(), trees.size());

274  for

(

size_t i

=0;

i

< clusters.size();

i

++) {

279  if

(!ref_filename.empty()) {

285

BOOST_REQUIRE(ref_istr);

286

vector<int> ref_clust_elems;

287  int

ref_num_clusters = 0;

288  int

ref_num_elems = 0;

292  char

* buff =

new char

[256];

293  while

(ref_istr.peek() == (

int

)

'#'

) {

294

ref_istr.getline(buff, 256);

299

ref_istr >> ref_num_clusters;

301

BOOST_REQUIRE_EQUAL((

int

)clusters.size(), ref_num_clusters);

305  for

(

int i

=0;

i

< ref_num_clusters;

i

++) {

307

BOOST_REQUIRE(!ref_istr.eof());

310

ref_istr >> ref_size;

311

BOOST_REQUIRE_EQUAL((

int

)clusters[ind++].

size

(), ref_size);

313

ref_num_elems += ref_size;

317  bool

zero_found =

false

;

318  for

(

int i

=0;

i

< ref_num_elems;

i

++) {

320

BOOST_REQUIRE(!ref_istr.eof());

323

ref_istr >> ref_elem;

325

ref_clust_elems.push_back(ref_elem);

329

BOOST_REQUIRE((!zero_found && ref_elem >= 0)

330

|| (zero_found && ref_elem > 0));

342

BOOST_REQUIRE_EQUAL(*elem, ref_clust_elems[ind++]);

354  const int

num_elements = 5;

368  const int

num_elements = 1;

385  const int

num_elements = 2;

403  const int

num_elements = 2;

426  const int

num_elements = (

int

)dmat.

GetCols

();

429  const double

max_distance = 0.8;

432  for

(

size_t i

=0;

i

< dmat.

GetCols

() - 1;

i

++) {

433  for

(

size_t

j=

i

+1;j < dmat.

GetCols

();j++) {

434  if

(dmat(

i

, j) < max_distance) {

435

links->

AddLink

((

int

)

i

, (

int

)j, dmat(

i

, j));

450

pre_clusters[0].AddElement(0);

451

pre_clusters[0].AddElement(1);

452

pre_clusters[0].AddElement(2);

453

pre_clusters[1].AddElement(3);

470

BOOST_REQUIRE_EQUAL(clusters.size(), 3u);

476  int

elem = *clust->begin();

477  if

(elem == 5 || elem == 3) {

478

BOOST_REQUIRE_EQUAL(clust->size(), 1u);

479

BOOST_REQUIRE(!presence[elem]);

480

presence[elem] =

true

;

483

BOOST_REQUIRE_EQUAL(clust->size(), 4u);

485

BOOST_REQUIRE(!presence[*it]);

486

presence[*it] =

true

;

491  ITERATE

(vector<bool>, it, presence) {

500  const int

kNumElements = 10;

508

unique_ptr<CClusterer> clusterer(

new CClusterer

(links));

509

clusterer->SetReportSingletons(

false

);

514

clusters.swap(clusterer->SetClusters());

524

clusterer->SetClusters().swap(clusters);

531

vector<size_t> sizes(kNumElements, 0);

541

vector< set<int> > reference(kNumElements);

542

reference[0].insert(0);

543

reference[0].insert(1);

544

reference[0].insert(2);

546

reference[3].insert(3);

547

reference[4].insert(4);

549

reference[5].insert(5);

550

reference[5].insert(6);

552

reference[7].insert(7);

553

reference[8].insert(8);

554

reference[9].insert(9);

558  sort

(cluster->begin(), cluster->end());

559  int

cl_index = *cluster->begin();

560

BOOST_REQUIRE_EQUAL(cluster->size(), sizes[cl_index]);

563

BOOST_REQUIRE(it != reference[cl_index].end());

BOOST_AUTO_TEST_SUITE_END() static int s_GetSegmentFlags(const CBioseq &bioseq)

Exceptions for CClusterer class.

int FindCenterElement(const TDistMatrix &dmatrix) const

Find element that is closest to the center of the cluster.

int GetPrototype(void) const

Get cluster prototype.

size_t size(void) const

Get cluster size.

Interface for CClusterer class used for clustering any type of data based on distance matrix.

void GetTrees(vector< TPhyTreeNode * > &trees) const

Get list of trees for clusters.

const TSingleCluster & GetSingleCluster(size_t index) const

Get list of elements of a specified cluster.

void SetMakeTrees(bool trees)

Set make cluster tree/dendrogram option.

void SetDistMatrix(const TDistMatrix &dmat)

Set new distance matrix.

const TDistMatrix & GetDistMatrix(void) const

Get distance matrix.

void SetLinks(CRef< CLinks > links)

Set distance links.

void Run(void)

Cluster elements.

const TClusters & GetClusters(void) const

Get clusters.

void ComputeClusters(double max_diam, EDistMethod dist_method=eCompleteLinkage, bool do_trees=true, double infinity=-1.0)

Compute clusters.

vector< TSingleCluster > TClusters

TClusters & SetClusters(void)

Set clusters.

void PurgeDistMatrix(void)

Delete distance matrix.

void GetClusterDistMatrix(int index, TDistMatrix &mat) const

Get distance matrix for elements of a selected cluster.

Set of edges with weights between nodes represented by zero-based positive integers.

void AddLink(int first, int second, double weight)

Add link.

Uint4 GetNumElements(void) const

Get number of nodes.

void Resize(size_t i, size_t j, T val=T())

resize this matrix, filling the empty cells with a known value

size_t GetRows() const

get the number of rows in this matrix

size_t GetCols() const

get the number of columns in this matrix

definition of a Culling tree

const_iterator find(const key_type &key) const

static void s_ReadDistMatrix(const string &filename, CClusterer::TDistMatrix &dmat)

Read distance matrix from file.

BOOST_AUTO_TEST_CASE(TestSingleCluster)

static void s_TestClusterTree(const CClusterer::TSingleCluster &cluster, const TPhyTreeNode *tree)

static void s_TestTree(vector< bool > &elems, const TPhyTreeNode *node)

static void s_TestClustersAndTrees(int num_elems, CClusterer &clusterer, const string &ref_filename="")

Check clusters.

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

void Reset(void)

Reset reference object.

IO_PREFIX::ifstream CNcbiIfstream

Portable alias for ifstream.

TNodeList_CI SubNodeBegin(void) const

Return first const iterator on subnode list.

TNodeList::const_iterator TNodeList_CI

bool IsLeaf() const

Report whether this is a leaf node.

TNodeList_CI SubNodeEnd(void) const

Return last const iterator on subnode list.

const TValue & GetValue(void) const

Return node's value.

unsigned int

A callback function used to compare two keys in a database.

constexpr auto sort(_Init &&init)

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

BOOST_AUTO_TEST_SUITE(psiblast_iteration)

Utility stuff for more convenient using of Boost.Test library.


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