/***************************************************************************** # 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. # #*****************************************************************************/ #include "guiHowToSortAlignedReads.h" #include #include #include "handleWindowManagerDelete2.h" #include #include #include #include "hp_exception_kludge.h" #include "contigwin.h" #include "guicontigwin.h" #include "centerWidgetOnWidget.h" static void cbUserPushedDismiss( Widget wid, XtPointer pClientData, XtPointer pCallData ) { guiHowToSortAlignedReads* pGuiHowToSortAlignedReads = (guiHowToSortAlignedReads*) pClientData; TRY_CATCH_WRAPPER( delete pGuiHowToSortAlignedReads ); } static void cbSortAtCursorChanged( Widget wid, XtPointer pClientData, XtPointer pCallData ) { guiHowToSortAlignedReads* pGuiHowToSortAlignedReads = (guiHowToSortAlignedReads*) pClientData; TRY_CATCH_WRAPPER( pGuiHowToSortAlignedReads->sortAtCursorChanged( wid ) ); } static void cbSortAlphaStrandChanged( Widget wid, XtPointer pClientData, XtPointer pCallData ) { guiHowToSortAlignedReads* pGuiHowToSortAlignedReads = (guiHowToSortAlignedReads*) pClientData; TRY_CATCH_WRAPPER( pGuiHowToSortAlignedReads->sortAlphaStrandChanged() ); } void guiHowToSortAlignedReads :: createWindow() { widPopupShell_ = XtVaCreatePopupShell( "How to Sort Reads", topLevelShellWidgetClass, pContigWin_->pGcw_->widGetGuiContigWinTopLevel(), XmNdeleteResponse, XmDO_NOTHING, NULL ); handleWindowManagerDelete2( widPopupShell_, cbUserPushedDismiss, this ); Widget widTopForm = XtVaCreateManagedWidget( "top form", xmFormWidgetClass, widPopupShell_, XmNshadowThickness, 0, XmNborderWidth, 0, NULL ); XmString xmsExplanation1 = XmStringCreateLtoR( "There are 3 ways to sort reads in the Aligned Reads \nWindow: \n\n1) alphabetically \n2) strand/left end \n3) a user-defined file. \n\nYou can switch between #1 and #2 by clicking below: \nNote that these sorts do not apply if the cursor is on the \nconsensus and visible and \"by quality\" is selected below.\n", XmFONTLIST_DEFAULT_TAG ); Widget widExplanation1 = XtVaCreateManagedWidget( "explanation", xmLabelWidgetClass, widTopForm, XmNlabelString, xmsExplanation1, XmNalignment, XmALIGNMENT_BEGINNING, XmNtopAttachment, XmATTACH_FORM, NULL ); XmStringFree( xmsExplanation1 ); // now strand/alpha stuff Widget widLabelForAlphaStrand = XtVaCreateManagedWidget( "Display reads sorted alphabetically\nor by strand/left read end?", xmLabelWidgetClass, widTopForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widExplanation1, XmNleftAttachment, XmATTACH_FORM, XmNalignment, XmALIGNMENT_BEGINNING, NULL ); Widget widAlphaStrandRadioBox = XmCreateRadioBox( widTopForm, "radioAlphaStrand", NULL, 0 ); XtVaSetValues( widAlphaStrandRadioBox, XmNtraversalOn, True, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widLabelForAlphaStrand, XmNleftAttachment, XmATTACH_FORM, XmNorientation, XmHORIZONTAL, XmNshadowThickness, 0, XmNborderWidth, 0, XmNmarginWidth, 0, NULL ); widSortReadsAlphabetically_ = XtVaCreateManagedWidget( "Alpha", xmToggleButtonWidgetClass, widAlphaStrandRadioBox, XmNset, pCP->bShowReadsAlphabetically_, NULL ); XtAddCallback( widSortReadsAlphabetically_, XmNvalueChangedCallback, cbSortAlphaStrandChanged, this ); Widget widSortByStrand = XtVaCreateManagedWidget( "Strand/Left End", xmToggleButtonWidgetClass, widAlphaStrandRadioBox, XmNset, !pCP->bShowReadsAlphabetically_, NULL ); XtManageChild( widAlphaStrandRadioBox ); XmString xmsHowToSort = XmStringCreateLtoR( "When you click on the consensus, \nhow do you want reads sorted at cursor position?", XmFONTLIST_DEFAULT_TAG ); Widget widLabel = XtVaCreateManagedWidget( "label1", xmLabelWidgetClass, widTopForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widAlphaStrandRadioBox, XmNleftAttachment, XmATTACH_FORM, XmNlabelString, xmsHowToSort, XmNalignment, XmALIGNMENT_BEGINNING, NULL ); XmStringFree( xmsHowToSort ); Widget widSortRadioBox = XmCreateRadioBox( widTopForm, "radio1", NULL, 0 ); XtVaSetValues( widSortRadioBox, XmNtraversalOn, True, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widLabel, XmNleftAttachment, XmATTACH_FORM, XmNorientation, XmHORIZONTAL, XmNshadowThickness, 0, XmNborderWidth, 0, XmNmarginWidth, 0, NULL ); widSortAtCursorByQuality_ = XtVaCreateManagedWidget( "by quality", xmToggleButtonWidgetClass, widSortRadioBox, XmNset, ( pCP->soShowReadsAtCursorSortedHow_ == "quality" ), NULL ); XtAddCallback( widSortAtCursorByQuality_, XmNvalueChangedCallback, cbSortAtCursorChanged, this ); widSortAtCursorByBase_ = XtVaCreateManagedWidget( "by base", xmToggleButtonWidgetClass, widSortRadioBox, XmNset, ( pCP->soShowReadsAtCursorSortedHow_ == "base" ), NULL ); XtAddCallback( widSortAtCursorByBase_, XmNvalueChangedCallback, cbSortAtCursorChanged, this ); widLeaveSortAsIs_ = XtVaCreateManagedWidget( "by method specified above", xmToggleButtonWidgetClass, widSortRadioBox, XmNset, ( pCP->soShowReadsAtCursorSortedHow_ == "none" ), NULL ); XtAddCallback( widLeaveSortAsIs_, XmNvalueChangedCallback, cbSortAtCursorChanged, this ); XtManageChild( widSortRadioBox ); XmString xmsExplanation2 = XmStringCreateLtoR( "If \"by quality\" is selected (above) and if you clicked \nthe cursor on the consensus, then the displayed \nreads will be sorted by quality at that consensus \nposition. They will revert to the previous sort (alpha or strand) if \nyou scroll so the cursor is no longer visisble. \n\nThe following .consedrc resources can set these \nmore permanently:\n\nconsed.showReadsAlphabetically: false\nconsed.showReadsInAlignedReadsWindowOrderedByFile: false\nconsed.showReadsInAlignedReadsWindowOrderedByThisFile: readOrder.txt\nconsed.showReadsSortedByQualityValuesAtCursor: false", XmFONTLIST_DEFAULT_TAG ); Widget widExplanation2 = XtVaCreateManagedWidget( "explanation", xmLabelWidgetClass, widTopForm, XmNlabelString, xmsExplanation2, XmNalignment, XmALIGNMENT_BEGINNING, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widSortRadioBox, NULL ); XmStringFree( xmsExplanation2 ); widDismissButton_ = XtVaCreateManagedWidget( "Dismiss", xmPushButtonWidgetClass, widTopForm, XmNtopAttachment, XmATTACH_WIDGET, XmNtopWidget, widExplanation2, XmNbottomAttachment, XmATTACH_FORM, NULL ); XtAddCallback( widDismissButton_, XmNactivateCallback, cbUserPushedDismiss, this ); XtPopup( widPopupShell_, XtGrabNone ); centerWidgetOnWidget( widDismissButton_, widTopForm ); } guiHowToSortAlignedReads :: ~guiHowToSortAlignedReads() { XtPopdown( widPopupShell_ ); XtDestroyWidget( widPopupShell_ ); } void guiHowToSortAlignedReads :: sortAtCursorChanged( Widget wid ) { // this will return 2 callbacks--one from the toggle button changing to // false, and one from the toggle button changing to true. // This check ensures that only one of these callbacks is processed. if ( XmToggleButtonGetState( wid ) != True ) return; if ( XmToggleButtonGetState( widSortAtCursorByQuality_ ) == True ) { pCP->soShowReadsAtCursorSortedHow_ = "quality"; } else if ( XmToggleButtonGetState( widSortAtCursorByBase_ ) == True ) { pCP->soShowReadsAtCursorSortedHow_ = "base"; } else { pCP->soShowReadsAtCursorSortedHow_ = "none"; } if ( pContigWin_->bIsEditCursorVisible() ) { int nConsPosOfCursor = pContigWin_->editCursor_.nConsPosGet(); if ( pCP->soShowReadsAtCursorSortedHow_ == "quality" ) pContigWin_->pContigView_->sortReadsByQualityAtConsPos( nConsPosOfCursor ); else if ( pCP->soShowReadsAtCursorSortedHow_ == "base" ) pContigWin_->pContigView_->sortReadsByBaseAtConsPos( nConsPosOfCursor ); else pContigWin_->pContigView_->sortReads(); } else { pContigWin_->pContigView_->sortReads(); } // now redisplay reads pContigWin_->drawBasesAndConsensus( true ); // erase first pContigWin_->displayHowReadsAreSorted(); } void guiHowToSortAlignedReads :: sortAlphaStrandChanged() { pCP->bShowReadsAlphabetically_ = ( XmToggleButtonGetState( widSortReadsAlphabetically_ ) == True ? true : false ); if ( pContigWin_->bIsEditCursorVisible() ) { int nConsPosOfCursor = pContigWin_->editCursor_.nConsPosGet(); if ( pCP->soShowReadsAtCursorSortedHow_ == "quality" ) pContigWin_->pContigView_->sortReadsByQualityAtConsPos( nConsPosOfCursor ); else if ( pCP->soShowReadsAtCursorSortedHow_ == "base" ) pContigWin_->pContigView_->sortReadsByBaseAtConsPos( nConsPosOfCursor ); else pContigWin_->pContigView_->sortReads(); } else { pContigWin_->pContigView_->sortReads(); } pContigWin_->drawBasesAndConsensus( true ); // erase first pContigWin_->displayHowReadsAreSorted(); }