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

gnBaseFeature.h

Go to the documentation of this file.
00001 /////////////////////////////////////////////////////////////////////////////
00002 // File:            gnBaseFeature.h
00003 // Purpose:         abstract Feature class
00004 // Description:     Provides an interface for Features in memory and on disk.
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 _gnBaseFeature_h_
00013 #define _gnBaseFeature_h_
00014 
00015 #include "gn/gnDefs.h"
00016 #include <string>
00017 #include <vector>
00018 #include "gn/gnClone.h"
00019 #include "gn/gnLocation.h"
00020 #include "gn/gnBaseQualifier.h"
00021 
00022 class gnFragmentSpec;
00023 
00024 /**
00025  * Features of DNA sequences can be accessed and manipulated using classes
00026  * derived from gnBaseFeature.  gnBaseFeature outlines a basic interface
00027  * and gives functionality its derived sequence classes, such as
00028  * gnCDSFeature.
00029  */
00030 class GNDLLEXPORT gnBaseFeature : public gnClone
00031 {
00032 public:
00033         gnBaseFeature();
00034         gnBaseFeature( string& name, uint32 id = 0, gnFragmentSpec* spec = NULL, gnLocation::gnLocationType lt = gnLocation::LT_Nothing, boolean broken = false );
00035         /**
00036          * Destructor, frees memory.
00037          */
00038         ~gnBaseFeature();
00039 
00040         virtual gnBaseFeature* Clone() const = 0;
00041         /**
00042          * Gets the feature name (e.g. CDS, trna...).
00043          * @return The feature name.
00044          */
00045         virtual string GetName() const;
00046         /**
00047          * Sets the feature name.
00048          * @param name The feature name.
00049          */
00050         virtual void SetName( const string& name );
00051         /**
00052          * Gets this feature's ID.
00053          * @return The feature's ID.
00054          */
00055         virtual uint32 GetID() const;
00056         /**
00057          * Sets this feature's ID.
00058          * @param id The feature's ID.
00059          */
00060         virtual void SetID(uint32 id);
00061         /**
00062          * Gets the gnFragmentSpec to which this feature refers.
00063          * @return The feature's ID.
00064          * @see gnFragmentSpec
00065          */
00066         virtual gnFragmentSpec* GetSpec() const;
00067         /**
00068          * Sets the gnFragmentSpec to which this feature refers.
00069          * @param spec A pointer to the fragment spec.
00070          */
00071         virtual void SetSpec(gnFragmentSpec* spec);
00072         /**
00073          * Gets this feature's location type.
00074          * @return The feature's location type.
00075          * @see gnLocationType
00076          */
00077         virtual gnLocation::gnLocationType GetLocationType() const;
00078         /**
00079          * Sets this feature's location type.
00080          * LT_BetweenBases is not a valid feature location type.
00081          * @param lType The feature's location type.
00082          * @see gnLocationType
00083          */
00084         virtual void SetLocationType( gnLocation::gnLocationType lType );
00085         /**
00086          * Returns the number of locations this feature describes.
00087          * @return The number of locations this feature describes.
00088          */
00089         virtual uint32 GetLocationListLength() const;
00090         /**
00091          * Adds a new location before the location at listI.
00092          * @param l The gnLocation to add.
00093          * @param listI The index into the location list to insert before.
00094          * @return True if successful, false otherwise.
00095          * @see gnLocation
00096          */
00097         virtual boolean AddLocation( const gnLocation& l, uint32 listI = 0);
00098         /**
00099          * Gets the location at listI.
00100          * @param listI The index into the location list to get.
00101          * @return The location.
00102          */
00103         virtual gnLocation GetLocation( uint32 listI ) const;
00104         /**
00105          * Deletes the location at listI.
00106          * @param listI The index into the location list to delete.
00107          * @return True if successful, false otherwise.
00108          */
00109         virtual boolean RemoveLocation( uint32 listI );
00110         /**
00111          * Sets the location at listI to a new location.
00112          * @param l The new location
00113          * @param listI The index into the location list to set.
00114          * @return True if successful, false otherwise.
00115          */
00116         virtual boolean SetLocation( const gnLocation& l, uint32 listI );
00117         /**
00118          * Increases this feature's coordinates by a specific number of bases.
00119          * @param i The number of bases to increase by.
00120          * @return True if successful, false if the feature was broken by the change.
00121          */
00122         virtual boolean MovePositive( const gnSeqI i );
00123         /**
00124          * Decreases this feature's coordinates by a specific number of bases.
00125          * @param i The number of bases to decrease by.
00126          * @return True if successful, false if the feature was broken by the change.
00127          */
00128         virtual boolean MoveNegative( const gnSeqI i );
00129         /**
00130          * Crops the start locations of this feature by the specified amount.
00131          * @param i The amount to crop.
00132          * @return True if successful, false if the feature was broken by the change.
00133          */
00134         virtual boolean CropStart( const gnSeqI i );
00135         /**
00136          * Crops the end locations of this feature by the specified amount.
00137          * @param i The amount to crop.
00138          * @return True if successful, false if the feature was broken by the change.
00139          */
00140         virtual boolean CropEnd( const gnSeqI i );
00141         /**
00142          * Crops the locations of this feature to fit within the given location.
00143          * @param l The location to crop reduce to.
00144          * @return True if successful, false if the feature was broken by the change.
00145          */
00146         virtual boolean Crop( const gnLocation& l );
00147         /**
00148          * Returns true if the feature is broken
00149          * @return True if the feature is broken
00150          */
00151         virtual boolean IsBroken() const;
00152         /**
00153          * Sets whether the feature is broken or not.
00154          * @param broke True if the feature should be broken, false otherwise
00155          */
00156         virtual void SetBroken(boolean broke);
00157 
00158         /**
00159          * Checks if the given coordinate is contained by this feature
00160          * @param i The coordinate to check
00161          * @return True if "i" is contained by this feature.  False otherwise
00162          */
00163         virtual boolean Contains( gnSeqI i ) const;
00164         /**
00165          * Checks if the given location is contained by this feature
00166          * @param l The location to check
00167          * @return True if "l" is contained by this feature.  False otherwise
00168          */
00169         virtual boolean Contains( const gnLocation& l ) const;
00170         /**
00171          * Checks if the given feature is entirely contained by this feature
00172          * @param feature The feature to check
00173          * @return True if "feature" is contained by this feature.  False otherwise
00174          */
00175         virtual boolean Contains( gnBaseFeature* feature ) const;
00176         /**
00177          * Checks if this feature is entirely contained by the given location
00178          * @param l The location to check
00179          * @return True if "l" contains by this feature.  False otherwise
00180          */
00181         virtual boolean IsContainedBy( const gnLocation& l ) const;
00182         /**
00183          * Checks if the given location intersects this feature
00184          * @param l The location to check
00185          * @return True if "l" intersects this feature.  False otherwise
00186          */
00187         virtual boolean Intersects( const gnLocation& l ) const;
00188         /**
00189          * Checks if the given feature intersects this feature
00190          * @param feature The location to check
00191          * @return True if "feature" intersects this feature.  False otherwise
00192          */
00193         virtual boolean Intersects( gnBaseFeature* feature ) const;
00194 
00195         /**
00196          * Returns the number of qualifiers in this feature.
00197          * @return The number of qualifiers in this feature.
00198          */
00199         virtual uint32 GetQualifierListLength() const;
00200         /**
00201          * Adds a new qualifier.
00202          * @param qualifier The qualifier to add.
00203          * @return True if successful, false otherwise.
00204          */
00205         virtual boolean AddQualifier( gnBaseQualifier* qualifier );
00206         /**
00207          * Looks for a qualifier by name.
00208          * @param name The name of the qualifier to look for.
00209          * @return True if a qualifier was found, false otherwise.
00210          */
00211         virtual boolean HasQualifier( const string& name ) const;
00212         /**
00213          * Searches for a qualifier by name, starting at the index listI.
00214          * @param name The name of the qualifier to look for.
00215          * @param listI The index into the qualifier list to start the search at.
00216          * @return The index of the qualifier.
00217          */
00218         virtual uint32 FirstIndexOfQualifier( const string& name, uint32 listI ) const;
00219         /**
00220          * Searches for a qualifier by name, ending at the index listI.
00221          * @param name The name of the qualifier to look for.
00222          * @param listI The index into the qualifier list to end the search at.
00223          * @return The index of the qualifier.
00224          */
00225         virtual uint32 LastIndexOfQualifier( const string& name, uint32 listI ) const;
00226         /**
00227          * Gets the name of the qualifier at the list index listI.
00228          * @param listI The index into the qualifier list.
00229          * @return The name of the qualifier.
00230          */
00231         virtual string GetQualifierName( uint32 listI ) const;
00232         /**
00233          * Gets the value of the qualifier at the list index listI.
00234          * @param listI The index into the qualifier list.
00235          * @return The value of the qualifier.
00236          */
00237         virtual string GetQualifierValue( uint32 listI ) const;
00238         /**
00239          * Gets the qualifier at the list index listI.
00240          * @param listI The index into the qualifier list.
00241          * @return The qualifier.
00242          */
00243         virtual gnBaseQualifier* GetQualifier( uint32 listI );
00244         /**
00245          * Deletes the qualifier at the list index listI.
00246          * @param listI The index into the qualifier list.
00247          * @return True if successful, false otherwise.
00248          */
00249         virtual boolean RemoveQualifier( uint32 listI );
00250         /**
00251          * Set the name and value of the qualifier at the list index listI.
00252          * @param name The new name of the qualifier.
00253          * @param value The new value of the qualifier.
00254          * @param listI The index into the qualifier list.
00255          * @return True if successful, false otherwise.
00256          */
00257         virtual boolean SetQualifier( string& name, string& value, uint32 listI );
00258         /**
00259          * Set the name of the qualifier at the list index listI.
00260          * @param name The new name of the qualifier.
00261          * @param listI The index into the qualifier list.
00262          * @return True if successful, false otherwise.
00263          */
00264         virtual boolean SetQualifierName( string& name, uint32 listI );
00265         /**
00266          * Set the value of the qualifier at the list index listI.
00267          * @param value The new value of the qualifier.
00268          * @param listI The index into the qualifier list.
00269          * @return True if successful, false otherwise.
00270          */
00271         virtual boolean SetQualifierValue( string& value, uint32 listI );
00272 protected:
00273         uint32 m_id;
00274         string m_name;
00275         boolean m_broken;
00276         gnLocation::gnLocationType m_locationType;
00277         vector< gnLocation > m_locationList;
00278         vector< gnBaseQualifier* > m_qualifierList;
00279         gnFragmentSpec* m_spec;
00280 };// class gnBaseFeature
00281 
00282 inline
00283 string gnBaseFeature::GetName() const{
00284         return m_name;
00285 }
00286 inline
00287 void gnBaseFeature::SetName( const string& name ){
00288         m_name = name;
00289 }
00290 inline
00291 uint32 gnBaseFeature::GetID() const{
00292         return m_id;
00293 }
00294 inline
00295 void gnBaseFeature::SetID(uint32 id){
00296         m_id = id;
00297 }
00298 inline
00299 gnFragmentSpec* gnBaseFeature::GetSpec() const{
00300         return m_spec;
00301 }
00302 inline
00303 void gnBaseFeature::SetSpec(gnFragmentSpec* spec){
00304         m_spec = spec;
00305 }
00306 inline
00307 boolean gnBaseFeature::IsBroken() const{
00308         return m_broken;
00309 }
00310 inline
00311 void gnBaseFeature::SetBroken(boolean broke){
00312         m_broken = broke;
00313 }
00314 
00315 inline
00316 gnLocation::gnLocationType gnBaseFeature::GetLocationType() const{
00317         return m_locationType;
00318 }
00319 inline
00320 void gnBaseFeature::SetLocationType( gnLocation::gnLocationType lType ){
00321         m_locationType = lType;
00322 }
00323 inline
00324 uint32 gnBaseFeature::GetLocationListLength() const{
00325         return m_locationList.size();
00326 }
00327 inline
00328 boolean gnBaseFeature::Crop( const gnLocation& l ){
00329         return CropStart(l.GetStart()) && CropEnd(l.GetEnd());
00330 }
00331 inline
00332 uint32 gnBaseFeature::GetQualifierListLength() const{
00333         return m_qualifierList.size();
00334 }
00335 
00336 #endif
00337         // _gnBaseFeature_h_

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