/***************************************************************************** # 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. # #*****************************************************************************/ // // contigwin.h // // the ContigWin object is the clean (non-gui) object corresponding // to the GuiContigWin, the application's character based window // that displays the consensus and aligned fragments as text // #ifndef CONTIGWIN_DEFINED #define CONTIGWIN_DEFINED #ifdef SCCS_ID static const char* ContigWinSccsId = "@(#)contigwin.h 1.41 04/16/96 16:11:04"; #endif #include using namespace std; #include "contig.h" #include "contigview.h" #include "assembly.h" #include "numutil.h" #include "guiapp.h" #include "editCursor.h" #include "guicolortext.h" #include "gotoListType.h" #include "multiProblemGotoList.h" #include "rwtptrvector.h" // do not include "colormode.h" class ColorMode; class ColorMeansMatch; class ColorMeansQuality; class ColorMeansEdited; class ColorMeansQualityAndTags; class ColorMeansEditedAndTags; // do not include guicontigwin.h class GuiContigWin; // do not include "EditAction.h" class EditAction; class TedWin; class Teditor; class guiMultiContigNavigator; class ContigWin { public: friend class GuiContigWin; ContigWin(); ~ContigWin(); // in .cpp because of circular include problem void deleteIfOK(); // ColorMode needs pointer to (current) contig Contig* pGetContig() { return pContig_; } void setContig(Contig* pContig) { pContig_ = pContig; } void drawBasesAndConsensus( const bool bEraseFirst ); void drawBases(); void drawProteinTranslation(); void drawConsensus(); void drawFragmentNames(); void drawScale(); void drawScaleUnpadded(); void drawScalePadded(); void drawHighlightedBases(); void drawSequencingDirectionArrow( const LocatedFragment* pLocFrag ); void drawVerticalLineAtCursorIfNecessary(); void drawVerticalLineAtCursorNoRedraw(); bool bDrawSeparatorBetweenTopAndBottomStrandReads(); void toggleHorizontalLineAtCursor(); void toggleVerticalLineAtCursor(); void popupTagInfoForTagsAtThisLocation( const int nScreenCharX, const int nFragLine ); void popupTagInfoForConsensusTagsAtThisLocation( const int nScreenCharX ); void showAllTraces( const int nScreenCharX ); void showAllTracesByConsensusPosition( const int nConsPos ); // keeping Rogue Wave happy... // for our purposes, two different ContigWins can never be equal bool operator == (const ContigWin& rCw) const { return (this == &rCw); } int nGetDisplayedBasesWide() const; // This has been modified to handle case in which user opens window wider // than the last fragments int nGetRightEdgeConsensusPosition() const { return MIN( nLeftEdgeConsensusPosition_ + nGetDisplayedBasesWide() - 1, pContig_->nGetLastDisplayableContigPos() ); } void GetColorAndBaseForRead( LocatedFragment* pLocatedFragment, const int nConsensusPosition, GuiColorText*& pguicolortextForBase, char& cBase ); // This is used for coloring the consensus bases void GetColorAndBaseForConsensus( const int nConsensusPosition, GuiColorText*& pGctForBase, char& cBase ); bool bGetNextColorWordForRead(LocatedFragment* pLocatedFragment, int& nTryScreenCharStart, const int nRightMostScreenChar, int& nActualScreenCharStart, char *szCharsToDraw, int& nNumberOfCharsToDraw, GuiColorText*& pguicolortextToUse ); bool bGetNextColorWordForConsensus( int& nTryScreenCharStart, const int nRightMostScreenChar, int& nActualScreenCharStart, char *szCharsToDraw, int& nNumberOfCharsToDraw, GuiColorText*& pguicolortextToUse ); bool bGetNextTagOnLine( const bool bReadTagNotConsensusTag, LocatedFragment* pLocFrag, int& nTryScreenCharStart, const int nRightMostScreenChar, int& nActualScreenCharStart, int& nNumberOfCharsWide, GuiColorText*& pGctToUseForTag ); bool bGetNextTaggedBasesForRead( LocatedFragment* pLocFrag, int& nTryScreenCharStart, const int nRightMostScreenChar, int& nActualScreenCharStart, RWCString& soBasesToDraw, GuiColorText*& pGctToUse ); // the screnn position is 0 based, but consensus and // fragment positions are always 1 based int nScreenCharToConsensusPosition( const int nScreenChar ) { return nScreenChar + nLeftEdgeConsensusPosition_; } int nConsensusPositionToScreenChar( const int nConsensusPosition ) { return nConsensusPosition - nLeftEdgeConsensusPosition_; } // sets slider size, max, etc. depending on contig data void setSliderForNewContig(); // sets slider to "empty" i.e. bar fills trough, no motion possible void emptySlider(); void emptyVerticalScrollBar(); // used, for example, when adding a column of pads void resetSliderMax(); void getNewContigView(); // responds to scrolling. expects the scrollbar position to // equal the padded, 1-based consensus position. void horizontalScrollBarMoved(int); // responds to scrolling. expects the scrollbar position to // equal the padded, 1-based consensus position. void verticalScrollBarMoved(int); void verticalScrollToMakeThisReadVisible( LocatedFragment* pLocFrag ); void setVerticalScrollBarForNewContig(); // force ContigWin to scroll to consensus position void scrollToConsensusPos(const int); // force ContigWin to scroll to consensus position void scrollToConsensusPosInCenter(const int); // combines scrollToConsensusPosInCenter and moveCursorToConsPos // but avoids several redraws and flashing void scrollToConsensusPosInCenterAndSetCursorOnConsensus( const int nNewCursorConsPos ); // for buttons << < > >> to scroll void scrollLeft(); void scrollLeftLeft(); void scrollRight(); void scrollRightRight(); void scrollToLeftOrRightEndOfConsensus( const bool bLeftNotRight ); void scrollToCursor(); void userTypedInConsPos( const RWCString& soConsPos ); void windowResized(); // pop up a dibox with information about the contig void showContigInfo(); // create and popup a Navigator box, which allows // users to move (scroll) quickly (automatically) between // items tags/problems/whatever on a list void createMultiProblemNavigator(); void createLowConsensusQualityNavigator(); void createHighQualityDiscrepancyNavigator( const bool bExcludeInCompressionTags, const bool bExcludeMostPads ); void createEditedNavigator(); void createEditedButNotNsNavigator(); void createTagsNavigator(); void createUnalignedHighQualityNavigator2(); void popupTracesByCursorPosition( const int nScreenCharX, const int nReadLine ); void popupTracesByConsensusPosition( LocatedFragment* pLocatedFragment, const int nConsensusPosition ); void popup4BestTracesByCursorPosition( const int nScreenCharX ); void popup4BestTracesByConsensusPosition( const int nConsensusPosition ); void find4BestReads( const int nConsPos, LocatedFragment*& pLocFrag1, LocatedFragment*& pLocFrag2, LocatedFragment*& pLocFrag3, LocatedFragment*& pLocFrag4 ); void scrollExistingTracesOrPopupIfNecessary( LocatedFragment* pLocatedFragment, const int nConsensusPosition ); TedWin* pGetTedWinByLocatedFragment( LocatedFragment* pLocatedFragment ); int nGetReadLineFromLocatedFragment( const LocatedFragment* pLocFrag ); void setTopAndBottomVisibleFragments(); // how many of each (for/rev) fragment line are on screen // pretty forgiving. if no current view, return 0. int nGetForFragsVisible() const { int nFrag = 0; if (pContigView_) { nFrag = pContigView_->nForwardFrags() - nIndexOfTopVisibleRead_; if (nFrag < 0 ) nFrag = 0; } return nFrag; } int nGetRevFragsVisible() const { int nFrag = 0; if (pContigView_) { nFrag = pContigView_->nReverseFrags(); } return nFrag; } // this is called as a result of the comp contig button being pressed. // affects the Contig, LocatedFragments, etc. but does not // cause refresh or repositioning. that gets done when a refresh // message comes back from the ConsEd. void complementContig(); // called by the complement edit action's refresh routine. // reposition the contig win so that it points to the same // strech of dna (now at the other "end") after complementation. void refreshAfterCompContig(); void refreshContigWinAndTeditor(); void initializeContigWinForNewContig( const int nStartLeftEdgeConsPos, const bool bPutInCenter ); void getContigErrorRate( char* szErrors ); void displayContigErrorRate(); // if passed true, draw the cursor at the current position // if passed false, draw the normal (non-cursor) background again void drawCursor(const bool bMakeVisible); // sends a message to Teditor to (un)draw // cursor if appropriate void drawTeditorCursors(const bool bMakeVisible); // returns a pointer to the EditCursor. needed by TedWin. EditCursor* pGetEditCursor() { return &editCursor_; } bool bIsEditCursorVisible(); void maybeSortReadsAtCursor(); void sortByQualityValuesAtCursor( const bool b ); void displayHowReadsAreSorted(); void clearAllCursors(); // currently unused // moves the cursor to the passed consensus relative position // if one exists. Sets the editCursor_ member to reflect the new // position. void moveCursorToConsPos(const int nConsPos); // variant of above that takes X char position on contigwin void moveCursorToConsCharXPos(const int nScreenCharXPos); // moves the cursor to the passed screen relative position // if one exists. note that the fragment // is indicated by screen line, not pointer to LocatedFragment. // this is a first cut void moveCursorToFragChar(const int nScreenCharXPos, const int nFragLine); // this version of above is called by the child TedWins, // and does the same thing only takes arguments of // the pointer to the located fragment and the // consensus relative position in the fragment void moveCursorToFragPos(const int nConsPos, LocatedFragment* pLocFrag); void moveCursorToNextReadPos( LocatedFragment* pLocFrag ); void setTeditor(Teditor* pTed) { pTeditor_ = pTed; } // this routine gets a pointer to an EditAction, which // it applies to itself and Teditor as // needed. Note that derived classes of editactions // may be passed, resulting in different kinds of refresh // // now deactivates undo button on any windows other than // the one the editaction came from void editNotify(EditAction*); void colorMeansMatch(); void colorMeansQuality(); void colorMeansEdited(); void colorMeansQualityAndTags(); void colorMeansEditedAndTags(); void setAceFileLabel( const RWCString& soAssemblyName ); int nFragLineFromPixelY(const int nPixelsY) const; // checks whether a segment, from nLeftConsPos to nRightConsPos, is // on the screen bool bIsOnScreen( const int nLeftConsPos, const int nRightConsPos, int& nLeftIntersectConsPos, int& nRightIntersectConsPos ); int nGetFragmentBasesMaxPixelY(); GuiColorText* pGetGuiColorTextForTag( const int nConsPos ); bool bMustLoadGuiColorTextArrayForTags() { return( ( pColorMode_ == (ColorMode*) GAPP->pColorMeansQualityAndTags_ ) || ( pColorMode_ == (ColorMode*) GAPP->pColorMeansEditedAndTags_ ) ); } void startHighlight( const int nScreenCharX, const bool bConsensusNotRead, const int nReadLine ); void continueHighlight( const int nPixelX, const int nPixelY ); void continueHighlight3( const int nConsPos ); void highlightFinished(); void clearHighlight(); void userReleasedMouseButton1( const int nPixelX, const int nPixelY ); void makeSelectionFromConsensus( const int nConsPosLeft, const int nConsPosRight ); void makeSelectionFromARead( LocatedFragment* pLocFrag, const int nConsPosLeft, const int nConsPosRight ); void automaticScrollingTimer(); void automaticallyScroll(); void toggleHighlightOfReadName( const int nPixelX, const int nPixelY ); void showBaseQuality(const int nScreenCharXPos, const int nReadIndex, const bool bReadBaseNotContigBase ); Teditor* pGetTeditor() { return( pTeditor_ ); } void pickPrimer( const int nScreenCharX, const bool bForwardNotReversePrimer, const bool bCloneNotSubcloneTemplate); // void createExperimentsList(); bool bIsThisTraceDisplayed( const LocatedFragment* pLocatedFragment ); void tellPhrapNotToOverlapReadsDiscrepantAtThisLocation( const int nCharX ); void makeAllReadsNAtThisLocation( const int nCharX ); void tearContigs( const int nScreenCharX ); void editAllReads( LocatedFragment* pMasterLocFrag_, const int nConsPos ); void navigateToNextOrPreviousItem( const bool bNextNotPrevious ); void raiseWindow(); void userPushedControlA(); void userPushedControlE(); void userPushedLeftArrow(); void userPushedRightArrow(); void userPushedDownArrow(); void userPushedUpArrow(); void userPushedLeftArrowAboveComma(); void userPushedRightArrowAbovePeriod(); void userOverstrikingConsensus( const int nConsPos, const char cNewBaseLower ); void pointerMoved( const int nPixelX, const int nPixelY ); void refreshContigName(); void showTemplateInfo(); void changeToXsToLeftInAllReads(); void changeToXsToRightInAllReads(); void changeToXsInAllReads( const char cRightOrLeft ); void createCloneEndTag( const bool bInsertToRight ); void compareReadsToReference(); void userPressedUserDefinedKey( const RWCString& soProgram, const RWCString& soArgument, const RWCString& soTagToApply ); void turnOnOrOffStartNumberingConsensusStartingAtUserDefinedPosition(); void showUncalledPeakInfo(); private: // this is a trivial example of a function that // responds to user input void charPress(const char); // responds to user button press void buttonPress(int, // button number int, // 1 = down, 0 = up int, // x pos in chars int); // y pos in chars void drawTagsForRead( const int nReadLine, GuiColorText** ppGuiColorTextArray ); void drawTags(); bool bTagIsOnScreen( tag* pTag, LocatedFragment* pLocFrag, int& nLeftIntersectConsPos, int& nRightIntersectConsPos ); void loadGuiColorTextArrayForTags( LocatedFragment* pLocFrag ); void loadGuiColorTextArrayForConsensusTags( ); bool bGetEntireVisibleConsensusBases( RWCString& soBasesToDraw, int& nActualScreenCharStart ); void resetRoomForReadNames(); // careful--above here is private member functions public: // pointer to current contig within assembly Contig *pContig_; // the associated trace window Teditor* pTeditor_; // pointer to current ColorMode object (will be // used by bGetNextColorWord() member function ColorMode* pColorMode_; // each contigwin has it's own EditCursor, used by editing, etc. EditCursor editCursor_; // used for ColorMeansTags RWTPtrVector aGuiColorTextArray_; // int nLastHighlightedScreenCharX_; int nButton1PressedScreenX_; bool bButton1PressedInReadBasesArea_; bool bButton1PressedInConsensusBasesArea_; int nButton1PressedReadLine_; // these are used to keep track when the users is moving the pointer, // whether it is still on the same base or not int nOldConsPosOfPointer_; int nOldReadLineOfPointer_; guiMultiContigNavigator* pGuiMultiContigNav_; int nIndexOfTopVisibleRead_; // relative to aFragmentsInView int nLeftEdgeConsensusPosition_; int bAutoConsensusMode_; // pointer to the current contig view ContigView *pContigView_; // 0 is the topmost fragment // these include fragments that // are too far up or down to be seen // pointer to the GuiContigWin. GuiContigWin* pGcw_; bool bDrewEverythingSinceLastDrewVerticalLine_; int nCurrentVerticalLineScreenCharPos_; }; #endif // CONTIGWIN_DEFINED