00001 ///////////////////////////////////////////////////////////////////////////// 00002 // File: gnSequence.h 00003 // Purpose: Sequence class 00004 // Description: Provides a high level sequence interface to all types of 00005 // sequence data. 00006 // Changes: 00007 // Version: libGenome 0.5.1 00008 // Author: Aaron Darling 00009 // Modified by: 00010 // Copyright: (c) Aaron Darling 00011 // Licenses: See COPYING file for details 00012 ///////////////////////////////////////////////////////////////////////////// 00013 #ifndef _gnSequence_h_ 00014 #define _gnSequence_h_ 00015 00016 #include "gn/gnDefs.h" 00017 00018 #include <string> 00019 #include <iostream> 00020 #include <list> 00021 #include "gn/gnBaseSource.h" 00022 #include "gn/gnGenomeSpec.h" 00023 #include "gn/gnSourceSpec.h" 00024 #include "gn/gnStringSpec.h" 00025 #include "gn/gnBaseFilter.h" 00026 #include "gn/gnCompare.h" 00027 00028 /** 00029 * gnSequence is the most commonly used class in libGenome. It provides a simple 00030 * and general way to manipulate genetic sequences, regardless of what kind of 00031 * database, web site, or file they are stored in. Sequence data can be 00032 * manipulated like a c++ string by using subseq() and erase(). gnSequence 00033 * updates annotated sequences with each change, breaking features if necessary. 00034 */ 00035 class GNDLLEXPORT gnSequence : public gnClone 00036 { 00037 public: 00038 /** 00039 * Empty Constructor, creates an empty gnSequence. 00040 */ 00041 gnSequence(); 00042 /** 00043 * Creates a gnSequence with a single fragment containing the bases in "seq". 00044 * @param seq The null terminated character array of base pairs to use. 00045 */ 00046 gnSequence( const gnSeqC* seq ); 00047 /** 00048 * Creates a gnSequence with a single fragment containing the bases in "str". 00049 * @param str The base pairs to use. 00050 */ 00051 gnSequence( const string& str ); 00052 /** 00053 * Creates a gnSequence with the genome stored in the gnGenomeSpec "gngs". 00054 * @param gngs the gnGenomeSpec to get contigs from. 00055 */ 00056 gnSequence( const gnGenomeSpec& gngs ); 00057 /** 00058 * Creates a gnSequence with the sequence fragment stored in the gnFragmentSpec "gnfs". 00059 * @param gnfs the gnFragmentSpec to get contigs from. 00060 */ 00061 gnSequence( const gnFragmentSpec& gnfs ); 00062 /** 00063 * Creates a gnSequence with the contig stored in the gnContigSpec "gncs". 00064 * Usually gncs will be a gnStringSpec or a gnSourceSpec. 00065 * @param gncs the gnContigSpec to get contigs from. 00066 */ 00067 gnSequence( const gnContigSpec& gncs ); 00068 /** 00069 * Creates a gnSequence with a single fragment containing the bases in "bases". 00070 * @param bases The base pairs to use 00071 * @param length The length of the base pair array. 00072 */ 00073 gnSequence( gnSeqC *bases, const gnSeqI length); 00074 /** 00075 * Copies the gnSequence "seq". 00076 * @param seq The gnSequence to copy. 00077 */ 00078 gnSequence( const gnSequence& seq); 00079 /** 00080 * Destructor, frees the memory used by this sequence. 00081 */ 00082 ~gnSequence(); 00083 00084 /** 00085 * Copies the gnSequence. 00086 */ 00087 gnSequence& operator=( const gnSequence& seq); 00088 00089 gnSequence* Clone() const; 00090 00091 /** 00092 * Returns the number of sequence fragments in this sequence. 00093 * @return the number of sequence fragments in this sequence. 00094 */ 00095 gnSeqI contigListSize() const; 00096 /** 00097 * Returns the number of sequence fragments in this sequence. 00098 * @return the number of sequence fragments in this sequence. 00099 */ 00100 gnSeqI contigListLength() const; 00101 /** 00102 * Returns the index of the contig which contains the specified base. 00103 * @param baseI A base pair in the contig. 00104 * @throws SeqIndexOutOfBounds will be propagated if baseI is invalid 00105 * @return The contig index which contains the base. 00106 */ 00107 uint32 contigIndexByBase( const gnSeqI baseI) const; 00108 /** 00109 * Returns a gnSequence containing the specified fragment. 00110 * @param contigI The index of the fragment to get. 00111 * @throws FragmentIndexOutOfBounds will be propagated if contigI is invalid 00112 * @return A gnSequence containing only the fragment. 00113 */ 00114 gnSequence contig( const uint32 contigI) const; 00115 /** 00116 * Returns a gnSequence containing only the fragment which contains the specified base. 00117 * @param baseI A base pair index in the contig 00118 * @throws SeqIndexOutOfBounds will be propagated if baseI is invalid 00119 * @return A gnSequence containing only the contig. 00120 */ 00121 gnSequence contigByBase( const gnSeqI baseI) const; 00122 /** 00123 * Returns the index of the base pair where the specified contig starts in this sequence. 00124 * @param contigI The index of the contig. 00125 * @throws FragmentIndexOutOfBounds will be propagated if contigI is invalid 00126 * @return The starting base pair index. 00127 */ 00128 virtual gnSeqI contigStart( const uint32 contigI) const; 00129 /** 00130 * Returns the length in base pairs of the specified contig in this sequence. 00131 * @param contigI The index of the contig. 00132 * @throws FragmentIndexOutOfBounds will be propagated if contigI is invalid 00133 * @return The length of the contig. 00134 */ 00135 virtual gnSeqI contigLength( const uint32 contigI) const; 00136 /** 00137 * Returns the index of the contig with the given name. 00138 * If two contigs have the same name, contigIndexByName() will return the first. 00139 * @param contigName The name of the contig. 00140 * @throws FragmentIndexOutOfBounds will be propagated if contigName is not found 00141 * @return The index of the contig. 00142 */ 00143 virtual uint32 contigIndexByName( string& contigName) const; 00144 /** 00145 * Returns the name of the specified contig. 00146 * @param contigI The index of the contig. 00147 * @throws FragmentIndexOutOfBounds will be propagated if contigI is invalid 00148 * @return The name of the contig. 00149 */ 00150 virtual string contigName( const uint32 contigI) const; 00151 /** 00152 * Returns a gnSequence containing only the named contig. 00153 * If two contigs have the same name, contigByName() will return the first. 00154 * @param contigName The name of the contig. 00155 * @throws FragmentIndexOutOfBounds will be propagated if contigName is not found 00156 * @return A gnSequence containing the contig. 00157 */ 00158 virtual gnSequence contigByName( string& contigName) const; 00159 /** 00160 * Merges the bases starting at base index "startI" and ending at "endI" into one contig, splitting existing contigs. 00161 * @param startI The starting base pair of the new contig. 00162 * @param endI The ending base pair of the new contig. 00163 * @throws SeqIndexOutOfBounds exception is propagated if startI or endI are invalid 00164 */ 00165 virtual void merge(const gnSeqI startI, const gnSeqI endI); 00166 /** 00167 * Merges the contigs starting at the contig index "startC" and ending at "endC" into one contig. 00168 * @param startC The starting contig of the new contig. 00169 * @param endC The ending contig of the new contig. 00170 * @throws FragmentIndexOutOfBounds exception is propagated if startC or endC are invalid 00171 */ 00172 virtual void mergeContigs(const uint32 startC, const uint32 endC); 00173 /** 00174 * Splits the specified contig after splitI 00175 * @param splitI The base pair to split after. 00176 * @param contigI The index of the contig to split or ALL_CONTIGS by default. 00177 */ 00178 virtual void splitContig(const gnSeqI splitI, const uint32 contigI=ALL_CONTIGS); 00179 00180 virtual void setContigName( const uint32 contigI, const string& contig_name); 00181 00182 /** 00183 * Returns the size of the feature list for the specified contig. 00184 * @return The feature list size. 00185 */ 00186 virtual uint32 getFeatureListLength() const; 00187 /** 00188 * Returns the feature specified by featureI. 00189 * @param featureI The index of the feature to return. 00190 * @throws FeatureIndexOutOfBounds exception is thrown if featureI does not reference a valid feature 00191 * @return A copy of the feature allocated on the heap. You must delete the feature when finished with it. 00192 */ 00193 virtual gnBaseFeature* getFeature(const uint32 featureI) const; 00194 /** 00195 * Creates a list of all features which are contained by coordinates specified. 00196 * @param lt The coordinates containing the features to return. 00197 * @param feature_vector The vector to store features in. Each feature pointer points to a copy of the feature on the heap which must be deleted. 00198 * @param index_vector A vector of indices which correspond to the features. 00199 */ 00200 virtual void getContainedFeatures(const gnLocation& lt, vector<gnBaseFeature*>& feature_vector, vector<uint32>& index_vector) const; 00201 /** 00202 * Creates a list of all features which intersect the coordinates specified. 00203 * @param lt The coordinates intersecting the features to return. 00204 * @param feature_vector The vector to store features in. Each feature pointer points to a copy of the feature on the heap which must be deleted. 00205 * @param index_vector A vector of indices which correspond to the features. 00206 */ 00207 virtual void getIntersectingFeatures(const gnLocation& lt, vector<gnBaseFeature*>& feature_vector, vector<uint32>& index_vector) const; 00208 /** 00209 * Adds the specified feature to the feature list. 00210 * @param feature The feature to add. 00211 * @return The feature index. 00212 */ 00213 virtual uint32 addFeature(gnBaseFeature* feature); 00214 /** 00215 * Removes the specified feature. 00216 * @param featureI The index in the feature list of the feature to remove. 00217 * @throws FeatureIndexOutOfBounds exception is thrown if featureI does not reference a valid feature 00218 */ 00219 virtual void removeFeature(const uint32 featureI); 00220 /** 00221 * Creates a list of features which may have been broken by an edit. 00222 * @param lt The coordinates containing the features to return. 00223 * @param feature_vector The vector to store features in. Each feature pointer points to a copy of the feature on the heap which must be deleted. 00224 */ 00225 virtual void getBrokenFeatures(const gnLocation& lt, vector<gnBaseFeature*>& feature_vector) const; 00226 /** 00227 * Returns the size of the header list for the specified contig. 00228 * @param contigI The index of the contig to use, or ALL_CONTIGS to add a general header. 00229 * @throws FragmentIndexOutOfBounds will be propagated if contigI is invalid 00230 * @return The header list size. 00231 */ 00232 virtual uint32 getHeaderListLength(const uint32 contigI) const; 00233 /** 00234 * Returns the feature specified by featureI. 00235 * @param contigI The index of the contig to use, or ALL_CONTIGS to get a general header. 00236 * @param headerI The index of the header to return. 00237 * @throws FragmentIndexOutOfBounds will be propagated if contigI is invalid 00238 * @throws HeaderIndexOutOfBounds will be propagated if headerI is invalid 00239 * @return The header, or NULL if headerI is out of range. 00240 */ 00241 virtual gnBaseHeader* getHeader(const uint32 contigI, const uint32 headerI) const; 00242 /** 00243 * Adds header information to a specified contig. 00244 * @param contigI The index of the contig to use, or ALL_CONTIGS to add a general header. 00245 * @param header The header to add. 00246 * @param headerI The index in the header list where this header should be inserted. 00247 * @throws FragmentIndexOutOfBounds will be propagated if contigI is invalid 00248 */ 00249 virtual void addHeader(const uint32 contigI, gnBaseHeader* header, const uint32 headerI); 00250 /** 00251 * Removes header information from a specified contig. 00252 * @param contigI The index of the contig to use, or ALL_CONTIGS to remove a general header. 00253 * @param headerI The index in the header list of the header to remove. 00254 * @throws FragmentIndexOutOfBounds will be propagated if contigI is invalid 00255 */ 00256 virtual void removeHeader(const uint32 contigI, const uint32 headerI); 00257 /** 00258 * Reverse complements a specified contig, or the entire sequence if ALL_CONTIGS is specified. 00259 * @param revComp True if the area should be reverse complement, false otherwise. 00260 * @param contigI The index of the contig to use, or ALL_CONTIGS. 00261 * @throws FragmentIndexOutOfBounds will be propagated if contigI is invalid 00262 */ 00263 virtual void setReverseComplement( const boolean revComp, const uint32 contigI=ALL_CONTIGS); 00264 /** 00265 * Returns true if a specified contig, or the entire sequence is reverse complement. 00266 * @param contigI The index of the contig to use, or ALL_CONTIGS for the whole sequence. 00267 * @throws FragmentIndexOutOfBounds will be propagated if contigI is invalid 00268 * @return True if the sequence is reverse complement, false otherwise. 00269 */ 00270 virtual boolean isReverseComplement( const uint32 contigI=ALL_CONTIGS ); 00271 /** 00272 * Returns true if this sequence is circular. 00273 * @return True if this sequence is circular. 00274 */ 00275 virtual boolean isCircular() const; 00276 /** 00277 * Sets whether this sequence should be read circular. 00278 * If circular is set, reads beyond the end of the sequence will pick up 00279 * at the beginning. 00280 * @param value True for circular, false otherwise. 00281 */ 00282 virtual void setCircular( const boolean value ); 00283 00284 /** 00285 * Converts the global sequence coordinate baseI to a contig local coordinate. 00286 * @param contigI This is set to the index of the contig containing baseI 00287 * @param baseI This is the global coordinate to be converted to contig local. 00288 * @throws SeqIndexOutOfBounds will be thrown if baseI is out of range 00289 */ 00290 virtual void globalToLocal(uint32& contigI, gnSeqI& baseI) const; 00291 00292 /** 00293 * Converts the local contig coordinate baseI to a global sequence coordinate. 00294 * @param contigI The index of the contig containing baseI. 00295 * @param baseI The local contig coordinate to be converted to global. 00296 * @throws SeqIndexOutOfBounds will be thrown if baseI is out of range 00297 * @throws FragmentIndexOutOfBounds will be propagated if contigI is invalid 00298 */ 00299 virtual void localToGlobal(const uint32 contigI, gnSeqI& baseI) const; 00300 /** 00301 * Converts the global sequence coordinate baseI to a local coordinate in the original 00302 * data source. globalToSource() will overwrite any values passed to it! 00303 * @param contigI This will be set to contig index in the original source. 00304 * @param baseI This will be set to the contig local base index in the original source. 00305 * @throws SeqIndexOutOfBounds will be thrown if baseI is out of range 00306 */ 00307 virtual void globalToSource(uint32& contigI, gnSeqI& baseI) const; 00308 /** 00309 * Converts the contig local sequence coordinate baseI in contig contigI to a 00310 * local coordinate in the original data source. localToSource() will overwrite any values 00311 * passed to it! 00312 * @param contigI This will be set to contig index in the original source. 00313 * @param baseI This will be set to the contig local base index in the original source. 00314 * @throws SeqIndexOutOfBounds will be thrown if baseI is out of range 00315 * @throws FragmentIndexOutOfBounds will be propagated if contigI is invalid 00316 */ 00317 virtual void localToSource(uint32& contigI, gnSeqI& baseI) const; 00318 /** 00319 * Loads the sequence located at the URL in "sourcename". 00320 * Possible URLs currently include only "file:///" URLs. 00321 * If no URL prefix is found then LoadSource assumes that "sourcename" 00322 * contains the name of a local file. 00323 * @param sourcename The location of the data to load. 00324 * @return True if successful. False otherwise. 00325 */ 00326 virtual bool LoadSource(const string sourcename); 00327 00328 /** Assigns a filter which all sequence data must pass through when 00329 * read from the object. 00330 * @param filt The filter to use. 00331 */ 00332 virtual void setFilter(const gnBaseFilter* filt); 00333 00334 /** Assigns a list of filters which all sequence data passes through 00335 * in order when read from the object. There may not be any NULL 00336 * pointers in the list. 00337 * @param filt_list The ordered list of filters to use. 00338 */ 00339 virtual void setFilterList(list<const gnBaseFilter*>& filt_list); 00340 00341 /** Returns the list of filters currently being used 00342 * @return The list of filters in use. 00343 */ 00344 virtual list<const gnBaseFilter*> getFilterList() const; 00345 00346 /** 00347 * Assigns the sequence "seq" to this sequence. 00348 * @param seq The seqence to assign to this sequence. 00349 */ 00350 virtual void assign(gnSequence& seq); 00351 00352 // Comparison Operators 00353 /** 00354 * Assigns the sequence "seq" to this sequence. 00355 */ 00356 void operator=(gnSequence& seq); 00357 boolean operator==(const gnSequence& seq) const; 00358 boolean operator!=(const gnSequence& seq) const; 00359 boolean operator<(const gnSequence& seq) const; 00360 boolean operator<=(const gnSequence& seq) const; 00361 boolean operator>(const gnSequence& seq) const; 00362 boolean operator>=(const gnSequence& seq) const; 00363 /** 00364 * Appends the bases in "seq" to this sequence. 00365 */ 00366 gnSequence& operator+=(const gnSequence& seq); 00367 /** 00368 * Compares the bases in "seq" to this sequence. 00369 * @param seq The sequence to compare this sequence to. 00370 * @return Negative if this sequence is lesser, 0 if the two sequences are 00371 * equal, and positive if this sequence is greater. 00372 */ 00373 virtual int compare(const gnSequence& seq) const; 00374 virtual int compare(const string& str) const; 00375 // Append and Insert Operators 00376 /** 00377 * Appends the bases in "seq" to this sequence. 00378 * @param seq The sequence to append to this sequence. 00379 */ 00380 virtual void append( const gnSequence& seq); 00381 /** 00382 * Inserts the first "len" bases in "bases" into this sequence.at "offset". 00383 * insert() will update the locations of all affected features. 00384 * @param offset The base pair to insert before. 00385 * @param bases The character array of bases to insert. 00386 * @param length The length of the character array. 00387 */ 00388 virtual void insert( const gnSeqI offset, const gnSeqC *bases, const gnSeqI length); 00389 /** 00390 * Inserts the annotated sequence in "seq" into this sequence.at "offset". 00391 * insert() will update the locations of all affected features. 00392 * @param offset The base pair to insert before. 00393 * @param seq The sequence to insert. 00394 */ 00395 virtual void insert( const gnSeqI offset, const gnSequence& seq); 00396 /** 00397 * Inserts the annotated sequence in "gnbs" into this sequence.at "offset". 00398 * insert() will update the locations of all affected features. 00399 * @param offset The base pair to insert before. 00400 * @param gnbs The spec to insert. 00401 */ 00402 virtual void insert( const gnSeqI offset, const gnGenomeSpec& gnbs); 00403 // Concatenation Operators 00404 /** 00405 * Concatenates this sequence with the annotated sequence in "seq". 00406 */ 00407 gnSequence const operator+(const gnSequence& seq) const; 00408 // Substrings and base deletion 00409 /** 00410 * Creates a sequence containing the "length" bases starting at "offset". 00411 * @param offset The base pair index to start the subsequence. 00412 * @param length The length of the subsequence. 00413 * @return The subsequence. 00414 */ 00415 gnSequence subseq(const gnSeqI offset, const gnSeqI length) const; 00416 /** 00417 * Deletes the "len" bases starting at "offset". 00418 * @param offset The base pair index to start erasing. 00419 * @param length The length of the sequence to erase 00420 */ 00421 virtual void erase( const gnSeqI offset=0, const gnSeqI length=GNSEQI_END ); 00422 // IO operators 00423 /** 00424 * Reads bases from the specified input stream (e.g. cin). 00425 */ 00426 friend std::istream& operator>>(std::istream& is, gnSequence& gns); //read from source. 00427 /** 00428 * Writes the bases in this sequence to the specified output stream (e.g. cout). 00429 */ 00430 friend std::ostream& operator<<(std::ostream& os, const gnSequence& gns); //write to source. 00431 // Size functions 00432 /** 00433 * Returns the length of this sequence. 00434 * @return the length of this sequence. 00435 */ 00436 virtual gnSeqI length() const; 00437 /** 00438 * Returns the length of this sequence. 00439 * @return the length of this sequence. 00440 */ 00441 virtual gnSeqI size() const; 00442 // Raw Sequence Access 00443 /** 00444 * Returns the "length" bases starting at "offset" as a string. 00445 * @param length The length of the sequence to convert 00446 * @param offset The base pair index of the sequence to convert 00447 * @return The string of base pairs. 00448 */ 00449 virtual string ToString( const gnSeqI length=GNSEQI_END, const gnSeqI offset=1 ) const; 00450 /** 00451 * Converts the "length" bases starting at "offset" into the string "str". 00452 * @param str The string to store bases in. 00453 * @param length The length, in base pairs, to convert. 00454 * @param offset The base pair index to start converting. 00455 * @return True if successful, false otherwise. 00456 */ 00457 virtual boolean ToString( string& str, const gnSeqI length=GNSEQI_END, const gnSeqI offset=1 ) const; 00458 /** 00459 * Converts the "length" bases starting at "offset" into the character array "pSeqC".. 00460 * After converting, "length" will be set to the actual length of the sequence. 00461 * Be sure to null terminate the character array if you are going to print it! 00462 * @param pSeqC The character array of bases to store bases in. 00463 * @param length The length, in base pairs, to convert. 00464 * @param offset The base pair index to start converting. 00465 * @return True if successful, false otherwise. 00466 */ 00467 virtual boolean ToArray( gnSeqC* pSeqC, gnSeqI length, const gnSeqI offset=1 ) const; 00468 /** 00469 * Returns the base at "offset". 00470 * @param offset The index of the base to get. 00471 * @return The base. 00472 */ 00473 virtual gnSeqC GetSeqC( const gnSeqI offset ) const; // return gnSeqC illegal char. 00474 /** 00475 * Returns the base at the specified index. 00476 * @return The base at the specified index. 00477 */ 00478 gnSeqC operator[]( const gnSeqI offset ) const; 00479 00480 /** 00481 * Get the spec (annotated sequence) which this sequence represents. 00482 * @return The spec represented by this gnSequence. 00483 */ 00484 virtual gnGenomeSpec* GetSpec() const; 00485 /** 00486 * Set the spec (annotated sequence) which this sequence represents. 00487 * @param s The new spec. 00488 */ 00489 virtual void SetSpec(gnGenomeSpec* s); 00490 00491 /** 00492 * Find looks for the search sequence within this gnSequence and returns 00493 * the position of the first match if any exists. 00494 * @param search The gnSequence to be found 00495 * @param offset The position where searching will begin (default is 0) 00496 * @return The first position where the search string is found or 00497 * GNSEQI_ERROR if the search sequence is not found. 00498 */ 00499 virtual gnSeqI find(const gnSequence& search, const gnSeqI offset=0) const; 00500 00501 private: 00502 gnGenomeSpec *spec; 00503 list<const gnBaseFilter*> filter_list; 00504 const gnCompare* comparator; 00505 }; // class gnSequence 00506 00507 00508 GNDLLEXPORT 00509 std::istream& operator>>(std::istream& is, gnSequence& gns); //read from source. 00510 GNDLLEXPORT 00511 std::ostream& operator<<(std::ostream& os, const gnSequence& gns); //write to source. 00512 00513 // Assignment Operators 00514 inline 00515 void gnSequence::operator=(gnSequence& seq){ 00516 spec = seq.spec->Clone(); 00517 } 00518 inline 00519 void gnSequence::assign(gnSequence& seq){ 00520 spec = seq.spec->Clone(); 00521 } 00522 inline 00523 boolean gnSequence::operator==(const gnSequence& seq) const{ 00524 return (compare(seq)==0); 00525 } 00526 inline 00527 boolean gnSequence::operator!=(const gnSequence& seq) const{ 00528 return (compare(seq)!=0); 00529 } 00530 inline 00531 boolean gnSequence::operator<(const gnSequence& seq) const{ 00532 return (compare(seq)<0); 00533 } 00534 inline 00535 boolean gnSequence::operator<=(const gnSequence& seq) const{ 00536 return (compare(seq)<=0); 00537 } 00538 inline 00539 boolean gnSequence::operator>(const gnSequence& seq) const{ 00540 return (compare(seq)>0); 00541 } 00542 inline 00543 boolean gnSequence::operator>=(const gnSequence& seq) const{ 00544 return (compare(seq)>=0); 00545 } 00546 // Append and Insert Operators 00547 inline 00548 gnSequence& gnSequence::operator+=(const gnSequence& seq){ 00549 insert(GNSEQI_END, *seq.spec); 00550 return *this; 00551 } 00552 inline 00553 void gnSequence::append( const gnSequence& seq){ 00554 insert(GNSEQI_END, *seq.spec); 00555 } 00556 //Feature functions 00557 inline 00558 uint32 gnSequence::getFeatureListLength() const{ 00559 return spec->GetFeatureListLength(); 00560 } 00561 inline 00562 gnBaseFeature* gnSequence::getFeature(const uint32 featureI) const{ 00563 return spec->GetFeature(featureI); 00564 } 00565 inline 00566 uint32 gnSequence::addFeature(gnBaseFeature* feature){ 00567 return spec->AddFeature(feature); 00568 } 00569 inline 00570 void gnSequence::removeFeature(const uint32 featureI){ 00571 spec->RemoveFeature(featureI); 00572 } 00573 inline 00574 void gnSequence::getContainedFeatures(const gnLocation& lt, vector<gnBaseFeature*>& feature_vector, vector<uint32>& index_vector) const{ 00575 spec->GetContainedFeatures(lt, feature_vector, index_vector); 00576 } 00577 inline 00578 void gnSequence::getIntersectingFeatures(const gnLocation& lt, vector<gnBaseFeature*>& feature_vector, vector<uint32>& index_vector) const{ 00579 spec->GetIntersectingFeatures(lt, feature_vector, index_vector); 00580 } 00581 inline 00582 void gnSequence::getBrokenFeatures(const gnLocation& lt, vector<gnBaseFeature*>& feature_vector) const{ 00583 spec->GetBrokenFeatures(lt, feature_vector); 00584 } 00585 00586 inline 00587 boolean gnSequence::isCircular() const{ 00588 return spec->IsCircular(); 00589 } 00590 00591 inline 00592 void gnSequence::setCircular( const boolean value ){ 00593 spec->SetCircular(value); 00594 } 00595 inline 00596 void gnSequence::insert( const gnSeqI offset, const gnSequence& seq){ 00597 insert(offset, *seq.spec); 00598 } 00599 00600 // Size functions 00601 inline 00602 gnSeqI gnSequence::length() const{ 00603 return spec->GetLength(); 00604 } 00605 inline 00606 gnSeqI gnSequence::size() const{ 00607 return spec->GetLength(); 00608 } 00609 inline 00610 gnGenomeSpec* gnSequence::GetSpec() const{ 00611 return spec; 00612 } 00613 inline 00614 void gnSequence::SetSpec(gnGenomeSpec* s){ 00615 if(spec != NULL) 00616 delete spec; 00617 spec = s; 00618 } 00619 00620 inline 00621 void gnSequence::setFilter(const gnBaseFilter* filt){ 00622 filter_list.clear(); 00623 if(filt != NULL) 00624 filter_list.push_back(filt); 00625 } 00626 inline 00627 void gnSequence::setFilterList(list<const gnBaseFilter*>& filt_list){ 00628 filter_list = filt_list; 00629 } 00630 inline 00631 list<const gnBaseFilter*> gnSequence::getFilterList() const{ 00632 return filter_list; 00633 } 00634 00635 00636 #endif 00637 // _gnSequence_h_