Protool/mutate.py
def Model_Mutations(pdbfile,mol2files,mutations,max_overlap=0.5,max_totalbump=1.0,return_score=False,store_mutation_operations=False):
    """Model a number of mutations in a pdbfile when one or more ligands are present"""
    #
    # Check for stupidity
    #
    if max_overlap>max_totalbump:
        max_totalbump=max_overlap
        print 'Adjusted total bump cutoff to %5.2f' %max_totalbump
    #
    # Read PDB file
    #
    import Protool
    P=Protool.structureIO()
    P.readpdb(pdbfile)
    P.remove_all_hydrogens()
    #
    # Read mol2 file
    #
    L=Protool.ligand(P)
    for mol2file in mol2files:
        print "Added %s with tag 'LIGAND'" %mol2file
        L.readmol2(mol2file,tag='LIGAND')
    #
    # Get the pdb lines
    #
    pdblines=P.writepdb('junk.pdb',nowrite=True)
    #
    # Pass the lines to FFF
    #
    import FFF.FFFcontrol
    myFFF=FFF.FFFcontrol.FFF()
    myFFF.parse_lines(pdblines)
    #myFFF.soup_stat()
    Model=FFF.FFFcontrol.model_class(myFFF,Rotamerlib,FFFaadef_dir)
    #
    # Store the wild type PDB file
    #
    if store_mutation_operations:
        wt_lines=myFFF.make_pdblines('PDB')
    #
    import pKa.pKD_tools as pKD_tools
    total_bump=0.0
    for mutation in mutations:
        resid=pKD_tools.get_resid_from_mut(mutation)
        chainid=resid.split(':')[0]
        resid=resid.split(':')[1]
        #
        # Get rid of the leading zeros
        #
        done=False
        while not done:
            if resid[0]=='0' and len(resid)>1:
                resid=resid[1:]
            else:
                done=True
        #
        newres=pKD_tools.get_newrestyp_from_mut(mutation)
        oldres=pKD_tools.get_oldrestyp_from_mut(mutation)
        opttype=3 # Rotamer library
        energies=Model.Mutate(chainid,resid,newres,opttype,max_overlap)
        bump_score=energies[0]
        Sum=energies[1]
        Coulomb=energies[2]
        #
        total_bump=total_bump+bump_score
        print 'Bump score: %5.2f, total bump: %5.2f' %(bump_score,total_bump)
        if bump_score>max_overlap or total_bump>max_totalbump:
            print 'Cannot model this set of mutations - too many bumps'
            if return_score:
                return False, total_bump
            else:
                return False
        print 'Bump score for %s: %5.3f' %(mutation,bump_score)
    print 'Total bump score for all mutations: %5.3f' %(total_bump)
    class FFF_fix:

        def __init__(self,FFF):
            self.PI=FFF
            return
    #
    # Create the instance
    #
    FFF_instance=FFF_fix(myFFF)
    #
    # Keep track of the changes that were made to the PDB file
    #
    if store_mutation_operations:
        mut_lines=FFF_instance.PI.make_pdblines('PDB')
        import Protool
        WT=Protool.structureIO()
        WT.parsepdb(wt_lines)
        wt_atoms=sorted(WT.atoms.keys())
        #
        MUT=Protool.structureIO()
        MUT.parsepdb(mut_lines)
        #
        mut_atoms=sorted(MUT.atoms.keys())
        wt_count=0
        mutcount=0
        
        def coord_diff(atom1,atom2):
            diff=0.0
            for coord in ['X','Y','Z']:
                diff=diff+abs(atom1[coord]-atom2[coord])
            return diff
        
        operations=[]
        for atom in wt_atoms:
            if not atom in mut_atoms:
                operations.append(['delete',atom,WT.atoms[atom]])
            elif coord_diff(WT.atoms[atom],MUT.atoms[atom])>0.1:
                operations.append(['delete',atom,WT.atoms[atom]])
                operations.append(['add',atom,MUT.atoms[atom]])
            else:
                pass
        for atom in mut_atoms:
            if not atom in wt_atoms:
                operations.append(['add',atom,MUT.atoms[atom]])
        #
        # Store these in FFF_fix
        #
        FFF_instance.mutate_operations=operations[:]
    #
    # Return the info
    #
    if (return_score):
        return FFF_instance,total_bump
    return FFF_instance
Model a number of mutations in a pdbfile when one or more ligands are present
Model a number of mutations in a pdbfile when one or more ligands are present
Model a number of mutations in a pdbfile when one or more ligands are present
def Model_Mutations(pdbfile,mol2files,mutations,max_overlap=0.5,max_totalbump=1.0,return_score=False,store_mutation_operations=False):
     Check for stupidity
    if max_overlap>max_totalbump:
        max_totalbump=max_overlap
        print 'Adjusted total bump cutoff to %5.2f' %max_totalbump
     Read PDB file
    import Protool
    P=Protool.structureIO()
    P.readpdb(pdbfile)
    P.remove_all_hydrogens()
     Read mol2 file
    L=Protool.ligand(P)
    for mol2file in mol2files:
        print "Added %s with tag 'LIGAND'" %mol2file
        L.readmol2(mol2file,tag='LIGAND')
     Get the pdb lines
    pdblines=P.writepdb('junk.pdb',nowrite=True)
     Pass the lines to FFF
    import FFF.FFFcontrol
    myFFF=FFF.FFFcontrol.FFF()
    myFFF.parse_lines(pdblines)
    myFFF.soup_stat()
    Model=FFF.FFFcontrol.model_class(myFFF,Rotamerlib,FFFaadef_dir)
     Store the wild type PDB file
    if store_mutation_operations:
        wt_lines=myFFF.make_pdblines('PDB')
    import pKa.pKD_tools as pKD_tools
    total_bump=0.0
    for mutation in mutations:
        resid=pKD_tools.get_resid_from_mut(mutation)
        chainid=resid.split(':')[0]
        resid=resid.split(':')[1]
         Get rid of the leading zeros
        done=False
        while not done:
            if resid[0]=='0' and len(resid)>1:
                resid=resid[1:]
            else:
                done=True
        newres=pKD_tools.get_newrestyp_from_mut(mutation)
        oldres=pKD_tools.get_oldrestyp_from_mut(mutation)
        opttype=3  Rotamer library
        energies=Model.Mutate(chainid,resid,newres,opttype,max_overlap)
        bump_score=energies[0]
        Sum=energies[1]
        Coulomb=energies[2]
        total_bump=total_bump+bump_score
        print 'Bump score: %5.2f, total bump: %5.2f' %(bump_score,total_bump)
        if bump_score>max_overlap or total_bump>max_totalbump:
            print 'Cannot model this set of mutations - too many bumps'
            if return_score:
                return False, total_bump
            else:
                return False
        print 'Bump score for %s: %5.3f' %(mutation,bump_score)
    print 'Total bump score for all mutations: %5.3f' %(total_bump)
    class FFF_fix:
        def __init__(self,FFF):
            self.PI=FFF
            return
     Create the instance
    FFF_instance=FFF_fix(myFFF)
     Keep track of the changes that were made to the PDB file
    if store_mutation_operations:
        mut_lines=FFF_instance.PI.make_pdblines('PDB')
        import Protool
        WT=Protool.structureIO()
        WT.parsepdb(wt_lines)
        wt_atoms=sorted(WT.atoms.keys())
        MUT=Protool.structureIO()
        MUT.parsepdb(mut_lines)
        mut_atoms=sorted(MUT.atoms.keys())
        wt_count=0
        mutcount=0
        def coord_diff(atom1,atom2):
            diff=0.0
            for coord in ['X','Y','Z']:
                diff=diff+abs(atom1[coord]-atom2[coord])
            return diff
        operations=[]
        for atom in wt_atoms:
            if not atom in mut_atoms:
                operations.append(['delete',atom,WT.atoms[atom]])
            elif coord_diff(WT.atoms[atom],MUT.atoms[atom])>0.1:
                operations.append(['delete',atom,WT.atoms[atom]])
                operations.append(['add',atom,MUT.atoms[atom]])
            else:
                pass
        for atom in mut_atoms:
            if not atom in wt_atoms:
                operations.append(['add',atom,MUT.atoms[atom]])
         Store these in FFF_fix
        FFF_instance.mutate_operations=operations[:]
     Return the info
    if (return_score):
        return FFF_instance,total_bump
    return FFF_instance
def Model_Mutations ( pdbfile , mol2files , mutations , max_overlap = 0.5 , max_totalbump = 1.0 , return_score = False , store_mutation_operations = False ) : if max_overlap > max_totalbump : max_totalbump = max_overlap print 'Adjusted total bump cutoff to %5.2f' % max_totalbump import Protool P = Protool . structureIO ( ) P . readpdb ( pdbfile ) P . remove_all_hydrogens ( ) L = Protool . ligand ( P ) for mol2file in mol2files : print "Added %s with tag 'LIGAND'" % mol2file L . readmol2 ( mol2file , tag = 'LIGAND' ) pdblines = P . writepdb ( 'junk.pdb' , nowrite = True ) import FFF . FFFcontrol myFFF = FFF . FFFcontrol . FFF ( ) myFFF . parse_lines ( pdblines ) Model = FFF . FFFcontrol . model_class ( myFFF , Rotamerlib , FFFaadef_dir ) if store_mutation_operations : wt_lines = myFFF . make_pdblines ( 'PDB' ) import pKa . pKD_tools as pKD_tools total_bump = 0.0 for mutation in mutations : resid = pKD_tools . get_resid_from_mut ( mutation ) chainid = resid . split ( ':' ) [ 0 ] resid = resid . split ( ':' ) [ 1 ] done = False while not done : if resid [ 0 ] == '0' and len ( resid ) > 1 : resid = resid [ 1 : ] else : done = True newres = pKD_tools . get_newrestyp_from_mut ( mutation ) oldres = pKD_tools . get_oldrestyp_from_mut ( mutation ) opttype = 3 energies = Model . Mutate ( chainid , resid , newres , opttype , max_overlap ) bump_score = energies [ 0 ] Sum = energies [ 1 ] Coulomb = energies [ 2 ] total_bump = total_bump + bump_score print 'Bump score: %5.2f, total bump: %5.2f' % ( bump_score , total_bump ) if bump_score > max_overlap or total_bump > max_totalbump : print 'Cannot model this set of mutations - too many bumps' if return_score : return False , total_bump else : return False print 'Bump score for %s: %5.3f' % ( mutation , bump_score ) print 'Total bump score for all mutations: %5.3f' % ( total_bump ) class FFF_fix : def __init__ ( self , FFF ) : self . PI = FFF return FFF_instance = FFF_fix ( myFFF ) if store_mutation_operations : mut_lines = FFF_instance . PI . make_pdblines ( 'PDB' ) import Protool WT = Protool . structureIO ( ) WT . parsepdb ( wt_lines ) wt_atoms = sorted ( WT . atoms . keys ( ) ) MUT = Protool . structureIO ( ) MUT . parsepdb ( mut_lines ) mut_atoms = sorted ( MUT . atoms . keys ( ) ) wt_count = 0 mutcount = 0 def coord_diff ( atom1 , atom2 ) : diff = 0.0 for coord in [ 'X' , 'Y' , 'Z' ] : diff = diff + abs ( atom1 [ coord ] - atom2 [ coord ] ) return diff operations = [ ] for atom in wt_atoms : if not atom in mut_atoms : operations . append ( [ 'delete' , atom , WT . atoms [ atom ] ] ) elif coord_diff ( WT . atoms [ atom ] , MUT . atoms [ atom ] ) > 0.1 : operations . append ( [ 'delete' , atom , WT . atoms [ atom ] ] ) operations . append ( [ 'add' , atom , MUT . atoms [ atom ] ] ) else : pass for atom in mut_atoms : if not atom in wt_atoms : operations . append ( [ 'add' , atom , MUT . atoms [ atom ] ] ) FFF_instance . mutate_operations = operations [ : ] if ( return_score ) : return FFF_instance , total_bump return FFF_instance
Model a number of mutations in a pdbfile when one or more ligands are present
Model a number of mutations in a pdbfile when one or more ligands are present
"""Model a number of mutations in a pdbfile when one or more ligands are present""" # # Check for stupidity # # # Read PDB file # # # Read mol2 file # # # Get the pdb lines # # # Pass the lines to FFF # #myFFF.soup_stat() # # Store the wild type PDB file # # # # Get rid of the leading zeros # # # Rotamer library # # # Create the instance # # # Keep track of the changes that were made to the PDB file # # # # # Store these in FFF_fix # # # Return the info #
pdbfile
mol2files
mutations
max_overlap
max_totalbump
return_score
store_mutation_operations