Exemple #1
0
def talosPlus2restraints( project, name=constants.TALOSPLUS_LIST_STR, status='noRefine', errorFactor=2.0 ):
    """
    Convert talos+ results to a CING dihedral restraint list
    """
    if project == None:
        nTmessage("talosPlus2restraints: No project defined")
        return True

    if project.molecule == None:
        nTmessage("talosPlus2restraints: No project defined")
        return True

    if not project.status.has_key('talosPlus') or not project.status.talosPlus.completed:
        nTmessage("talosPlus2restraints: No talos+ data")
        return True

    if name in project.dihedrals.names():
        project.dihedrals.delete(name)

    dhl = project.dihedrals.new(name=name, status=status)
    for res in project.molecule.allResidues():
        if res.talosPlus and res.talosPlus.classification=='Good':
            lower = res.talosPlus.phi.value-errorFactor*res.talosPlus.phi.error
            upper = res.talosPlus.phi.value+errorFactor*res.talosPlus.phi.error
            atoms = getDeepByKeysOrAttributes( res, constants.PHI_STR, constants.ATOMS_STR )
            if atoms:
                d = DihedralRestraint(atoms, lower, upper)
                dhl.append(d)

            lower = res.talosPlus.psi.value-errorFactor*res.talosPlus.psi.error
            upper = res.talosPlus.psi.value+errorFactor*res.talosPlus.psi.error
            atoms = getDeepByKeysOrAttributes( res, constants.PSI_STR, constants.ATOMS_STR )
            if atoms:
                d = DihedralRestraint(atoms, lower, upper)
                dhl.append(d)
        #end if
    #end for
    nTmessage('==> Created %s', dhl)
Exemple #2
0
def test( projects, stream=sys.stdout ):
    # A hack to get residue specific results
    selectedResidues = projects[0].molecule.setResiduesFromRanges('all')

    for res in selectedResidues:
        rmsds3 = calcPhiPsiRmsds( projects, ranges=[res.resNum] )

        printRmsds('Relative Phi-Psi '+res.name, rmsds3, stream )
        res.phipsiRmsds = rmsds3
        for p in projects.entries[1:]:
            val = getDeepByKeysOrAttributes(projects, 'moleculeMap', res, p.name)
            if val == None:
                nTerror('Setting phipsiRmsds residue %s project %s (mapping not found)', res.name, p)
                continue
            val.phipsiRmsds = rmsds3
Exemple #3
0
def filterListByObjectClassName( myList, className ):
    'Return new list with only those objects that have given class name.'
    result = []
    if myList == None:
        return result
    if not isinstance(myList, list):
        nTerror('Input is not a list but a %s' % str(myList))
        return result
#    if len(myList) == 0:
#        return result
    for obj in myList:
        oClassName = getDeepByKeysOrAttributes(obj, '__class__', '__name__' )
#        nTdebug("oClassName: %s" % oClassName)
        if oClassName == className:
            result.append(obj)
    return result
Exemple #4
0
def filterListByObjectClassName(myList, className):
    'Return new list with only those objects that have given class name.'
    result = []
    if myList == None:
        return result
    if not isinstance(myList, list):
        nTerror('Input is not a list but a %s' % str(myList))
        return result
#    if len(myList) == 0:
#        return result
    for obj in myList:
        oClassName = getDeepByKeysOrAttributes(obj, '__class__', '__name__')
        #        nTdebug("oClassName: %s" % oClassName)
        if oClassName == className:
            result.append(obj)
    return result
Exemple #5
0
def mkYasaraByResidueMacro(projects, keys,
                            minValue = 0.0, maxValue = 1.0, reverseColorScheme = False,
                            path = None
                           ):

#    nTdebug('mkYasaraByResidueMacro: keys: %s, minValue: %s maxValue: %s', keys, minValue, maxValue)

    if path==None:
        stream = sys.stdout
    else:
        stream = open( path, 'w')
    #end if

    fprintf(stream, 'Console off\n')
    fprintf(stream, 'ColorRes All, Gray\n')
    fprintf(stream, 'PropRes All, -999\n')
    if reverseColorScheme:
        fprintf(stream, 'ColorPar Property Min,red,%f\n', minValue)
        fprintf(stream, 'ColorPar Property Max,blue,%f\n', maxValue)
    else:
        fprintf(stream, 'ColorPar Property Min,blue,%f\n', minValue)
        fprintf(stream, 'ColorPar Property Max,red,%f\n', maxValue)

    for p in projects:
        for res in p.molecule.allResidues():
            value = getDeepByKeysOrAttributes(res, *keys)
    #        if res.has_key(property) and res[property] != None and not isNaN(res[property]):
            if value != None and not isNaN(value):
                fprintf(stream, 'PropRes object %d Residue %d, %.4f\n', p.id+1, res.resNum, value)
        #end for

    fprintf(stream, 'ColorAll Property\n')
    fprintf(stream, 'Console on\n')

    if path:
        stream.close()