00001 #include "libGenome/gnSequence.h"
00002 #include "libGenome/gnFASSource.h"
00003 #include <algorithm>
00004
00005 using namespace std;
00006 using namespace genome;
00007
00008 int main( int argc, char* argv[] )
00009 {
00010 if( argc != 2 )
00011 {
00012 cerr << "Usage: " << argv[0] << " <mfa name>\n";
00013 cerr << "One file will be written for each sequence entry in the MFA file\n";
00014 return -1;
00015 }
00016 gnSequence mfa_seq;
00017 mfa_seq.LoadSource( argv[1] );
00018 for( uint i = 0; i < mfa_seq.contigListSize(); ++i )
00019 {
00020 string ofname = mfa_seq.contigName(i);
00021 remove( ofname.begin(), ofname.end(), ';' );
00022 remove( ofname.begin(), ofname.end(), ' ' );
00023 ofstream ofile( ofname.c_str() );
00024 if( !ofile.is_open() )
00025 {
00026 cerr << "Error opening \"" << ofname << "\"\n";
00027 return -1;
00028 }
00029 gnSequence contig_seq = mfa_seq.contig(i);
00030 gnFASSource::Write( contig_seq, ofile, false, false );
00031 }
00032 return 0;
00033 }
00034