예제 #1
0
    def test_Benchmark(self):
        """Mod.Benchmark test"""
        from Biskit import Pymoler

        self.b = Benchmark(self.outfolder)

        self.b.go()

        pdb = T.load(self.outfolder + "/modeller/PDBModels.list")[0]

        reference = PDBModel(self.outfolder + "/reference.pdb")
        tmp_model = pdb.clone()

        reference = reference.compress(reference.maskCA())
        pdb = pdb.compress(pdb.maskCA())
        tmp_model = tmp_model.compress(tmp_model.maskCA())

        tm = tmp_model.transformation(reference,
                                      n_it=0,
                                      profname="rms_outliers")
        pdb = pdb.transform(tm)

        if self.local:
            pm = Pymoler()
            pm.addPdb(pdb, "m")
            pm.addPdb(reference, "r")
            pm.colorAtoms("m", tmp_model.profile("rms_outliers"))
            pm.add('set ribbon_trace,1')
            pm.add('show ribbon')
            pm.show()

            if self.DEBUG:
                self.log.add(
                    'The result from the benchmarking is in %s/benchmark'%\
                    self.outfolder)

            globals().update(locals())
예제 #2
0
    def test_Benchmark(self):
        """Mod.Benchmark test"""
        from Biskit import Pymoler

        self.b = Benchmark( self.outfolder )

        self.b.go()

        pdb = T.load( self.outfolder + "/modeller/PDBModels.list" )[0]

        reference = PDBModel(self.outfolder  + "/reference.pdb" )
        tmp_model = pdb.clone()

        reference = reference.compress( reference.maskCA() )
        pdb       = pdb.compress( pdb.maskCA() )
        tmp_model = tmp_model.compress(tmp_model.maskCA())

        tm = tmp_model.transformation( reference, n_it=0,
                                       profname="rms_outliers")
        pdb = pdb.transform( tm )

        if self.local:
            pm = Pymoler()
            pm.addPdb( pdb, "m" )
            pm.addPdb( reference, "r" )
            pm.colorAtoms( "m", tmp_model.profile("rms_outliers") )
            pm.add('set ribbon_trace,1')
            pm.add('show ribbon')
            pm.show()

            if self.DEBUG:
                self.log.add(
                    'The result from the benchmarking is in %s/benchmark'%\
                    self.outfolder)

            globals().update( locals() )
예제 #3
0
파일: analyse.py 프로젝트: graik/biskit
    else: 
        folders = d

                       
    T.flushPrint("Starting job...\n")

    for f in folders:
            a = A(outFolder=f)
            a.go()

    T.flushPrint("Done.\n")
    
    ## show result in PyMol
    if options.has_key('s'):
        p=Pymoler()
        p.addPdb( folders[0] + a.F_FINAL_PDB )
        p.add('color_b')
        p.add('select na, b<0')
        p.add('color grey, na')
        p.add('hide all')
        p.add('show cartoon')
        p.add('show stick')
        p.add('hide stick, name o+c+n')
        p.add('select ca, /////ca')
        p.add('label ca,"%s-%s"%(resn, resi)')
        p.add('select none')
        p.show()


        
예제 #4
0
def main(options):

    ##     ## get extra options from external file
    ##     if options.has_key('x'):
    ##         options.update( _parseExternalOptions( options['x'] ) )

    fname = options['i']  # input pdb file
    outPath = options['o']

    chainMask = options.get('cmask', None)
    if chainMask: chainMask = toIntList(chainMask)

    try:
        if options.has_key('h'):
            fheader = options['h']
        else:
            fheader = options['t'] + '/head.inp'
        if options.has_key('s'):
            fsegment = options['s']
        else:
            fsegment = options['t'] + '/segment.inp'
        if options.has_key('e'):
            ftail = options['e']
        else:
            ftail = options['t'] + '/end.inp'
    except:
        errWriteln(
            "You have to specify either all three template files or\n" +
            "(option -t) a folder that contains head.inp, segment.inp, end.inp.\n"
            +
            "If both -t and -h, -s, or -e are present, files specified with\n"
            + "-h, -s, -e are preferred.")

    ## check that input pdb file name (stripped of its path and extension)
    ## is at least 5 characters long and starts with a number
    ## Prompt user for renaming of the file.
    name = stripFilename(fname)

    ## the filename is OK, but it has the same name as used for the
    ## XPLOR output therefore we append _original to the input file
    if toInt(name[0]) == None or len(name) == 4:
        print "##### NOTE: ######"
        print "The pdb file name you gave is OK, but exactly"
        print "the same name will be used for the output from"
        print "the XPLOR script. Therefore '_original' will be"
        print "appended to the input pdb file you gave."
        base, ext = absfile(fname).split('.')
        new_fname = base + '_original.' + ext

        os.rename(fname, new_fname)
        fname = new_fname

    if toInt(name[0]) == None or len(name) < 4:
        print "##### WARNING: ######"
        print "The pdb file name you gave is either shorter "
        print "than 4 characters or it doesn't start with a number."
        print "This will cause the X-PLOR job to fail"
        msg = "Do you want to rename the file (Y/N)?"

        if upper(raw_input(msg)) == 'Y':
            new_name = upper(raw_input("Give a new filname:"))

            ## check that the new name is OK
            if toInt(new_name[0]) == None or len(new_name) < 4:
                raise StandardError, \
                      'You gave an incorrect new filename. Exiting'

            ## create link
            else:
                new_file = '%s/%s.%s' % (os.path.dirname(
                    absfile(fname)), new_name, fname.split('.')[-1])
                os.link(fname, new_file)
                print 'Link from %s to %s created sucessfully'\
                      %(absfile(fname), new_file)
                fname = new_file

    ## switch on Amber specialities ?
    amber = options.has_key('a')

    ## cap N- and C-term of chain breaks?
    capBreaks = options.has_key('cap')

    cleaner = ChainCleaner(
        ChainSeparator(fname,
                       outPath,
                       int(options['c']),
                       capBreaks=capBreaks,
                       chainMask=chainMask))

    # initialize with output path and base file name for generate.inp file
    xplorer = Xplor(outPath,
                    cleaner,
                    fheader,
                    fsegment,
                    ftail,
                    amber,
                    extras=options)

    xplorer.generateInp()

    ## run X-Plor
    if options.has_key('exe'):

        out, error, returncode = Executor(
            'xplor',
            strict=0,
            f_in=xplorer.cleaner.pdbname + "_generate.inp",
            f_out=xplorer.cleaner.pdbname + '_generate.log').run()
    ## Show structure in pymol
    if options.has_key('view'):

        pm = Pymoler()
        mname = pm.addPdb(xplorer.outname + '.pdb')
        pm.add('select xray-wat, segi 1XWW')
        pm.add('select added-wat, segi 1WWW')
        pm.add('select hydrogens, elem H')
        pm.add('hide everything, xray-wat OR added-wat OR hydrogens')
        pm.add('select none')

        colors = [hex2rgb(c, str) for c in hexColors(len(xplorer.chains))]

        i = 0
        for c in xplorer.chains:
            print colors[i], c.segment_id
            pm.add('set_color col_%i, %s' % (i, colors[i]))
            pm.add('color col_%i, segi %s and elem c' % (i, c.segment_id))
            i += 1

        pm.add('zoom all')
        pm.show()
예제 #5
0
## get filenames of all models
models = glob.glob('%s/modeller/%s*.pdb' %
                   (outFolder, tools.stripFilename(f_target)))

## create a Trajectory object with the models
traj = Trajectory(pdbs=models)

## fit the models against the average structure iteratively
traj.blockFit2ref()

## calculate and print rmsd matrix
rmsHeavy = traj.pairwiseRmsd()
print '\nHEAVY ATOM RMSD BETWEEN MODELS::'
__printMatrix(rmsHeavy)

## same thing for backbone atoms
BBMask = traj[0].maskBB()
traj.blockFit2ref(mask=BBMask)
rmsBB = traj.pairwiseRmsd(aMask=BBMask)
print '\nBACKBONE RMSD BETWEEN MODELS:'
__printMatrix(rmsBB)

if options.has_key('view'):

    ## show backbone superimposed structures in pymol
    pm = Pymoler()
    for t in traj:
        pm.addPdb(t)

    pm.show()
예제 #6
0
## get filenames of all models 
models = glob.glob( '%s/modeller/%s*.pdb'%(outFolder,
                                           tools.stripFilename(f_target)) )

## create a Trajectory object with the models
traj = Trajectory( pdbs=models )

## fit the models against the average structure iteratively
traj.blockFit2ref()

## calculate and print rmsd matrix
rmsHeavy = traj.pairwiseRmsd()
print '\nHEAVY ATOM RMSD BETWEEN MODELS::'
__printMatrix( rmsHeavy )

## same thing for backbone atoms
BBMask = traj[0].maskBB()
traj.blockFit2ref( mask = BBMask )
rmsBB = traj.pairwiseRmsd( aMask = BBMask  )
print '\nBACKBONE RMSD BETWEEN MODELS:'
__printMatrix( rmsBB )

if options.has_key('view'):
    
    ## show backbone superimposed structures in pymol
    pm = Pymoler( )
    for t in traj:
        pm.addPdb( t )

    pm.show()
예제 #7
0
파일: analyse.py 프로젝트: ostrokach/biskit
        d = [f]

    if options.has_key('d'):
        folders = T.toList(options['d'])
    else:
        folders = d

    T.flushPrint("Starting job...\n")

    for f in folders:
        a = A(outFolder=f)
        a.go()

    T.flushPrint("Done.\n")

    ## show result in PyMol
    if options.has_key('s'):
        p = Pymoler()
        p.addPdb(folders[0] + a.F_FINAL_PDB)
        p.add('color_b')
        p.add('select na, b<0')
        p.add('color grey, na')
        p.add('hide all')
        p.add('show cartoon')
        p.add('show stick')
        p.add('hide stick, name o+c+n')
        p.add('select ca, /////ca')
        p.add('label ca,"%s-%s"%(resn, resi)')
        p.add('select none')
        p.show()
예제 #8
0
파일: Complex.py 프로젝트: ostrokach/biskit
class Test(BT.BiskitTest):
    """Test case"""

    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 )
예제 #9
0
파일: pdb2xplor.py 프로젝트: graik/biskit
def main(options):

##     ## get extra options from external file
##     if options.has_key('x'):
##         options.update( _parseExternalOptions( options['x'] ) )

    fname = options['i']            # input pdb file
    outPath = options['o']

    chainMask = options.get('cmask', None)
    if chainMask: chainMask = toIntList(chainMask)

    try:
        if options.has_key('h'):
            fheader = options['h']
        else:
            fheader = options['t'] + '/head.inp'
        if options.has_key('s'):
            fsegment = options['s']
        else:
            fsegment = options['t'] + '/segment.inp'
        if options.has_key('e'):
            ftail = options['e']
        else:
            ftail = options['t'] + '/end.inp'
    except:
        errWriteln("You have to specify either all three template files or\n"+
                   "(option -t) a folder that contains head.inp, segment.inp, end.inp.\n" +
                   "If both -t and -h, -s, or -e are present, files specified with\n" +
                   "-h, -s, -e are preferred.")

    ## check that input pdb file name (stripped of its path and extension)
    ## is at least 5 characters long and starts with a number
    ## Prompt user for renaming of the file.
    name = stripFilename(fname)

    ## the filename is OK, but it has the same name as used for the
    ## XPLOR output therefore we append _original to the input file
    if toInt( name[0] )== None or len(name)==4 :
        print "##### NOTE: ######"
        print "The pdb file name you gave is OK, but exactly"
        print "the same name will be used for the output from"
        print "the XPLOR script. Therefore '_original' will be"
        print "appended to the input pdb file you gave."
        base, ext = absfile(fname).split('.')
        new_fname = base +'_original.' + ext

        os.rename( fname, new_fname )
        fname = new_fname

    if toInt( name[0] )== None or len(name)<4 :
        print "##### WARNING: ######"
        print "The pdb file name you gave is either shorter "
        print "than 4 characters or it doesn't start with a number."
        print "This will cause the X-PLOR job to fail"
        msg = "Do you want to rename the file (Y/N)?"

        if upper( raw_input( msg ) ) == 'Y':
            new_name = upper( raw_input( "Give a new filname:" ) )

            ## check that the new name is OK
            if toInt( new_name[0] )== None or len(new_name)<4 :
                raise StandardError, \
                      'You gave an incorrect new filename. Exiting'

            ## create link
            else:
                new_file = '%s/%s.%s'%(os.path.dirname(absfile(fname)),
                                       new_name,
                                       fname.split('.')[-1])
                os.link(fname, new_file)
                print 'Link from %s to %s created sucessfully'\
                      %(absfile(fname), new_file)
                fname = new_file

    ## switch on Amber specialities ?
    amber = options.has_key('a')

    ## cap N- and C-term of chain breaks?
    capBreaks = options.has_key('cap')

    cleaner = ChainCleaner(
        ChainSeparator(fname, outPath,
                       int(options['c']),
                       capBreaks=capBreaks,
                       chainMask=chainMask) )

    # initialize with output path and base file name for generate.inp file
    xplorer = Xplor(outPath, cleaner, fheader, fsegment, ftail, amber, extras=options )

    xplorer.generateInp()

    ## run X-Plor
    if options.has_key('exe'):

        out, error, returncode = Executor( 'xplor' , strict=0,
                                           f_in=xplorer.cleaner.pdbname + "_generate.inp",
                                           f_out=xplorer.cleaner.pdbname + '_generate.log').run()
    ## Show structure in pymol
    if options.has_key('view'):

        pm = Pymoler( )
        mname = pm.addPdb( xplorer.outname + '.pdb' )
        pm.add('select xray-wat, segi 1XWW')
        pm.add('select added-wat, segi 1WWW')
        pm.add('select hydrogens, elem H')
        pm.add('hide everything, xray-wat OR added-wat OR hydrogens')
        pm.add('select none')

        colors = [ hex2rgb(c, str) for c in hexColors( len(xplorer.chains) )]

        i=0
        for c in xplorer.chains:
            print colors[i], c.segment_id
            pm.add( 'set_color col_%i, %s'%( i, colors[i] ) )
            pm.add('color col_%i, segi %s and elem c'%( i, c.segment_id ) )
            i += 1

        pm.add('zoom all')
        pm.show()