libsequence  1.9.5
PolyTableSliceTest.cc
Go to the documentation of this file.
1 #include <boost/test/unit_test.hpp>
3 #include <Sequence/SimData.hpp>
4 #include <iostream>
6 #include <vector>
7 #include <utility>
8 #include <string>
9 
10 using namespace std;
11 using namespace Sequence;
12 
13 BOOST_AUTO_TEST_SUITE(PolyTableSliceTest)
14 
15 BOOST_AUTO_TEST_CASE( lastwindows1 )
16 {
17  vector<pair<double,string> > data;
18  for(double i = 0.05 ; i < 0.9 ; i += 0.01 )
19  data.push_back(make_pair(i,string("001000")));
20 
21  SimData d(data.begin(),data.end());
22  PolyTableSlice<SimData> w(d.sbegin(),d.send(),0.1,0.001,0.,1.);
23  unsigned nwindows = unsigned(1./0.001);
24  BOOST_REQUIRE_EQUAL(w.size(),nwindows);
25 }
26 
27 BOOST_AUTO_TEST_CASE( nwindows1 )
28 {
29  vector<pair<double,string> > data;
30  for(double i = 0.05 ; i < 0.9 ; i += 0.01 )
31  data.push_back(make_pair(i,string("001000")));
32 
33  SimData d(data.begin(),data.end());
34  PolyTableSlice<SimData> w(d.sbegin(),d.send(),64);
35  unsigned ewindows = std::ceil(double(d.numsites())/64);
36  BOOST_REQUIRE_EQUAL(w.size(),std::ceil(double(d.numsites())/double(ewindows)));
37  for(auto i = w.cbegin();i!=w.cend();++i)
38  {
39  auto wi = w.get_slice(i);
40  BOOST_CHECK( wi.empty() == false );
41  }
42 }
43 
44 BOOST_AUTO_TEST_CASE( nwindows2 )
45 {
46  //Make 10x as many SNPs
47  vector<pair<double,string> > data;
48  for(double i = 0.05 ; i < 0.9 ; i += 0.001 )
49  data.push_back(make_pair(i,string("001000")));
50 
51  SimData d(data.begin(),data.end());
52  PolyTableSlice<SimData> w(d.sbegin(),d.send(),64);
53  unsigned ewindows = std::ceil(double(d.numsites())/64);
54  BOOST_REQUIRE_EQUAL(w.size(),std::ceil(double(d.numsites())/double(ewindows)));
55  for(auto i = w.cbegin();i!=w.cend();++i)
56  {
57  auto wi = w.get_slice(i);
58  BOOST_CHECK( wi.empty() == false );
59  }
60 }
61 
62 
63 BOOST_AUTO_TEST_SUITE_END()
STL namespace.
The namespace in which this library resides.
Declaration of Sequence::SimData, a class representing polymorphism data from coalescent simulations ...
Data from coalescent simulations.
A container class for "sliding windows" along a polymorphism table.