Sequence::PolyTable Class Reference
[Classes Related to Polymorphism tables]

The base class for polymorphism tables. More...

#include <Sequence/PolyTable.hpp>

Inheritance diagram for Sequence::PolyTable:

Sequence::PolySites Sequence::SimData Sequence::SimpleSNP

List of all members.

Public Types

typedef std::string & reference
typedef const std::string & const_reference
typedef std::vector
< std::string >::size_type 
size_type
typedef std::vector
< std::string >::iterator 
data_iterator
typedef std::vector
< std::string >
::const_iterator 
const_data_iterator
typedef std::vector< double >
::iterator 
pos_iterator
typedef std::vector< double >
::const_iterator 
const_pos_iterator
typedef
Sequence::polySiteVector::const_iterator 
const_site_iterator

Public Member Functions

data_iterator begin ()
data_iterator end ()
const_data_iterator begin () const
const_data_iterator end () const
pos_iterator pbegin ()
pos_iterator pend ()
const_pos_iterator pbegin () const
const_pos_iterator pend () const
const_site_iterator sbegin () const
const_site_iterator send () const
 PolyTable (const size_t &nsam=0, const size_t nsnps=0)
 PolyTable (PolyTable::const_site_iterator beg, PolyTable::const_site_iterator end)
std::vector< double > GetPositions (void) const
std::vector< std::string > GetData (void) const
virtual void ApplyFreqFilter (unsigned mincount, bool haveOutgroup=false, unsigned outgroup=0)
virtual void RemoveMultiHits (bool skipOutgroup=false, unsigned outgroup=0)
virtual void RemoveMissing (bool skipOutgroup=false, unsigned outgroup=0)
virtual void RemoveAmbiguous (bool skipOutgroup=false, unsigned outgroup=0)
virtual void Binary (bool haveOutgroup=false, unsigned outgroup=0, bool strictInfSites=true)
virtual bool operator== (const PolyTable &rhs) const
virtual bool operator!= (const PolyTable &rhs) const
 operator Sequence::polySiteVector () const
const_reference operator[] (const size_type &i) const
reference operator[] (const size_type &i)
bool empty () const
bool assign (PolyTable::const_site_iterator beg, PolyTable::const_site_iterator end)
template<typename numeric_type, typename string_type>
bool assign (const numeric_type *_positions, const size_t &_num_positions, const string_type *_data, const size_t &_num_individuals)
size_type size (void) const
double position (const std::vector< double >::size_type &i) const
unsigned numsites (void) const
virtual std::istream & read (std::istream &h)=0 throw (Sequence::badFormat,std::exception)
virtual std::ostream & print (std::ostream &h) const =0


Detailed Description

The base class for polymorphism tables.

This is a base class for dealing with polymorphism data. It has no real utility in and of itself, other than defining the interface to derived classes

Note:
Segregating site positions are stored as double rather than int. This is because they can be represented as int (for example, in the case of Sequence::PolySites). However, it is also reasonable that positions be described as falling along a continuous interval (as in the case of Sequence::SimData or Sequence::MS_Interface).
This class is case-insensitive. That is, your data can include the characters {A,a,G,g,C,c,T,t,N,n,-,0,1}, and still work with this library.

Definition at line 59 of file PolyTable.hpp.


Member Typedef Documentation

typedef std::vector<std::string>::iterator Sequence::PolyTable::data_iterator

non-const iterator to the data

Definition at line 86 of file PolyTable.hpp.

typedef std::vector<std::string>::const_iterator Sequence::PolyTable::const_data_iterator

const iterator to the data

Definition at line 90 of file PolyTable.hpp.

typedef std::vector<double>::iterator Sequence::PolyTable::pos_iterator

non-const iterator to the positions

Definition at line 94 of file PolyTable.hpp.

typedef std::vector<double>::const_iterator Sequence::PolyTable::const_pos_iterator

const iterator to the positions

Definition at line 98 of file PolyTable.hpp.

typedef Sequence::polySiteVector::const_iterator Sequence::PolyTable::const_site_iterator

Const iterator to segregating sites. The value type of this iterator is const std::pair<double,std::string>, where the double is the position of the segregating site, and the string the list of states at the site. The first character in the string corresponds to the state of the first character in the PolyTable (i.e. (*this)[0]), etc.

Examples:
PolyTableIterators.cc.

Definition at line 107 of file PolyTable.hpp.


Constructor & Destructor Documentation

Sequence::PolyTable::PolyTable ( const size_t &  nsam = 0,
const size_t  nsnps = 0 
) [explicit]

Default constructor

Parameters:
nsam when non-zero, the table is allocated to contain a vector of nsam strings, each of length nsnps. Each string is filled with a blank space (the ' ' character).
nsps when non-zero, the table is allocated to contain nsnps position (each with position 0)

Definition at line 37 of file PolyTable.cc.


Member Function Documentation

PolyTable::data_iterator Sequence::PolyTable::begin (  ) 

Returns:
an iterator pointing to the beginning of the std::vector<string> containing the data
Examples:
PolyTableIterators.cc.

Definition at line 153 of file PolyTable.cc.

PolyTable::data_iterator Sequence::PolyTable::end (  ) 

Returns:
an iterator pointing to the end of the std::vector<string> containing the data
Examples:
PolyTableIterators.cc.

Definition at line 163 of file PolyTable.cc.

PolyTable::const_data_iterator Sequence::PolyTable::begin (  )  const

Returns:
a const iterator pointing to the beginning of the std::vector<string> containing the data

Definition at line 173 of file PolyTable.cc.

PolyTable::const_data_iterator Sequence::PolyTable::end (  )  const

Returns:
a const iterator pointing to the end of the std::vector<string> containing the data

Definition at line 182 of file PolyTable.cc.

PolyTable::pos_iterator Sequence::PolyTable::pbegin (  ) 

Returns:
an iterator pointing to the beginning of the list of positions
Examples:
PolyTableIterators.cc.

Definition at line 191 of file PolyTable.cc.

PolyTable::pos_iterator Sequence::PolyTable::pend (  ) 

Returns:
an iterator pointing to the end of the list of positions
Examples:
PolyTableIterators.cc.

Definition at line 200 of file PolyTable.cc.

PolyTable::const_pos_iterator Sequence::PolyTable::pbegin (  )  const

Returns:
a const iterator pointing to the beginning of the list of positions

Definition at line 209 of file PolyTable.cc.

PolyTable::const_pos_iterator Sequence::PolyTable::pend (  )  const

Returns:
a const iterator pointing to the beginning of the list of positions

Definition at line 217 of file PolyTable.cc.

PolyTable::const_site_iterator Sequence::PolyTable::sbegin (  )  const

Returns:
an object of type Sequence::PolyTable::const_site_iterator These iterators allow access to the columns (segregating sites) of polymorphism tables
Examples:
PolyTableIterators.cc, slidingWindow.cc, and slidingWindow2.cc.

Definition at line 226 of file PolyTable.cc.

PolyTable::const_site_iterator Sequence::PolyTable::send (  )  const

Returns:
an object of type Sequence::PolyTable::const_site_iterator These iterators allow access to the columns (segregating sites) of polymorphism tables
Examples:
PolyTableIterators.cc, slidingWindow.cc, and slidingWindow2.cc.

Definition at line 241 of file PolyTable.cc.

std::vector< double > Sequence::PolyTable::GetPositions ( void   )  const

Returns PolyTable::positions.

Definition at line 519 of file PolyTable.cc.

std::vector< std::string > Sequence::PolyTable::GetData ( void   )  const

Returns PolyTable::data, a vector of std::strings containing polymorphic sites. Assuming the vector is returned to a vector<string> called data, accessing data[i][j] accesses the j-th site of the i-th sequence

Definition at line 527 of file PolyTable.cc.

void Sequence::PolyTable::ApplyFreqFilter ( unsigned  mincount,
bool  haveOutgroup = false,
unsigned  outgroup = 0 
) [virtual]

go through the data and remove all positions where there is a variant at count (# of occurences in the sample) < minfreq

Parameters:
mincount minimum count of a variant in the data. Variants that occur < mincount times are thrown out.
haveOutgroup true if an outgroup is present in the data, false otherwise
outgroup the index in the data array containing the outgroup (if present)

Definition at line 256 of file PolyTable.cc.

void Sequence::PolyTable::RemoveMultiHits ( bool  skipOutgroup = false,
unsigned  outgroup = 0 
) [virtual]

go through the data and remove all the sites with more than 2 states segregating. By default, this routine also removes sites where there are 2 states segregating in the ingroup. and the outgroup (if present) has a 3rd state.

Parameters:
skipOutgroup default is false. If true, the character state of the outgroup is ignored.
outgroup the index of the outgroup in the data vector

Definition at line 321 of file PolyTable.cc.

void Sequence::PolyTable::RemoveMissing ( bool  skipOutgroup = false,
unsigned  outgroup = 0 
) [virtual]

go through the data and remove all the sites with missing data (the character N).

Parameters:
skipOutgroup default is false. If true, the character state of the outgroup is ignored.
outgroup the index of the outgroup in the data vector

Definition at line 360 of file PolyTable.cc.

void Sequence::PolyTable::RemoveAmbiguous ( bool  skipOutgroup = false,
unsigned  outgroup = 0 
) [virtual]

go through the data and remove all the sites with states other than {A,G,C,T,N,-}

Parameters:
skipOutgroup default is false. If true, the character state of the outgroup is ignored.
outgroup the index of the outgroup in the data vector

Definition at line 402 of file PolyTable.cc.

void Sequence::PolyTable::Binary ( bool  haveOutgroup = false,
unsigned  outgroup = 0,
bool  strictInfSites = true 
) [virtual]

Recode the polymorphism table in 0,1 (binary notation)

Parameters:
haveOutgroup use true if an outgroup is present, false otherwise
outgroup the index of the outgroup in the data vector used to construct the object
strictInfSites if true, throw out all sites with > 2 character states (including outgroup!)
Note:
if haveOutgroup== true, then 0 means an ancestral state and 1 a derived state in the resulting. /note If haveOutgroup == true, and there are sites with missing data in the outrgroup sequence, those sites are removed from the data, since its assumed you actually want to know ancestral/derived for every site

Reimplemented in Sequence::SimData.

Definition at line 440 of file PolyTable.cc.

Sequence::PolyTable::operator Sequence::polySiteVector (  )  const

allow (implicit) typecast of Sequence::PolyTable to Sequence::polySiteVector

Definition at line 140 of file PolyTable.cc.

const_reference Sequence::PolyTable::operator[] ( const size_type &  i  )  const [inline]

Return the i-th element of PolyTable::data.

Note:
range-checking done by assert()

Definition at line 150 of file PolyTable.hpp.

reference Sequence::PolyTable::operator[] ( const size_type &  i  )  [inline]

Return the i-th element of PolyTable::data.

Note:
range-checking done by assert()

Definition at line 160 of file PolyTable.hpp.

bool Sequence::PolyTable::empty (  )  const

Returns:
true if object contains no data, false otherwise
Examples:
slidingWindow.cc.

Definition at line 66 of file PolyTable.cc.

bool Sequence::PolyTable::assign ( PolyTable::const_site_iterator  beg,
PolyTable::const_site_iterator  end 
)

Assignment operation, allowing a range of polymorphic sites to be assigned to a polymorphism table. This exists mainly for two purposes. One is the ability to assign tables from "slices" of other tables. Second is to facilitate the writing of "sliding window" routines.

Returns:
true if the assignment was successful, false otherwise. The only case where false is returned is if the number of individuals at each site is not the constan from beg to end.

Definition at line 71 of file PolyTable.cc.

template<typename numeric_type, typename string_type>
bool Sequence::PolyTable::assign ( const numeric_type *  _positions,
const size_t &  _num_positions,
const string_type *  _data,
const size_t &  _num_individuals 
) [inline]

Assign SNP data to the polymorphism table from a vector/array.

Parameters:
_positions an array representing the positions of the SNPs
_num_positions the number of elements in _positions
_data an array containing the characters for each SNP in each individual
_num_individuals the number of elements in _data
Note:
If the length of the elements in _data does not equal _num_positions, the assignment will fail and you will be left with an empty polymorphism table. The following piece of code shows how to assign from a std::vector:
      Sequence::PolySites snpTable;
      std::vector<double> positions;
      std::vector<std::string> data;
      //fill positions and data...
      if ( snpTable.assign(&positions[0],positions.size(),&data[0],data.size()) == true )
      {
      //ok
      }
      else
      {
      //assignment failed for some reason...
      }

Definition at line 34 of file PolyTable.tcc.

size_type Sequence::PolyTable::size ( void   )  const [inline]

Return how many std::strings are stored in PolyTable::data.

Definition at line 214 of file PolyTable.hpp.

double Sequence::PolyTable::position ( const std::vector< double >::size_type &  i  )  const [inline]

Return the i-th position from the PolyTable::positions.

Note:
range-checking done by assert()

Definition at line 223 of file PolyTable.hpp.

unsigned Sequence::PolyTable::numsites ( void   )  const [inline]

Return how many positions are stored in PolyTable::positions

Examples:
bottleneck.cc.

Definition at line 233 of file PolyTable.hpp.

virtual std::istream& Sequence::PolyTable::read ( std::istream &  h  )  throw (Sequence::badFormat,std::exception) [pure virtual]

read is a pure virtual function. Calls to istream & operator>> (istream & s, PolyTable & c) act via this routine, which must be defined in all derived classes

Implemented in Sequence::PolySites, Sequence::SimData, and Sequence::SimpleSNP.

virtual std::ostream& Sequence::PolyTable::print ( std::ostream &  h  )  const [pure virtual]

print is a pure virtual function. Calls to ostream & operator<<(ostream & s, PolyTable & c) act via this routine, which must be defined in all derived classes

Implemented in Sequence::PolySites, Sequence::SimData, and Sequence::SimpleSNP.


The documentation for this class was generated from the following files:

Generated on Wed Feb 4 09:31:49 2009 for libsequence by  doxygen 1.5.6