gnFragmentSpec.h Source File

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

# gnFragmentSpec.h

Go to the documentation of this file.

    00001
    00002 // File:            gnFragmentSpec.h
    00003 // Purpose:         abstract Spec class
    00004 // Description:     Genome level spec class
    00005 // Changes:
    00006 // Version:         libGenome 0.1.0
    00007 // Author:          Aaron Darling
    00008 // Last Edited:     April 15, 2001, 10:34:50pm
    00009 // Modified by:
    00010 // Copyright:       (c) Aaron Darling
    00011 // Licenses:        Proprietary
    00013 #ifndef _gnFragmentSpec_h_
    00014 #define _gnFragmentSpec_h_
    00015
    00016 #include "gn/gnDefs.h"
    00017
    00018 #include <vector>
    00019 #include <string>
    00020
    00021 #include "gn/gnClone.h"
    00022 #include "gn/gnBaseFeature.h"
    00023 #include "gn/gnBaseHeader.h"
    00024 #include "gn/gnContigSpec.h"
    00025 #include "gn/gnMultiSpec.h"
    00026 #include "gn/gnException.h"
    00027
    00035 class GNDLLEXPORT gnFragmentSpec : public gnMultiSpec
    00036 {
    00037 public:
    00038         gnFragmentSpec();
    00042         virtual ~gnFragmentSpec();
    00047         gnFragmentSpec( const gnFragmentSpec& s);
    00048         virtual gnFragmentSpec* Clone() const;
    00049         virtual void Clear();
    00050 // Base Spec stuff
    00051         virtual void SetReverseComplement( const boolean value );
    00052
    00053 //Multispec stuff
    00054         virtual uint32 GetSpecListLength() const;
    00055         virtual gnContigSpec* GetSpec( const uint32 i ) const;
    00056         virtual gnContigSpec* GetSpecByBase( const gnSeqI baseI ) const;
    00057         virtual void AddSpec( gnBaseSpec* spec, const uint32 i = UINT32_MAX );
    00058         virtual void RemoveSpec( uint32 i );
    00059
    00060         virtual void CropStart( gnSeqI cropLen );
    00061         virtual void CropEnd( gnSeqI cropLen );
    00062         virtual uint32 AddFeature( gnBaseFeature* feat );
    00063         virtual uint32 GetFeatureListLength() const;
    00064         virtual gnBaseFeature* GetFeature( const uint32 i ) const;
    00065         virtual void GetContainedFeatures(const gnLocation& lt, vector<gnBaseFeature*>& feature_vector, vector<uint32>& index_vector) const;
    00066         virtual void GetIntersectingFeatures(const gnLocation& lt, vector<gnBaseFeature*>& feature_vector, vector<uint32>& index_vector) const;
    00067         virtual void GetBrokenFeatures(const gnLocation& lt, vector<gnBaseFeature*>& feature_vector) const;
    00068         virtual void RemoveFeature( const uint32 i );
    00069
    00078         virtual gnFragmentSpec* CloneRange( const gnSeqI startI, const gnSeqI len ) const;
    00079
    00080 protected:
    00081         vector <gnContigSpec*> m_SpecList;
    00082         //Feature stuff...
    00083         vector <gnBaseFeature*> m_featureList;
    00084
    00085 }; // class gnFragmentSpec
    00086
    00087 inline
    00088 gnFragmentSpec* gnFragmentSpec::Clone() const{
    00089         return new gnFragmentSpec(*this);
    00090 }
    00091
    00092 inline
    00093 uint32 gnFragmentSpec::GetSpecListLength() const{
    00094         return m_SpecList.size();
    00095 }
    00096
    00097 inline
    00098 gnContigSpec *gnFragmentSpec::GetSpec( const uint32 i ) const{
    00099         if(i < m_SpecList.size())
    00100                 return m_SpecList[i];
    00101         Throw_gnEx(ContigIndexOutOfBounds());
    00102 }
    00103
    00104 inline
    00105 gnContigSpec* gnFragmentSpec::GetSpecByBase( const gnSeqI baseI ) const{
    00106         return m_SpecList[GetSpecIndexByBase(baseI)];
    00107 }
    00108
    00109 inline
    00110 void gnFragmentSpec::AddSpec( gnBaseSpec* spec, const uint32 i ){
    00111         uint32 index = i == UINT32_MAX ? m_SpecList.size() : i;
    00112         if(index <= m_SpecList.size()){
    00113                 m_SpecList.insert(m_SpecList.begin() + index, (gnContigSpec*)spec);
    00114         }
    00115 }
    00116
    00117 inline
    00118 void gnFragmentSpec::RemoveSpec( uint32 i ){
    00119         if(i < GetSpecListLength()){
    00120                 m_SpecList.erase(m_SpecList.begin() + i);
    00121         }else
    00122                 Throw_gnEx(ContigIndexOutOfBounds());
    00123 }
    00124
    00125 inline
    00126 uint32 gnFragmentSpec::AddFeature( gnBaseFeature* feat )
    00127 {
    00128         m_featureList.push_back(feat);
    00129         feat->SetSpec(this);
    00130         return m_featureList.size()-1;
    00131 }
    00132 inline
    00133 uint32 gnFragmentSpec::GetFeatureListLength() const
    00134 {
    00135         return m_featureList.size();
    00136 }
    00137 inline
    00138 gnBaseFeature* gnFragmentSpec::GetFeature(const uint32 i) const
    00139 {
    00140         return m_featureList[i]->Clone();
    00141 }
    00142 inline
    00143 void gnFragmentSpec::RemoveFeature( const uint32 i)
    00144 {
    00145         if(i >= m_featureList.size())
    00146                 Throw_gnEx(FeatureIndexOutOfBounds());
    00147         delete m_featureList[i];
    00148         m_featureList.erase(m_featureList.begin() + i);
    00149 }
    00150
    00151 #endif
    00152         // _gnFragmentSpec_h_