/***************************************************************************** # 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. # #*****************************************************************************/ // // consed.h // // NOTE: this is not the main module. the main() procedure is // in file main.cpp. // // the ConsEd is the high-level implementation of the // consensus editor application. it is implemented without // reference to or use of gui/Motif/X dependent // objects, code, or techniques. // // there can be only one ConsEd object in any given // incarnation of the consEd application. // // the consed object keeps lists (arrays) of pointers to // all the existing ContigWins. the ContigWin ctors // and dtors of keep the consed informed // of their birth or demise. this allows the consed // object to send refresh messages to all appropriate // (i.e. affected) objects after an edit, and to close // (i.e. delete) those objects when a different assembly is // created (consed can handle multiple contigs but only one // assembly (i.e. .ace file) at a time. // #ifndef CONSED_INCLUDED #define CONSED_INCLUDED #include #include "rwtptrorderedvector.h" #include "sysdepend.h" #include "selection.h" #include "filename.h" #include "guiapp.h" // this is required for sgi, linux, and dec compilers or else get: // // "/usr/local/rogue/rw/tpordvec.cc", line 122: error(3430): none of the // available operator functions matches these operands // if (*(*this)(i) == *val) // ^ // detected during instantiation of "size_t // RWTPtrOrderedVector::occurrencesOf(const // compareContigs *) const" #include "compareContigs.h" // this needs to be included to help the Digital C++ compiler // which can't handle forward declarations in a template class #include "editaction.h" // This also needs to be included to help the Digital C++ compiler // since it needs contigwin.h for instanciation of the templates // in ConsEd #include "contigwin.h" #include "guiMultiContigNavigator.h" class guiTopWindow; class ChooseContig; class Assembly; class assemblyView; class GuiSearchForString; class autoReport; // Must include guiDisplayDigest.h (rather than just class guiDisplayDigest) // or else sgi compiler will give the following problem. "index" is used // in guiDisplayDigest.cpp but apparently the sgi compiler tries to // instantiate it in addAlignedSequence.o maybe since that is the // place that includes consed.h which has an array of guiDisplayDigest // --- C++ prelinker: addAlignedSequence.o --- // "rwtptrorderedvector_inc.cpp", line 9: error(3430): none of the available // operator functions matches these operands // if ( ( *( ppArray_[nIndex] )) == (*pVal) ) { // ^ // detected during instantiation of "int // RWTPtrOrderedVector::index(const // guiDisplayDigest *)" // 1 error detected in the compilation of "addAlignedSequence.cpp". // C++ prelinker: Error compiling addAlignedSequence.o // CC failed. Goodbye. // *** Error code 1 // pmake: Error: 1 error #include "guiDisplayDigest.h" class ConsEd { public: ConsEd(); ~ConsEd() { delete pSelection_; } // normal application exit void exitProgram() { exit(0); } // return a pointer to the current assembly Assembly* pAssemblyGet() { return pAssembly_; } static Assembly* pGetAssembly() { return( pGlobalConsEd_->pAssembly_ ); } static autoReport* pGetAutoReport() { return( pGlobalConsEd_->pAutoReport_ ); } void SetAssembly( Assembly* pAssembly ) { pAssembly_ = pAssembly; } // passed pointer to a derived class of EditAction // tells it to go do itself. if no exception is // thrown (i.e. succeeds) pointer is added to // edit history void doEditAction(EditAction* pEdAct, const bool bWriteToEditHistoryFile); void doEditAction2( EditAction* pEditAction, const bool bWriteToEditHistoryFile, const bool bRefresh ); void doEditActionNoRefresh( EditAction* pEditAction, const bool bWriteToEditHistoryFile ); // called when the XtApplication timeout says it's // time to blink the cursor. sends cursor draw message // to all ContigWins. void blinkAllCursors( const bool bBlinkOn ); // "undoes" the last edit action, removes from history void undoLastEditAction( const bool bWriteToEditHistoryFile ); EditAction* pGetLastEditAction(); // when the application come up, the first ContigWin is created // automatically. ContigWin* pGetFirstContigWin(); // return the current selection object selection* pGetSelection() { return( pSelection_ ); } // the ContigWin ctor tells the ConsEd that there's a new // one to add to the list or an old one to delete. // (list used for refresh notification, etc.) void addNewContigWin(ContigWin* pCw); void removeContigWin(ContigWin* pCw); void deleteAllContigWinsForContig( Contig* pContig ); void deleteAllCompareContigWindowsForContig( Contig* pContig ); void deleteAllCompareContigWindows(); void deleteAllContigWins(); void closeAllWindows(); ContigWin* pContigWinGetWithNoContig(); // this member function provides read access to the // sole instance static ConsEd* pGetConsEd() { return pGlobalConsEd_; } FileName filGetChromatDir() { return filChromatDir_; } FileName filGetPHDDir() { return filPHDDir_; } // indicates that consed is being run in debug mode bool bDebug_; void quitConsed(); void setAssemblyNameOnAllContigwins( const RWCString& soAssemblyName ); void showXResources(); void showConsedVersion(); char* szGetConsedVersion(); void askUserForFileToOpen(); void openAssemblyFile(const char* szFilePath); guiTopWindow* pGetGuiTopWindow() { return( GuiApp :: pGetGuiApp()->pGetGuiTopWindow() ); } void searchForString(); void updateContigListOnMainConsedWindow(); void choseContig( const int nIndex, const bool bReadListNotContigList ); void choseContig2( LocatedFragment* pLocFrag ); ContigWin* pPutContigInAContigWin( Contig* pContig, const int nStartPaddedConsPos ); ContigWin* pGetContigWinByContig( Contig* pContig ); // for compare contigs window ContigWin* pGetSecondContigWinByContig( Contig* pContig ); // if can't find existing contigwin with this contig, then create a // new contigwin. Otherwise use existing one ContigWin* pScrollExistingContigWinOrMakeNewContigWin( Contig* pContig, const int nStartPaddedConsPos ); ContigWin* pScrollExistingContigWinOrMakeNewContigWinAndSetCursorOnConsensus( Contig* pContig, const int nConsPos ); void perhapsApplyEditHistoryFile( const RWCString& soAceFileOpened ); void createCompareContigs( ContigWin* pContigWin, int nConsensusPosition ); compareContigs* pCreateCompareContigsForAssemblyView(); void ccompareContigs(ContigWin* pContigWin); bool bFoundAndDeletedThisCompareContigsFromList( compareContigs* pCompareContigs ); void findCompareContigWindow( compareContigs*& pCompareContigs, bool& bFirstNotSecondContigInCompareContigsWindow ); bool bIsThisContigWinOnAnyCompareContigsWindow( ContigWin* pContigWin ); void deleteOtherCompareContigsWindowsWithSameContigs( compareContigs* pCompareContigs, Contig* pContig1, Contig* pContig2 ); void deleteAllCompareContigsWindows(); void refreshAllContigWinsAndAllTeditors(); void refreshAllContigWins(); void getNewContigViewsForAllContigWins(); ChooseContig* pGetChooseContig() { return( pChooseContig_ ); } void disallowUndos(); void unsetAllCursors(); // currently unused static float fInterpolateGelPosition( const int nFragSize, const int nLowerFragSize, const float fLowerGelPosition, const int nUpperFragSize, const float fUpperGelPosition ); static void getRangeOfFragmentIndicesForFragmentSize( const int nFragSize, int& nLowerIndex, int& nUpperIndex ); static float fGetPositionOnGelFromRestrictionFragmentSize( const int nFragSize ); static bool bCouldGetFragmentSizeFromGelPosition( const float fGelPosition, int& nFragSize ); void whatToDoBeforeModifyAssembly(); void addGuiMultiContigNavigator( guiMultiContigNavigator* pGuiMulti ); void startUpConsedWithCustomNavigationFile( const FileName& filCustomNavigationFile ); void startUpConsedAtMainContigPos( const RWCString& soUnpaddedPos ); public: bool bUsingPhdFiles_; // pointer to the current assembly object Assembly* pAssembly_; // the list of extant ContigWin objects RWTPtrOrderedVector dapContigWin_; // a history of successful edit actions RWTPtrOrderedVector dapEditHistory_; // there is only one selection at a time selection* pSelection_; // // there can only be one consed, and the static pointer // to that instance is here // static ConsEd* pGlobalConsEd_; // fail if anyone tries to create a second. static bool bConsEdCreated_; // these are the default directories containing the chromatigrams // and the PHD files, respectively FileName filChromatDir_; FileName filPHDDir_; ChooseContig* pChooseContig_; RWTPtrOrderedVector aGuiMultiContigNavigator_; // guiMultiContigNavigator* pGuiMultiContigNavigator_; RWTPtrOrderedVector aCompareContigs_; GuiSearchForString* pGuiSearchForString_; assemblyView* pAssemblyView_; RWTPtrOrderedVector aGuiDisplayDigest_; autoReport* pAutoReport_; }; #endif // CONSED_INCLUDED