00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00013
00014 #define _gnDNXSource_h_
00015
00016 #include "gn/gnDefs.h"
00017
00018
00019 #include <string>
00020 #include <vector>
00021 #include <fstream>
00022 #include <time.h>
00023
00024 #include "gn/gnSetup.h"
00025 #include "gn/gnFileSource.h"
00026 #include "gn/gnSourceSpec.h"
00027 #include "gn/gnSequence.h"
00028
00035
00036 class GNDLLEXPORT gnDNXSource : public gnFileSource
00037 {
00038 public:
00042 gnDNXSource();
00047 gnDNXSource( const gnDNXSource& s );
00051 ~gnDNXSource();
00052
00053 gnDNXSource* Clone() const;
00054
00055 uint32 GetContigListLength() const;
00056 boolean HasContig( const string& name ) const;
00057 uint32 GetContigID( const string& name ) const;
00058 string GetContigName( const uint32 i ) const;
00059 gnSeqI GetContigSeqLength( const uint32 i ) const;
00060
00061 boolean SeqRead( const gnSeqI start, char* buf, uint32& bufLen, const uint32 contigI=ALL_CONTIGS ) ;
00062
00071 static boolean Write(gnSequence& sequence, const string& filename);
00081 static boolean Write(gnBaseSource *source, const string& filename);
00090 static boolean Write(gnGenomeSpec *spec, const string& filename);
00091
00092 gnGenomeSpec* GetSpec() const;
00093 gnFileContig* GetFileContig( const uint32 contigI ) const;
00094 private:
00095 boolean ParseStream( istream& fin );
00096 static void ValidateName(string& name);
00097
00098 gnGenomeSpec *m_DNXSpec;
00099 };
00100
00101 inline
00102 gnDNXSource* gnDNXSource::Clone() const
00103 {
00104 return new gnDNXSource( *this );
00105 }
00106
00107 inline
00108 uint32 gnDNXSource::GetContigListLength() const
00109 {
00110 return m_DNXSpec->GetSpecListLength();
00111 }
00112
00113 inline
00114 boolean gnDNXSource::SeqRead( const gnSeqI start, char* buf, uint32& bufLen, const uint32 contigI )
00115 {
00116 return m_DNXSpec->SeqRead(start, buf, bufLen, contigI);
00117 }
00118
00119 inline
00120 boolean gnDNXSource::Write(gnSequence& sequence, const string& filename){
00121 return Write(sequence.GetSpec(), filename);
00122 }
00123 inline
00124 boolean gnDNXSource::Write(gnBaseSource *source, const string& filename){
00125 return Write(source->GetSpec(), filename);
00126 }
00127 inline
00128 gnGenomeSpec *gnDNXSource::GetSpec() const{
00129 return m_DNXSpec->Clone();
00130 }
00131
00132 #endif
00133
00134