00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00013
00014 #ifndef _gnRAWSource_h_
00015 #define _gnRAWSource_h_
00016
00017 #include "gn/gnDefs.h"
00018
00019 #include <string>
00020 #include <fstream>
00021 #include <vector>
00022 #include "gn/gnFileSource.h"
00023 #include "gn/gnFileContig.h"
00024 #include "gn/gnSourceSpec.h"
00025 #include "gn/gnSequence.h"
00026
00035
00036 class GNDLLEXPORT gnRAWSource : public gnFileSource
00037 {
00038 public:
00042 gnRAWSource();
00047 gnRAWSource( const gnRAWSource& s );
00051 ~gnRAWSource();
00055 gnRAWSource* Clone() const;
00056
00057 uint32 GetContigListLength() const;
00058 boolean HasContig( const string& name ) const;
00059 uint32 GetContigID( const string& name ) const;
00060 string GetContigName( const uint32 i ) const;
00061 gnSeqI GetContigSeqLength( const uint32 i ) const;
00062
00063 boolean SeqRead( const gnSeqI start, char* buf, uint32& bufLen, const uint32 contigI=ALL_CONTIGS );
00064
00071 static boolean Write(gnSequence& sequence, const string& filename);
00078 static boolean Write(gnBaseSource *source, const string& filename);
00079 gnGenomeSpec *GetSpec() const;
00080 gnFileContig* GetFileContig( const uint32 contigI ) const;
00081 private:
00082 boolean SeqSeek( const gnSeqI start, const uint32& contigI, uint64& startPos, uint64& readableBytes );
00083 boolean SeqStartPos( const gnSeqI start, gnFileContig& contig, uint64& startPos, uint64& readableBytes );
00084 boolean ParseStream( istream& fin );
00085
00086 gnFileContig* m_contig;
00087 gnGenomeSpec* m_spec;
00088 };
00089
00090 inline
00091 gnRAWSource* gnRAWSource::Clone() const
00092 {
00093 return new gnRAWSource( *this );
00094 }
00095
00096 inline
00097 uint32 gnRAWSource::GetContigListLength() const
00098 {
00099 return m_contig == NULL? 0 : 1;
00100 }
00101 inline
00102 boolean gnRAWSource::Write(gnBaseSource *source, const string& filename){
00103 gnSequence gns(*source->GetSpec());
00104 return Write(gns, filename);
00105 }
00106
00107 #endif
00108