/***************************************************************************** # Copyright (C) 1994-2008 by David Gordon. # All rights reserved. # # This software is part of a beta-test version of the Consed/Autofinish # package. It should not be redistributed or # used for any commercial purpose, including commercially funded # sequencing, without written permission from the author and the # University of Washington. # # This software is provided ``AS IS'' and any express or implied # warranties, including, but not limited to, the implied warranties of # merchantability and fitness for a particular purpose, are disclaimed. # In no event shall the authors or the University of Washington be # liable for any direct, indirect, incidental, special, exemplary, or # consequential damages (including, but not limited to, procurement of # substitute goods or services; loss of use, data, or profits; or # business interruption) however caused and on any theory of liability, # whether in contract, strict liability, or tort (including negligence # or otherwise) arising in any way out of the use of this software, even # if advised of the possibility of such damage. # # Building Consed from source is error prone and not simple which is # why I provide executables. Due to time limitations I cannot # provide any assistance in building Consed. Even if you do not # modify the source, you may introduce errors due to using a # different version of the compiler, a different version of motif, # different versions of other libraries than I used, etc. For this # reason, if you discover Consed bugs, I can only offer help with # those bugs if you first reproduce those bugs with an executable # provided by me--not an executable you have built. # # Modifying Consed is also difficult. Although Consed is modular, # some modules are used by many other modules. Thus making a change # in one place can have unforeseen effects on many other features. # It may takes months for you to notice these other side-effects # which may not seen connected at all. It is not feasable for me to # provide help with modifying Consed sources because of the # potentially huge amount of time involved. # #*****************************************************************************/ // // gotoList.h // // this include file defines GotoItem and gotoList objects. // // The GotoItem object is a location, defined as an area of interest // in either a Contig's consensus sequence or an individual // fragment. It is uniquely identified by the contig (& fragment) // names, its start and stop index. // // The gotoList object is an abstract base class which contains // a list of GotoItems. Derived classes will differ largely in the // way these are created (ctors) and trivially in the descriptions // of themselves they return. // // The first and probably most typical derived class of gotoList // is LowConsQualGotoList, whose ctor reads through a contig // and creates a GotoItem for each location where one or more bases // in the consensus sequence is of low quality. This list // will be passed to the Navigator object, so the user can // quickly review, presumably fix, and acknowledge these problems. // // Note that the derived classes are not included in the same file. // This file does not need any Contig or ConsEd include files, // but others (for derived classes) probably will. // // #ifndef gotoList_INCLUDED #define gotoList_INCLUDED #ifdef SCCS_ID static const char* gotoListSccsId = "@(#)gotoList.h 1.12 11/16/98 02:00:46"; #endif #include "rwcstring.h" #include "mbtPtrOrderedVector.h" #include "sysdepend.h" class LocatedFragment; class Contig; // the GotoItem object describes the location and reason for // the GotoItem. class gotoItem { public: // gotoItem() // : // nGotoItemStart_(0), // nGotoItemEnd_(0), // bIsConsensusGotoItem_(false), // bUserHasAck_(false) {} gotoItem(Contig* pContig, // contig name LocatedFragment* pLocFrag, // fragment name. if null or blank, gotoItem // refers to consensus rather than fragment const int nStart, // starting index into sequence const int nEnd, // ending index into seq const int nUnpaddedStart, // same but for display const int nUnpaddedEnd, const RWCString& soDescription, // string describing the gotoItem's raison d'etre // i.e. "Poor consensus quality" const bool bPrefixContigToDescription = true, void* pOtherData = NULL ); // used for assemblyView :: userClickedButtonInNavigatorWindow gotoItem( gotoItem* pGotoItem ); bool bConsensusGotoItem() const { return bIsConsensusGotoItem_; } // return const ref to name of contig it applies to Contig* pGetContig() const { return pContig_; } // return const ref to name of fragment it applies to if there is one, // empty string otherwise LocatedFragment* pGetLocFrag() const { return pLocFrag_; } // return index of starting position of area gotoItem applies to int nGetStart() const { return nGotoItemStart_; } // return index of ending position of area GotoItem applies to int nGetEnd() const { return nGotoItemEnd_; } // same only unpadded, 1 based, suitable for display int nGetUnpaddedStart() const { return nUnpaddedGotoItemStart_; } // return index of ending position of area GotoItem applies to int nGetUnpaddedEnd() const { return nUnpaddedGotoItemEnd_; } // return formatted description of GotoItem const RWCString& soGetFullDesc() const { return soFullDescription_; } void setFullDescription( const RWCString& soFullDescription ) { soFullDescription_ = soFullDescription; } // comparison operators are for maintaining sorted array bool operator == (const gotoItem& rGotoItem) const { return (pContig_ == rGotoItem.pContig_) && (pLocFrag_ == rGotoItem.pLocFrag_ ) && (nGotoItemStart_ == rGotoItem.nGotoItemStart_) && (nGotoItemEnd_ == rGotoItem.nGotoItemEnd_); } bool operator<( const gotoItem& rGotoItem) const; void setNewEnd( const int nConsPos, const int nUnpaddedConsPos ); private: void setFullDescription(); public: Contig* pContig_; LocatedFragment* pLocFrag_; // NULL if bIsConsensusGotoItem_ true. RWCString soFullDescription_; // includes contig, read, and position // used by navigator listbox RWCString soInitialDescription_; // used to build soFullDescription_ // doesn't have position, read or // contig name // area to which GotoItem applies // currently stored in two flavors int nUnpaddedGotoItemStart_; int nUnpaddedGotoItemEnd_; int nGotoItemStart_; int nGotoItemEnd_; bool bIsConsensusGotoItem_; // true if GotoItem applies to consensus // rather than particular frag void* pOtherData_; }; // class GotoItem // this is an abstract base class for gotoList objects // derived classes must supply a useful ctor, i.e. a way of // making a gotoList according to some criteria, and a description // function, e.g. // // const char* szGetListDescription() const { // return "I'm a list of "; // } // class gotoList { public: // the derived classes will mostly be concerned with // non-default ctors - i.e. building a list based on some // criteria like quality gotoList( ) { apGotoItem_.soName_ = "gotoList::apGotoItem_"; } // should always have one of these in a virtual base class. Why, Chris? ~gotoList() {} // tried apGotoItem_.clearAndDestroy() but multiProblemGotoList // copies gotoItems and then destroys the list which created // seg fault // gotoList can be indexed, of course const gotoItem* operator [] (const int nIndex) const { return apGotoItem_[nIndex]; } // index returning non-const reference gotoItem* operator [] (const int nIndex) { return apGotoItem_[nIndex]; } gotoItem* pGetGotoItem( const int nIndex) { return apGotoItem_[nIndex]; } // how many GotoItems in the list? int nGetNumGotoItems() const { return apGotoItem_.length(); } // resize the list. you really only want to do this once, // before you start adding data. void resizeGotoList(const int nSize) { apGotoItem_.resize(nSize); } // inserts new GotoItem into list, maintains sort order void addToList(gotoItem* pGotoItem) { apGotoItem_.insert(pGotoItem); } void sortByPosition(); void sortByLength(); bool bIsSortedByLength(); void appendAnotherList( gotoList* pGotoList ); void consolidateGotoItems( const int nConsolidateIfLessThanOrEqualToThisDistance ); void removeDuplicates(); public: // sorted dynamic array of pointers to gotoItems mbtPtrOrderedVector apGotoItem_; }; // gotoList #endif // gotoList.h