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

gnStringSpec.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 // File:            gnStringSpec.h
00003 // Purpose:         implements gnContigSpec for strings
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 _gnStringSpec_h_
00013 #define _gnStringSpec_h_
00014 
00015 #include "gn/gnDefs.h"
00016 
00017 #include <string>
00018 #include "gn/gnContigSpec.h"
00019 #include "gn/gnBaseSource.h"
00020 
00021 /**
00022  * gnStringSpec stores a sequence and annotation data in memory.
00023  * For a more complete description see the gnBaseSpec documentation.
00024  */
00025 class GNDLLEXPORT gnStringSpec : public gnContigSpec
00026 {
00027 public:
00028         /**
00029          * Empty constructor.
00030          */
00031         gnStringSpec();
00032         /**
00033          * Constructor, creates a gnStringSpec using sequence data in the given string.
00034          * A circular spec will be created if the end index is greater than the start.
00035          * @param m_string The string to read base pairs from.
00036          * @param startI The index to start reading base pairs from the string.
00037          * @param endI The index to stop reading base pairs from the string.
00038          * @param revComp True if the sequence is read reverse complement.
00039          */
00040         gnStringSpec( const string& m_string, const gnSeqI startI=0, const gnSeqI endI=GNSEQI_END, const boolean revComp = false);
00041         /**
00042          * Copy constructor.
00043          * @param s the gnStringSpec to copy.
00044          */
00045         gnStringSpec( const gnStringSpec& s );
00046         ~gnStringSpec();
00047 // Clone
00048         gnStringSpec* Clone() const;
00049         virtual void Clear();
00050 // Value Access methods
00051 
00052         virtual gnSeqI GetSourceLength() const;
00053 
00054         
00055 // Source Spec Specific functions
00056         virtual gnBaseSource *GetSource() const;
00057 
00058         /**
00059          * Copies a specified range of bases and returns a pointer to
00060          * the resulting gnStringSpec.  You must delete the copy when you
00061          * are finished with it.
00062          * @param startI The first base pair to copy
00063          * @param len The length of the piece to copy
00064          * @return A copy of the gnStringSpec containing only the specified bases
00065          */
00066         virtual gnStringSpec* CloneRange( const gnSeqI startI, const gnSeqI len ) const;
00067 
00068 protected:
00069         virtual boolean Read(const gnSeqI start, gnSeqC* buf, gnSeqI& bufLen ) const;
00070         string m_seqString;
00071         
00072 }; // class gnStringSpec
00073 
00074 inline
00075 gnStringSpec* gnStringSpec::Clone() const
00076 {
00077         return new gnStringSpec( *this );
00078 }
00079 inline
00080 gnSeqI gnStringSpec::GetSourceLength() const{
00081         return m_seqString.length();
00082 }
00083 inline
00084 gnBaseSource* gnStringSpec::GetSource() const
00085 {
00086         return NULL;
00087 }
00088 
00089 inline
00090 boolean gnStringSpec::Read(const gnSeqI start, gnSeqC* buf, gnSeqI& bufLen) const{
00091         memcpy(buf, m_seqString.data() + start, bufLen);
00092         return true;
00093 }
00094 
00095 #endif
00096         // _gnStringSpec_h_

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