00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
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
00035 class GNDLLEXPORT gnRAWSource :
public gnFileSource
00036 {
00037
public:
00041 gnRAWSource();
00046 gnRAWSource(
const gnRAWSource& s );
00050 ~gnRAWSource();
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,
gnSeqI& bufLen,
const uint32 contigI=ALL_CONTIGS );
00063
00070
static boolean Write(
gnSequence& sequence,
const string& filename);
00077
static boolean Write(
gnBaseSource *source,
const string& filename);
00078
gnGenomeSpec *
GetSpec()
const;
00079
gnFileContig*
GetFileContig(
const uint32 contigI )
const;
00080
00081
static boolean CheckRawData(
boolean set =
false,
boolean check =
false );
00082
private:
00083
boolean SeqSeek(
const gnSeqI start,
const uint32& contigI,
uint64& startPos,
uint64& readableBytes );
00084
boolean SeqStartPos(
const gnSeqI start,
gnFileContig& contig,
uint64& startPos,
uint64& readableBytes );
00085
boolean ParseStream( istream& fin );
00086
00087 gnFileContig* m_contig;
00088 gnGenomeSpec* m_spec;
00089 };
00090
00091
inline
00092 gnRAWSource*
gnRAWSource::Clone()
const
00093
{
00094
return new gnRAWSource( *
this );
00095 }
00096
00097
inline
00098 uint32 gnRAWSource::GetContigListLength()
const
00099
{
00100
return m_contig == NULL? 0 : 1;
00101 }
00102
inline
00103 boolean gnRAWSource::Write(
gnBaseSource *source,
const string& filename){
00104
gnSequence gns(*source->
GetSpec());
00105
return Write(gns, filename);
00106 }
00107
00108
inline
00109 boolean gnRAWSource::CheckRawData(
boolean set,
boolean check ){
00110
static boolean check_raw_data =
false;
00111
if( set ){
00112 check_raw_data = check;
00113 }
00114
return check_raw_data;
00115 }
00116
#endif
00117