/***************************************************************************** # 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 "guiNavigateByReadDepth.h" #include #include #include #include #include #include #include #include #include "hp_exception_kludge.h" #include "handleWindowManagerDelete2.h" #include #include "bIsNumericMaybeWithWhitespace.h" #include "consedParameters.h" #include "popupErrorMessage.h" #include "gotoList.h" #include "consed.h" static void cbApply( Widget wid, XtPointer pClientData, XtPointer pCallData ) { guiNavigateByReadDepth* pGuiReadDepth = (guiNavigateByReadDepth*) pClientData; TRY_CATCH_WRAPPER( pGuiReadDepth->userClickedSearch(); ); } static void cbDismiss( Widget wid, XtPointer pClientData, XtPointer pCallData ) { guiNavigateByReadDepth* pGuiReadDepth = (guiNavigateByReadDepth*) pClientData; TRY_CATCH_WRAPPER( delete pGuiReadDepth ); } #ifdef NO_POUND_POUND_MACROS #define makeLabelAndToggleButtonCP( parameterNameWithoutPrefix, label ) \ Widget wid ## parameterNameWithoutPrefix ## Form = \ XtVaCreateManagedWidget( "form", \ xmFormWidgetClass, \ widRowCol, \ XmNshadowThickness, 0, \ NULL ); \ \ wid ## parameterNameWithoutPrefix ## _ = XtVaCreateManagedWidget( \ #parameterNameWithoutPrefix , \ xmToggleButtonWidgetClass, \ wid ## parameterNameWithoutPrefix ## Form, \ XmNtraversalOn, False, \ XmNlabelString, xmsEmpty, \ XmNmarginHeight, 0, \ XmNmarginWidth, 0, \ XmNshadowThickness, 0, \ XmNtopAttachment, XmATTACH_FORM, \ XmNbottomAttachment, XmATTACH_FORM, \ XmNleftAttachment, XmATTACH_FORM, \ XmNleftOffset, 10, \ XmNset, pCP->b ## parameterNameWithoutPrefix ## _, \ NULL ); \ \ Widget wid ## parameterNameWithoutPrefix ## Label = \ XtVaCreateManagedWidget( \ label , \ xmLabelWidgetClass, \ wid ## parameterNameWithoutPrefix ## Form, \ XmNtopAttachment, XmATTACH_FORM, \ XmNbottomAttachment, XmATTACH_FORM, \ XmNrightAttachment, XmATTACH_FORM, \ XmNleftAttachment, XmATTACH_WIDGET, \ XmNleftWidget, wid ## parameterNameWithoutPrefix ## _, \ XmNalignment, XmALIGNMENT_BEGINNING, \ NULL ); \ #else #define makeLabelAndToggleButtonCP( parameterNameWithoutPrefix, label ) \ Widget wid ## parameterNameWithoutPrefix ## Form = \ XtVaCreateManagedWidget( "form", \ xmFormWidgetClass, \ widRowCol, \ XmNshadowThickness, 0, \ NULL ); \ \ wid ## parameterNameWithoutPrefix ## _ = XtVaCreateManagedWidget( \ #parameterNameWithoutPrefix , \ xmToggleButtonWidgetClass, \ wid ## parameterNameWithoutPrefix ## Form, \ XmNtraversalOn, False, \ XmNlabelString, xmsEmpty, \ XmNmarginHeight, 0, \ XmNmarginWidth, 0, \ XmNshadowThickness, 0, \ XmNtopAttachment, XmATTACH_FORM, \ XmNbottomAttachment, XmATTACH_FORM, \ XmNleftAttachment, XmATTACH_FORM, \ XmNleftOffset, 10, \ XmNset, pCP->b ## parameterNameWithoutPrefix ## _, \ NULL ); \ \ Widget wid ## parameterNameWithoutPrefix ## Label = \ XtVaCreateManagedWidget( \ ##label , \ xmLabelWidgetClass, \ wid ## parameterNameWithoutPrefix ## Form, \ XmNtopAttachment, XmATTACH_FORM, \ XmNbottomAttachment, XmATTACH_FORM, \ XmNrightAttachment, XmATTACH_FORM, \ XmNleftAttachment, XmATTACH_WIDGET, \ XmNleftWidget, wid ## parameterNameWithoutPrefix ## _, \ XmNalignment, XmALIGNMENT_BEGINNING, \ NULL ); \ #endif static const int nRightPositionOfLabels = 70; static const int nLeftPositionOfInputFields = 80; #ifdef NO_POUND_POUND_MACROS #define makeLabelAndIntegerTextField( parameterNameWithoutPrefix, label ) \ Widget wid ## parameterNameWithoutPrefix ## Form = XtVaCreateManagedWidget( \ "form", \ xmFormWidgetClass, \ widRowCol, \ XmNshadowThickness, 0, \ NULL ); \ \ Widget wid ## parameterNameWithoutPrefix ## Label = XtVaCreateManagedWidget( \ label , \ xmLabelWidgetClass, \ wid ## parameterNameWithoutPrefix ## Form, \ XmNtopAttachment, XmATTACH_FORM, \ XmNbottomAttachment, XmATTACH_FORM, \ XmNleftAttachment, XmATTACH_FORM, \ XmNrightAttachment, XmATTACH_POSITION, \ XmNrightPosition, nRightPositionOfLabels, \ XmNalignment, XmALIGNMENT_END, \ NULL ); \ \ char sz ## parameterNameWithoutPrefix[200]; \ sprintf( sz ## parameterNameWithoutPrefix, "%d", \ consedParameters::pGetConsedParameters()->n ## parameterNameWithoutPrefix ## _ ); \ \ \ wid ## parameterNameWithoutPrefix ## _ = XtVaCreateManagedWidget( \ #parameterNameWithoutPrefix , \ xmTextFieldWidgetClass, \ wid ## parameterNameWithoutPrefix ## Form, \ XmNtraversalOn, True, \ XmNtopAttachment, XmATTACH_FORM, \ XmNbottomAttachment, XmATTACH_FORM, \ XmNleftAttachment, XmATTACH_POSITION, \ XmNleftPosition, nLeftPositionOfInputFields, \ XmNrightAttachment, XmATTACH_FORM, \ XmNvalue, sz ## parameterNameWithoutPrefix , \ NULL ); \ \ XtAddCallback( wid ## parameterNameWithoutPrefix ## _, \ XmNactivateCallback, \ (XtCallbackProc )XmProcessTraversal, \ (XtPointer) XmTRAVERSE_NEXT_TAB_GROUP ); #else #define makeLabelAndIntegerTextField( parameterNameWithoutPrefix, label ) \ Widget wid ## parameterNameWithoutPrefix ## Form = XtVaCreateManagedWidget( \ "form", \ xmFormWidgetClass, \ widRowCol, \ XmNshadowThickness, 0, \ NULL ); \ \ Widget wid ## parameterNameWithoutPrefix ## Label = XtVaCreateManagedWidget( \ ##label , \ xmLabelWidgetClass, \ wid ## parameterNameWithoutPrefix ## Form, \ XmNtopAttachment, XmATTACH_FORM, \ XmNbottomAttachment, XmATTACH_FORM, \ XmNleftAttachment, XmATTACH_FORM, \ XmNrightAttachment, XmATTACH_POSITION, \ XmNrightPosition, nRightPositionOfLabels, \ XmNalignment, XmALIGNMENT_END, \ NULL ); \ \ char sz ## parameterNameWithoutPrefix ## [200]; \ sprintf( sz ## parameterNameWithoutPrefix, "%d", \ consedParameters::pGetConsedParameters()->n ## parameterNameWithoutPrefix ## _ ); \ \ \ wid ## parameterNameWithoutPrefix ## _ = XtVaCreateManagedWidget( \ #parameterNameWithoutPrefix , \ xmTextFieldWidgetClass, \ wid ## parameterNameWithoutPrefix ## Form, \ XmNtraversalOn, True, \ XmNtopAttachment, XmATTACH_FORM, \ XmNbottomAttachment, XmATTACH_FORM, \ XmNleftAttachment, XmATTACH_POSITION, \ XmNleftPosition, nLeftPositionOfInputFields, \ XmNrightAttachment, XmATTACH_FORM, \ XmNvalue, sz ## parameterNameWithoutPrefix , \ NULL ); \ \ XtAddCallback( wid ## parameterNameWithoutPrefix ## _, \ XmNactivateCallback, \ (XtCallbackProc )XmProcessTraversal, \ (XtPointer) XmTRAVERSE_NEXT_TAB_GROUP ); #endif #define checkIfNumeric( Parameter ) \ szValue = XmTextFieldGetString( wid ## Parameter ## _ );\ soValue = szValue; \ XtFree( szValue ); \ int nPerhaps ## Parameter; \ if ( !bIsNumericMaybeWithWhitespace( soValue, nPerhaps ## Parameter ) ) { \ RWCString soError = #Parameter " must be numeric but instead is: \""; \ soError += soValue; \ soError += "\""; \ popupErrorMessage( soError ); \ return; \ } guiNavigateByReadDepth :: ~guiNavigateByReadDepth() { XtPopdown( widPopupShell_ ); XtDestroyWidget( widPopupShell_ ); } void guiNavigateByReadDepth :: createWindow() { widPopupShell_ = XtVaCreatePopupShell( "Navigate by High (or Low) Depth of Coverage", topLevelShellWidgetClass, GuiApp::pGetGuiApp()->widGetTopLevel(), XmNtransient, False, XmNdeleteResponse, XmDO_NOTHING, NULL ); handleWindowManagerDelete2( widPopupShell_, cbDismiss, this ); // put on a main window so we can have a menu bar Widget widMainWin = XtVaCreateManagedWidget( "mainwin", xmMainWindowWidgetClass, widPopupShell_, XmNancestorSensitive, True, NULL ); int nArgs = 0; Arg aArg[30]; Widget widForm = XtVaCreateManagedWidget( "form", xmFormWidgetClass, widMainWin, XmNancestorSensitive, True, NULL ); widDismiss_ = XtVaCreateManagedWidget( "Dismiss", xmPushButtonWidgetClass, widForm, XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 10, XmNrightAttachment, XmATTACH_POSITION, XmNrightPosition, 70, NULL ); XtAddCallback( widDismiss_, XmNactivateCallback, cbDismiss, this ); widSearch_ = XtVaCreateManagedWidget( "Search", xmPushButtonWidgetClass, widForm, XmNbottomAttachment, XmATTACH_FORM, XmNbottomOffset, 10, XmNleftAttachment, XmATTACH_POSITION, XmNleftPosition, 10, NULL ); XtAddCallback( widSearch_, XmNactivateCallback, cbApply, this ); Widget widRowCol = XtVaCreateManagedWidget( "rowcol", xmRowColumnWidgetClass, widForm, XmNleftAttachment, XmATTACH_FORM, XmNrightAttachment, XmATTACH_FORM, XmNtopAttachment, XmATTACH_FORM, XmNbottomAttachment, XmATTACH_WIDGET, XmNbottomWidget, widDismiss_, NULL ); XmString xmsEmpty = XmStringCreateSimple( "" ); makeLabelAndToggleButtonCP( NavigateByHighDepthOfCoverageNotLow, "show high depth (not low depth)" ); makeLabelAndIntegerTextField( QualityThresholdForNavigateByDepthOfCoverage, "quality to be used for read depth calc" ); makeLabelAndIntegerTextField( MinDepthForNavigateByDepthOfCoverage, "min depth of coverage" ); XtPopup( widPopupShell_, XtGrabNone ); } void guiNavigateByReadDepth :: userClickedSearch() { char* szValue; RWCString soValue; checkIfNumeric( QualityThresholdForNavigateByDepthOfCoverage ); pCP->nQualityThresholdForNavigateByDepthOfCoverage_ = nPerhapsQualityThresholdForNavigateByDepthOfCoverage; checkIfNumeric( MinDepthForNavigateByDepthOfCoverage ); pCP->nMinDepthForNavigateByDepthOfCoverage_ = nPerhapsMinDepthForNavigateByDepthOfCoverage; pCP->bNavigateByHighDepthOfCoverageNotLow_ = ( XmToggleButtonGetState( widNavigateByHighDepthOfCoverageNotLow_ ) == True ) ? true : false; gotoList* pGotoList; ConsEd::pGetAssembly()->getHighOrLowDepthOfCoverageRegions( pCP->bNavigateByHighDepthOfCoverageNotLow_, pCP->nQualityThresholdForNavigateByDepthOfCoverage_, pCP->nMinDepthForNavigateByDepthOfCoverage_, pGotoList ); RWCString soTitle; RWCString soFirstLine; RWCString soSecondLine; if ( pCP->bNavigateByHighDepthOfCoverageNotLow_ ) { soTitle = "High Depth of Coverage Regions"; soFirstLine = "regions with at least " + RWCString( (long) pCP->nMinDepthForNavigateByDepthOfCoverage_ ) + " reads"; soSecondLine = "of at least quality " + RWCString( (long) pCP->nQualityThresholdForNavigateByDepthOfCoverage_ ) + " Regions combined if this close: " + RWCString( (long) pCP->nNavigateByHighOrLowDepthCoalesceRegionsIfThisClose_ ); } else { soTitle = "Low Depth of Coverage Regions"; soFirstLine = "regions with at most " + RWCString( (long) pCP->nMinDepthForNavigateByDepthOfCoverage_ ) + " reads"; soSecondLine = "of at least quality " + RWCString( (long) pCP->nQualityThresholdForNavigateByDepthOfCoverage_ ) + " Regions combined if this close: " + RWCString( (long) pCP->nNavigateByHighOrLowDepthCoalesceRegionsIfThisClose_ ); } ConsEd::pGetConsEd()->addGuiMultiContigNavigator( new guiMultiContigNavigator( soTitle, soFirstLine, soSecondLine, 75, // nWidthInChars "", NULL, NULL, NULL, pGotoList, NULL ) ); delete this; }