-
Notifications
You must be signed in to change notification settings - Fork 4
/
phy_to_fasta.cpp
52 lines (40 loc) · 1.24 KB
/
phy_to_fasta.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include <iostream>
#include <algorithm>
#include <iterator>
#include "ivymike/fasta.h"
#include "ivymike/multiple_alignment.h"
#include "ivymike/algorithm.h"
#include "ivymike/tree_traversal_utils.h"
static bool nogap( char c ) {
c = toupper(c);
return c != '-' && c != 'N';
}
#if __cplusplus <= 199711L && !defined(_MSC_VER)
namespace std {
// OH NOES, copy_if is c++11... rip it from gnu
template<typename _InputIterator, typename _OutputIterator,
typename _Predicate>
_OutputIterator copy_if(_InputIterator __first, _InputIterator __last,
_OutputIterator __result, _Predicate __pred)
{
for (; __first != __last; ++__first)
if (__pred(*__first))
{
*__result = *__first;
++__result;
}
return __result;
}
}
#endif
int main() {
ivy_mike::multiple_alignment ma;
ma.load_phylip( std::cin );
for( size_t i = 0; i < ma.names.size(); ++i ) {
std::cout << ">" << ma.names[i] << "\n";
const std::vector< uint8_t > &d = ma.data.at(i);
std::copy_if( d.begin(), d.end(), std::ostream_iterator<char>(std::cout), nogap );
std::cout << "\n";
}
return 1;
}