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