Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

gnRAWSource.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 // File:            gnRAWSource.h
00003 // Purpose:         Implements gnBaseSource for raw data files
00004 // Description:     
00005 // Changes:        
00006 // Version:         libGenome 0.5.1 
00007 // Author:          Aaron Darling 
00008 // Modified by:     
00009 // Copyright:       (c) Aaron Darling 
00010 // Licenses:        See COPYING file for details 
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  * gnRAWSource reads raw sequence data from a text file.
00028  * This class reads and writes raw sequence to and from files.
00029  * A raw sequence does not contain any newlines, fragment delimiters, or other
00030  * type of annotation.
00031  * gnRAWSource is used by gnSourceFactory to read files and should only be used 
00032  * directly.when writing out raw files by calling gnRAWSource::Write( mySpec, "C:\\myFile.txt");
00033  */
00034 
00035 class GNDLLEXPORT gnRAWSource : public gnFileSource
00036 {
00037 public:
00038         /**
00039          * Empty Constructor, does nothing.
00040          */
00041         gnRAWSource();  
00042         /**
00043          * Clone Constructor copies the specified gnRAWSource.
00044          * @param s The gnRAWSource to copy.
00045          */
00046         gnRAWSource( const gnRAWSource& s );
00047         /**
00048          * Destructor, frees memory.
00049          */
00050         ~gnRAWSource();
00051         /**
00052          * Returns an exact copy of this class.
00053          */
00054         gnRAWSource* Clone() const;
00055 // Contig Access methods        
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 
00064         /**
00065          * Writes the specified gnSequence to a raw file named "filename".
00066          * @param sequence The gnSequence to write out.
00067          * @param filename The name of the file to write.
00068          * @return True if successful, false otherwise.
00069          */
00070         static boolean Write(gnSequence& sequence, const string& filename);
00071         /**
00072          * Writes the specified source to a raw file named "filename".
00073          * @param source The source to write out.
00074          * @param filename The name of the file to write.
00075          * @return True if successful, false otherwise.
00076          */
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 };// class gnRAWSource
00090 // Clone        
00091 inline
00092 gnRAWSource* gnRAWSource::Clone() const
00093 {
00094         return new gnRAWSource( *this );
00095 }
00096 // Contig Access methods        
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         // _gnRAWSource_h_

Generated on Fri May 9 12:57:51 2003 for libGenome by doxygen1.3-rc3