libsequence  1.9.5
Alignment.hpp
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 2003-2009 Kevin Thornton, krthornt[]@[]uci.edu
4 
5 Remove the brackets to email me.
6 
7 This file is part of libsequence.
8 
9 libsequence is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13 
14 libsequence is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18 
19 You should have received a copy of the GNU General Public License
20 long with libsequence. If not, see <http://www.gnu.org/licenses/>.
21 
22 */
23 
24 #ifndef __ALIGNMENT_HPP__
25 #define __ALIGNMENT_HPP__
26 #include <iosfwd>
27 #include <fstream>
28 #include <vector>
29 #include <string>
30 #include <stdexcept>
54 namespace Sequence
55 {
56  namespace Alignment
57  {
58  //fill a vector<T> from a file
59  template < typename T >
60  void GetData (std::vector < T >&seqarray,
61  const char *infilename);
62  //fill a vector<T> from a stream
63  template < typename T >
64  std::istream & GetData (std::vector < T >&seqarray,
65  std::istream & input_stream);
66  //fill a vector<T> with N objects from a stream
67  template < typename T >
68  std::istream & ReadNObjects ( std::vector < T > &seqarray, const unsigned & n,
69  std::istream & input_stream);
70  //check if elements of data contain a gap character '-'
71  template < typename T >
72  bool Gapped (const std::vector < T >&data);
73  //verify that all elements of data are the same length
74  template < typename T >
75  bool IsAlignment (const std::vector < T >&data);
76  //check to make sure that an aligment contains
77  //characters that the SNP routines in this library can handle
78  template<typename Iterator>
79  bool validForPolyAnalysis( Iterator beg,
80  Iterator end );
81  //return the length of the alignment without gaps
82  template < typename T >
83  unsigned UnGappedLength (const std::vector <T>&data);
84  //remove all gaps from an alignment
85  template <typename T>
86  void RemoveGaps (std::vector <T> &data);
87  //remove all gaps from the ends of an alignment
88  template < typename T >
89  void RemoveTerminalGaps (std::vector < T >&data);
90  template < typename T >
91  void RemoveFixedOutgroupInsertions( std::vector<T> & data,
92  unsigned site,
93  const unsigned & ref );
94  //see manual
95  template < typename T >
96  std::vector < T >Trim (const std::vector < T >&data,
97  const std::vector <int> &sites);
98  //see manual
99  template < typename T >
100  std::vector < T >TrimComplement (const std::vector < T >&data,
101  const std::vector <int> &sites);
102 
103  //declaration of specializations
104  template<> bool Gapped(const std::vector<std::string> &data);
105  template <> bool IsAlignment(const std::vector<std::string> &data);
106  template<>
107  bool validForPolyAnalysis( std::vector<std::string>::const_iterator beg,
108  std::vector<std::string>::const_iterator end );
109  template<>
110  bool validForPolyAnalysis( std::vector<std::string>::iterator beg,
111  std::vector<std::string>::iterator end );
112  template <>
113  unsigned UnGappedLength (const std::vector <std::string>&data) ;
114  template <>
115  void RemoveGaps (std::vector <std::string> &data);
116  template <>
117  void RemoveTerminalGaps (std::vector <std::string> &data);
118  template <>
119  void RemoveFixedOutgroupInsertions(std::vector<std::string> &data,
120  unsigned site,
121  const unsigned & ref);
122  template <>
123  std::vector <std::string >Trim (const std::vector <std::string>&data,
124  const std::vector <int> &sites);
125 
126  template <>
127  std::vector <std::string> TrimComplement (const std::vector <std::string>&data,
128  const std::vector <int> &sites);
129 
130  }
131 }
132 #include <Sequence/bits/Alignment.tcc>
133 #endif
The namespace in which this library resides.