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

gnDNXSource.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 // File:            gnDNXSource.h
00003 // Purpose:         Implements gnBaseSource for .DNX 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 #ifndef _gnDNXSource_h_
00013 #define _gnDNXSource_h_
00014 
00015 #include "gn/gnDefs.h"
00016 
00017 
00018 #include <string>
00019 #include <vector>
00020 #include <fstream>
00021 #include <time.h>
00022 
00023 #include "gn/gnSetup.h"
00024 #include "gn/gnFileSource.h"
00025 #include "gn/gnSourceSpec.h"
00026 #include "gn/gnSequence.h"
00027 
00028 /**
00029  * gnDNXSource implements the DNX file source.
00030  * This class reads and writes the Blattner Lab DNX file format.
00031  * DNX files may be written by calling:
00032  * gnDNXSource::Write( mySpec, "C:\\myFile.dnx");
00033  */
00034 
00035 class GNDLLEXPORT gnDNXSource : public gnFileSource
00036 {
00037 public:
00038         /**
00039          * Empty Constructor, does nothing.
00040          */
00041         gnDNXSource();  
00042         /**
00043          * The copy constructor copies the given gnDNXSource.
00044          * @param s A gnDNXSource to copy.
00045          */
00046         gnDNXSource( const gnDNXSource& s );
00047         /**
00048          * Destructor, frees memory.
00049          */
00050         ~gnDNXSource();
00051 
00052         gnDNXSource* Clone() const;
00053 
00054         uint32 GetContigListLength() const;
00055         boolean HasContig( const string& name ) const;
00056         uint32 GetContigID( const string& name ) const;
00057         string GetContigName( const uint32 i ) const;
00058         gnSeqI GetContigSeqLength( const uint32 i ) const;
00059 
00060         boolean SeqRead( const gnSeqI start, char* buf, uint32& bufLen, const uint32 contigI=ALL_CONTIGS ) ;
00061 
00062         /**
00063          * Writes the given gnSequence to a DNX file named "filename".
00064          * Actual sequence and annotation data will be written to GenBank
00065          * files.  The DNX file will then reference any created GenBank files.
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          * This method is deprecated.
00073          * Writes the given gnBaseSource to a DNX file named "filename".
00074          * Actual sequence and annotation data will be written to GenBank
00075          * files.  The DNX file will then reference any created GenBank files.
00076          * @param source The source to write out.
00077          * @param filename The name of the file to write.
00078          * @return True if successful, false otherwise.
00079          */
00080         static boolean Write(gnBaseSource *source, const string& filename);
00081         /**
00082          * Writes the given gnGenomeSpec to a DNX file named "filename".
00083          * Actual sequence and annotation data will be written to GenBank
00084          * files.  The DNX file will then reference any created GenBank files.
00085          * @param spec The spec to write out.
00086          * @param filename The name of the file to write.
00087          * @return True if successful, false otherwise.
00088          */
00089         static boolean Write(gnGenomeSpec *spec, const string& filename);
00090 
00091         gnGenomeSpec* GetSpec() const;
00092         gnFileContig* GetFileContig( const uint32 contigI ) const;
00093 private:
00094         boolean ParseStream( istream& fin );
00095         static void ValidateName(string& name);
00096 
00097         gnGenomeSpec *m_DNXSpec;
00098 };// class gnDNXSource
00099 
00100 inline
00101 gnDNXSource* gnDNXSource::Clone() const
00102 {
00103         return new gnDNXSource( *this );
00104 }
00105 
00106 inline
00107 uint32 gnDNXSource::GetContigListLength() const
00108 {
00109         return m_DNXSpec->GetSpecListLength();
00110 }
00111 //read sequence data from the file
00112 inline
00113 boolean gnDNXSource::SeqRead( const gnSeqI start, char* buf, uint32& bufLen, const uint32 contigI ) 
00114 {
00115         return m_DNXSpec->SeqRead(start, buf, bufLen, contigI);
00116 }
00117 
00118 inline
00119 boolean gnDNXSource::Write(gnSequence& sequence, const string& filename){
00120         return Write(sequence.GetSpec(), filename);
00121 }
00122 inline
00123 boolean gnDNXSource::Write(gnBaseSource *source, const string& filename){
00124         return Write(source->GetSpec(), filename);
00125 }
00126 inline
00127 gnGenomeSpec *gnDNXSource::GetSpec() const{
00128         return m_DNXSpec->Clone();
00129 }
00130 
00131 #endif
00132         // _gnDNXSource_h_
00133 

Generated on Mon Feb 3 02:34:39 2003 for libGenome by doxygen1.3-rc3