#include "fasta.h" // interface to fasta file handling #include "bit_string.h" // interface file for special strings #include <string> #include <stdexcept> #include <iostream> using bioinfo::fasta; using bioinfo::nmer_string; using namespace std; int main(int argc, char* argv[]) { try { /* 4 nucleic acid character codes (2 bits for now). * making the nmer_string 6 bits results in * 3 nucleic acids per "character" (3-mer) */ typedef bioinfo::nmer_string<6>::string bit_string; /* example fasta file */ string fasta_file = "example.fasta"; /* read fasta file and store sequence and header data in mf */ fasta<bit_string> mf(fasta_file); cout<<"Reads ascii text, prints key codes for 3mers by default "<<endl; cout<<mf; fasta<bit_string>::const_iterator iter = mf.begin(); fasta<bit_string>::const_iterator stop = mf.end(); while( iter != stop ) { const fasta_seq<bit_string>& fseq = *iter; // fasta headers stored as strings const string& header = fseq.get_header(); // sequence should behave like a basic_string const bit_string& str = fseq.get_seq(); if( str[0] == "tcc" ) { cout<<"First 3mer in sequence is tcc"<<endl; } const char* cstr = str.c_str(); cout<<"Maybe I want to print out the characters "; cout<<"and not the bit compressed 3mer keys"<<cstr<<endl; ++iter; } } catch(const std::exception& err) { cerr<<err.what()<<endl; } catch(...) { cerr<<"Unhandled exception. Gotta Jet G."<<endl; } return 0; }