def defineSteps(self): 
     self.insertStep('createDir', verifyfiles=[self.ExtraDir], path=self.ExtraDir)
     # launch relion program
     self.insertRelionClassifyContinue()
     #self.ImgStar = self.extraPath(replaceBasenameExt(tmpFileNameXMD, '.star'))
     lastIteration = self.NumberOfIterations
     NumberOfClasses=self.NumberOfClasses
     firstIteration = self.ContinueFromIteration
     ProtRelionBase.defineSteps2(self, firstIteration
                                     , lastIteration 
                                     , NumberOfClasses)
    def __init__(self, scriptname, project):
        ProtRelionBase.__init__(self, protDict.relion_classify_continue.name, scriptname, project)
        self.PrevRun=self.project.getProtocolFromFile(self.inputFileName)
        #self.setPreviousRun(self.ImportRun)
        
        self.Import = 'from protocol_relion_classify_continue import *'
        self.relionType='classify'
        #if optimizer has not been properly selected this will 
        #fail, let us go ahead and handle the situation in verify
        try:
            self.inputProperty('NumberOfClasses')
            self.inputProperty('SamplingRate')
            self.inputProperty('MaskRadiusA')
            self.inputProperty('RegularisationParamT')
            #self.lastIterationPrecRun=self.PrevRun.lastIter()

            #self.NumberOfClasses      = self.PrevRun.NumberOfClasses
            #self.SamplingRate         = self.PrevRun.SamplingRate
            #self.MaskDiameterA        = self.PrevRun.MaskDiameterA
            #self.RegularisationParamT = self.PrevRun.RegularisationParamT
        except:
            print "Can not access the parameters from the original relion run"
 def createFilenameTemplates(self):
     myDict=ProtRelionBase.createFilenameTemplates(self)        
     #myDict['volume']=self.extraIter + "class%(ref3d)03d.spi"
     #myDict['volumeMRC']=self.extraIter + "class%(ref3d)03d.mrc:mrc"
     myDict['volume']=self.extraIter + "class%(ref3d)03d.mrc:mrc"
     
     self.relionFiles += ['model']
     #relionFiles=['data','model','optimiser','sampling']
     for v in self.relionFiles:
         myDict[v+'Re']=self.extraIter + v +'.star'
         myDict[v+'Xm']=self.extraIter + v +'.xmd'
     myDict['imagesAssignedToClass']='imagesAssignedToClass@'+self.ExtraDir+'/dataForVisualize.xmd'
     extraIter = join('%(workingDir)s', 'extra', 'relion_it%(iter)03d_optimiser.star')
     myDict['optimiserCont'] = extraIter
     return myDict
 def summary(self):
     lines         = ProtRelionBase.summary(self)
     lastIteration = self.lastIter()
     lines += ['Continuation from run: <%s>, iter: <%d>' % (self.PrevRunName, self.ContinueFromIteration)]
     if (lastIteration - self.ContinueFromIteration) < 0 :
         performedIteration=0
     else:
         performedIteration=lastIteration - self.ContinueFromIteration
     lines += ['Performed <%d> iterations (number estimated from the files in working directory)' % performedIteration ]
     lines += ['Input fileName = <%s>'%self.inputFileName]
     #lines += ['test = <%s>'%self.getFilename('optimiserRe',iter=3)]
     #lines += ['test = <%s>'%self.PrevRun.getFilename('optimiserRe',iter=3)]
     #lines += ['WorkingDir = <%s>'%self.WorkingDir]
     #lines += ['WorkingDir2 = <%s>'%self.PrevRun.WorkingDir]
     #lines += ['lastIter = <%s>'%self.lastIter()]
     #lines += ['lastIter2 = <%s>'%self.PrevRun.lastIter()]
     return lines