libsequence  1.9.5
polySiteVectorTest.cc
Go to the documentation of this file.
3 #include <Sequence/PolySites.hpp>
5 #include <boost/test/unit_test.hpp>
6 #include <cstdio>
7 #include <cstdlib>
8 #include <cctype>
9 #include <iterator>
10 #include <iostream>
11 #include <algorithm>
12 #include <functional>
13 
14 using psite = Sequence::polymorphicSite;
15 using Ptable = Sequence::polySiteVector;
16 
17 BOOST_AUTO_TEST_SUITE(PolySiteVectorTest)
18 
19 BOOST_AUTO_TEST_CASE( ptable_remove_1 )
20 {
21 
22  Ptable t = { psite(1.,"AAGC"),
23  psite(2.,"ACZA") }; //site 2 has a non-DNA character
24 
25  BOOST_CHECK_EQUAL( t.size(), 2 );
26 
27  t.erase( std::remove_if( t.begin(),
28  t.end(),
29  []( const psite & __p ) {
30  return std::find_if(__p.second.begin(),
31  __p.second.end(),
33  != __p.second.end();
34  } ),
35  t.end() );
36  BOOST_CHECK_EQUAL( t.size(), 1 );
37 }
38 
39 BOOST_AUTO_TEST_CASE( ptable_make_from_polytable )
40 {
41  using psite = Sequence::polymorphicSite;
42  Ptable t = { psite(1.,"AAGC"),
43  psite(2.,"ACAA") };
44 
45  Sequence::PolySites ps(t.begin(),t.end());
46 
47  BOOST_REQUIRE( std::distance(t.begin(),t.end()) ==
48  std::distance(ps.sbegin(),ps.send()) );
49 
50  auto t_i = t.begin();
51  auto ps_i = ps.sbegin();
52 
53  while( t_i < t.end() )
54  {
55  BOOST_CHECK_EQUAL(t_i->first,ps_i->first);
56  BOOST_CHECK_EQUAL(t_i->second,ps_i->second);
57  ++t_i;
58  ++ps_i;
59  }
60 
61  Ptable t2(Sequence::make_polySiteVector(ps));
62 
63  BOOST_REQUIRE( t == t2 );
64 }
65 BOOST_AUTO_TEST_SUITE_END()
polySiteVector make_polySiteVector(const Sequence::PolyTable &data) __attribute__((deprecated))
Polymorphism tables for sequence data.
Definition: PolySites.hpp:33
This functor can be used to determine if a range contains characters that the SNP analysis routines i...
std::vector< polymorphicSite > polySiteVector
Site-major variation tables in ASCII format.
Sequence::PolySites, generates polymorphism tables from data.
std::pair< double, std::string > polymorphicSite