gnGenomeSpec.h Source File

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

# gnGenomeSpec.h

Go to the documentation of this file.

    00001 /////////////////////////////////////////////////////////////////////////////
    00002 // File:            gnGenomeSpec.h
    00003 // Purpose:         abstract Spec class
    00004 // Description:     Genome level spec class
    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 _gnGenomeSpec_h_
    00013 #define _gnGenomeSpec_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 #include "gn/gnMultiSpec.h"
    00024 #include "gn/gnFragmentSpec.h"
    00025 #include "gn/gnException.h"
    00026
    00027 /**
    00028  * This class contains references to the sequence data, annotation,
    00029  * and other related header data for an organism's genome.  The genome
    00030  * is organized into a list of sequence fragments (specs), a list of
    00031  * features, and a list of headers.
    00032  */
    00033 class GNDLLEXPORT gnGenomeSpec : public gnMultiSpec
    00034 {
    00035 public:
    00036         gnGenomeSpec();
    00037         /**
    00038          * Copy constructor.
    00039          * @param s the gnGenomeSpec to copy.
    00040          */
    00041         gnGenomeSpec( const gnGenomeSpec& s);
    00042         /**
    00043          * Destructor, frees memory.
    00044          */
    00045         virtual ~gnGenomeSpec();
    00046 // Clone
    00047         virtual gnGenomeSpec* Clone() const;
    00048         virtual void Clear();
    00049 // Base Spec stuff
    00050         virtual void SetReverseComplement( const boolean value );
    00051
    00052 //Multispec stuff
    00053         virtual uint32 GetSpecListLength() const;
    00054         virtual gnFragmentSpec* GetSpec( const uint32 i ) const;
    00055         virtual gnFragmentSpec* GetSpecByBase( const gnSeqI baseI ) const;
    00056         virtual void AddSpec( gnBaseSpec* spec, const uint32 i = UINT32_MAX );
    00057         virtual void RemoveSpec( uint32 i );
    00058         virtual void MergeFragments( const uint32 startC, const uint32 endC);
    00059
    00060         virtual uint32 AddFeature( gnBaseFeature* feat );
    00061         virtual uint32 GetFeatureListLength() const;
    00062         virtual gnBaseFeature* GetFeature( const uint32 i ) const;
    00063         virtual void GetContainedFeatures(const gnLocation& lt, vector<gnBaseFeature*>& feature_vector, vector<uint32>& index_vector) const;
    00064         virtual void GetIntersectingFeatures(const gnLocation& lt, vector<gnBaseFeature*>& feature_vector, vector<uint32>& index_vector) const;
    00065         virtual void GetBrokenFeatures(const gnLocation& lt, vector<gnBaseFeature*>& feature_vector) const;
    00066         virtual void RemoveFeature( const uint32 i );
    00067         /**
    00068          * Copies a specified range of bases and returns a pointer to
    00069          * the resulting gnGenomeSpec.  You must delete the copy when you
    00070          * are finished with it.
    00071          * @param startI The first base pair to copy
    00072          * @param len The length of the piece to copy
    00073          * @return A copy of the gnGenomeSpec containing only the specified bases
    00074          */
    00075         virtual gnGenomeSpec* CloneRange( const gnSeqI startI, const gnSeqI len ) const;
    00076
    00077 protected:
    00078         vector <gnFragmentSpec*> m_SpecList;
    00079
    00080 }; // class gnGenomeSpec
    00081
    00082 inline
    00083 gnGenomeSpec* gnGenomeSpec::Clone() const{
    00084         return new gnGenomeSpec(*this);
    00085 }
    00086
    00087 inline
    00088 uint32 gnGenomeSpec::GetSpecListLength() const{
    00089         return m_SpecList.size();
    00090 }
    00091
    00092 inline
    00093 gnFragmentSpec* gnGenomeSpec::GetSpec( const uint32 i ) const{
    00094         if(i < m_SpecList.size())
    00095                 return m_SpecList[i];
    00096         Throw_gnEx(FragmentIndexOutOfBounds());
    00097 }
    00098
    00099 inline
    00100 gnFragmentSpec* gnGenomeSpec::GetSpecByBase( const gnSeqI baseI ) const{
    00101         return m_SpecList[GetSpecIndexByBase(baseI)];
    00102 }
    00103
    00104 inline
    00105 void gnGenomeSpec::AddSpec( gnBaseSpec* spec, const uint32 i ){
    00106         uint32 index = i == UINT32_MAX ? m_SpecList.size() : i;
    00107         if(index <= m_SpecList.size()){
    00108                 m_SpecList.insert(m_SpecList.begin() + index, (gnFragmentSpec*)spec);
    00109         }
    00110 }
    00111
    00112 inline
    00113 void gnGenomeSpec::RemoveSpec( uint32 i ){
    00114         if(i < GetSpecListLength()){
    00115                 m_SpecList.erase(m_SpecList.begin() + i);
    00116         }
    00117 }
    00118
    00119 #endif
    00120         // _gnGenomeSpec_h_