コード例 #1
0
ファイル: protocol_nma_base.py プロジェクト: I2PC/scipion
 def computeModesStep(self, fnPseudoatoms, numberOfModes, cutoffStr):
     (baseDir,fnBase)=os.path.split(fnPseudoatoms)
     fnBase=fnBase.replace(".pdb","")
     fnDistanceHist=os.path.join(baseDir,'extra',fnBase+'_distance.hist')
     rc = self._getRc(fnDistanceHist)
     self._enterWorkingDir()
     self.runJob('nma_record_info.py', "%d %s.pdb %d" % (numberOfModes, fnBase, rc),env=getNMAEnviron())
     self.runJob("nma_pdbmat.pl","pdbmat.dat",env=getNMAEnviron())
     self.runJob("nma_diag_arpack","",env=getNMAEnviron())
     if not exists("fort.11"):
         self._printWarnings(redStr("Modes cannot be computed. Check the number of modes you asked to compute and/or consider increasing cut-off distance. The maximum number of modes allowed by the method for pseudoatomic normal mode analysis is 3 times the number of pseudoatoms but the protocol allows only up to 200 modes as 20-100 modes are usually enough.  If the number of modes is below the minimum between 200 and 3 times the number of pseudoatoms, consider increasing cut-off distance."))
     cleanPath("diag_arpack.in", "pdbmat.dat")
     self._leaveWorkingDir()
コード例 #2
0
 def reformatOutputStep(self, fnPseudoatoms):
     self._enterWorkingDir()
     n = self._countAtoms(fnPseudoatoms)
     self.runJob("nma_reformat_vector_foranimate.pl", "%d fort.11" % n, env=getNMAEnviron())
     self.runJob("cat", "vec.1* > vec_ani.txt")
     self.runJob("rm", "-f vec.1*")
     self.runJob("nma_reformat_vector.pl", "%d fort.11" % n, env=getNMAEnviron())
     makePath("modes")
     self.runJob("mv", "-f vec.* modes")
     self.runJob("nma_prepare_for_animate.py", "", env=getNMAEnviron())
     self.runJob("rm", "-f vec_ani.txt fort.11 matrice.sdijf")
     moveFile("vec_ani.pkl", "extra/vec_ani.pkl")
     self._leaveWorkingDir()
コード例 #3
0
    def reformatPdbOutputStep(self, numberOfModes):
        self._enterWorkingDir()

        makePath('modes')
        Natoms = self._countAtoms("atoms.pdb")
        fhIn = open('diagrtb.eigenfacs')
        fhAni = open('vec_ani.txt', 'w')

        for n in range(numberOfModes):
            # Skip two lines
            fhIn.readline()
            fhIn.readline()
            fhOut = open('modes/vec.%d' % (n + 1), 'w')
            for i in range(Natoms):
                line = fhIn.readline()
                fhOut.write(line)
                fhAni.write(line.rstrip().lstrip() + " ")
            fhOut.close()
            if n != (numberOfModes - 1):
                fhAni.write("\n")
        fhIn.close()
        fhAni.close()
        self.runJob("nma_prepare_for_animate.py", "", env=getNMAEnviron())
        cleanPath("vec_ani.txt")
        moveFile('vec_ani.pkl', 'extra/vec_ani.pkl')

        self._leaveWorkingDir()
コード例 #4
0
ファイル: protocol_nma.py プロジェクト: I2PC/scipion
 def animateModesStep(self, numberOfModes,amplitude,nFrames,downsample,pseudoAtomThreshold,pseudoAtomRadius):
     makePath(self._getExtraPath('animations'))
     self._enterWorkingDir()
     
     if self.structureEM:
         fn = "pseudoatoms.pdb"
         self.runJob("nma_animate_pseudoatoms.py","%s extra/vec_ani.pkl 7 %d %f extra/animations/animated_mode %d %d %f"%\
                   (fn,numberOfModes,amplitude,nFrames,downsample,pseudoAtomThreshold),env=getNMAEnviron())
     else:
         fn="atoms.pdb"
         self.runJob("nma_animate_atoms.py","%s extra/vec_ani.pkl 7 %d %f extra/animations/animated_mode %d"%\
                   (fn,numberOfModes,amplitude,nFrames),env=getNMAEnviron())
     
     for mode in range(7,numberOfModes+1):
         fnAnimation = join("extra", "animations", "animated_mode_%03d" % mode)
         fhCmd=open(fnAnimation+".vmd",'w')
         fhCmd.write("mol new %s.pdb\n" % self._getPath(fnAnimation))
         fhCmd.write("animate style Loop\n")
         fhCmd.write("display projection Orthographic\n")
         if self.structureEM:
             fhCmd.write("mol modcolor 0 0 Beta\n")
             fhCmd.write("mol modstyle 0 0 Beads %f 8.000000\n"%(pseudoAtomRadius))
         else:
             fhCmd.write("mol modcolor 0 0 Index\n")
             #fhCmd.write("mol modstyle 0 0 Beads 1.000000 8.000000\n")
             fhCmd.write("mol modstyle 0 0 NewRibbons 1.800000 6.000000 2.600000 0\n")
         fhCmd.write("animate speed 0.5\n")
         fhCmd.write("animate forward\n")
         fhCmd.close();
     
     self._leaveWorkingDir()
コード例 #5
0
ファイル: protocol_nma.py プロジェクト: I2PC/scipion
    def reformatPdbOutputStep(self, numberOfModes):
        self._enterWorkingDir()
        
        makePath('modes')
        Natoms = self._countAtoms("atoms.pdb")
        fhIn = open('diagrtb.eigenfacs')
        fhAni = open('vec_ani.txt','w')
        
        for n in range(numberOfModes):
            # Skip two lines
            fhIn.readline()
            fhIn.readline()
            fhOut=open('modes/vec.%d'%(n+1),'w')
            for i in range(Natoms):
                line=fhIn.readline()
                fhOut.write(line)
                fhAni.write(line.rstrip().lstrip()+" ")
            fhOut.close()
            if n!=(numberOfModes-1):
                fhAni.write("\n")
        fhIn.close()
        fhAni.close()
        self.runJob("nma_prepare_for_animate.py","",env=getNMAEnviron())
        cleanPath("vec_ani.txt")
        moveFile('vec_ani.pkl', 'extra/vec_ani.pkl')

        self._leaveWorkingDir()
コード例 #6
0
ファイル: protocol_nma.py プロジェクト: EyeSeeTea/scipion-web
 def animateModesStep(self, numberOfModes,amplitude,nFrames,downsample,pseudoAtomThreshold,pseudoAtomRadius):
     makePath(self._getExtraPath('animations'))
     self._enterWorkingDir()
     
     if self.structureEM:
         fn = "pseudoatoms.pdb"
         self.runJob("nma_animate_pseudoatoms.py","%s extra/vec_ani.pkl 7 %d %f extra/animations/animated_mode %d %d %f"%\
                   (fn,numberOfModes,amplitude,nFrames,downsample,pseudoAtomThreshold),env=getNMAEnviron())
     else:
         fn="atoms.pdb"
         self.runJob("nma_animate_atoms.py","%s extra/vec_ani.pkl 7 %d %f extra/animations/animated_mode %d"%\
                   (fn,numberOfModes,amplitude,nFrames),env=getNMAEnviron())
     
     for mode in range(7,numberOfModes+1):
         fnAnimation = join("extra", "animations", "animated_mode_%03d" % mode)
         fhCmd=open(fnAnimation+".vmd",'w')
         fhCmd.write("mol new %s.pdb\n" % self._getPath(fnAnimation))
         fhCmd.write("animate style Loop\n")
         fhCmd.write("display projection Orthographic\n")
         if self.structureEM:
             fhCmd.write("mol modcolor 0 0 Beta\n")
             fhCmd.write("mol modstyle 0 0 Beads %f 8.000000\n"%(pseudoAtomRadius))
         else:
             fhCmd.write("mol modcolor 0 0 Index\n")
             #fhCmd.write("mol modstyle 0 0 Beads 1.000000 8.000000\n")
             fhCmd.write("mol modstyle 0 0 NewRibbons 1.800000 6.000000 2.600000 0\n")
         fhCmd.write("animate speed 0.5\n")
         fhCmd.write("animate forward\n")
         fhCmd.close();
     
     self._leaveWorkingDir()
コード例 #7
0
 def reformatOutputStep(self, fnPseudoatoms):
     self._enterWorkingDir()
     n = self._countAtoms(fnPseudoatoms)
     self.runJob("nma_reformat_vector_foranimate.pl",
                 "%d fort.11" % n,
                 env=getNMAEnviron())
     self.runJob("cat", "vec.1* > vec_ani.txt")
     self.runJob("rm", "-f vec.1*")
     self.runJob("nma_reformat_vector.pl",
                 "%d fort.11" % n,
                 env=getNMAEnviron())
     makePath("modes")
     self.runJob("mv", "-f vec.* modes")
     self.runJob("nma_prepare_for_animate.py", "", env=getNMAEnviron())
     self.runJob("rm", "-f vec_ani.txt fort.11 matrice.sdijf")
     moveFile('vec_ani.pkl', 'extra/vec_ani.pkl')
     self._leaveWorkingDir()
コード例 #8
0
 def computeModesStep(self, fnPseudoatoms, numberOfModes, cutoffStr):
     (baseDir, fnBase) = os.path.split(fnPseudoatoms)
     fnBase = fnBase.replace(".pdb", "")
     fnDistanceHist = os.path.join(baseDir, 'extra',
                                   fnBase + '_distance.hist')
     rc = self._getRc(fnDistanceHist)
     self._enterWorkingDir()
     self.runJob('nma_record_info.py',
                 "%d %s.pdb %d" % (numberOfModes, fnBase, rc),
                 env=getNMAEnviron())
     self.runJob("nma_pdbmat.pl", "pdbmat.dat", env=getNMAEnviron())
     self.runJob("nma_diag_arpack", "", env=getNMAEnviron())
     if not exists("fort.11"):
         self._printWarnings(
             redStr(
                 "Modes cannot be computed. Check the number of modes you asked to compute and/or consider increasing cut-off distance. The maximum number of modes allowed by the method for pseudoatomic normal mode analysis is 3 times the number of pseudoatoms but the protocol allows only up to 200 modes as 20-100 modes are usually enough.  If the number of modes is below the minimum between 200 and 3 times the number of pseudoatoms, consider increasing cut-off distance."
             ))
     cleanPath("diag_arpack.in", "pdbmat.dat")
     self._leaveWorkingDir()
コード例 #9
0
ファイル: protocol_nma.py プロジェクト: I2PC/scipion
    def computePdbModesStep(self, numberOfModes, RTBblockSize, RTBForceConstant, cutoffStr):
        rc = self._getRc(self._getExtraPath('atoms_distance.hist'))
                
        self._enterWorkingDir()
        self.runJob('nma_record_info_PDB.py', "%d %d atoms.pdb %f %f" % (numberOfModes, RTBblockSize, rc, RTBForceConstant),
                    env=getNMAEnviron())
        self.runJob("nma_elnemo_pdbmat","",env=getNMAEnviron())
        self.runJob("nma_diagrtb","",env=getNMAEnviron())

        if not exists("diagrtb.eigenfacs"):
            msg = "Modes cannot be computed. Check the number of modes you asked to compute and/or consider "
            msg += "increasing cut-off distance. The maximum number of modes allowed by the method for atomic "
            msg += "normal mode analysis is 6 times the number of RTB blocks but the protocol allows only up "
            msg += "to 200 modes as 20-100 modes are usually enough. If the number of modes is below the minimum "
            msg += "between 200 and 6 times the number of RTB blocks, consider increasing cut-off distance."
            self._printWarnings(redStr(msg) + '\n')
        self.runJob("rm","-f *.dat_run diagrtb.dat pdbmat.xyzm pdbmat.sdijf pdbmat.dat")
        
        self._leaveWorkingDir()
コード例 #10
0
ファイル: protocol_nma.py プロジェクト: EyeSeeTea/scipion-web
    def computePdbModesStep(self, numberOfModes, RTBblockSize, RTBForceConstant, cutoffStr):
        rc = self._getRc(self._getExtraPath('atoms_distance.hist'))
                
        self._enterWorkingDir()
        self.runJob('nma_record_info_PDB.py', "%d %d atoms.pdb %f %f" % (numberOfModes, RTBblockSize, rc, RTBForceConstant),
                    env=getNMAEnviron())
        self.runJob("nma_elnemo_pdbmat","",env=getNMAEnviron())
        self.runJob("nma_diagrtb","",env=getNMAEnviron())

        if not exists("diagrtb.eigenfacs"):
            msg = "Modes cannot be computed. Check the number of modes you asked to compute and/or consider "
            msg += "increasing cut-off distance. The maximum number of modes allowed by the method for atomic "
            msg += "normal mode analysis is 6 times the number of RTB blocks but the protocol allows only up "
            msg += "to 200 modes as 20-100 modes are usually enough. If the number of modes is below the minimum "
            msg += "between 200 and 6 times the number of RTB blocks, consider increasing cut-off distance."
            self._printWarnings(redStr(msg) + '\n')
        self.runJob("rm","-f *.dat_run diagrtb.dat pdbmat.xyzm pdbmat.sdijf pdbmat.dat")
        
        self._leaveWorkingDir()
コード例 #11
0
    def qualifyModesStep(self, numberOfModes, collectivityThreshold,
                         structureEM):
        self._enterWorkingDir()

        fnVec = glob("modes/vec.*")

        if len(fnVec) < numberOfModes:
            msg = "There are only %d modes instead of %d. "
            msg += "Check the number of modes you asked to compute and/or consider increasing cut-off distance."
            msg += "The maximum number of modes allowed by the method for atomic normal mode analysis is 6 times"
            msg += "the number of RTB blocks and for pseudoatomic normal mode analysis 3 times the number of pseudoatoms. "
            msg += "However, the protocol allows only up to 200 modes as 20-100 modes are usually enough. If the number of"
            msg += "modes is below the minimum between these two numbers, consider increasing cut-off distance."
            self._printWarnings(redStr(msg % (len(fnVec), numberOfModes)))

        fnDiag = "diagrtb.eigenfacs"

        if structureEM:
            self.runJob("nma_reformatForElNemo.sh",
                        "%d" % numberOfModes,
                        env=getNMAEnviron())
            fnDiag = "diag_arpack.eigenfacs"

        self.runJob("echo",
                    "%s | nma_check_modes" % fnDiag,
                    env=getNMAEnviron())
        cleanPath(fnDiag)

        fh = open("Chkmod.res")
        mdOut = xmipp.MetaData()
        collectivityList = []

        for n in range(numberOfModes):
            line = fh.readline()
            collectivity = float(line.split()[1])
            collectivityList.append(collectivity)

            objId = mdOut.addObject()
            modefile = self._getPath("modes", "vec.%d" % (n + 1))
            mdOut.setValue(xmipp.MDL_NMA_MODEFILE, modefile, objId)
            mdOut.setValue(xmipp.MDL_ORDER, long(n + 1), objId)

            if n >= 6:
                mdOut.setValue(xmipp.MDL_ENABLED, 1, objId)
            else:
                mdOut.setValue(xmipp.MDL_ENABLED, -1, objId)
            mdOut.setValue(xmipp.MDL_NMA_COLLECTIVITY, collectivity, objId)

            if collectivity < collectivityThreshold:
                mdOut.setValue(xmipp.MDL_ENABLED, -1, objId)
        fh.close()
        idxSorted = [
            i[0]
            for i in sorted(enumerate(collectivityList), key=lambda x: x[1])
        ]
        score = [0] * numberOfModes
        for i in range(numberOfModes):
            score[i] += i + 1
            score[idxSorted[i]] += numberOfModes - i
        i = 0
        for objId in mdOut:
            score_i = float(score[i]) / (2.0 * numberOfModes)
            mdOut.setValue(xmipp.MDL_NMA_SCORE, score_i, objId)
            i += 1
        mdOut.write("modes.xmd")
        cleanPath("Chkmod.res")

        self._leaveWorkingDir()
コード例 #12
0
ファイル: protocol_nma_base.py プロジェクト: I2PC/scipion
 def qualifyModesStep(self, numberOfModes, collectivityThreshold, structureEM, suffix=''):
     self._enterWorkingDir()
     
     fnVec = glob("modes/vec.*")
     
     if len(fnVec) < numberOfModes:
         msg = "There are only %d modes instead of %d. "
         msg += "Check the number of modes you asked to compute and/or consider increasing cut-off distance."
         msg += "The maximum number of modes allowed by the method for atomic normal mode analysis is 6 times"
         msg += "the number of RTB blocks and for pseudoatomic normal mode analysis 3 times the number of pseudoatoms. "
         msg += "However, the protocol allows only up to 200 modes as 20-100 modes are usually enough. If the number of"
         msg += "modes is below the minimum between these two numbers, consider increasing cut-off distance." 
         self._printWarnings(redStr(msg % (len(fnVec), numberOfModes)))
         print redStr('Warning: There are only %d modes instead of %d.'% (len(fnVec), numberOfModes))
         print redStr("Check the number of modes you asked to compute and/or consider increasing cut-off distance.")
         print redStr("The maximum number of modes allowed by the method for atomic normal mode analysis is 6 times")
         print redStr("the number of RTB blocks and for pseudoatomic normal mode analysis 3 times the number of pseudoatoms.")
         print redStr("However, the protocol allows only up to 200 modes as 20-100 modes are usually enough. If the number of")
         print redStr("modes is below the minimum between these two numbers, consider increasing cut-off distance.")
        
     fnDiag = "diagrtb.eigenfacs"
     
     if structureEM:
         self.runJob("nma_reformatForElNemo.sh", "%d" % len(fnVec),env=getNMAEnviron())
         fnDiag = "diag_arpack.eigenfacs"
         
     self.runJob("echo", "%s | nma_check_modes" % fnDiag,env=getNMAEnviron())
     cleanPath(fnDiag)
     
     fh = open("Chkmod.res")
     mdOut = xmipp.MetaData()
     collectivityList = []
     
     for n in range(len(fnVec)):
         line = fh.readline()
         collectivity = float(line.split()[1])
         collectivityList.append(collectivity)
 
         objId = mdOut.addObject()
         modefile = self._getPath("modes", "vec.%d" % (n+1))
         mdOut.setValue(xmipp.MDL_NMA_MODEFILE, modefile, objId)
         mdOut.setValue(xmipp.MDL_ORDER, long(n+1), objId)
         
         if n >= 6:
             mdOut.setValue(xmipp.MDL_ENABLED, 1, objId)
         else:
             mdOut.setValue(xmipp.MDL_ENABLED, -1, objId)
         mdOut.setValue(xmipp.MDL_NMA_COLLECTIVITY, collectivity, objId)
         
         if collectivity < collectivityThreshold:
             mdOut.setValue(xmipp.MDL_ENABLED,-1,objId)
     fh.close()
     idxSorted = [i[0] for i in sorted(enumerate(collectivityList), key=lambda x:x[1])]
     
     score = []
     for j in range(len(fnVec)):
         score.append(0)
     
     modeNum = []
     l = 0
     for k in range(len(fnVec)):
         modeNum.append(k)
         l += 1
     
     #score = [0]*numberOfModes
     for i in range(len(fnVec)):
         score[i] += i+1
         score[idxSorted[i]] += modeNum[i] - i
     i = 0
     for objId in mdOut:
         score_i = float(score[i])/(2.0*l)
         mdOut.setValue(xmipp.MDL_NMA_SCORE, score_i, objId)
         i+=1
     mdOut.write("modes%s.xmd"%suffix)
     cleanPath("Chkmod.res")
     
     self._leaveWorkingDir()