|
gnSequence.hGo to the documentation of this file.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.1.0 00008 // Author: Aaron Darling 00009 // Last Edited: April 15, 2001, 10:34:50pm 00010 // Modified by: 00011 // Copyright: (c) Aaron Darling 00012 // Licenses: Proprietary 00014 #ifndef _gnSequence_h_ 00015 #define _gnSequence_h_ 00016 00017 #include "gn/gnDefs.h" 00018 00019 #include <string> 00020 #include <iostream> 00021 #include <list> 00022 #include "gn/gnBaseSource.h" 00023 #include "gn/gnGenomeSpec.h" 00024 #include "gn/gnSourceSpec.h" 00025 #include "gn/gnStringSpec.h" 00026 #include "gn/gnBaseFilter.h" 00027 #include "gn/gnCompare.h" 00028 00036 class GNDLLEXPORT gnSequence : public gnClone 00037 { 00038 public: 00042 gnSequence(); 00047 gnSequence( const gnSeqC* seq ); 00052 gnSequence( const string& str ); 00057 gnSequence( const gnGenomeSpec& gngs ); 00062 gnSequence( const gnFragmentSpec& gnfs ); 00068 gnSequence( const gnContigSpec& gncs ); 00074 gnSequence( gnSeqC *bases, const gnSeqI length); 00079 gnSequence( const gnSequence& seq); 00083 ~gnSequence(); 00084 00088 gnSequence& operator=( const gnSequence& seq); 00089 00090 gnSequence* Clone() const; 00091 00096 gnSeqI contigListSize() const; 00101 gnSeqI contigListLength() const; 00108 uint32 contigIndexByBase( const gnSeqI baseI) const; 00115 gnSequence contig( const uint32 contigI) const; 00122 gnSequence contigByBase( const gnSeqI baseI) const; 00129 virtual gnSeqI contigStart( const uint32 contigI) const; 00136 virtual gnSeqI contigLength( const uint32 contigI) const; 00144 virtual uint32 contigIndexByName( string& contigName) const; 00151 virtual string contigName( const uint32 contigI) const; 00159 virtual gnSequence contigByName( string& contigName) const; 00166 virtual void merge(const gnSeqI startI, const gnSeqI endI); 00173 virtual void mergeContigs(const uint32 startC, const uint32 endC); 00179 virtual void splitContig(const gnSeqI splitI, const uint32 contigI=ALL_CONTIGS); 00180 00181 virtual void setContigName( const uint32 contigI, const string& contig_name); 00182 00188 virtual uint32 getFeatureListLength() const; 00195 virtual gnBaseFeature* getFeature(const uint32 featureI) const; 00202 virtual void getContainedFeatures(const gnLocation& lt, vector<gnBaseFeature*>& feature_vector, vector<uint32>& index_vector) const; 00209 virtual void getIntersectingFeatures(const gnLocation& lt, vector<gnBaseFeature*>& feature_vector, vector<uint32>& index_vector) const; 00215 virtual uint32 addFeature(gnBaseFeature* feature); 00221 virtual void removeFeature(const uint32 featureI); 00227 virtual void getBrokenFeatures(const gnLocation& lt, vector<gnBaseFeature*>& feature_vector) const; 00234 virtual uint32 getHeaderListLength(const uint32 contigI) const; 00243 virtual gnBaseHeader* getHeader(const uint32 contigI, const uint32 headerI) const; 00251 virtual void addHeader(const uint32 contigI, gnBaseHeader* header, const uint32 headerI); 00258 virtual void removeHeader(const uint32 contigI, const uint32 headerI); 00265 virtual void setReverseComplement( const boolean revComp, const uint32 contigI=ALL_CONTIGS); 00272 virtual boolean isReverseComplement( const uint32 contigI=ALL_CONTIGS ); 00277 virtual boolean isCircular() const; 00284 virtual void setCircular( const boolean value ); 00285 00292 virtual void globalToLocal(uint32& contigI, gnSeqI& baseI) const; 00293 00301 virtual void localToGlobal(const uint32 contigI, gnSeqI& baseI) const; 00309 virtual void globalToSource(uint32& contigI, gnSeqI& baseI) const; 00319 virtual void localToSource(uint32& contigI, gnSeqI& baseI) const; 00328 virtual bool LoadSource(const string sourcename); 00329 00334 virtual void setFilter(const gnBaseFilter* filt); 00335 00341 virtual void setFilterList(list<const gnBaseFilter*>& filt_list); 00342 00346 virtual list<const gnBaseFilter*> getFilterList() const; 00347 00352 virtual void assign(gnSequence& seq); 00353 00354 // Comparison Operators 00358 void operator=(gnSequence& seq); 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 boolean operator>(const gnSequence& seq) const; 00364 boolean operator>=(const gnSequence& seq) const; 00368 gnSequence& operator+=(const gnSequence& seq); 00375 virtual int compare(const gnSequence& seq) const; 00376 virtual int compare(const string& str) const; 00377 // Append and Insert Operators 00382 virtual void append( const gnSequence& seq); 00390 virtual void insert( const gnSeqI offset, const gnSeqC *bases, const gnSeqI length); 00397 virtual void insert( const gnSeqI offset, const gnSequence& seq); 00404 virtual void insert( const gnSeqI offset, const gnGenomeSpec& gnbs); 00405 // Concatenation Operators 00409 gnSequence const operator+(const gnSequence& seq) const; 00410 // Substrings and base deletion 00417 gnSequence subseq(const gnSeqI offset, const gnSeqI length) const; 00423 virtual void erase( const gnSeqI offset=0, const gnSeqI length=GNSEQI_END ); 00424 // IO operators 00428 friend std::istream& operator>>(std::istream& is, gnSequence& gns); //read from source. 00432 friend std::ostream& operator<<(std::ostream& os, const gnSequence& gns); //write to source. 00433 // Size functions 00438 virtual gnSeqI length() const; 00443 virtual gnSeqI size() const; 00444 // Raw Sequence Access 00451 virtual string ToString( const gnSeqI length=GNSEQI_END, const gnSeqI offset=1 ) const; 00459 virtual boolean ToString( string& str, const gnSeqI length=GNSEQI_END, const gnSeqI offset=1 ) const; 00469 virtual boolean ToArray( gnSeqC* pSeqC, gnSeqI length, const gnSeqI offset=1 ) const; 00475 virtual gnSeqC GetSeqC( const gnSeqI offset ) const; // return gnSeqC illegal char. 00480 gnSeqC operator[]( const gnSeqI offset ) const; 00481 00486 virtual gnGenomeSpec* GetSpec() const; 00491 virtual void SetSpec(gnGenomeSpec* s); 00492 00501 virtual gnSeqI find(const gnSequence& search, const gnSeqI offset=0) const; 00502 00503 private: 00504 gnGenomeSpec *spec; 00505 list<const gnBaseFilter*> filter_list; 00506 const gnCompare* comparator; 00507 }; // class gnSequence 00508 00509 00510 GNDLLEXPORT 00511 std::istream& operator>>(std::istream& is, gnSequence& gns); //read from source. 00512 GNDLLEXPORT 00513 std::ostream& operator<<(std::ostream& os, const gnSequence& gns); //write to source. 00514 00515 // Assignment Operators 00516 inline 00517 void gnSequence::operator=(gnSequence& seq){ 00518 spec = seq.spec->Clone(); 00519 } 00520 inline 00521 void gnSequence::assign(gnSequence& seq){ 00522 spec = seq.spec->Clone(); 00523 } 00524 inline 00525 boolean gnSequence::operator==(const gnSequence& seq) const{ 00526 return (compare(seq)==0); 00527 } 00528 inline 00529 boolean gnSequence::operator!=(const gnSequence& seq) const{ 00530 return (compare(seq)!=0); 00531 } 00532 inline 00533 boolean gnSequence::operator<(const gnSequence& seq) const{ 00534 return (compare(seq)<0); 00535 } 00536 inline 00537 boolean gnSequence::operator<=(const gnSequence& seq) const{ 00538 return (compare(seq)<=0); 00539 } 00540 inline 00541 boolean gnSequence::operator>(const gnSequence& seq) const{ 00542 return (compare(seq)>0); 00543 } 00544 inline 00545 boolean gnSequence::operator>=(const gnSequence& seq) const{ 00546 return (compare(seq)>=0); 00547 } 00548 // Append and Insert Operators 00549 inline 00550 gnSequence& gnSequence::operator+=(const gnSequence& seq){ 00551 insert(GNSEQI_END, *seq.spec); 00552 return *this; 00553 } 00554 inline 00555 void gnSequence::append( const gnSequence& seq){ 00556 insert(GNSEQI_END, *seq.spec); 00557 } 00558 //Feature functions 00559 inline 00560 uint32 gnSequence::getFeatureListLength() const{ 00561 return spec->GetFeatureListLength(); 00562 } 00563 inline 00564 gnBaseFeature* gnSequence::getFeature(const uint32 featureI) const{ 00565 return spec->GetFeature(featureI); 00566 } 00567 inline 00568 uint32 gnSequence::addFeature(gnBaseFeature* feature){ 00569 return spec->AddFeature(feature); 00570 } 00571 inline 00572 void gnSequence::removeFeature(const uint32 featureI){ 00573 spec->RemoveFeature(featureI); 00574 } 00575 inline 00576 void gnSequence::getContainedFeatures(const gnLocation& lt, vector<gnBaseFeature*>& feature_vector, vector<uint32>& index_vector) const{ 00577 spec->GetContainedFeatures(lt, feature_vector, index_vector); 00578 } 00579 inline 00580 void gnSequence::getIntersectingFeatures(const gnLocation& lt, vector<gnBaseFeature*>& feature_vector, vector<uint32>& index_vector) const{ 00581 spec->GetIntersectingFeatures(lt, feature_vector, index_vector); 00582 } 00583 inline 00584 void gnSequence::getBrokenFeatures(const gnLocation& lt, vector<gnBaseFeature*>& feature_vector) const{ 00585 spec->GetBrokenFeatures(lt, feature_vector); 00586 } 00587 00588 inline 00589 boolean gnSequence::isCircular() const{ 00590 return spec->IsCircular(); 00591 } 00592 00593 inline 00594 void gnSequence::setCircular( const boolean value ){ 00595 spec->SetCircular(value); 00596 } 00597 inline 00598 void gnSequence::insert( const gnSeqI offset, const gnSequence& seq){ 00599 insert(offset, *seq.spec); 00600 } 00601 00602 // Size functions 00603 inline 00604 gnSeqI gnSequence::length() const{ 00605 return spec->GetLength(); 00606 } 00607 inline 00608 gnSeqI gnSequence::size() const{ 00609 return spec->GetLength(); 00610 } 00611 inline 00612 gnGenomeSpec* gnSequence::GetSpec() const{ 00613 return spec; 00614 } 00615 inline 00616 void gnSequence::SetSpec(gnGenomeSpec* s){ 00617 if(spec != NULL) 00618 delete spec; 00619 spec = s; 00620 } 00621 00622 inline 00623 void gnSequence::setFilter(const gnBaseFilter* filt){ 00624 filter_list.clear(); 00625 if(filt != NULL) 00626 filter_list.push_back(filt); 00627 } 00628 inline 00629 void gnSequence::setFilterList(list<const gnBaseFilter*>& filt_list){ 00630 filter_list = filt_list; 00631 } 00632 inline 00633 list<const gnBaseFilter*> gnSequence::getFilterList() const{ 00634 return filter_list; 00635 } 00636 00637 00638 #endif 00639 // _gnSequence_h_ Generated at Fri Nov 30 15:36:52 2001 for libGenome by 1.2.8.1 written by Dimitri van Heesch, © 1997-2001 |