Example #1
0
def mkJmolMacros(project):
    """
    Generate the Jmol macros in the moleculeDirectories.Jmol dir.
    """
    if not project.molecule:
        nTerror("mkJmolMacros: no molecule defined")
        return
    # end if

    # save first model
    molName = project.molecule.name + "_0"
    path = project.moleculePath("jmol", molName + ".pdb")
    project.molecule.toPDBfile(path, model=0)

    #    mkYasaraByResidueMacro(project, ['procheck','gf'],
    #                           minValue=-3.0,maxValue=1.0,
    #                           reverseColorScheme=True,
    #                           path=project.moleculePath('yasara','gf.mcr')
    #                          )
    #
    #    mkYasaraByResidueMacro(project, ['Qshift','backbone'],
    #                           minValue=0.0,maxValue=0.05,
    #                           reverseColorScheme=False,
    #                           path=project.moleculePath('yasara','Qshift.mcr')
    #                          )

    mkJmolByResidueROGMacro(project, object=1, path=project.moleculePath("jmol", "rog.spt"))
Example #2
0
def mkJmolByResidueROGMacro(project, object=None, path=None, stream=None):
    if path:
        stream = open(path, "w")
    elif stream:
        pass
    else:
        stream = sys.stdout
    # end if

    if not stream:
        nTerror("mkJmolByResidueROGMacro: undefined output stream")
        return
    # endif

    if object == None:
        fprintf(stream, "select *; color grey\n")
    else:
        fprintf(stream, "select */%d; color grey\n", object)

    for res in project.molecule.allResidues():
        if object == None:
            fprintf(stream, "select %d:%s.*; ", res.resNum, res.chain.name)
        else:
            fprintf(stream, "select %d:%s.*/%d; ", res.resNum, res.chain.name, object)
        fprintf(stream, "color %s\n", res.rogScore.colorLabel)
    # end for

    if path:
        stream.close()
Example #3
0
    def select(self, rangesString, filter=True):
        """
        select residues on the basis of rangesString
        Only convert a residue ranges string, e.g. 'A.-10--2,B.3'

        return True on error
        Adapted from code in Molecule class
        """
        #GWV 20130524: convert unicode to string as procheckStatus.ranges field sometimes?? is stored in unicode
        if type(rangesString) == unicode:
            rangesString = str(rangesString)
        if type(rangesString) != str:
            nTerror('ResidueRange.select: ranges type [%s] should have been a string' % type(ranges) )
            return True
        rangesString = rangesString.strip()

        # clear self
        self.clear()

        # everything
        if rangesString == '*' or rangesString == 'all':
            [self.append(res) for res in self.molecule.allResidues()]
            self.method = ResidueRange.FROM_STRING
            return False
        #selections
        for substr in rangesString.split(','):
            self._parseSubstring(substr.strip())
        if filter:
            self.filter()
        self.method = ResidueRange.FROM_STRING
        return False
Example #4
0
def mkJmolByResidueROGMacro(project, object=None, path=None, stream=None):
    if path:
        stream = open(path, 'w')
    elif stream:
        pass
    else:
        stream = sys.stdout
    #end if

    if not stream:
        nTerror('mkJmolByResidueROGMacro: undefined output stream')
        return
    #endif

    if object == None:
        fprintf(stream, 'select *; color grey\n')
    else:
        fprintf(stream, 'select */%d; color grey\n', object)

    for res in project.molecule.allResidues():
        if object == None:
            fprintf(stream, 'select %d:%s.*; ', res.resNum, res.chain.name)
        else:
            fprintf(stream, 'select %d:%s.*/%d; ', res.resNum, res.chain.name,
                    object)
        fprintf(stream, 'color %s\n', res.rogScore.colorLabel)
    #end for

    if path:
        stream.close()
Example #5
0
def mkJmolMacros(project):
    """
    Generate the Jmol macros in the moleculeDirectories.Jmol dir.
    """
    if not project.molecule:
        nTerror('mkJmolMacros: no molecule defined')
        return
    #end if

    # save first model
    molName = project.molecule.name + '_0'
    path = project.moleculePath('jmol', molName + '.pdb')
    project.molecule.toPDBfile(path, model=0)

    #    mkYasaraByResidueMacro(project, ['procheck','gf'],
    #                           minValue=-3.0,maxValue=1.0,
    #                           reverseColorScheme=True,
    #                           path=project.moleculePath('yasara','gf.mcr')
    #                          )
    #
    #    mkYasaraByResidueMacro(project, ['Qshift','backbone'],
    #                           minValue=0.0,maxValue=0.05,
    #                           reverseColorScheme=False,
    #                           path=project.moleculePath('yasara','Qshift.mcr')
    #                          )

    mkJmolByResidueROGMacro(project,
                            object=1,
                            path=project.moleculePath('jmol', 'rog.spt'))
Example #6
0
    def calculate(self, residue):
        """Calculate the PseudoRotation angles and pucker amplitudes
           for all models of residue.

           return a (Ntlist,NTlist,ETclassification) tuple with the PseudoRotation angles
           and pucker amplitudes, or (None,None,None) on error.

        """
        from cing import printf, nTerror, NTlist
        from math import atan2

        if not residue.hasProperties('nucleic'):
            nTerror('PseudoRotation.calculate: residue %s is not nucleic acid',
                    residue)
            return (None, None, None)
        #end if

        diheds = []
        for J, dihed in self.angleMap:
            if dihed not in residue:
                nTerror(
                    'PseudoRotation.calculate: dihedral "%s" not defined for residue %s',
                    dihed, residue)
                return (None, None, None)
            #end if
            diheds.append(residue[dihed])
        #end for
        #print diheds

        nmodels = len(diheds[0])
        Plist = NTlist()
        tauMlist = NTlist()
        for i in range(nmodels):
            taus = []
            for d in diheds:
                taus.append(d[i])
            #end for

            # Do fit and calculate P and pucker
            c = self.fit(taus)
            P = atan2(-c[1], c[0])
            tauM = c[0] / cos(P)
            P = P / pi * 180.0  # convert to degrees

            Plist.append(P)
            tauMlist.append(tauM)

            #printf( '%1d %8.2f %8.2f\n',i, P, tauM )
        #end for

        Plist.cAverage()
        Plist.limit(Plist.cav - 180.0,
                    Plist.cav + 180.0)  # Center around circular average,
        Plist.average()  # to calculate sd in this step
        Plist.limit(0.0, 360.0)  # and rescale to 0,360 range
        tauMlist.average()

        ETname = self.getETnomenclature(Plist.cav, Plist.sd)
        return Plist, tauMlist, ETname
Example #7
0
    def calculate(self, residue):
        """Calculate the PseudoRotation angles and pucker amplitudes
           for all models of residue.

           return a (Ntlist,NTlist,ETclassification) tuple with the PseudoRotation angles
           and pucker amplitudes, or (None,None,None) on error.

        """
        from cing import printf, nTerror, NTlist
        from math import atan2

        if not residue.hasProperties("nucleic"):
            nTerror("PseudoRotation.calculate: residue %s is not nucleic acid", residue)
            return (None, None, None)
        # end if

        diheds = []
        for J, dihed in self.angleMap:
            if dihed not in residue:
                nTerror('PseudoRotation.calculate: dihedral "%s" not defined for residue %s', dihed, residue)
                return (None, None, None)
            # end if
            diheds.append(residue[dihed])
        # end for
        # print diheds

        nmodels = len(diheds[0])
        Plist = NTlist()
        tauMlist = NTlist()
        for i in range(nmodels):
            taus = []
            for d in diheds:
                taus.append(d[i])
            # end for

            # Do fit and calculate P and pucker
            c = self.fit(taus)
            P = atan2(-c[1], c[0])
            tauM = c[0] / cos(P)
            P = P / pi * 180.0  # convert to degrees

            Plist.append(P)
            tauMlist.append(tauM)

            # printf( '%1d %8.2f %8.2f\n',i, P, tauM )
        # end for

        Plist.cAverage()
        Plist.limit(Plist.cav - 180.0, Plist.cav + 180.0)  # Center around circular average,
        Plist.average()  # to calculate sd in this step
        Plist.limit(0.0, 360.0)  # and rescale to 0,360 range
        tauMlist.average()

        ETname = self.getETnomenclature(Plist.cav, Plist.sd)
        return Plist, tauMlist, ETname
Example #8
0
def procheck_old( project, ranges=None ):
    """
    Adds <Procheck> instance to molecule. Run procheck and parse result
    """
    if not project.molecule:
        nTerror('ERROR procheck: no molecule defined\n')
        return None
    #end if

    if project.molecule.has_key('procheck'):
        del(project.molecule.procheck)
    #end if

    pcheck = gvProcheck( project )
    if not pcheck: return None

    pcheck.run( ranges=ranges )
    project.molecule.procheck = pcheck

    return project.molecule.procheck
Example #9
0
def procheck_old(project, ranges=None):
    """
    Adds <Procheck> instance to molecule. Run procheck and parse result
    """
    if not project.molecule:
        nTerror('ERROR procheck: no molecule defined\n')
        return None
    #end if

    if project.molecule.has_key('procheck'):
        del (project.molecule.procheck)
    #end if

    pcheck = gvProcheck(project)
    if not pcheck: return None

    pcheck.run(ranges=ranges)
    project.molecule.procheck = pcheck

    return project.molecule.procheck
Example #10
0
    def parseResult(self):
        """
        Get summary

        Parse procheck .rin files and store result in procheck NTdict
        of each residue of mol

        """
        path = os.path.join(self.rootPath, sprintf('%s.sum',
                                                   self.molecule.name))
        fp = open(path, 'r')
        if not fp:
            nTerror('gvProcheck.parseResult: %s not found', path)
        else:
            self.summary = ''.join(fp.readlines())
            fp.close()
        #end if

        for i in range(1, self.molecule.modelCount + 1):
            path = os.path.join(self.rootPath,
                                sprintf('%s_%03d.rin', self.molecule.name, i))
            #print '> parsing >', path

            for line in AwkLike(path, minLength=64, commentString="#"):
                result = self._parseProcheckLine(line.dollar[0])
                chain = result['chain']
                resNum = result['resNum']
                residue = self.molecule.decodeNameTuple(
                    (cing.PDB, chain, resNum, None))
                if not residue:
                    nTerror('Procheck.parseResult: residue not found (%s,%d)',
                            chain, resNum)
                else:

                    residue.setdefault('procheck', NTstruct())
                    for field, value in result.iteritems():
                        residue.procheck.setdefault(field, NTlist())
                        residue.procheck[field].append(value)
                    #end for
                #end if
                del (result)
Example #11
0
    def parseResult(self):
        """
        Get summary

        Parse procheck .rin files and store result in procheck NTdict
        of each residue of mol

        """
        path = os.path.join(self.rootPath, sprintf("%s.sum", self.molecule.name))
        fp = open(path, "r")
        if not fp:
            nTerror("gvProcheck.parseResult: %s not found", path)
        else:
            self.summary = "".join(fp.readlines())
            fp.close()
        # end if

        for i in range(1, self.molecule.modelCount + 1):
            path = os.path.join(self.rootPath, sprintf("%s_%03d.rin", self.molecule.name, i))
            # print '> parsing >', path

            for line in AwkLike(path, minLength=64, commentString="#"):
                result = self._parseProcheckLine(line.dollar[0])
                chain = result["chain"]
                resNum = result["resNum"]
                residue = self.molecule.decodeNameTuple((cing.PDB, chain, resNum, None))
                if not residue:
                    nTerror("Procheck.parseResult: residue not found (%s,%d)", chain, resNum)
                else:

                    residue.setdefault("procheck", NTstruct())
                    for field, value in result.iteritems():
                        residue.procheck.setdefault(field, NTlist())
                        residue.procheck[field].append(value)
                    # end for
                # end if
                del (result)