/***************************************************************************** # 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. # #*****************************************************************************/ #ifndef COMPARECONTIGS_INCLUDED #define COMPARECONTIGS_INCLUDED #include "compareContigsTypes.h" #include "rwcstring.h" #include "rwtvalorderedvector.h" #include "bool.h" #include "compareContigsCursor.h" #include "contigSegment.h" class paddedPieceOfRead; class Contig; class guiCompareContigs; class paddedPieceOfRead; class ContigWin; class LocatedFragment; class GuiColorText; class seqMatch; class compareContigs { public: guiCompareContigs* pGuiCompareContigs_; ContigWin* pContigWin1_; ContigWin* pContigWin2_; // if the user decides to join the contigs, this is where the new // one is put ContigWin* pNewContigWin_; Contig* pContig1_; Contig* pContig2_; bool bContig1ComplementedWRTAlignedReadsWindow_; bool bContig2ComplementedWRTAlignedReadsWindow_; // WRT = "with respect to" // Note: even when the contig is complemented wrt the Aligned // Reads Window, // nContig1LeftEdgeConsensusPosition_ is in uncomplemented // coordinates so the user can find the same base // at the same position in both the Compare Contigs Window // as well as the Aligned Reads Window. int nContig1LeftEdgeConsensusPosition_; int nContig2LeftEdgeConsensusPosition_; int nAlignmentWindowLeftEdgeZeroBasedPos_; RWCString soAlignmentMiddleLine_; paddedPieceOfRead* pPaddedPieceOfReadTop_; paddedPieceOfRead* pPaddedPieceOfReadBot_; bool bAlignmentExists_; // note: nPosition_ is in consensus positions of // each contig respectively compareContigsCursor curTopContig1_; compareContigsCursor curTopContig2_; int nPinnedConsPos1_; int nPinnedConsPos2_; // note: nPosition_ is in zero-based coordinates of // paddedPieceOfRead.soBasesAndPads_ compareContigsCursor curAlignmentWindow_; // for joining contigs Contig* pNewContig_; RWTValOrderedVector contigSegments_; int nInNewJoinedContigAlignedRegionLeftConsPos_; int nInNewJoinedContigAlignedRegionRightConsPos_; LocatedFragment* pFakeLocFrag_; public: compareContigs( ContigWin* pContigWin, const int nConsPos1); compareContigs(); // for assemblyView ~compareContigs(); // this makes RWTPtrOrderedVector in ConsEd happy bool operator==( const compareContigs& compC ) const { return( this == &compC ); } void addSecondContig( ContigWin* pContigWin2, const int nConsPos2 ); void doCompareContigs(); void alignKnownRegions( const int nUnpaddedStart1, const int nUnpaddedEnd1, const int nUnpaddedStart2, const int nUnpaddedEnd2, const bool bComplemented ); void addContext( const compareContigsTypes eContig1OrContig2, RWCString& soAlignment, const int nUnpaddedStart, const int nUnpaddedEnd ); void printAlignment( const RWCString& soAlignmentTop, const RWCString& soAlignmentMid, const RWCString& soAlignmentBot ); void contigExposure( const compareContigsTypes eContig1OrContig2); void alignmentWindowExposure( ); void drawScale( const compareContigsTypes eContig1OrContig2 ); void drawContigBases( const compareContigsTypes eContig1OrContig2 ); void drawScaleAndBases( const compareContigsTypes eContig1OrContig2 ); void drawAlignmentWindowScaleAndBases(); void drawAlignmentWindowScale( const compareContigsTypes eContig1OrContig2 ); void drawAlignmentWindowBases( const compareContigsTypes eContig1OrContig2 ); void drawAlignmentWindowMiddleLine( ); void displayDiscrepancyNumberAndRate(); int nGetRightEdgeConsensusPosition( const compareContigsTypes eContig1OrContig2 ); int nGetRightEdgeAlignmentWindowZeroBasedPosition(); // notice that screen position is zero-based int nConsensusPositionToScreenChar( const compareContigsTypes eContig1OrContig2, const int nConsensusPosition ); // notice that screen position is zero-based int nAlignmentWindowZeroBasedPosToScreenChar( const int nZeroBasedPos ) { return( nZeroBasedPos - nAlignmentWindowLeftEdgeZeroBasedPos_ ); } int nScreenCharToConsensusPosition( const compareContigsTypes eContig1OrContig2, const int nScreenChar ); void horizontalScrollBarMoved( const compareContigsWindowTypes eWindow, const int nNewScrollBarPosition ); Contig* pGetContig( const compareContigsTypes eContig1OrContig2 ) { return (eContig1OrContig2 == eContig1 ) ? pContig1_ : pContig2_; } ContigWin* pGetContigWin( const compareContigsTypes eContig1OrContig2 ) { return (eContig1OrContig2 == eContig1 ) ? pContigWin1_ : pContigWin2_; } int nGetLeftEdgeConsensusPosition( const compareContigsTypes eContig1OrContig2 ) { return (eContig1OrContig2 == eContig1 ) ? nContig1LeftEdgeConsensusPosition_ : nContig2LeftEdgeConsensusPosition_; } bool bIsContigComplemented( const compareContigsTypes eContig1OrContig2 ) { if ( eContig1OrContig2 == eContig1 ) return( bContig1ComplementedWRTAlignedReadsWindow_ ); else return( bContig2ComplementedWRTAlignedReadsWindow_ ); } int nGetScrollBarPositionFromLeftEdgeConsensusPosition( const compareContigsTypes eContig1OrContig2, const int nLeftEdgeConsensusPosition ); void setScrollBarForNewContig( const compareContigsTypes eContig1OrContig2 ); void setAlignmentWindowScrollBarForNewAlignment(); paddedPieceOfRead* pGetPaddedPieceOfRead( const compareContigsTypes eContig1OrContig2 ); bool bVisibleOnAlignmentWindow( const int nZeroBasedPos ); void drawAlignmentWindowCursor(const bool bBlinkOn ); void getGuiColorTextAndBaseForCursor( const int nZeroBasedAlignPos, paddedPieceOfRead* pPaddedPieceOfRead, const bool bBlinkOn, char& cBaseOrPad, GuiColorText*& pGuiColorTextOfBase ); void drawTopContigWindowCursor( const bool bBlinkOn, const compareContigsTypes eContig1OrContig2 ); // return a reference compareContigsCursor& curGetCompareContigsTopContigCursor( const compareContigsTypes eContig1OrContig2) { if (eContig1OrContig2 == eContig1 ) return( curTopContig1_ ); else return( curTopContig2_ ); } void setAlignmentCursor( const int nScreenCharX ); void setAlignmentCursorAtAlignmentPos( const int n0AlignmentPos ); void setTopContigCursorByScreenPos( const compareContigsTypes eContig1OrContig2, const int nScreenCharX ); void setTopContigCursorByConsensusPosition( const compareContigsTypes eContig1OrContig2, const int nScreenCharX ); void blinkAllCursors( const bool bBlinkOn ); void scrollContigWin( const compareContigsTypes eContig1OrContig2 ); void joinContigs(); void addContigSegment( const int nUnpaddedStart1, const int nUnpaddedEnd1, const int nUnpaddedStart2, const int nUnpaddedEnd2 ); void addColumnsOfPadsToAlignContigs(); void getBestContigSegment( const int nContigSeg, Contig*& pBestContig, int& nBestPaddedStart, int& nBestPaddedEnd ); void calculateTotalQualitiesOfContigSegment( contigSegment& cs ); void findEndOfDiscrepantSegment( const int nPaddedStart, // zero-based paddedPieceOfRead coordinates int& nPaddedEnd, // zero-based paddedPieceOfRead coordinates int& nUnpaddedEnd1, // in unpadded pContig1_ coordinates int& nUnpaddedEnd2, // in unpadded pContig2_ coordinates bool& bEndOfAlignment ); void findEndOfMatchSegment( const int nPaddedStart, int& nPaddedEnd, int& nUnpaddedEnd1, int& nUnpaddedEnd2, bool& bEndOfAlignment ); bool bContigSegmentsOK( ); void createFakeRead(); bool bCheckAddColumnsOfPadsToAlignContigs(); void dumpContigSegments(); void makeContigSegmentsContiguous( Contig* pLeftContig, const int nNewConsPosFromNotLeftConsPos ); float fGetEstimatedTimeToDoAlignment(); bool bUserThoughtAlignmentWouldTakeTooLong(); void popupForAssemblyView( seqMatch* pSeqMatch ); void complementContig( const compareContigsTypes eContig1OrContig2 ); enum ePrevOrNextType { ePrevDiscrepancy = 1, eNextDiscrepancy = 2 }; void prevNextDiscrepancy( const ePrevOrNextType ePrevOrNext ); }; #endif