gnBaseSpec.h Source File

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

# gnBaseSpec.h

Go to the documentation of this file.

    00001 /////////////////////////////////////////////////////////////////////////////
    00002 // File:            gnBaseSpec.h
    00003 // Purpose:         abstract Spec class
    00004 // Description:     Defines a basic interface for all specs
    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 _gnBaseSpec_h_
    00013 #define _gnBaseSpec_h_
    00014
    00015 #include "gn/gnDefs.h"
    00016
    00017 #include <vector>
    00018 #include <string>
    00019
    00020 #include "gn/gnClone.h"
    00021 #include "gn/gnBaseFeature.h"
    00022 #include "gn/gnBaseHeader.h"
    00023
    00024 /**
    00025  * gnBaseSpec is the class which stores genetic information and is best accessed using gnSequence.
    00026  */
    00027 class GNDLLEXPORT gnBaseSpec : public gnClone
    00028 {
    00029 public:
    00030         gnBaseSpec(){}
    00031         /**
    00032          * Destructor, frees memory.
    00033          */
    00034         virtual ~gnBaseSpec(){}
    00035         virtual gnBaseSpec* Clone() const = 0;
    00036         virtual gnBaseSpec* CloneRange( const uint32 startI, const uint32 len ) const = 0;
    00037         /**
    00038          * Get the name of the contig associated with this spec.
    00039          * @return The contig name or an empty string if none exists.
    00040          */
    00041         virtual string GetName() const;
    00042         /**
    00043          * Sets the name for this contig
    00044          * @param name The new name.
    00045          * @return True if successful.  Honestly, I don't know how this could be unsuccessful...
    00046          */
    00047         virtual void SetName( const string& name );
    00048         /**
    00049          * Get the length of all the sequence data covered by this spec.
    00050          * @return This spec's length in base pairs.
    00051          */
    00052         virtual gnSeqI GetLength() const = 0;
    00053         /**
    00054          * Returns true if this spec is read reverse complement.
    00055          * @return True if this spec is read reverse complement.
    00056          */
    00057         virtual boolean IsReverseComplement() const;
    00058         /**
    00059          * Returns true if this spec's sequence is circular.
    00060          * @return True if this spec's sequence is circular.
    00061          */
    00062         virtual boolean IsCircular() const;
    00063         /**
    00064          * Sets the reverse complement bit for this spec.
    00065          * @param value True for reverse complement, false otherwise.
    00066          */
    00067         virtual void SetReverseComplement( const boolean value ) = 0;
    00068         /**
    00069          * Sets whether this spec should be read circular.
    00070          * If circular is set, reads beyond the end of this spec will pick up
    00071          * at the beginning and read up to the start index.
    00072          * @param value True for circular, false otherwise.
    00073          */
    00074         virtual void SetCircular( const boolean value );
    00075         /**
    00076          * Crop the first cropLen bases from the sequence. CropStart will
    00077          * delete features and headers associated with the cropped bases.
    00078          * @param cropLen The number of base pairs to delete from the beginning.
    00079          */
    00080         virtual void CropStart( gnSeqI cropLen ) = 0;
    00081         /**
    00082          * Crop the last cropLen bases from the sequence. CropEnd will
    00083          * delete features and headers associated with the cropped bases.
    00084          * @param cropLen The number of base pairs to delete from the end.
    00085          */
    00086         virtual void CropEnd( gnSeqI cropLen ) = 0;
    00087
    00088         /**
    00089          * Reads sequence data from this spec.
    00090          * SeqRead will attempt to read "bufLen" base pairs starting at "start", an offset into the sequence.
    00091          * Reading inside a specific contig can be accomplished by supplying the "contigI" parameter with
    00092          * a valid contig index.
    00093          * SeqRead stores the sequence data in "buf" and returns the actual number of bases read in "bufLen".
    00094          * SeqRead will return false if a serious error occurs.
    00095          * @param start The base pair to start reading at.
    00096          * @param buf The character array to store base pairs into.
    00097          * @param bufLen The number of base pairs to read.  This will be modified to reflect the actual number of bases read.
    00098          * @param contigI The index of the subspec to read or ALL_CONTIGS by default.
    00099          * @return True if the operation was successful.
    00100          */
    00101         virtual boolean SeqRead(const gnSeqI start, gnSeqC* buf, uint32& bufLen, const uint32 contigI ) const = 0;
    00102         /**
    00103          * Clears all data from this spec.
    00104          */
    00105         virtual void Clear();
    00106 protected:
    00107         boolean m_reverseComplement;
    00108         boolean m_circular;
    00109
    00110         string m_name;
    00111         string m_sourceName;
    00112
    00113 }; // class gnBaseSpec
    00114
    00115 inline
    00116 string gnBaseSpec::GetName() const{
    00117         return m_name;
    00118 }
    00119 inline
    00120 void gnBaseSpec::SetName( const string& name ){
    00121         m_name = name;
    00122 }
    00123 inline
    00124 boolean gnBaseSpec::IsReverseComplement() const{
    00125         return m_reverseComplement;
    00126 }
    00127 inline
    00128 boolean gnBaseSpec::IsCircular() const{
    00129         return m_circular;
    00130 }
    00131 inline
    00132 void gnBaseSpec::SetCircular( const boolean value ){
    00133         m_circular = value;
    00134 }
    00135 inline
    00136 void gnBaseSpec::Clear(){
    00137         m_sourceName = "";
    00138         m_name = "";
    00139         m_reverseComplement = false;
    00140         m_circular = false;
    00141 }
    00142
    00143 #endif
    00144         // _gnBaseSpec_h_