コード例 #1
0
ファイル: Complex.py プロジェクト: ostrokach/biskit
 def getSurface( model, key ):
     if verbose:
         log.write("Calculating SurfaceRacer data for %s..."%key)
         d = PDBDope( model )
         d.addSurfaceRacer( probe=1.4 )
     if verbose:
         log.writeln('Done.')
         result['%s_AS'%key] = model.profile('AS')
         result['%s_MS'%key] = model.profile('MS')
         result['%s_relAS'%key] = model.profile('relAS')
         result['%s_relMS'%key] = model.profile('relMS')
コード例 #2
0
def createHexInp(recPdb,
                 recModel,
                 ligPdb,
                 ligModel,
                 comPdb=None,
                 outFile=None,
                 macDock=None,
                 silent=0,
                 sol=512):
    """
    Prepare a Hex macro file for the docking of the receptor(s)
    against ligand(s).

    @param recPdb: hex-formatted PDB
    @type  recPdb: str
    @param recModel: hex-formatted PDB
    @type  recModel: str
    @param ligPdb: PDBModel, get distances from this one
    @type  ligPdb: PDBModel
    @param ligModel: PDBModel, getdistances from this one
    @type  ligModel: PDBModel
    @param comPdb: reference PDB
    @type  comPdb: str
    @param outFile: base of file name for mac and out
    @type  outFile: str

    @param macDock: None -> hex decides (from the size of the molecule),
                    1 -> force macroDock, 0-> force off (default: None)
    @type  macDock: None|1|0
    @param silent: don't print distances and macro warnings (default: 0)
    @type  silent: 0|1
    @param sol: number of solutions that HEx should save (default: 512)
    @type  sol: int

    @return: HEX macro file name, HEX out generated bu the macro,
             macro docking status
    @rtype: str, str, boolean
    """
    ## files and names
    recCode = t.stripFilename(recPdb)[0:4]
    ligCode = t.stripFilename(ligPdb)[0:4]

    outFile = outFile or recCode + '-' + ligCode

    ## hex macro name
    macName = t.absfile(outFile + '_hex.mac')

    ## hex rotation matrix output name
    outName_all = t.absfile(outFile + '_hex.out')
    outName_clust = t.absfile(outFile + '_hex_cluster.out')

    ## add surface profiles if not there
    if not recModel.atoms.has_key('relAS'):
        #t.flushPrint('\nCalculating receptor surface profile')
        rec_asa = PDBDope(recModel)
        rec_asa.addSurfaceRacer()
    if not ligModel.atoms.has_key('relAS'):
        #t.flushPrint('\nCalculating ligand surface profile')
        lig_asa = PDBDope(ligModel)
        lig_asa.addSurfaceRacer()

    ## surface masks, > 95% exposed
    rec_surf_mask = N.greater(recModel.profile('relAS'), 95)
    lig_surf_mask = N.greater(ligModel.profile('relAS'), 95)

    ## maximun and medisn distance from centre of mass to any surface atom
    recMax, recMin = centerSurfDist(recModel, rec_surf_mask)
    ligMax, ligMin = centerSurfDist(ligModel, lig_surf_mask)

    ## approxinate max and min center to centre distance
    maxDist = recMax + ligMax
    minDist = recMin + ligMin

    ## molecular separation and search range to be used in the docking
    molSep = (maxDist + minDist) / 2
    molRange = 2 * (maxDist - molSep)

    if not silent:
        print 'Docking setup: %s\nRecMax: %.1f RecMin: %.1f\nLigMax: %.1f LigMin: %.1f\nMaxDist: %.1f MinDist: %.1f\nmolecular_separation: %.1f r12_range: %.1f\n' % (
            outFile, recMax, recMin, ligMax, ligMin, maxDist, minDist, molSep,
            molRange)

    if recMax > 30 and ligMax > 30 and not silent:
        print '\nWARNING! Both the receptor and ligand radius is ',
        print 'greater than 30A.\n'

    ## determine docking mode to use
    macroDocking = 0

    if macDock == None:
        if recMax > 35 and not silent:
            print '\nReceptor has a radius that exceeds 35A ',
            print '-> Macro docking will be used'
            macroDocking = 1
    else:
        macroDocking = macDock

    #####################
    ## write macro file

    macOpen = open(macName, 'w')

    macOpen.write('# -- ' + macName + ' --\n')
    macOpen.write(' \n')
    macOpen.write('open_receptor ' + t.absfile(recPdb) + '\n')
    macOpen.write('open_ligand ' + t.absfile(ligPdb) + '\n')

    if comPdb and comPdb[-4:] == '.pdb':
        macOpen.write('open_complex ' + comPdb + '\n')

    macOpen.write('\n')

    head = """
# -------------- general settings ----------------
disc_cache 1                   # disc cache on (0 off)
docking_sort_mode 1            # Sort solutions by cluster (0 by energy)
docking_cluster_mode 1         # Display all clusters (0 display best)
docking_cluster_threshold 2.00
# docking_cluster_bumps  number

# ------------ molecule orientation --------------
molecule_separation %(separation)i
commit_view """ % ({
        'separation': round(molSep)
    })

    macro = """
# -------------- macro docking -------------------
macro_min_coverage 25
macro_sphere_radius 15
macro_docking_separation 25
activate_macro_model"""


    tail = """
# -------------- docking setup -------------------
docking_search_mode 0          # full rotational search

receptor_range_angle  180      # 0, 15, 30, 45, 60, 75, 90, 180
docking_receptor_samples 720   # 362, 492, 642, 720, 980, 1280

ligand_range_angle  180
docking_ligand_samples 720

twist_range_angle 360          # 0, 15, 30, 60, 90, 180, 360
docking_alpha_samples 128      # 64, 128, 256

r12_step 0.500000              # 0.1, 0.2, 0.25, 0.5, 0.75, 1, 1.5, 2
r12_range %(range)i

docking_radial_filter 0        # Radial Envelope Filter - None

grid_size 0.600                # 0.4, 0.5, 0.6, 0.75, 1.0
# docking_electrostatics 0       # use only surface complimentarity
docking_electrostatics 1      # use electrostatic term for scoring clusters

docking_main_scan 16     # 
docking_main_search 26

max_docking_solutions %(nr_sol)i # number of solutions to save

# -------------- post-processing ----------------
docking_refine 0    # None
#  docking_refine 1    # Backbone Bumps
#  docking_refine 2    # MM energies
#  docking_refine 3    # MM minimization

# ---------------- run docking ------------------
activate_docking
#  save_docking %(output_clust)s
#  save_range 1 512 ./ dock .pdb

# ------------ also save all solutions ----------
docking_sort_mode 0            # Sort solutions by energy (1 by cluster)
save_docking %(output_all)s""" \
         %({'range':round(molRange), 'output_all':outName_all,
            'nr_sol':int(sol), 'output_clust':outName_clust} )

    macOpen.writelines(head)

    ## macro docking will not work with multiple models, if both are added to
    ## the hex macro file - macrodocking will be skipped during the docking run
    if macroDocking:
        macOpen.writelines(macro)

    macOpen.writelines(tail)

    macOpen.close()

    return macName, outName_all, macroDocking
コード例 #3
0
ファイル: trajFluct.py プロジェクト: tybiot/biskit
traj.fit(prof='rms2avg')

f_global = traj.getFluct_global()

f_local = traj.getFluct_local()

ref = traj.getRef()

## disconnect ref from its source
ref.disconnect()

ref.atoms.set('fluct_global',
              f_global,
              comment='fluctuation around average position in A')

ref.atoms.set('fluct_local',
              f_local,
              comment='fluctuation after fitting to each residue backbone')

try:

    doper = PDBDope(ref)

    flushPrint('adding accessible surface profiles...')
    doper.addSurfaceRacer()

except Exception, why:
    errWriteln("Couldn't add surface area profiles, ProfileError: ", why)

dump(traj, options['o'])
コード例 #4
0
ファイル: trajFluct.py プロジェクト: graik/biskit
traj.fit( prof='rms2avg', ref=traj.ref )
traj.fit( prof='rms2avg' )

f_global = traj.getFluct_global()

f_local = traj.getFluct_local()

ref = traj.getRef()

## disconnect ref from its source
ref.disconnect()

ref.atoms.set( 'fluct_global', f_global,
                comment='fluctuation around average position in A' )

ref.atoms.set( 'fluct_local', f_local,
                comment='fluctuation after fitting to each residue backbone')

try:

    doper = PDBDope( ref )

    flushPrint('adding accessible surface profiles...')
    doper.addSurfaceRacer()

except Exception, why:
    errWriteln("Couldn't add surface area profiles, ProfileError: ", why)

dump( traj, options['o'] )
コード例 #5
0

if __name__ == '__main__':

    from Biskit import PDBDope
    from Biskit.tools import *
    from Biskit.Dock import Complex

    print "Loading"
    m_com = load(testRoot() + '/com/ref.complex').model()
    rec = m_com.takeChains([0])
    lig = m_com.takeChains([1])

    ## add molecular surface to components
    doper = PDBDope(rec)
    doper.addSurfaceRacer(probe=1.4)
    surf_rec = rec.profile2mask('MS', 0.0001, 101)

    doper = PDBDope(lig)
    doper.addSurfaceRacer(probe=1.4)
    surf_lig = lig.profile2mask('MS', 0.0001, 101)

    ## kick out non-surface
    rec = rec.compress(surf_rec)
    lig = lig.compress(surf_lig)

    com = Complex(rec, lig)

    ## get interface patch
    cont = com.atomContacts(cutoff=6.0)
    rec_if = N0.sum(cont, 1)
コード例 #6
0

if __name__ == '__main__':

    from Biskit import PDBDope
    from Biskit.tools import *
    from Biskit.Dock import Complex

    print "Loading"
    m_com = load( testRoot() + '/com/ref.complex' ).model()
    rec = m_com.takeChains([0])
    lig = m_com.takeChains([1])

    ## add molecular surface to components
    doper = PDBDope( rec )
    doper.addSurfaceRacer( probe=1.4 )
    surf_rec = rec.profile2mask( 'MS', 0.0001, 101 )

    doper = PDBDope( lig )
    doper.addSurfaceRacer( probe=1.4 )
    surf_lig = lig.profile2mask( 'MS', 0.0001, 101 )

    ## kick out non-surface
    rec = rec.compress( surf_rec )
    lig = lig.compress( surf_lig )

    com = Complex( rec, lig )

    ## get interface patch
    cont = com.atomContacts( cutoff=6.0 )
    rec_if = N0.sum( cont, 1 )
コード例 #7
0
ファイル: Complex.py プロジェクト: ostrokach/biskit
    def test_Complex(self):
        """Dock.Complex test"""

        lig = PCRModel( t.testRoot() + "/com/1BGS.psf",
                        t.testRoot() + "/com/lig.model")

        rec = PCRModel( t.testRoot() + "/com/1BGS.psf",
                        t.testRoot() + "/com/rec.model")

        rec = rec.compress( rec.maskHeavy() )
        lig = lig.compress( lig.maskHeavy() )

        c = Complex(rec, lig)
        c.info['soln'] = 1

        cont = c.atomContacts( 6.0 )
        contProfile_lig = N.sum( cont )
        contProfile_rec = N.sum( cont, 1 )

        try:
            dope = PDBDope( c.rec_model )
            dope.addSurfaceRacer( probe=1.4 )
            rec_surf = c.rec_model.profile2mask( 'MS', 0.0000001, 1000 )

            dope = PDBDope( c.lig_model )
            dope.addSurfaceRacer( probe=1.4 )
            lig_surf = c.lig_model.profile2mask( 'MS', 0.0000001, 1000 )
        except:
            pass

        if self.local:           
            from Biskit import Pymoler

            self.pm = Pymoler()
            self.pm.addPdb( c.rec(), 'rec' )
            self.pm.addPdb( c.lig(), 'lig' )

            self.pm.colorAtoms( 'rec', contProfile_rec )
            self.pm.colorAtoms( 'lig', contProfile_lig )

            rec_sphere = c.rec().clone()
            rec_sphere.xyz = mathUtils.projectOnSphere( rec_sphere.xyz )

            lig_sphere = c.lig().clone()
            lig_sphere.xyz = mathUtils.projectOnSphere( lig_sphere.xyz )

            self.pm.addPdb( rec_sphere, 'rec_sphere' )
            self.pm.addPdb( lig_sphere, 'lig_sphere' )

            self.pm.colorAtoms( 'rec_sphere', contProfile_rec )
            self.pm.colorAtoms( 'lig_sphere', contProfile_lig )

            self.pm.add( 'hide all')

            self.pm.add( 'color grey, (b=0)' )
            self.pm.add( 'show stick, (rec or lig)' )
            self.pm.add( 'show surf, rec_sphere')

            self.pm.add( 'zoom all' )

            self.pm.show()
            
            globals().update( locals() )

        self.assertEqual( N.sum(contProfile_lig) + N.sum(contProfile_rec),
                          2462 )
コード例 #8
0
ファイル: hexTools.py プロジェクト: ostrokach/biskit
def createHexInp( recPdb, recModel, ligPdb, ligModel, comPdb=None,
                  outFile=None, macDock=None, silent=0, sol=512 ):
    """
    Prepare a Hex macro file for the docking of the receptor(s)
    against ligand(s).

    @param recPdb: hex-formatted PDB
    @type  recPdb: str
    @param recModel: hex-formatted PDB
    @type  recModel: str
    @param ligPdb: PDBModel, get distances from this one
    @type  ligPdb: PDBModel
    @param ligModel: PDBModel, getdistances from this one
    @type  ligModel: PDBModel
    @param comPdb: reference PDB
    @type  comPdb: str
    @param outFile: base of file name for mac and out
    @type  outFile: str

    @param macDock: None -> hex decides (from the size of the molecule),
                    1 -> force macroDock, 0-> force off (default: None)
    @type  macDock: None|1|0
    @param silent: don't print distances and macro warnings (default: 0)
    @type  silent: 0|1
    @param sol: number of solutions that HEx should save (default: 512)
    @type  sol: int

    @return: HEX macro file name, HEX out generated bu the macro,
             macro docking status
    @rtype: str, str, boolean
    """
    ## files and names
    recCode = t.stripFilename( recPdb )[0:4]          
    ligCode = t.stripFilename( ligPdb )[0:4]

    outFile = outFile or recCode + '-' + ligCode

    ## hex macro name
    macName = t.absfile( outFile + '_hex.mac' )

    ## hex rotation matrix output name
    outName_all = t.absfile( outFile + '_hex.out'  )
    outName_clust = t.absfile( outFile + '_hex_cluster.out')

    ## add surface profiles if not there
    if not recModel.atoms.has_key('relAS'):
        #t.flushPrint('\nCalculating receptor surface profile')
        rec_asa = PDBDope( recModel )
        rec_asa.addSurfaceRacer()
    if not ligModel.atoms.has_key('relAS'):
        #t.flushPrint('\nCalculating ligand surface profile')
        lig_asa = PDBDope( ligModel )
        lig_asa.addSurfaceRacer()

    ## surface masks, > 95% exposed
    rec_surf_mask = N.greater( recModel.profile('relAS'), 95 )
    lig_surf_mask = N.greater( ligModel.profile('relAS'), 95 )

    ## maximun and medisn distance from centre of mass to any surface atom
    recMax, recMin = centerSurfDist( recModel, rec_surf_mask )
    ligMax, ligMin = centerSurfDist( ligModel, lig_surf_mask )

    ## approxinate max and min center to centre distance
    maxDist = recMax + ligMax 
    minDist = recMin + ligMin

    ## molecular separation and search range to be used in the docking
    molSep = ( maxDist + minDist ) / 2
    molRange = 2 * ( maxDist - molSep )

    if not silent:
        print 'Docking setup: %s\nRecMax: %.1f RecMin: %.1f\nLigMax: %.1f LigMin: %.1f\nMaxDist: %.1f MinDist: %.1f\nmolecular_separation: %.1f r12_range: %.1f\n'%(outFile, recMax, recMin, ligMax, ligMin, maxDist, minDist, molSep, molRange)

    if recMax > 30 and ligMax > 30 and not silent:
        print '\nWARNING! Both the receptor and ligand radius is ',
        print 'greater than 30A.\n'     

    ## determine docking mode to use
    macroDocking = 0

    if macDock==None:
        if recMax > 35 and not silent:
            print '\nReceptor has a radius that exceeds 35A ',
            print '-> Macro docking will be used'
            macroDocking = 1
    else:
        macroDocking = macDock

    #####################
    ## write macro file

    macOpen= open( macName, 'w')

    macOpen.write('# -- ' + macName + ' --\n')
    macOpen.write(' \n')
    macOpen.write('open_receptor '+ t.absfile(recPdb) +'\n')
    macOpen.write('open_ligand '+ t.absfile(ligPdb) +'\n')

    if comPdb and comPdb[-4:] == '.pdb':
        macOpen.write('open_complex '+comPdb+'\n')

    macOpen.write('\n')

    head = """
# -------------- general settings ----------------
disc_cache 1                   # disc cache on (0 off)
docking_sort_mode 1            # Sort solutions by cluster (0 by energy)
docking_cluster_mode 1         # Display all clusters (0 display best)
docking_cluster_threshold 2.00
# docking_cluster_bumps  number

# ------------ molecule orientation --------------
molecule_separation %(separation)i
commit_view """%({'separation': round(molSep)} )


    macro ="""
# -------------- macro docking -------------------
macro_min_coverage 25
macro_sphere_radius 15
macro_docking_separation 25
activate_macro_model"""


    tail = """
# -------------- docking setup -------------------
docking_search_mode 0          # full rotational search

receptor_range_angle  180      # 0, 15, 30, 45, 60, 75, 90, 180
docking_receptor_samples 720   # 362, 492, 642, 720, 980, 1280

ligand_range_angle  180
docking_ligand_samples 720

twist_range_angle 360          # 0, 15, 30, 60, 90, 180, 360
docking_alpha_samples 128      # 64, 128, 256

r12_step 0.500000              # 0.1, 0.2, 0.25, 0.5, 0.75, 1, 1.5, 2
r12_range %(range)i

docking_radial_filter 0        # Radial Envelope Filter - None

grid_size 0.600                # 0.4, 0.5, 0.6, 0.75, 1.0
# docking_electrostatics 0       # use only surface complimentarity
docking_electrostatics 1      # use electrostatic term for scoring clusters

docking_main_scan 16     # 
docking_main_search 26

max_docking_solutions %(nr_sol)i # number of solutions to save

# -------------- post-processing ----------------
docking_refine 0    # None
#  docking_refine 1    # Backbone Bumps
#  docking_refine 2    # MM energies
#  docking_refine 3    # MM minimization

# ---------------- run docking ------------------
activate_docking
#  save_docking %(output_clust)s
#  save_range 1 512 ./ dock .pdb

# ------------ also save all solutions ----------
docking_sort_mode 0            # Sort solutions by energy (1 by cluster)
save_docking %(output_all)s""" \
         %({'range':round(molRange), 'output_all':outName_all,
            'nr_sol':int(sol), 'output_clust':outName_clust} )

    macOpen.writelines( head )

    ## macro docking will not work with multiple models, if both are added to
    ## the hex macro file - macrodocking will be skipped during the docking run
    if macroDocking:
        macOpen.writelines( macro )

    macOpen.writelines( tail )

    macOpen.close()

    return macName, outName_all, macroDocking