Sequence::Alignment Namespace Reference
[Classes and functions dealing with alignments]

Routines fundamental to aligned data. More...

Functions

template<>
bool Gapped (const std::vector< std::string > &data)
template<>
bool IsAlignment (const std::vector< std::string > &data)
template<>
bool validForPolyAnalysis (std::vector< std::string >::const_iterator beg, std::vector< std::string >::const_iterator end)
template<>
bool validForPolyAnalysis (std::vector< std::string >::iterator beg, std::vector< std::string >::iterator end)
template<>
unsigned UnGappedLength (const std::vector< std::string > &data) throw (Sequence::SeqException)
template<>
void RemoveGaps (std::vector< std::string > &data)
template<>
void RemoveTerminalGaps (std::vector< std::string > &data)
template<>
void RemoveFixedOutgroupInsertions (std::vector< std::string > &data, unsigned site, const unsigned &ref)
template<>
std::vector< std::string > Trim (const std::vector< std::string > &data, const std::vector< int > &sites) throw (Sequence::SeqException)
template<>
std::vector< std::string > TrimComplement (const std::vector< std::string > &data, const std::vector< int > &sites) throw (Sequence::SeqException)
template<typename T >
void GetData (std::vector< T > &seqarray, const char *infilename)
template<typename T >
std::istream & GetData (std::vector< T > &seqarray, std::istream &input_stream)
template<typename T >
std::istream & ReadNObjects (std::vector< T > &seqarray, unsigned n, std::istream &input_stream)
template<typename T >
void EmptyVector (std::vector< T * > &seqarray)
template<typename T >
bool Gapped (const std::vector< T > &data)
template<typename T >
bool IsAlignment (const std::vector< T > &data)
template<typename Iterator >
bool validForPolyAnalysis (Iterator beg, Iterator end)
template<typename T >
unsigned UnGappedLength (const std::vector< T > &data)
template<typename T >
void RemoveGaps (std::vector< T > &data)
template<typename T >
void RemoveTerminalGaps (std::vector< T > &data)
template<typename T >
void RemoveFixedOutgroupInsertions (std::vector< T > &data, unsigned site, const unsigned &ref)
template<typename T >
std::vector< T > Trim (const std::vector< T > &data, const std::vector< int > &sites) throw (Sequence::SeqException)
template<typename T >
std::vector< T > TrimComplement (const std::vector< T > &data, const std::vector< int > &sites) throw (Sequence::SeqException)

Detailed Description

Routines fundamental to aligned data.

#include<Sequence/Alignment.hpp>
This namespace defines a series of template routines used for manipulating aligned sequence data. The routines may be used on their own, and are also the building blocks for alignment I/O as defined in Sequence::AlignStream.

Note:
Valid types for instantiation of these templates are the following: std::pair<std::string,std::string>, or anything derived from there, which include Sequence::Seq, etc. This requirment is checked at compile time via compile-time assertions using the boost library. There are also specializations such that std::string is also a valid type.

Function Documentation

template<typename T >
void Sequence::Alignment::EmptyVector ( std::vector< T * > &  seqarray  )  [inline]

Free all the memory in seqarray by deleting every objet, and resize() seqarray to 0

Parameters:
seqarray the vector<T*> you want emptied

Definition at line 148 of file Alignment.tcc.

template<typename T >
bool Sequence::Alignment::Gapped ( const std::vector< T > &  data  )  [inline]
Parameters:
data vector<T> containing sequence data
Returns:
true if the vector contains a gap character ('-') , false otherwise.

Definition at line 161 of file Alignment.tcc.

template<>
bool Sequence::Alignment::Gapped ( const std::vector< std::string > &  data  )  [inline]

specialization for std::string

Examples:
gestimator.cc.
template<typename T >
std::istream & Sequence::Alignment::GetData ( std::vector< T > &  seqarray,
std::istream &  input_stream 
) [inline]

Read objects of type T and put them into the vector seqarray. Note that seqarray is not const, so that's where the data go. This function is similar to GetData(vector<T> &seqarray, const char *infilename), except that it is passed a reference to an open input stream, such as a file stream, cin, etc.

Parameters:
seqarray an empty vector<T> that you want filled
input_stream name of istream from which fo fill seqarray

Definition at line 94 of file Alignment.tcc.

template<typename T >
void Sequence::Alignment::GetData ( std::vector< T > &  seqarray,
const char *  infilename 
) [inline]

Read objects of type T and put them into the vector seqarray. Note that seqarray is not const, so that's where the data go. infilename refers to a file from which to read the data. Any exceptions that can be thrown when reading the data are not caught here.
Example:

      #include <iostream>
      #include <Sequence/Fasta.hpp>
      #include <Sequence/Alignment.hpp>
      //using namespace std;
      using namespace Sequence;
      int main
      {
      vector<Fasta> data;
      const char *infile = foo;
      try {
      Alignment::GetData(&data,foo);
      } catch (SeqException &e) {
      cerr << "whoa--exception caught"<<endl;
      e.print(cerr);
      cerr << endl;
      }
      }
Parameters:
seqarray a vector<T> that you want filled
infilename name of file from which fo fill seqarray
Note:
if infilename is NULL, the function returns, having done nothing
Examples:
gestimator.cc, PolyTableIterators.cc, slidingWindow.cc, and slidingWindow2.cc.

Definition at line 44 of file Alignment.tcc.

template<typename T >
bool Sequence::Alignment::IsAlignment ( const std::vector< T > &  data  )  [inline]

A vector of sequences/strings is only an alignment if all strings are the same length.

Parameters:
data vector<T> to check

Definition at line 180 of file Alignment.tcc.

template<>
bool Sequence::Alignment::IsAlignment ( const std::vector< std::string > &  data  )  [inline]

specialization for std::string

Examples:
PolyTableIterators.cc, slidingWindow.cc, and slidingWindow2.cc.
template<typename T >
std::istream & Sequence::Alignment::ReadNObjects ( std::vector< T > &  seqarray,
unsigned  n,
std::istream &  input_stream 
) [inline]

Read a fixed number n of objects of type T and put them into the vector seqarray. Note that seqarray is not const, so that's where the data go. This function is similar to GetData(vector<T> &seqarray, const char *infilename), except that it is passed a reference to an open input stream, such as a file stream, cin, etc.

Parameters:
seqarray an empty vector<T> that you want filled
n number of objects of type T to read
input_stream name of istream from which fo fill seqarray
Note:
the stream is not closed after each read of n records!!

Definition at line 120 of file Alignment.tcc.

template<typename T >
void Sequence::Alignment::RemoveFixedOutgroupInsertions ( std::vector< T > &  data,
unsigned  site,
const unsigned &  ref 
) [inline]

Removes all positions from data that for which the outgroup contains an insertion relative to ingroup

Parameters:
data a vector of Seq objects
site index of the site at which to begin (set to 0 usually)
ref the index of the outgroup in data

Definition at line 368 of file Alignment.tcc.

template<typename T >
void Sequence::Alignment::RemoveGaps ( std::vector< T > &  data  )  [inline]

Modifies the data vector to remove all positions that contain the gap character'-'.

Parameters:
data vector<T> to modify

Definition at line 263 of file Alignment.tcc.

template<>
void Sequence::Alignment::RemoveGaps ( std::vector< std::string > &  data  )  [inline]

a specialization for std::string

Examples:
gestimator.cc.
template<typename T >
void Sequence::Alignment::RemoveTerminalGaps ( std::vector< T > &  data  )  [inline]

Remove all gapped sites from the ends of the alignment, up until the first site on either side that is ungapped.

Parameters:
data vector<T> to modify

Definition at line 306 of file Alignment.tcc.

template<>
void Sequence::Alignment::RemoveTerminalGaps ( std::vector< std::string > &  data  )  [inline]

a specialization for std::string

template<typename T >
std::vector< T > Sequence::Alignment::Trim ( const std::vector< T > &  data,
const std::vector< int > &  sites 
) throw (Sequence::SeqException) [inline]

Returns a copy of the data vector, modified in the following way. The sites vector contains an even number of sites (whose values are sorted). If sites does not contain an even number of values Sequence::SeqException is thrown. If sites is empty, Sequence::SeqException is thrown. The values in sites represent a series of intervals that you wish to keep, and the return vector is consists only of those--i.e. all positions not present in the intervals defined in sites are lost. For example, if you pass a vector<int> containing the values 0,10,21, and 30, then the data vector is modified so that positions 0 through 10 and 21 through 30 are all that remains. One intended use of this function is to pull, for example, the coding region out of an aligned block.

Parameters:
data the original data
sites vector<int> containing an even number of integers specifying the intervals of data to keep
Exceptions:
Sequence::SeqException 

Definition at line 404 of file Alignment.tcc.

template<>
std::vector< std::string > Sequence::Alignment::Trim ( const std::vector< std::string > &  data,
const std::vector< int > &  sites 
) throw (Sequence::SeqException) [inline]

a specialization for std::string

template<typename T >
std::vector< T > Sequence::Alignment::TrimComplement ( const std::vector< T > &  data,
const std::vector< int > &  sites 
) throw (Sequence::SeqException) [inline]

Returns a copy the data vector, modified in the following way. The sites vector contains an even number of sites (whose values are sorted). If sites does not contain an even number of values Sequence::SeqException is thrown. If sites is empty, Sequence::SeqException is thrown. The values in sites represent a series of intervals that you wish to keep, and the return vector consists only of sites not present in sites--i.e. all positions not present in the intervals defined in sites are kept. For example, if you pass a vector<int> containing the values 0,10,21, and 30, then the data vector is modified so that positions 11 through 20 and 31 through the end of the sequences are all that remains.

Parameters:
data the original data
sites vector<int> containing an even number of integers specifying the intervals of data to throw away
Exceptions:
Sequence::SeqException 

Definition at line 458 of file Alignment.tcc.

template<>
std::vector< std::string > Sequence::Alignment::TrimComplement ( const std::vector< std::string > &  data,
const std::vector< int > &  sites 
) throw (Sequence::SeqException) [inline]

a specialization for std::string

template<typename T >
unsigned Sequence::Alignment::UnGappedLength ( const std::vector< T > &  data  )  [inline]

Returns the number of sites in the alignment for which all objects do not contain the gap character '-'. If the data are not aligned, the value Sequence::SEQMAXUNSIGNED is returned as an error.

Parameters:
data vector<T> to check

Definition at line 229 of file Alignment.tcc.

template<>
unsigned Sequence::Alignment::UnGappedLength ( const std::vector< std::string > &  data  )  throw (Sequence::SeqException) [inline]

specialization for std::string

template<typename Iterator >
bool Sequence::Alignment::validForPolyAnalysis ( Iterator  beg,
Iterator  end 
) [inline]
Returns:
true if each element in the range [beg,end) only contains characters in the set {A,G,C,T,N,-}, false otherwise

Definition at line 197 of file Alignment.tcc.

template<>
bool Sequence::Alignment::validForPolyAnalysis ( std::vector< std::string >::const_iterator  beg,
std::vector< std::string >::const_iterator  end 
) [inline]

specialization for std::string

Examples:
PolyTableIterators.cc, slidingWindow.cc, and slidingWindow2.cc.
Generated on Thu Aug 11 13:22:05 2011 for libsequence by  doxygen 1.6.3