コード例 #1
0
def setupMDL(env,name):
    from modeller.scripts import complete_pdb
    mdl = complete_pdb(env, name)
    mdl.patch_ss()
    name = name.split(".pdb")[0]+"m.pdb"
    mdl.write(file=name)
    return name,mdl
コード例 #2
0
def evaluate_single_model(pdb):
	env.libs.topology.read(file='$(LIB)/top_heav.lib') 
	env.libs.parameters.read(file='$(LIB)/par.lib') 
	mdl = complete_pdb(env, pdb)
	s = selection(mdl)   
	s.assess_dope(output='ENERGY_PROFILE NO_REPORT', 
					file='TvLDH.profile',
              normalize_profile=True, smoothing_window=15)
コード例 #3
0
ファイル: homology.py プロジェクト: LabBlouin/LabBlouinTools
def completePDB(pdbin,pdbout):
    '''
    Given a PDB, clean/complete the PDB using
    Modeller's complete_pdb function.
    '''
    # Squelch stdout.
    save_ = sys.stdout
    sys.stdout = cStringIO.StringIO()
    # Perform PDB completion.
    env = environ()
    env.libs.topology.read('${LIB}/top_heav.lib')
    env.libs.parameters.read('${LIB}/par.lib')    
    m = complete_pdb(env,pdbin)
    m.write(file=pdbout)
    # Reclaim stdout.
    sys.stdout = save_
コード例 #4
0
ファイル: soap.py プロジェクト: salilab/cryptosite
def soap_score():
    import modeller
    from modeller.scripts import complete_pdb
    from modeller import soap_protein_od

    env = modeller.environ()
    env.libs.topology.read(file='$(LIB)/top_heav.lib')
    env.libs.parameters.read(file='$(LIB)/par.lib')

    # Set up SOAP-Protein-OD scoring (we create the scorer once and keep it
    # around, since reading in the potential from disk can take a long time).
    sp = soap_protein_od.Scorer()

    out = open('SnapList.txt','w')

    cnt = 0
    files = [i for i in glob.glob('pm.pdb*.pdb')
             if 'pm.pdb.B10010002.pdb' not in i]
    for fil in files:

        try:
            cnt += 1
            # Read a model previously generated by Modeller's automodel class
            mdl = complete_pdb(env, fil)
            # Select all atoms
            atmsel = modeller.selection(mdl)

            # Assess with the above Scorer
            try:
                score = atmsel.assess(sp)
                out.write(fil+'\t'+str(score)+'\n')
            except modeller.ModellerError:
                print("The SOAP-Protein-OD library file is not included "
                      "with MODELLER.")
                print("Please get it from https://salilab.org/SOAP/.")
        # Was 'except: pass' but this will hide genuine errors. Replace with
        # a more specific list of exceptions (and test)
        except: raise

    out.close()
コード例 #5
0
ファイル: test_dope.py プロジェクト: aghozlane/pcm
def compute_profile(pdb_file, profile_file):
    """Compute the profile of each model
    """
    env = get_environment([pdb_file])
    # env and pdbfile
    pdb = complete_pdb(env, pdb_file)
    # all atom selection
    s = selection(pdb)
    # profile result
    normal_result = s.assess_dope()
    # output='ENERGY_PROFILE NO_REPORT',
    # normalize_profile=False
    # get_profile(profile_file)
    profile = s.get_dope_profile()
#     profile = s.get_dopehr_profile()
#     profile.write_to_file(profile_file)
#     val = []
#     with open(profile_file, "rt") as test:
#         for i in test:
# #             print(i.split())
#             val += [float(i.split()[1])]
#     for i in profile:
#         print(i)
    return [i.energy for i in profile], normal_result
コード例 #6
0
# This will enforce cis conformation for Pro-56.

# Make a model and stereochemical restraints:

from modeller import *
from modeller.scripts import complete_pdb, cispeptide

log.level(output=1, notes=1, warnings=1, errors=1, memory=0)
env = environ()
env.io.atom_files_directory = ['../atom_files']

env.libs.topology.read(file='$(LIB)/top_heav.lib')
env.libs.parameters.read(file='$(LIB)/par.lib')

code = '1fas'
mdl = complete_pdb(env, code)
rsr = mdl.restraints
atmsel = selection(mdl)
rsr.make(atmsel, restraint_type='stereo', spline_on_site=False)

# Change the Pro-56 restraint from trans to cis:
a = mdl.chains[0].atoms
cispeptide(rsr, atom_ids1=(a['O:56'], a['C:56'], a['N:57'], a['CA:57']),
                atom_ids2=(a['CA:56'], a['C:56'], a['N:57'], a['CA:57']))

# Constrain the distance between alpha carbons in residues 5 and 15 to
# be less than 10 angstroms:
rsr.add(forms.upper_bound(group=physical.xy_distance,
                          feature=features.distance(a['CA:5'], a['CA:15']),
                          mean=10., stdev=0.1))
コード例 #7
0
ファイル: optimization.py プロジェクト: mluciarr/McComplex
def Optimizemodel(pdb_file):
    """
	It creates a PDB file with the optimized model from the input pdb, 
	with its energies and restraint contributions. Also it will create pdbs on 
	every step of the Molecular Dynamics optimization. The energy is returned as
	the total value	of Modeller's objective function, molpdf. 
	It also shows the topt 10 contributors to the molpdf before and after optimization
	"""
    # Setting up
    env = environ()
    env.io.atom_files_directory = ['../atom_files']
    env.edat.dynamic_sphere = True

    env.libs.topology.read(file='$(LIB)/top_heav.lib')
    env.libs.parameters.read(file='$(LIB)/par.lib')

    code, ext = pdb_file.split('.')

    # Complete the pdb and make a model
    mdl = complete_pdb(env, pdb_file)
    mdl.write(file=code + '.ini')

    # Select all atoms from the model, make restraints and save them in a file
    atmsel = selection(mdl)
    mdl.restraints.make(atmsel, restraint_type='stereo', spline_on_site=False)
    mdl.restraints.write(file=code + '.rsr')

    # Check the energy before optimization and save it in a var
    initial_mpdf = atmsel.energy()

    # Create optimizer objects
    cg = conjugate_gradients(output='REPORT')
    md = molecular_dynamics(output='REPORT')

    # Open a file to get basic stats on each optimization
    stats_file = open(code + '_opt.stats', 'w')

    # Run MD. Write out a PDB structure every 10 steps during the run.
    # Write stats every 10 steps
    md.optimize(atmsel,
                temperature=300,
                max_iterations=50,
                actions=[
                    actions.write_structure(10, code + '.MD%04d.pdb'),
                    actions.trace(10, stats_file)
                ])

    # Run CG, and write stats every 5 steps
    cg.optimize(atmsel,
                max_iterations=50,
                actions=[actions.trace(5, stats_file)])

    # Final energy
    final_mpdf = atmsel.energy()

    # Assess DOPE
    atmsel.assess_dope(output='ENERGY_PROFILE NO_REPORT',
                       file='TvLDH.profile',
                       normalize_profile=True,
                       smoothing_window=15)

    # Print the energies and the contributions
    initial_cont_all = dict(initial_mpdf[1])
    top_init_conts = dict(
        sorted(initial_cont_all.items(), key=itemgetter(1), reverse=True)[:5])

    l.info("\n\nThe initial energy of " + code + " is " + str(initial_mpdf[0]))
    print("\n\nThe initial energy of " + code + " is " + str(initial_mpdf[0]))
    print("The top 10 initial contributions the restraints are:\n")
    for keys, values in top_init_conts.items():
        print(keys, ":", values)

    final_cont_all = dict(final_mpdf[1])
    top_final_conts = dict(
        sorted(final_cont_all.items(), key=itemgetter(1), reverse=True)[:5])

    l.info("\n\nThe final energy of " + code + " is " + str(final_mpdf[0]))
    print("\n\nThe final energy of " + code + " is " + str(final_mpdf[0]))
    print("Final contributions the restraints are:\n")
    for keys, values in top_final_conts.items():
        print(keys, ":", values)

    mdl.write(file=code + '_optimized.pdb')
コード例 #8
0
from modeller import *
from modeller.scripts import complete_pdb

log.verbose()  # request verbose output
env = environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib')  # read topology
env.libs.parameters.read(file='$(LIB)/par.lib')  # read parameters

# read model file
mdl = complete_pdb(env, 'Q9VYG2.B99990003.pdb')

# Assess with DOPE:
s = selection(mdl)  # all atom selection
s.assess_dope(output='ENERGY_PROFILE NO_REPORT',
              file='Q9VYG2.profile',
              normalize_profile=True,
              smoothing_window=15)
コード例 #9
0
ファイル: dope-rg.py プロジェクト: niefca/Corrine-s_codes
import os
from MDAnalysis import *
from MDAnalysis.analysis.align import *
import numpy
import numpy.linalg
from modeller import *
from modeller.scripts import complete_pdb


env = environ()
env.edat.radii_factor = 0.92
env.edat.dynamic_sphere= True
env.libs.topology.read('${LIB}/top_heav.lib')
env.libs.parameters.read('${LIB}/par.lib')	#load parameters
env.io.atom_files_directory = ['.', '${LIB}/atom_files/']
log.verbose()
table = open('analysis.txt', 'w')
for x in os.listdir('.'):
	if x.endswith('.pdb'):
		new_mod = complete_pdb(env, x)
		dope = new_mod.assess_normalized_dope()

		bcat = MDAnalysis.Universe(x)
		bcat_sel = bcat.selectAtoms('name CA or backbone')	
		bcat_RG = bcat_sel.radiusOfGyration()
		
		table.write(str(x)+'\t'+str(dope)+'\t'+str(bcat_RG)+'\n')
table.close()

コード例 #10
0
from modeller import *
from modeller.scripts import complete_pdb

log.verbose()    # request verbose output
env = environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib') # read topology
env.libs.parameters.read(file='$(LIB)/par.lib') # read parameters

# read model file
mdl = complete_pdb(env, 'lrrk2.B99990002.pdb')

# Assess with DOPE:
s = selection(mdl)   # all atom selection
s.assess_dope(output='ENERGY_PROFILE NO_REPORT', file='lrrk2.profile',
              normalize_profile=True, smoothing_window=15)
コード例 #11
0
def calc(version, configfile, atomfile, inputsequencefile, outputfile):
    #a list, where the helical residues should be
    #TODO read out configfile
    try:
        global log
        helixrange = []
        config = open(configfile, 'r')
        for line in config:
            line = line.strip()
            values = line.split(',')
            pdbname = values[0]
            proteinname = values[1]
            residuename = values[2]
            startlinker = values[3]
            endlinker   = values[4]
            if (len(values)-3)%2 == 0:
                for helixbase in range(3, len(values)-1, 2):
                    helixrange.append((int(values[helixbase]), int(values[helixbase+1])))
            else:
                log.error("calc", "wrong number of parameters in configfile")
                config.close()
                return -2
        config.close()
    except:
        log.error("calc", "reading config file")
        return -3

    try:
        modelsegments = ('FIRST:' + residuename,'LAST:' + residuename) #from where to where in the PDB, default is first to last aa
        aligncodespdb = pdbname + residuename
        alnfile = proteinname + "-" + aligncodespdb + ".ali"

        log.minimal()
        env = environ()

        env.libs.topology.read('${MODINSTALL9v14}/'+version+'/modlib/top_heav.lib')
        env.libs.parameters.read('${MODINSTALL9v14}/'+version+'/modlib/par.lib')
    except:
        log.error("calc", "unable to setup environment")
        return -4

    try:
        aln = alignment(env)
        mdl = model(env, file= atomfile, model_segment=modelsegments) #the PDB file

        aln.append_model(mdl, align_codes=aligncodespdb, atom_files=atomfile)
        aln.append(file=inputsequencefile, align_codes=proteinname) #in here the sequence has been.
        aln.align2d()

        aln.write(file=alnfile, alignment_format='PIR')
    except:
        log.error("calc", "unable to write alignment file")
        return -5

    class cycModel(dopehr_loopmodel):
        def special_patches(self, aln):
            # Link between last residue (-1) and first (0) to make chain cyclic:
            self.patch(residue_type="LINK",
                        residues=(self.residues[-1], self.residues[0]))
                        
                        
                        
    class RestraintsModel(cycModel):
        def special_restraints(self, aln):
            for helix in helixrange:
                self.restraints.add(secondary_structure.alpha(self.residue_range(str(helix[0]), str(helix[1]))))

    class MyLoop(RestraintsModel):
        def select_loop_atoms(self):
            return selection(self.residue_range(startlinker, endlinker))


    # Disable default NTER and CTER patching
    env.patch_default = False 

       
    try:
        a = MyLoop(env, alnfile=alnfile,
                      knowns=pdbname + residuename, sequence=proteinname,
                      loop_assess_methods=(assess.DOPE,
                                      assess.normalized_dope,
                                      assess.DOPEHR,
                                      assess.GA341))
        # generate 10 models
        a.starting_model = 1
        a.ending_model = 2


        a.library_schedule    = autosched.slow
        a.max_var_iterations  = 5000
        a.md_level            = refine.slow
        a.repeat_optimization = 5
        a.max_molpdf = 1e6
        a.final_malign3d = True
        
        # generate 10*5 loopmodels
        a.loop.starting_model = 1
        a.loop.ending_model   = 4

        a.loop.library_schedule    = autosched.slow
        a.loop.max_var_iterations  = 5000
        a.loop.md_level       = refine.slow
        a.loop.repeat_optimization = 5
        a.loop.max_molpdf = 1e6
        a.loop.final_malign3d = True
    except:
        log.error("calc", "setting up loopmodal")
        return -6

    try:
        a.make()
    except:
        log.error("calc", "making loopmodal")
        return -7

    try:
        ok_models = [x for x in a.outputs if x['failure'] is None]

        # Rank the models by Energy Score
        ok_models.sort(key=lambda a: a['DOPE-HR score'])

        # Get top model
        bestmodel = ok_models[0]

        print "BEGIN***************************************************************************"
        print str(bestmodel['DOPE-HR score']) + ";" + str(bestmodel['Normalized DOPE score'])
        print "END*****************************************************************************"


        refmodel = complete_pdb(env, bestmodel["name"])

        refmodel_atms = selection(refmodel)
        refmodel.restraints.unpick_all()
        refmodel.restraints.condense()
    except:
        log.error("calc", "setting up refmodal")
        return -8

    try:
        refmodel.restraints.make(refmodel_atms, restraint_type='STEREO', spline_on_site=False)
    except:
        log.error("calc", "making refmodal")
        return -9

    try:
        for helix in helixrange:
            refmodel.restraints.add(secondary_structure.alpha(refmodel.residue_range(str(helix[0]), str(helix[1]))))
        sel = selection(refmodel)
    except:
        log.error("calc", "adding helixranges to restraints")
        return -10

    try:
        thefile = open("cg_mod_out.dat", "w")
    except:
        log.error("calc", "opening file cg_mod_out.dat")
        return -11
    
    try:
        cg_mod = conjugate_gradients()
        cg_mod.optimize(refmodel, min_atom_shift=0.0001, max_iterations=10000, actions=[actions.trace(5,thefile)])
    except:
        log.error("calc", "cg_mod.optimize")
        return -12

    try:
        refmodel.write(file=outputfile)
    except:
        log.error("calc", "writing outputfile %s" % outputfile)
        return -13

    return 0
コード例 #12
0
from modeller import *
from modeller.scripts import complete_pdb

log.verbose()  # request verbose output
env = environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib')  # read topology
env.libs.parameters.read(file='$(LIB)/par.lib')  # read parameters

# read model file
mdl = complete_pdb(env, 'TvLDH.B99990004.pdb')

# Assess with DOPE:
s = selection(mdl)  # all atom selection
s.assess_dope(output='ENERGY_PROFILE NO_REPORT',
              file='TvLDH.profile',
              normalize_profile=True,
              smoothing_window=15)
コード例 #13
0
def model_protein(SEQ, tmplts):
    """
    align query sequence to sequence of template PDB structure
    """
    best_model = haspdb
    best_score = 0
    best_rmsd = 0
    best_seqid = 100

    for template in tmplts:
        PDB = template[0:5]

        identifier = SEQ + '_' + PDB
        seqfile = SEQ + '.pir'

        chain = PDB[-1]
        coords = PDB + '.pdb'

        model_dir = '../data/homology/' + SEQ + '_' + PDB
        if not os.path.exists(model_dir):
            os.makedirs(model_dir)
        shutil.copy2('../data/pdb/templates/' + coords, model_dir)
        os.chdir(model_dir)
        parse_pir(yeast_seqs[SEQ], seqfile)

        env = environ()
        aln = alignment(env)
        mdl = model(env,
                    file=PDB,
                    model_segment=('FIRST:' + chain, 'LAST:' + chain))

        aln.append_model(mdl, align_codes=PDB, atom_files=coords)
        aln.append(file=seqfile, align_codes=SEQ)
        aln.align2d()

        aln.write(identifier + '.ali', alignment_format='PIR')
        aln.write(identifier + '.pap', alignment_format='PAP')

        env = environ()
        a = automodel(env,
                      identifier + '.ali',
                      knowns=PDB,
                      sequence=SEQ,
                      assess_methods=(assess.DOPE, assess.GA341))
        a.starting_model = 1
        a.ending_model = 5
        a.make()

        homology_models = glob.glob(SEQ + '*.pdb')

        for homology_model in homology_models:
            env.libs.topology.read(file='$(LIB)/top_heav.lib')  # read topology
            env.libs.parameters.read(file='$(LIB)/par.lib')  # read parameters

            mdl = complete_pdb(env, homology_model)
            s = selection(mdl)

            score = s.assess_dope()

            rmsd, seqid = compute_rmds(homology_model, template)

            if score < best_score:
                best_score = np.copy(score)
                best_rmsd = np.copy(rmsd)
                best_seqid = np.copy(seqid)
                best_model = model_dir + '/' + homology_model

        os.chdir('../../../code/')

    return best_model, best_score, best_rmsd, best_seqid
コード例 #14
0
def refine_model(pdb, seqid):
    """
    refine and complete exisiting PDB
    """
    pdbcode = pdb.split('.')[0]
    coords = pdb + '.pdb'

    best_model = 'none'
    best_score = 0

    model_dir = '../data/homology/' + seqid + '_' + pdbcode
    if not os.path.exists(model_dir):
        os.makedirs(model_dir)
        shutil.copy2('../data/pdb/templates/' + coords, model_dir)
    os.chdir(model_dir)

    #write reference sequence to file
    parse_pir(yeast_seqs[seqid], seqid + '.seq')

    # Get the sequence of PDB file, and write to an alignment file
    e = environ()
    m = model(e, file=pdbcode)
    aln = alignment(e)
    aln.append_model(m, align_codes=pdbcode)
    aln.append(file=seqid + '.seq', align_codes=seqid)
    aln.salign()
    aln.write(file=seqid + '.ali')

    # check that there are actually gaps in PDB to model
    g = []
    for record in SeqIO.parse(seqid + '.ali', "pir"):
        g.append(record.seq.count('-'))

    # if PDB complete, no need to model
    if np.max(np.array(g)) < 1:
        best_model = model_dir + '/' + coords
        best_score = -100000

    else:
        # Load the automodel class
        log.verbose()
        env = environ()

        a = automodel(env,
                      seqid + '.ali',
                      knowns=pdbcode,
                      sequence=seqid,
                      assess_methods=(assess.DOPE, assess.GA341))
        a.starting_model = 1
        a.ending_model = 3
        a.make()

        refined_models = glob.glob(seqid + '*.pdb')

        for refined_model in refined_models:
            env.libs.topology.read(file='$(LIB)/top_heav.lib')  # read topology
            env.libs.parameters.read(file='$(LIB)/par.lib')  # read parameters

            mdl = complete_pdb(env, refined_model)
            s = selection(mdl)
            score = s.assess_dope()

            if score < best_score:
                best_score = np.copy(score)
                best_model = model_dir + '/' + refined_model

    os.chdir('../../../code/')

    return best_model, best_score
コード例 #15
0
ファイル: get_soap_score.py プロジェクト: piercelab/main
#!/usr/bin/env python                                                                                                              

import os, sys
from sys import argv

script, filename, start_pos, end_pos = argv
chainid = 'A'

from modeller import *
from modeller.scripts import complete_pdb
from modeller import soap_loop
#from modeller import soap_protein_od
env = environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib')
env.libs.parameters.read(file='$(LIB)/par.lib')
env.edat.contact_shell = -999
sp = soap_loop.Scorer()
#sp = soap_protein_od.Scorer()
mdl = complete_pdb(env, filename)
#atmsel = selection(mdl.chains[0])
atmsel = selection(mdl.residue_range(str(start_pos)+":"+chainid, str(end_pos)+":"+chainid))
score = atmsel.assess(sp)

print "GRGR", score, filename
コード例 #16
0
sp = soap_protein_od.Scorer()

# only calculate for single chains, because ga341 and dope only calculate first chains

models = [
    'model_dimer.pdb', 'model_locked_dimer.pdb', 'model_fragment_dimer.pdb'
]
templates = ['template_dimer_all.pdb', 'template_fragment_dimer_all.pdb']
files = models + templates

for f in files:
    if (not os.path.isfile(f)):
        continue
    print("; FILE " + f)
    # read model file
    mdl = complete_pdb(env, f)

    if mdl.seq_id < 0 or mdl.seq_id > 100:
        mdl.seq_id = 100

    # Assess all atoms with DOPE:
    #s = selection(mdl)
    #print("calling assess_ga341 mdl")
    #score_ga341 = mdl.assess_ga341()
    #print("; ENERGY assess_ga341 " + str(score_ga341))

    #print("calling assess_normalized_dope mdl")
    #score_normalized_dope = mdl.assess_normalized_dope()
    #print("; ENERGY assess_normalized_dope " + str(score_normalized_dope))

    for c in mdl.chains:
コード例 #17
0
# fornisce il modello migliore
m = ok_models[0]
print "Top model: %s (DOPE score %.3f)" % (m['name'], m[key])




from modeller.scripts import complete_pdb

env.libs.topology.read(file='$(LIB)/top_heav.lib') # read topology
env.libs.parameters.read(file='$(LIB)/par.lib') # read parameters

num_file = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10']

nome_file_input = 'snd0405.B999900%s.pdb'

nome_file_output = 'modello%s.profile'

for ciclo in num_file:
    mdl = complete_pdb(env, nome_file_input % ciclo) # read model file
    s = selection(mdl)   # all atom selection
    s.assess_dope(output='ENERGY_PROFILE NO_REPORT', file=nome_file_output % ciclo,
              normalize_profile=True, smoothing_window=15) # Assess with DOPE:

mdl = complete_pdb(env, '1CVS-c_149-359.pdb') # read model file
s = selection(mdl)   # all atom selection
s.assess_dope(output='ENERGY_PROFILE NO_REPORT', file='templato.profile',
              normalize_profile=True, smoothing_window=15) # Assess with DOPE:

コード例 #18
0
ファイル: AutoSub.py プロジェクト: williamdlees/AmberUtils
def main(argv):
    parser = argparse.ArgumentParser(description="Perform a substitution and find the best generated model of the chain, using Modeller")
    parser.add_argument('pdbfile', help='input file (PDB)')
    parser.add_argument('chain', help='chain')
    parser.add_argument('subs', help='substitutions (residue, number, ..)')
    parser.add_argument('overlap', help='number of overlap residues to remodel either side of substitutions')
    parser.add_argument('models', help='number of models to build')
    parser.add_argument('outfile', help='output file (PDB)')
    parser.add_argument('-l', '--loopmodels', help='run DOPE-HR loop model refinement, generating LOOPMODELS refined models')
    parser.add_argument('-r', '--restore_res', help='restore Amber residue names to PDB defaults before running Modeller', action='store_true')
    parser.add_argument('-v', '--verbose', help='verbose output', action='store_true')

    args = parser.parse_args()
    if len(args.chain) > 1:
        print 'Error: chain must be a single letter'
        quit()

    if args.loopmodels:
        loopmodels = int(args.loopmodels)
    else:
        loopmodels = 0
        
    subs = {}
    insertions = {}
    deletions = {}
    for sub in args.subs.split(','):
        try:
            orig_res = sub[0]
            rep_res = sub[-1:]

            def pdb_num(s):     # put residue number, insertion code into a standardised format
                res_num = s
                res_letter = ' '
                if not res_num[-1:].isdigit():
                    res_letter = res_num[-1:]
                    res_num = res_num[:-1]
                res_num = '%-4d%s' % (int(res_num), res_letter)
                return res_num

            if '.' not in sub:
                res_num = pdb_num(sub[1:-1])
                subs[res_num] = [orig_res, rep_res, -1, sub]
                if args.restore_res and rep_res == 'H':
                    print 'Warning: the histidine substitution in %s will require adjustment to reflect its protonation.' % sub
            elif orig_res == '-':
                (res_num, rep_res) = sub[1:].split('.')
                res_num = pdb_num(res_num)
                if res_num in insertions:
                    insertions[res_num][1] += rep_res
                else:
                    insertions[res_num] = [orig_res, rep_res, -1, sub]
                if 'H' in rep_res:
                    print 'Warning: the histidine insertion in %s will require adjustment to reflect its protonation.' % sub
            else:
                (res_num, rep_res) = sub[1:].split('.')
                res_num = pdb_num(res_num)
                if res_num in deletions:
                    deletions[res_num][1] += rep_res
                else:
                    deletions[res_num] = [orig_res, rep_res, -1, sub]
                if 'H' in rep_res:
                    print 'Warning: the histidine substitution in %s will require adjustment to reflect its protonation.' % sub
        except:
            print 'Format error in substitution %s' % sub
            quit()

    if args.restore_res:
        print 'Restoring standard residue names.'
        changes = {}
        changes['HIE'] = 'HIS'
        changes['HID'] = 'HIS'
        changes['HIP'] = 'HIS'
        changes['CYX'] = 'CYS'

    reported = ''
    index = -1
    prev_chain = ''
    prev_res = ''
    sub_seq = ''
    with open(args.pdbfile, "r") as f, open('restored.pdb', "w") as of:
        for line in f:
            if len(line) > 26 and line[:6] == 'ATOM  ':
                resnum = '%-4d%s' % (int(line[22:26]), line[26])
                resname = line[17:20]
                chain = line[21]
                
                if chain != prev_chain and chain == args.chain:
                    index = 0
                    prev_chain = chain
                
                if args.restore_res and resname in changes:
                    line = line.replace(resname, changes[resname])
                    if reported != resnum + chain:
                        print '%s %s %s -> %s' % (resnum, chain, resname, changes[resname])
                        reported = resnum + chain
                                        
                if chain == args.chain and resnum != prev_res:
                    index += 1                  # first residue has index 1
                    prev_res = resnum
                    if resnum in subs and subs[resnum][2] < 0:
                        if res_codes[resname] != subs[resnum][0]:
                            print 'Error: original residue %s does not match substitution code %s' % (resname, subs[resnum][3])
                            quit()
                        else:
                            sub_seq += subs[resnum][1]
                            subs[resnum][2] = index
                    else:
                        sub_seq += res_codes[resname]

                    if resnum in insertions:
                        insertions[resnum][2] = index
                    elif resnum in deletions:
                        deletions[resnum][2] = index
                        if res_codes[resname] != deletions[resnum][0]:
                            print 'Error: original residue %s does not match substitution code %s' % (resname, deletions[resnum][3])
                            quit()

            of.write(line)
        
    error = False
    lowest_sub = 9999
    highest_sub = 0
    for s in(subs, insertions, deletions):
        for k, sub in s.iteritems():
            if sub[2] < 0:
                print 'Residue %s:%s (required for substitution %s) was not found in the PDB file' % (args.chain, k, sub[3])
                error = True
            else:
                lowest_sub = min(lowest_sub, sub[2])
                highest_sub = max(highest_sub, sub[2])

    if error:
        quit()

    e = environ()
    e.libs.topology.read(file='$(LIB)/top_heav.lib')
    e.libs.parameters.read(file='$(LIB)/par.lib')
    m = complete_pdb(e, 'restored.pdb')
    
    # If we don't save and re-read the model, the residue numbering does not get saved properly in the alignment file.
    
    m.write('completed.pdb')
    m = model(e, file=args.pdbfile, model_segment=('FIRST:' + args.chain, 'LAST:' + args.chain))
    aln = alignment(e)
    aln.append_model(m, align_codes='restored.pdb')
    aln.append_sequence(sub_seq)
    aln[1].code = 'sub'
    aln.write(file='alignment.ali')

    # Before we read things back in, fix up the alignment file for any insertions or deletions
    if len(insertions) > 0 or len(deletions) > 0:
        al_seqs = get_sequences('alignment.ali')

        if len(deletions) > 0:
            l = list(al_seqs[1])
            for k,d in deletions.iteritems():
                for i in range(len(d[1])):
                    l[d[2]-1+i] = d[1][i]
            al_seqs[1] = "".join(l)

        if len(insertions) > 0:
            # Sort the insertions so that we start with the highest index - that way the indeces
            # stay valid as the sequence length increases
            sorted(insertions, key=lambda k: k[2])

            # Insert the specified residue at the specified position in the sequence, return the updated sequence
            def insert_seq(s, r, p):
                seq = s[:p] + r + s[p:]
                return seq

            if len(al_seqs) != 2:
                print 'Internal error: wrong number of sequences in alignment.ali'
                quit()

            for k,ins in insertions.iteritems():
                al_seqs[0] = insert_seq(al_seqs[0], '-'*len(ins[1]), ins[2])
                al_seqs[1] = insert_seq(al_seqs[1], ins[1], ins[2])

        rep_sequences('alignment.ali', al_seqs)

    startpos = max(lowest_sub - int(args.overlap), 0)
    endpos = highest_sub + int(args.overlap)
    
    if args.verbose:
        log.verbose()
    else:
        log.minimal()
    
    class MyModel(automodel):
        def select_atoms(self):
            s = selection(self.residue_range(startpos, min(endpos, len(self.residues) - 1)))
            return s

    class MyLoopModel(dopehr_loopmodel):
        def select_atoms(self):
            s = selection(self.residue_range(startpos, min(endpos, len(self.residues) - 1)))
            return s

    if loopmodels > 0:
        a = MyLoopModel(e, alnfile='alignment.ali', knowns='restored.pdb', sequence='sub')
        a.md_level = None
        a.loop.starting_model = 1
        a.loop.ending_model = loopmodels
    else:
        a = MyModel(e, alnfile='alignment.ali', knowns='restored.pdb', sequence='sub')

    a.starting_model = 1
    a.ending_model = int(args.models)
    
    a.make()
    
    bestmolpdf = 999999
    bestpdfname = ''
    outputs = a.outputs if loopmodels == 0 else a.loop.outputs
    for output in outputs:
        if output['failure'] is None:
            if output['molpdf'] < bestmolpdf:
                bestmolpdf = output['molpdf']
                bestpdfname = output['name']
    
    if bestpdfname == '':
        print 'Error in modelling run: no modelled files produced.'
        quit()
    
    print 'Best modelled file is %s: objective function value %f' % (bestpdfname, bestmolpdf)
    copyfile(bestpdfname, args.outfile)
コード例 #19
0
from modeller import *
from modeller.scripts import complete_pdb

log.verbose()  # request verbose output
env = environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib')  # read topology
env.libs.parameters.read(file='$(LIB)/par.lib')  # read parameters

# read model file
mdl = complete_pdb(env, 'WTGFP.B99990005.pdb')

# Assess with DOPE:
s = selection(mdl)  # all atom selection
s.assess_dope(output='ENERGY_PROFILE NO_REPORT',
              file='WTGFP.profile',
              normalize_profile=True,
              smoothing_window=15)
コード例 #20
0
import matplotlib.pyplot as plt
from modeller import *
from modeller.scripts import complete_pdb

template_pdb_id = '2a31'
pdb_lyst = (template_pdb_id, 'TMPRSS2_254.B99990001', 'TMPRSS2_254.B99990002',
            'TMPRSS2_254.B99990003')

log.verbose()  # request verbose output
env = environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib')  # read topology
env.libs.parameters.read(file='$(LIB)/par.lib')  # read parameters

for fileName in pdb_lyst:
    # read model file
    mdl = complete_pdb(env, fileName + '.pdb')
    # Assess with DOPE:
    s = selection(mdl)  # all atom selection
    s.assess_dope(output='ENERGY_PROFILE NO_REPORT',
                  file=fileName + '.profile',
                  normalize_profile=True,
                  smoothing_window=15)


def r_enumerate(seq):
    """Enumerate a sequence in reverse order"""
    # Note that we don't use reversed() since Python 2.3 doesn't have it
    num = len(seq) - 1
    while num >= 0:
        yield num, seq[num]
        num -= 1
コード例 #21
0
     ## NON-BONDED ENERGY TERMS

     #soft sphere potential
     env.edat.dynamic_sphere=False #turn off the soft-sphere
     #lennard-jones potential (more accurate)
     env.edat.dynamic_lennard=True
     env.edat.contact_shell = 4.0
     env.edat.update_dynamic = 0.39

     env.io.atom_files_directory = work_dir

     env.libs.parameters.read(file='$(LIB)/par.lib')
     env.libs.topology.read(file='$(LIB)/top_heav.lib')

     mdl1= complete_pdb(env, './' + model_name + str(i) +'.pdb')
     mdl=complete_pdb(env, './' + receptor + '.pdb')
     print(mdl1.residues[0])

     ## DIHEDRAL ANGLES PREDICTED BY USE OF KNOWN TEMPLATE STRUCTURE (PREPARE ALIGNMENT FILE)
     ali = alignment(env)
     ali.append(file = alig,align_codes = 'all')
     modelname = model_name + str(i) + '.pdb'
     ali.append_model(mdl1, atom_files = modelname, align_codes = modelname)
     ## copy
     ali.append_model(mdl1, align_codes = modelname)


        ## DIHEDRAL ANGLE RESTRAINTS (USE HOMOLOGS AND DIHEDRAL LIBRARY)
     mdl1.env.edat.nonbonded_sel_atoms = 1  # selected region "feels" the rest of system through the non-bonded terms
     sched = autosched.loop.make_for_model(mdl1)
コード例 #22
0
ファイル: energy.py プロジェクト: bjornwallner/proq2-server
env = environ()
env.io.atom_files_directory = ['../atom_files']
env.libs.topology.read(file='$(LIB)/top_heav.lib')
env.libs.parameters.read(file='$(LIB)/par.lib')

def patch_disulfides(mdl):
    # Must patch disulfides here to calculate the non-bonded
    # energy properly. Also, when you use hydrogens, disulfides
    # must always be patched so that sulfhydril hydrogens are
    # removed from the model.
    for ids in [ ('17', '39'),
                 ( '3', '22'),
                 ('53', '59'),
                 ('41', '52') ]:
        mdl.patch(residue_type='DISU', residues=[mdl.residues[r] for r in ids])

mdl = complete_pdb(env, "1fas", patch_disulfides)

# Select all atoms
atmsel = selection(mdl)

mdl.restraints.make(atmsel, restraint_type='stereo', spline_on_site=False)

# Actually calculate the energy
(molpdf, terms) = atmsel.energy(edat=energy_data(dynamic_sphere=True))

# molpdf is the total 'energy', and terms contains the contributions from
# each physical type. Here we print out the bond length contribution:
print "Bond energy is %.3f" % terms[physical.bond]
コード例 #23
0
def main(argv):
    parser = argparse.ArgumentParser(description="Perform a substitution and find the best generated model of the chain, using Modeller")
    parser.add_argument('pdbfile', help='input file (PDB)')
    parser.add_argument('chain', help='chain')
    parser.add_argument('subs', help='substitutions (residue, number, ..)')
    parser.add_argument('overlap', help='number of overlap residues to remodel either side of substitutions')
    parser.add_argument('models', help='number of models to build')
    parser.add_argument('outfile', help='output file (PDB)')
    parser.add_argument('-r', '--restore_res', help='restore Amber residue names to PDB defaults before running Modeller', action='store_true')
    parser.add_argument('-v', '--verbose', help='verbose output', action='store_true')

    args = parser.parse_args()
    if len(args.chain) > 1:
        print 'Error: chain must be a single letter'
        quit()
        
    subs = {}
    for sub in args.subs.split(','):
        try:
            orig_res = sub[0]
            rep_res = sub[-1:]
            res_num = sub[1:-1]
            res_letter = ' '
            if not res_num[-1:].isdigit():
                res_letter = res_num[-1:]
                res_num = res_num[:-1]
            res_num = '%-4d%s' % (int(res_num), res_letter)
            subs[res_num] = [orig_res, rep_res, -1, sub]
            if args.restore_res and rep_res == 'H':
                print 'Warning: the histidine substitution in %s will require adjustment to reflect its protonation.' % sub
        except:
            print 'Format error in substitution %s' % sub
            quit()

    if args.restore_res:
        print 'Restoring standard residue names.'
        changes = {}
        changes['HIE'] = 'HIS'
        changes['HID'] = 'HIS'
        changes['HIP'] = 'HIS'
        changes['CYX'] = 'CYS'

    reported = ''
    index = -1
    prev_chain = ''
    prev_res = ''
    sub_seq = ''
    with open(args.pdbfile, "r") as f, open('restored.pdb', "w") as of:
        for line in f:
            if len(line) > 26 and line[:6] == 'ATOM  ':
                resnum = '%-4d%s' % (int(line[22:26]), line[26])
                resname = line[17:20]
                chain = line[21]
                
                if chain != prev_chain and chain == args.chain:
                    index = 0
                    prev_chain = chain
                
                if args.restore_res and resname in changes:
                    line = line.replace(resname, changes[resname])
                    if reported != resnum + chain:
                        print '%s %s %s -> %s' % (resnum, chain, resname, changes[resname])
                        reported = resnum + chain
                                        
                if chain == args.chain and resnum != prev_res:
                    index += 1
                    prev_res = resnum
                    if resnum in subs and subs[resnum][2] < 0:
                        if res_codes[resname] != subs[resnum][0]:
                            print 'Error: original residue %s does not match substitution code %s' % (resname, subs[resnum][3])
                            sub_seq += res_codes[resname]
                        else:
                            sub_seq += subs[resnum][1]
                            subs[resnum][2] = index
                    else:
                        sub_seq += res_codes[resname]

            of.write(line)
        
    error = False
    lowest_sub = 9999
    highest_sub = 0
    for k, sub in subs.iteritems():
        if sub[2] < 0:
            print 'Residue %s:%s (required for substitution %s) was not found in the PDB file' % (args.chain, k, sub[3])
            error = True
        else:
            lowest_sub = min(lowest_sub, sub[2])
            highest_sub = max(highest_sub, sub[2])

    if error:
        quit()

    e = environ()
    e.libs.topology.read(file='$(LIB)/top_heav.lib')
    e.libs.parameters.read(file='$(LIB)/par.lib')
    m = complete_pdb(e, 'restored.pdb')
    
    # If we don't save and re-read the model, the residue numbering does not get saved properly in the alignment file.
    
    m.write('completed.pdb')
    m = model(e, file=args.pdbfile, model_segment=('FIRST:' + args.chain, 'LAST:' + args.chain))
    aln = alignment(e)
    aln.append_model(m, align_codes='restored.pdb')
    aln.append_sequence(sub_seq)
    aln[1].code = 'sub'
    aln.write(file='alignment.ali')

    startpos = max(lowest_sub - int(args.overlap), 0)
    endpos = highest_sub + int(args.overlap)
    
    if args.verbose:
        log.verbose()
    else:
        log.minimal()
    
    class MyModel(automodel):
        def select_atoms(self):
            s = selection(self.residue_range(startpos, min(endpos, len(self.residues) - 1)))
            return s

    a = MyModel(e, alnfile='alignment.ali', knowns='restored.pdb', sequence='sub')
    a.starting_model = 1
    a.ending_model = int(args.models)
    
    a.make()
    
    bestmolpdf = 999999
    bestpdfname = ''
    for output in a.outputs:
        if output['failure'] is None:
            if output['molpdf'] < bestmolpdf:
                bestmolpdf = output['molpdf']
                bestpdfname = output['name']
    
    if bestpdfname == '':
        print 'Error in modelling run: no modelled files produced.'
        quit()
    
    print 'Best modelled file is %s: objective function value %f' % (bestpdfname, bestmolpdf)
    copyfile(bestpdfname, args.outfile)
コード例 #24
0
"""
Produces a per-residue energy evaluation of the model(s).
"""

from __future__ import print_function
import argparse
import os
import sys

ap = argparse.ArgumentParser(description=__doc__)
ap.add_argument('pdb_f', nargs='+',
                help='PDB file names')

cmd = ap.parse_args()

from modeller import *
from modeller.scripts import complete_pdb

env = environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib') # read topology
env.libs.parameters.read(file='$(LIB)/par.lib') # read parameters

for pdb in cmd.pdb_f:
    # read model file
    mdl = complete_pdb(env, pdb)

    # Assess with DOPE:
    s = selection(mdl)   # all atom selection
    s.assess_dope(output='ENERGY_PROFILE NO_REPORT', file=pdb[:-4]+'.dope_profile',
                  normalize_profile=True, smoothing_window=15)
コード例 #25
0
from modeller import *
from modeller.scripts import complete_pdb

log.verbose()    # request verbose output
env = environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib') # read topology
env.libs.parameters.read(file='$(LIB)/par.lib') # read parameters

# read model file
mdl = complete_pdb(env, 'sequence.B99990001.pdb')

# Assess with DOPE:
s = selection(mdl)   # all atom selection
s.assess_dope(output='ENERGY_PROFILE NO_REPORT', file='TvLDH.profile',
              normalize_profile=True, smoothing_window=15)
コード例 #26
0
from modeller import *
from modeller.scripts import complete_pdb
import sys

#programa para gerar o valor de ga341 e dope a partir de arquivos.pdb gerados pela modelagem

arqpdb = sys.argv[1]

env = environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib')
env.libs.parameters.read(file='$(LIB)/par.lib')

# Read a model previously generated by Modeller's automodel class
mdl = complete_pdb(env, arqpdb)

# Set template-model sequence identity. (Not needed in this case, since
# this is written by Modeller into the .pdb file.)
mdl.seq_id = 37.037

score = mdl.assess_ga341()

env = environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib')
env.libs.parameters.read(file='$(LIB)/par.lib')

# Read a model previously generated by Modeller's automodel class
mdl = complete_pdb(env, arqpdb)

zscore = mdl.assess_normalized_dope()
コード例 #27
0
# This script illustrates the use of the swap_atoms_in_res
# argument to the selection.superpose() command:

# Need to make sure that the topologies of the two molecules
# superposed are exactly the same:

from modeller import *
from modeller.scripts import complete_pdb

env = environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib')
env.libs.parameters.read(file='$(LIB)/par.lib')

atfil = '../atom_files/pdb1fdn.ent'
mdl = complete_pdb(env, atfil)
aln = alignment(env)
aln.append_model(mdl, align_codes='orig')

mdl2 = model(env, file='1fdn.swap.atm')
aln.append_model(mdl2, align_codes='swap')
atmsel = selection(mdl)
atmsel.superpose(mdl2, aln, swap_atoms_in_res='')
atmsel.superpose(mdl2, aln, swap_atoms_in_res='DEFHLNQRVY', fit=False)
atmsel.superpose(mdl2, aln, swap_atoms_in_res='', fit=True)
コード例 #28
0
ファイル: chains.py プロジェクト: bjornwallner/proq2-server
# Example for 'chain' objects

from modeller import *
from modeller.scripts import complete_pdb

env = environ()
env.io.atom_files_directory = ['../atom_files']
env.libs.topology.read(file='$(LIB)/top_heav.lib')
env.libs.parameters.read(file='$(LIB)/par.lib')

mdl = complete_pdb(env, "1b3q")

# Print existing chain IDs and lengths:
print "Chain IDs and lengths: ", [(c.name, len(c.residues))
                                  for c in mdl.chains]

# Set new chain IDs:
mdl.chains['A'].name = 'X'
mdl.chains['B'].name = 'Y'

# Write out chain sequences:
for c in mdl.chains:
    c.write(file='1b3q%s.chn' % c.name,
            atom_file='1b3q',
            align_code='1b3q%s' % c.name)
コード例 #29
0
# best to create 'sp' just once and keep it around, since reading in the
# potential from disk can take a long time).
sp = soap_protein_od.Scorer()

# only calculate for single chains, because ga341 and dope only calculate first chains

models = ['model_dimer.pdb', 'model_locked_dimer.pdb', 'model_fragment_dimer.pdb']
templates = ['template_dimer_all.pdb', 'template_fragment_dimer_all.pdb']
files = models + templates

for f in files:
    if (not os.path.isfile(f)):
        continue
    print("; FILE " + f)
    # read model file
    mdl = complete_pdb(env, f)
    
    if mdl.seq_id < 0 or mdl.seq_id > 100:
        mdl.seq_id = 100
        
    # Assess all atoms with DOPE:
    #s = selection(mdl)
    #print("calling assess_ga341 mdl")
    #score_ga341 = mdl.assess_ga341()
    #print("; ENERGY assess_ga341 " + str(score_ga341))
    
    #print("calling assess_normalized_dope mdl")
    #score_normalized_dope = mdl.assess_normalized_dope()
    #print("; ENERGY assess_normalized_dope " + str(score_normalized_dope))
    
    for c in mdl.chains:
コード例 #30
0
def main(argv):

    #Get Inputs
    if (len(argv) < 2):
        print(
            "Error! DOPE.py requires 2 arguments: <Output_File> , <IDs_File>")
        sys.exit(2)

    #Get the Results File Name
    try:
        input_file = os.environ.get(
            'TOOLHOME') + "/Results/Step_" + argv[1] + ".txt"
        output_file = os.environ.get('TOOLHOME') + "/Results/" + argv[0]

    except TypeError:
        print("TOOLHOME Environment not Set. Are you running Main.py?")
        sys.exit(2)

    #Get IDs & Models Folder Locations
    try:
        ids = open(input_file).read().split()
        models_folder = ids[0]
        ids = ids[1:]

    except:
        print("Specified <IDs_File> could not be located or is invalid")
        sys.exit(2)

    #Setup DOPE Environment
    try:
        #Setup Log
        log.level(output=0, notes=0, warnings=0, errors=1, memory=0)

        #Setup Environment
        env = environ()
        env.libs.topology.read(file='$(LIB)/top_heav.lib')
        env.libs.parameters.read(file='$(LIB)/par.lib')

    except:
        print("Could not setup DOPE environment")
        sys.exit(2)

    #Open Output File
    output = open(output_file, "w+")
    output.write(models_folder + "\n")

    #Save Previous Working Directory
    previious_dir = os.getcwd()

    #Change Current Working Directory
    os.chdir(os.path.dirname(__file__))

    #Display Progress
    print("Extracting DOPE from \"" + "Step_" + argv[1] + ".txt\"")

    #Iterate IDs
    for id_num in ids:

        #Get Model File
        model_file = models_folder + "ID_" + id_num + ".pdb"

        # Read a model previously generated by Modeller's automodel class
        mdl = complete_pdb(env, model_file)

        # Select all atoms in the first chain
        atmsel = selection(mdl.chains[0])

        #Calculate Dope Score
        score = atmsel.assess_dope()

        # Write Results
        output.write(id_num + "\t" + str(score) + "\n")

    # Finally...
    output.close

    #Return to Previous Working Directory
    os.chdir(previious_dir)
コード例 #31
0
# Example for: selection.rotate_dihedrals()

from modeller import *
from modeller.scripts import complete_pdb

# This will optimize and randomize dihedrals in a MODEL
env = environ()
env.io.atom_files_directory = ['../atom_files']
env.libs.topology.read(file='$(LIB)/top_heav.lib')
env.libs.parameters.read(file='$(LIB)/par.lib')

# Select dihedral angle types for optimization and randomization:
dih = 'phi psi omega chi1 chi2 chi3 chi4 chi5'

# Read the sequence, get its topology and coordinates:
mdl = complete_pdb(env, '1fas')

# Select all atoms
atmsel = selection(mdl)

atmsel.rotate_dihedrals(change='RANDOMIZE', deviation=90.0, dihedrals=dih)
mdl.write(file='1fas.ini1')

# Get restraints from somewhere and optimize dihedrals:
mdl.restraints.make(atmsel, restraint_type='stereo', spline_on_site=False)
atmsel.rotate_dihedrals(change='OPTIMIZE', deviation=90.0, dihedrals=dih)
mdl.write(file='1fas.ini2')
コード例 #32
0
def modeller_funcs(pdb_file, options):
    """
    This functions optimizes a protein structure saved in a pdb file.
    It optimizes the stereochemistry of the given model including non-bonded contacts.
    :param pdb_file: pdb file with the structure we want to optimize.
    :return: returns a pdb file with optimized structure.
    """

    env = environ()
    env.io.atom_files_directory = ['../atom_files']
    env.edat.dynamic_sphere = True

    env.libs.topology.read(file='$(LIB)/top_heav.lib')
    env.libs.parameters.read(file='$(LIB)/par.lib')

    path, ext = pdb_file.split('.')
    dir, code = path.split('/')

    mdl = complete_pdb(env, pdb_file)
    # mdl.write(file=code + '.ini')

    # Select all atoms:
    atmsel = selection(mdl)

    # Calculate initial energy and energy profile for the built structure
    mpdf_ini = atmsel.energy()
    z_score_ini = mdl.assess_normalized_dope()
    mdl_ep_ini = atmsel.get_dope_profile()
    mdl_ep_ini_smoothed = mdl_ep_ini.get_smoothed(window=50)
    energy_profile_txt_path = dir + '/' + code + '_DOPE_EnergyProfile.txt'
    mdl_ep_ini_smoothed.write_to_file(energy_profile_txt_path)
    print("\nModel energy")
    print("The unoptimized model energy of " + code + " is: " + str(mpdf_ini[0]))
    print("\nZ-score")
    print("The unoptimized Z-score of " + code + " is: " + str(z_score_ini))

    if options.optimize is None:
        energy_profile_plot(options, path, energy_profile_txt_path)

    else:
        # Create optimizer objects and set defaults for all further optimizations
        cg = conjugate_gradients(output='NO_REPORT')

        # Open a file to get basic stats on each optimization
        trcfil = open(dir + '/optimization_stats_' + code + '.txt', 'w')

        # Run CG on the all-atom selection; write stats every 5 steps
        cg.optimize(atmsel, max_iterations=20, actions=actions.trace(5, trcfil))

        # Finish off with some more CG, and write stats every 5 steps
        cg.optimize(atmsel, max_iterations=20,
                    actions=[actions.trace(5, trcfil)])

        mpdf = atmsel.energy()
        # Calculate the normalized Z-score for the model after optimization
        z_score = mdl.assess_normalized_dope()
        print("\nModel energy")
        print("The final energy of " + code + " is: " + str(mpdf[0]))
        print("\nZ-score")
        print("The final z-score of " + code + " is: " + str(z_score))

        # Getting the energy profile of our optimized model
        mdl_ep_fin = atmsel.get_dope_profile()

        # Smooth the energy profile by applying a smoothing window of 50
        mdl_ep_fin_smoothed = mdl_ep_fin.get_smoothed(window=50)
        energy_profile_txt_path_opt = path + '_optimized_DOPE_EnergyProfile.txt'
        mdl_ep_fin_smoothed.write_to_file(energy_profile_txt_path_opt)
        mdl.write(file=path + '_optimized.pdb')
        energy_profile_plot(options, path, energy_profile_txt_path, energy_profile_txt_path_opt)
コード例 #33
0
from modeller import *
from modeller.scripts import complete_pdb
from modeller.optimizers import molecular_dynamics, conjugate_gradients
from modeller.automodel import autosched
log.none()

env = environ()
env.libs.topology.read('${LIB}/top_heav.lib')
env.libs.parameters.read('${LIB}/par.lib')
env.edat.dynamic_sphere=False
env.edat.dynamic_lennard=True
env.edat.contact_shell = 4.0
env.edat.update_dynamic = 0.39

m = complete_pdb(env, inputs.pdbfile)

wildtype_dope_score = m.assess_normalized_dope()

headerline = str('Protein,DOPE Score\n')
wildtype_score = str('WT,') + str(wildtype_dope_score) + str('\n')

dopefile = open(dirname+'/DOPE_scores.txt',"w")
line = dopefile.write(str(headerline))
line = dopefile.write(str(wildtype_score))
dopefile.close()

m.write(file=dirname+'/'+PDB_FILE.replace('.pdb','_receptor.pdb'))

f = open(dirname+'/'+PDB_FILE.replace('.pdb','_receptor.pdb'))
lines = f.readlines()
コード例 #34
0
from modeller import *
from modeller.scripts import complete_pdb

log.verbose()    # request verbose output
env = environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib') # read topology
env.libs.parameters.read(file='$(LIB)/par.lib') # read parameters

# read model file
mdl = complete_pdb(env, '1qg8_fill.BL00230001.pdb')

# Assess all atoms with DOPE:
s = selection(mdl)
s.assess_dope(output='ENERGY_PROFILE NO_REPORT', file='model23.profile',
              normalize_profile=True, smoothing_window=15)
コード例 #35
0
from modeller import *
from modeller.scripts import complete_pdb

log.verbose()  # request verbose output
env = environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib')  # read topology
env.libs.parameters.read(file='$(LIB)/par.lib')  # read parameters

# directories for input atom files
env.io.atom_files_directory = './:../atom_files'

# read model file
mdl = complete_pdb(env, 'qseq1_2.BL00090001.pdb')

s = selection(mdl)
s.assess_dope(output='ENERGY_PROFILE NO_REPORT',
              file='qseq1_2.profile',
              normalize_profile=True,
              smoothing_window=15)
              knowns='1iok', sequence='P0A6F5',
              assess_methods=assess.DOPE)
a.starting_model = 1
a.ending_model = 10
a.make()

# Get a list of all successfully built models from a.outputs

ok_models = filter(lambda x: x['failure'] is None, a.outputs)

#truncated the models, as residues 524-548 were not covered by the template
truncated_models_fn=[]
full_model_norm_dope_scores=[]
for ok_model in ok_models:
    mdl_fn=ok_model['name']
    mdl = complete_pdb(env, mdl_fn)
    full_model_norm_dope_scores.append(mdl.assess_normalized_dope())
    sel=selection(mdl.residue_range(1,524))
    truncated_fn=mdl_fn.split(".pdb")[0]+".truncated.pdb"
    sel.write(truncated_fn)
    truncated_models_fn.append(truncated_fn)

norm_dope_scores=[]
fitting_scores=[]
# score models by normalized dope
for mdl_fn in truncated_models_fn:
    # Read a model previously generated by Modeller's automodel class
    mdl = complete_pdb(env, mdl_fn)
    norm_dope_scores.append(mdl.assess_normalized_dope())

# score models by em
コード例 #37
0
    a.starting_model = 1
    a.ending_model = 5
    a.make()

    ###################################################################################################
    #										Evaluate_Model.py
    print(
        "###################################################################################################"
    )
    print("#																Evaluate_Model.py")
    print(
        "###################################################################################################"
    )

    from modeller import *
    from modeller.scripts import complete_pdb

    #log.verbose()    # request verbose output
    #env = environ()
    env.libs.topology.read(file='$(LIB)/top_heav.lib')  # read topology
    env.libs.parameters.read(file='$(LIB)/par.lib')  # read parameters

    # read model file
    mdl = complete_pdb(env, selected_PDB + '.B99990002.pdb')

    # Assess with DOPE:
    s = selection(mdl)  # all atom selection
    s.assess_dope(output='ENERGY_PROFILE NO_REPORT',
                  file=selected_PDB + '.profile',
                  normalize_profile=True,
                  smoothing_window=15)
コード例 #38
0
from modeller import *
from modeller.scripts import complete_pdb

log.verbose()  # request verbose output
env = Environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib')  # read topology
env.libs.parameters.read(file='$(LIB)/par.lib')  # read parameters

# directories for input atom files
env.io.atom_files_directory = './:../atom_files'

# read model file
mdl = complete_pdb(env, '1bdm.pdb', model_segment=('FIRST:A', 'LAST:A'))

s = Selection(mdl)
s.assess_dope(output='ENERGY_PROFILE NO_REPORT',
              file='1bdmA.profile',
              normalize_profile=True,
              smoothing_window=15)
コード例 #39
0
from modeller import *
from modeller.scripts import complete_pdb

log.verbose()    # request verbose output
env = environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib') # read topology
env.libs.parameters.read(file='$(LIB)/par.lib') # read parameters

# directories for input atom files
env.io.atom_files_directory = './:../atom_files'

# read model file
mdl = complete_pdb(env, 'template1.pdb', model_segment=('FIRST:A', 'LAST:A'))

s = selection(mdl)
s.assess_dope(output='ENERGY_PROFILE NO_REPORT', file='template1.profile',
              normalize_profile=True, smoothing_window=15)
コード例 #40
0
ファイル: attach-ctd.py プロジェクト: niefca/Corrine-s_codes
if not os.path.isdir('models/'):
   os.makedirs('models/')

env = environ()
env.edat.radii_factor = 0.95	# if having clashing problems increase this number at risk of bad angles
env.edat.dynamic_sphere= True
env.libs.topology.read('${LIB}/top_heav.lib')
env.libs.parameters.read('${LIB}/par.lib')		#load parameters
env.io.atom_files_directory = ['.', '${LIB}/atom_files/']
log.none()

x = 0 # a counter that will be used for naming the models later

for mod in os.listdir(ctd_loc):
    if mod.endswith(".pdb"):
       	mdl_n = complete_pdb(env, ctd_loc+mod)	
	mdl_n.write(file='CTD.pdb')		# write a temporary pdb file to be used for modelling and aligment
	
	mdl_ori = model(env)
	aln_ori = alignment(env)
	mdl_ori.build_sequence(BCAT_seq)
	aln_ori.append_sequence(BCAT_seq)	# original model with sequence of beta-catenin
	aln_ori[0].code = 'BCAT'
	aln_ori.write(file='alignments/BCAT.ali') 

	aln_final = alignment(env, file='alignments/BCAT.ali')
	mdl_arm = model(env)
	mdl_arm.read(file= known_mod)
	aln_final.append_model(mdl_arm, align_codes=known_mod, atom_files=known_mod)
	aln_final.salign(
		  gap_function=False,
コード例 #41
0
from modeller import *
from modeller.scripts import complete_pdb

log.verbose()    # request verbose output
env = environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib') # read topology
env.libs.parameters.read(file='$(LIB)/par.lib') # read parameters

# read model file
mdl = complete_pdb(env, '6eqe.pdb')

# Assess with DOPE:
s = selection(mdl)   # all atom selection
s.assess_dope(output='ENERGY_PROFILE NO_REPORT', file='templateDOPE.txt',
              normalize_profile=True, smoothing_window=15)
コード例 #42
0
from modeller import *
from modeller.scripts import complete_pdb

log.verbose()
env = environ()
env.libs.topology.read(file="$(LIB)/top_heav.lib")
env.libs.parameters.read(file="$(LIB)/par.lib")
aln = alignment(env)
mdl = model(env, file="1bdm", model_segment=("FIRST:A", "LAST:A"))
aln.append_model(mdl, align_codes="1bdmA", atom_files="1bdm.pdb")
for code in (("TvLDH.BL00080001"), ("TvLDH.B99990001")):
    mdl = complete_pdb(env, code)
    aln.append_model(mdl, atom_files=code, align_codes=code)
aln.align2d()
aln.write(file="TvLDH.BL00080001-1bdmA.ali", alignment_format="PIR")
コード例 #43
0
from modeller import *
from modeller.scripts import complete_pdb

log.verbose()  # request verbose output
env = environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib')  # read topology
env.libs.parameters.read(file='$(LIB)/par.lib')  # read parameters

# read model file
mdl = complete_pdb(env, 'qseq1.B99990005.pdb')

# Assess with DOPE:
s = selection(mdl)  # all atom selection
s.assess_dope(output='ENERGY_PROFILE NO_REPORT',
              file='qseq1.profile',
              normalize_profile=True,
              smoothing_window=15)
コード例 #44
0
from modeller import *
from modeller.scripts import complete_pdb
from modeller.optimizers import conjugate_gradients

env = environ()

env.io.atom_files_directory = ['../atom_files']
log.verbose()
env.libs.topology.read(file='$(LIB)/top_heav.lib')
env.libs.parameters.read(file='$(LIB)/par.lib')

# Read in the model
mdl = complete_pdb(env, "1fdn")
rsr = mdl.restraints

# Select all C-alpha atoms
allat = selection(mdl)
allca = allat.only_atom_types('CA')

# Create a pseudo atom that is the center of all C-alphas, and activate it
center = pseudo_atom.gravity_center(allca)
rsr.pseudo_atoms.append(center)

# Constrain every C-alpha to be no more than 10 angstroms from the center
for at in allca:
    r = forms.upper_bound(group=physical.xy_distance,
                          feature=features.distance(at, center),
                          mean=10.0,
                          stdev=0.1)
    rsr.add(r)
コード例 #45
0
# Example for: model.assess_ga341()

from modeller import *
from modeller.scripts import complete_pdb

env = environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib')
env.libs.parameters.read(file='$(LIB)/par.lib')

# Read a model previously generated by Modeller's automodel class
mdl = complete_pdb(env, '../atom_files/1fdx.B99990001.pdb')

# Set template-model sequence identity. (Not needed in this case, since
# this is written by Modeller into the .pdb file.)
mdl.seq_id = 37.037

score = mdl.assess_ga341()
コード例 #46
0
from modeller import *
from modeller.scripts import complete_pdb

log.verbose()    # request verbose output
env = environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib') # read topology
env.libs.parameters.read(file='$(LIB)/par.lib') # read parameters

# directories for input atom files
env.io.atom_files_directory = './:../atom_files'

# read model file
mdl = complete_pdb(env, '1bdm.pdb', model_segment=('FIRST:A', 'LAST:A'))

s = selection(mdl)
s.assess_dope(output='ENERGY_PROFILE NO_REPORT', file='1bdmA.profile',
              normalize_profile=True, smoothing_window=15)
コード例 #47
0
def analyze_seq(description, seq):
    """Simple 'analysis' of a sequence of residues, from a model or alignment"""
    numcys = 0
    for res in seq:
        if res.pdb_name == 'CYS':
            numcys += 1
    print "%s contains %d residues, of which %d are CYS" \
          % (description, len(seq), numcys)


env = environ()
env.io.atom_files_directory = ['../atom_files']
env.libs.topology.read(file='$(LIB)/top_heav.lib')
env.libs.parameters.read(file='$(LIB)/par.lib')

mdl = complete_pdb(env, "1fas")

# 'mdl.residues' is a list of all residues in the model
print "1-letter code of 1st residue: ", mdl.residues[0].code
print "PDB name of residue '10': ", mdl.residues['10:'].pdb_name

# Get the first aligned sequence from a file
aln = alignment(env, file='../commands/toxin.ali')
firstseq = aln[0]

# Analyze all residues in the model, a subset, and all residues in the
# alignment sequence
analyze_seq("Model 1fas", mdl.residues)
analyze_seq("First 10 residues of 1fas", mdl.residue_range('1:', '10:'))
analyze_seq("Aligned sequence %s" % firstseq.code, firstseq.residues)
コード例 #48
0
ファイル: evaluate_model.py プロジェクト: bh0085/projects
from modeller import *
from modeller.scripts import complete_pdb

log.verbose()    # request verbose output
env = environ()
env.libs.topology.read(file='$(LIB)/top_heav.lib') # read topology
env.libs.parameters.read(file='$(LIB)/par.lib') # read parameters

# read model file
mdl = complete_pdb(env, 'TvLDH.B99990002.pdb')

# Assess with DOPE:
s = selection(mdl)   # all atom selection
s.assess_dope(output='ENERGY_PROFILE NO_REPORT', file='TvLDH.profile',
              normalize_profile=True, smoothing_window=15)
コード例 #49
0
		           gap_penalties_2d=(0.35, 1.2, 0.9, 1.2, 0.6, 8.6, 1.2, 0., 0.),
		           similarity_flag=True)

		aln.write(file=protein_name+'-mult.ali', alignment_format='PIR')
		aln.write(file=protein_name+'-mult.pap', alignment_format='PAP')

		#model_mult.py
		env = environ()
		a = automodel(env, alnfile=protein_name+'-mult.ali',
		              knowns=(next_best_name), sequence=protein_name)
		a.starting_model = 1
		a.ending_model = 5
		a.make()

		#evaluate_model.py
		log.verbose()    # request verbose output
		env = environ()
		env.libs.topology.read(file='$(LIB)/top_heav.lib') # read topology
		env.libs.parameters.read(file='$(LIB)/par.lib') # read parameters

		# read model file
		mdl = complete_pdb(env, protein_name+'.B99990001.pdb')

		# Assess all atoms with DOPE:
		s = selection(mdl)
		s.assess_dope(output='ENERGY_PROFILE NO_REPORT', file=protein_name+'.profile',
		              normalize_profile=True, smoothing_window=15)
	elif inact_struc != protein_name:
		continue
	else: continue