29 using Sequence::operator+=;
30 using Sequence::Alignment::GetData;
33 bool validStates(
const std::map<char,unsigned> & counts)
40 for( map<char,unsigned>::const_iterator i = counts.begin() ;
44 char ch = toupper(i->first);
45 if ( ch !=
'A' && ch !=
'G' && ch !=
'C' && ch !=
'T' && ch !=
'N' )
51 int main(
int argc,
char **argv)
55 cerr <<
"usage: ufs file outgroup_index\n";
59 const char * fastafile = argv[1];
60 const unsigned outgroup = atoi(argv[2]);
63 vector<Fasta> alignment;
64 GetData(alignment,fastafile);
65 if( ! IsAlignment(alignment) )
67 cerr << fastafile <<
" not aligned\n";
74 vector< unsigned > ufs(alignment.size()-1,0);
78 for( PolySites::const_site_iterator i = SNPtable.sbegin() ;
79 i != SNPtable.send() ; ++i )
81 const char ancstate = i->second[outgroup];
91 std::map<char,unsigned> counts =
makeCountList(i->second.begin(),i->second.begin()+outgroup);
95 counts +=
makeCountList(i->second.begin()+outgroup+1,i->second.end());
97 if( ! validStates(counts) )
99 cerr <<
"site " << i->first <<
" contains characters other than A,G,C,T,N\n";
103 for( map<char,unsigned>::const_iterator i = counts.begin() ;
107 if ( toupper(i->first) != ancstate )
116 for(
unsigned i=0;i<ufs.size();++i)
118 cout << i+1 <<
'\t' << ufs[i] <<
'\n';
Polymorphism tables for sequence data.
bool IsAlignment(const std::vector< std::string > &data)
Declaration of namespace Sequence::Alignment.
Declaration of Sequence::makeCountList (an alternative to Sequence::stateCounter), Sequence::internalGapCheck.
Sequence::PolySites, generates polymorphism tables from data.
Declaration of Sequence::Fasta streams.
std::map< typename std::iterator_traits< Iterator >::value_type, unsigned > makeCountList(Iterator beg, Iterator end)
Declarations of operators to add associative containers together.