
from PyQt4 import QtGui,QtCore
import CCP4TaskWidget
import CCP4Widgets

def whatNext(jobId=None):
  return [ 'buccaneer_build_refine_mr' ]


class Cmrbump_basic(CCP4TaskWidget.CTaskWidget):

  TASKNAME = 'mrbump_basic'
  TASKVERSION = 0.1
  TASKMODULE='molecular_replacement'
  TASKTITLE='Automated structure solution - MrBUMP'
  DESCRIPTION='Run a quick MrBUMP job with streamlined settings'
  RANK=1
  WHATNEXT = ['prosmart_refmac','buccaneer_build_refine_mr','coot_rebuild']

  def __init__(self,parent):
    CCP4TaskWidget.CTaskWidget.__init__(self,parent)

  def drawContents(self):

    self.setProgramHelpFile('mrbump_basic')

#-  --------------------          --------------------          --------------------

    folder = self.openFolder(folderFunction='inputData',title='Input Data')

    self.createLine( [ 'subtitle', 'Target Sequence', 'Sequence of your target structure' ] )

    self.createLine( [ 'widget', 'SEQIN' ] )
    self.createLine( [ 'label', 'The number of monomers to search for', 'widget', 'NMON' ] )

    self.createLine( [ 'subtitle', 'Experimental Data', 'Observed intensities or amplitudes, and Free-R flags' ] )
    self.createLine( [ 'widget', 'F_SIGF' ] )
    self.createLine( [ 'widget', 'FREERFLAG' ] )

#-   --------------------          --------------------          --------------------

    folder = self.openFolder(folderFunction='controlParameters',title='Options')

#    self.createLine( [ 'advice', 'Tick box to open a folder and define parameter(s) manually' ] )

    self.createLine( [ 'label', 'Expected number of copies', 'widget', 'NMASU'] )#, toggle=[ 'OPEN_SCORE', 'open', [ True ] ] )

    self.closeFolder()
#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_PRF', 'open', [ True ] ] )
#    self.createLine( [ 'widget', 'OPEN_PRF', 'advice', 'Search method' ] )
#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_PRF', 'open', [ True ] ] )
#    self.createLine( [ 'label', '         ', 'label', 'SAPTF = Spherically Averaged Phased Translation Function' ], toggle=[ 'OPEN_PRF', 'open', [ True ] ] )
#    self.createLine( [ 'label', '         ', 'label', 'PRF = Phased Rotation Function' ], toggle=[ 'OPEN_PRF', 'open', [ True ] ] )
#    self.createLine( [ 'label', '         ', 'label', 'RF(M) = Rotation Function (f-obs from the density outside of the fixed Model)' ], toggle=[ 'OPEN_PRF', 'open', [ True ] ] )
#    self.createLine( [ 'label', '         ', 'label', 'RF(S) = Rotation Function (f-obs from the density inside a Sphere)' ], toggle=[ 'OPEN_PRF', 'open', [ True ] ] )
#    self.setMenuText( 'PRF', {
#       'n': 'RF(M) + PTF',
#       'y': 'SAPTF + PRF + PTF',
#       's': 'SAPTF + RF(S) + PTF',
#    } )
#    self.createLine( [ 'label', '         ', 'widget', '-guiMode', 'multiLineRadio', 'PRF' ], toggle=[ 'OPEN_PRF', 'open', [ True ] ] )
#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_PRF', 'open', [ True ] ] )


#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_NPEAKS', 'open', [ True ] ] )
#    self.createLine( [ 'widget', 'OPEN_NPEAKS', 'advice', 'Number of peaks to analyse' ] )
#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_NPEAKS', 'open', [ True ] ] )
#    self.createLine( [ 'label', '         ', 'label', 'Number of Rotation Function peaks', 'widget', 'NP'], toggle=[ 'OPEN_NPEAKS', 'open', [ True ] ] )
#    self.createLine( [ 'label', '         ', 'label', 'Number of Translation Function peaks', 'widget', 'NPT'], toggle=[ 'OPEN_NPEAKS', 'open', [ True ] ] )
#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_NPEAKS', 'open', [ True ] ] )


#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_SCORE', 'open', [ True ] ] )
#    self.createLine( [ 'widget', 'OPEN_SCORE', 'advice', 'Scoring putative solutions' ] )
#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_SCORE', 'open', [ True ] ] )
#    self.createLine( [ 'label', '         ', 'label', 'CC = Correlation Coefficient' ], toggle=[ 'OPEN_SCORE', 'open', [ True ] ] )
#    self.createLine( [ 'label', '         ', 'label', 'PF = Packing Function' ], toggle=[ 'OPEN_SCORE', 'open', [ True ] ] )
#    self.setMenuText( 'SCORE', {
#       'y': 'Use CC times PF as a score and stop translation search if contrast is > 3.0',
#       'n': 'Use CC times PF and do not stop',
#       'c': 'Use CC and do not stop',
#    } )
#    self.createLine( [ 'label', '         ', 'widget', '-guiMode', 'multiLineRadio', 'SCORE' ], toggle=[ 'OPEN_SCORE', 'open', [ True ] ] )
#    self.createLine( [ 'label', '         ', 'label', 'Expected number of copies (for contrast calculation only)', 'widget', 'NMON_EXP'], toggle=[ 'OPEN_SCORE', 'open', [ True ] ] )
#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_SCORE', 'open', [ True ] ] )


#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_ANISO', 'open', [ True ] ] )
#    self.createLine( [ 'widget', 'OPEN_ANISO', 'advice', 'Scaling' ] )
#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_ANISO', 'open', [ True ] ] )
#    self.setMenuText( 'ANISO', {
#       'y': 'anisotropic',
#       'n': 'isotropic',
#       'k': 'none',
#    } )
#    self.createLine( [ 'label', '         ', 'widget', '-guiMode', 'multiLineRadio', 'ANISO' ], toggle=[ 'OPEN_ANISO', 'open', [ True ] ] )
#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_ANISO', 'open', [ True ] ] )


#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_HIGH_PATH_VAR', 'open', [ True ] ] )
#    self.createLine( [ 'widget', 'OPEN_HIGH_PATH_VAR', 'advice', 'High pass filter parameter' ] )
#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_HIGH_PATH_VAR', 'open', [ True ] ] )
#    self.createLine( [ 'label', '         ', 'advice', '(B-add, the B-factor applied to input structure amplitudes)' ], toggle=[ 'OPEN_HIGH_PATH_VAR', 'open', [ True ] ] )
#    self.setMenuText( 'HIGH_PATH_VAR', {
#       's': 'From identity between model and sequence (if sequence given)',
#       'i': 'From identity specified manually',
#       'r': 'From high resolution limit',
#       'b': 'Directly as the value of additional B-factor',
#    } )
#    self.createLine( [ 'label', '         ', 'widget', '-guiMode', 'multiLineRadio', 'HIGH_PATH_VAR' ], toggle=[ 'OPEN_HIGH_PATH_VAR', 'open', [ True ] ] )
#    lab1 = 'Identity between search and target sequences (from 0 to 1)'
#    self.createLine( [ 'label', '         ', 'label', lab1, 'widget', 'SIM' ], toggleFunction=[ self.openSIM, [ 'OPEN_HIGH_PATH_VAR', 'HIGH_PATH_VAR' ] ] )
#    lab1 = 'High resolution limit, Ang'
#    self.createLine( [ 'label', '         ', 'label', lab1, 'widget', 'RESMAX' ], toggleFunction=[ self.openRESMAX, [ 'OPEN_HIGH_PATH_VAR', 'HIGH_PATH_VAR' ] ] )
#    lab1 = 'B-add'
#    self.createLine( [ 'label', '         ', 'label', lab1, 'widget', 'BADD' ], toggleFunction=[ self.openBADD, [ 'OPEN_HIGH_PATH_VAR', 'HIGH_PATH_VAR' ] ] )
#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_HIGH_PATH_VAR', 'open', [ True ] ] )


#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_LOW_PATH_VAR', 'open', [ True ] ] )
#    self.createLine( [ 'widget', 'OPEN_LOW_PATH_VAR', 'advice', 'Low pass filter parameter' ] )
#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_LOW_PATH_VAR', 'open', [ True ] ] )
#    self.createLine( [ 'label', '         ', 'advice', '(B-off, the B-factor of the removed fraction of structure amplitudes)' ], toggle=[ 'OPEN_LOW_PATH_VAR', 'open', [ True ] ] )
#    self.setMenuText( 'LOW_PATH_VAR', {
#       'c': 'From completeness of the search model',
#       'r': 'From low resolution limit',
#       'b': 'Directly as the value of additional B-factor',
#    } )
#    self.createLine( [ 'label', '         ', 'widget', '-guiMode', 'multiLineRadio', 'LOW_PATH_VAR' ], toggle=[ 'OPEN_LOW_PATH_VAR', 'open', [ True ] ] )
#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_LOW_PATH_VAR', 'open', [ True ] ] )


#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_SEQ', 'open', [ True ] ] )
#    self.createLine( [ 'widget', 'OPEN_SEQ', 'advice', 'Sequence modification options' ] )
#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_SEQ', 'open', [ True ] ] )
#    self.createLine( [ 'label', '         ', 'advice', 'Perform alignment and use it to rename residues and trimm side chains' ], toggle=[ 'OPEN_SEQ', 'open', [ True ] ] )
#    self.setMenuText( 'SEQ', {
#       'y': 'always',
#       'd': 'only for sequence identity > 20%',
#       'n': 'never'
#    } )
#    self.createLine( [ 'label', '         ', 'widget', '-guiMode', 'multiLineRadio', 'SEQ' ], toggle=[ 'OPEN_SEQ', 'open', [ True ] ] )
#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_SEQ', 'open', [ True ] ] )


#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_SURF', 'open', [ True ] ] )
#    self.createLine( [ 'widget', 'OPEN_SURF', 'advice', 'B-factors modification options' ] )
#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_SURF', 'open', [ True ] ] )
#    self.setMenuText( 'SURF', {
#       'y': 'Increase B-factor on the molecular surface for all functions',
#       'c': 'Increase B-factor on the surface for Packing function only',
#       'n': 'Do not do anything',
#       '2': 'Set B-factors of all atoms to 20',
#       'a': 'Use poly-alanine model with all B-factors 20',
#    } )
#    self.createLine( [ 'label', '         ', 'widget', '-guiMode', 'multiLineRadio', 'SURF' ], toggle=[ 'OPEN_SURF', 'open', [ True ] ] )
#-  self.createLine( [ 'advice', '' ], toggle=[ 'OPEN_SURF', 'open', [ True ] ] )


#-   --------------------          --------------------          --------------------


    print 'CTaskMolrep stackedWidgets'
    for w in self.findChildren( CCP4TaskWidget.CStackedWidget ) :
      print '   ', w, w.controlVar

    self.updateViewFromModel()


#-   --------------------          --------------------          --------------------


  def openSIM( self ) :

    gui = self.container.guiParameters
    if gui.OPEN_HIGH_PATH_VAR and str( gui.HIGH_PATH_VAR ) == 'i' :
      return True

    else:
      return False


  def openRESMAX( self ) :

    gui = self.container.guiParameters
    if gui.OPEN_HIGH_PATH_VAR and str( gui.HIGH_PATH_VAR ) == 'r' :
      return True

    else:
      return False


  def openBADD( self ) :

    gui = self.container.guiParameters
    if gui.OPEN_HIGH_PATH_VAR and str( gui.HIGH_PATH_VAR ) == 'b' :
      return True

    else:
      return False


