00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifdef HAVE_CONFIG_H
00010 #include "config.h"
00011 #endif
00012
00013 #include "libMems/GappedAlignment.h"
00014 #include <sstream>
00015 #include "libGenome/gnFilter.h"
00016
00017 #include <fstream>
00018
00019 using namespace std;
00020 using namespace genome;
00021 namespace mems {
00022
00023 GappedAlignment::GappedAlignment() :
00024 AbstractGappedAlignment< SparseAbstractMatch<> >()
00025 {}
00026
00027 GappedAlignment::GappedAlignment( uint seq_count, gnSeqI align_length ) :
00028 AbstractGappedAlignment< SparseAbstractMatch<> >( seq_count, align_length )
00029 {
00030 align_matrix.resize(seq_count);
00031 }
00032
00033 void GappedAlignment::SetAlignment( const vector< string >& seq_align ){
00034 align_matrix = seq_align;
00035 if( seq_align.size() > 0 )
00036 SetAlignmentLength(seq_align[0].size());
00037 else
00038 SetAlignmentLength(0);
00039 }
00040
00041 std::ostream& operator<<( std::ostream& os, const GappedAlignment& ga );
00042 std::ostream& operator<<( std::ostream& os, const GappedAlignment& ga ){
00043 os << "GappedAlignmentSeqs: " << ga.SeqCount() << endl;
00044 os << ga.AlignmentLength();
00045 for( uint seqI = 0; seqI < ga.SeqCount(); seqI++ )
00046 os << '\t' << ga.Start( seqI );
00047 os << endl;
00048 for( uint seqI = 0; seqI < ga.SeqCount(); seqI++ ){
00049 os << ga.align_matrix[ seqI ] << endl;
00050 }
00051 return os;
00052 };
00053
00054 std::istream& operator>>( std::istream& is, GappedAlignment& ga );
00055 std::istream& operator>>( std::istream& is, GappedAlignment& ga ){
00056 uint seq_count;
00057 string nuffin;
00058 is >> nuffin;
00059 is >> seq_count;
00060 ga = GappedAlignment( seq_count, 0 );
00061 is >> nuffin;
00062 for( uint seqI = 0; seqI < seq_count; seqI++ ){
00063 int64 startI;
00064 is >> startI;
00065 ga.SetStart( seqI, startI );
00066 }
00067 for( uint seqI = 0; seqI < seq_count; seqI++ ){
00068 string seq;
00069 is >> seq;
00070 ga.align_matrix.push_back( seq );
00071 }
00072 if( ga.align_matrix.size() > 0 )
00073 ga.SetAlignmentLength( ga.align_matrix[ 0 ].length() );
00074 return is;
00075 };
00076
00077 }