Skip to content

Commit

Permalink
Use Modeller 10 class names
Browse files Browse the repository at this point in the history
  • Loading branch information
benmwebb committed Jan 26, 2021
1 parent d8d3088 commit 9893336
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 27 deletions.
6 changes: 3 additions & 3 deletions lib/cryptosite/am_bmi.py
Expand Up @@ -11,12 +11,12 @@ def get_sas(pdb, probe):
import modeller

# Read the PDB file
env = modeller.environ()
mdl = modeller.model(env)
env = modeller.Environ()
mdl = modeller.Model(env)
mdl.read(file=pdb)

# Calculate atomic accessibilities (in Biso) with appropriate probe_radius
myedat = modeller.energy_data()
myedat = modeller.EnergyData()
myedat.radii_factor = 1.6
mdl.write_data(edat=myedat, output='PSA ATOMIC_SOL',
psa_integration_step=0.05, probe_radius=probe)
Expand Down
4 changes: 2 additions & 2 deletions lib/cryptosite/analysis.py
Expand Up @@ -111,9 +111,9 @@ def get_qioft(landscape, rcut=11.):
"""Calculate Qi for all models in a landscape."""
import modeller
modeller.log.none()
e = modeller.environ()
e = modeller.Environ()
e.io.hetatm = False
m = modeller.model(e)
m = modeller.Model(e)

for dirname in _get_subdirectories(landscape):
with open(os.path.join(dirname, 'list')) as fh:
Expand Down
20 changes: 10 additions & 10 deletions lib/cryptosite/cleaning.py
Expand Up @@ -15,8 +15,8 @@ def get_pdb_seq(pdb, chain):
'''
import modeller

e = modeller.environ()
m = modeller.model(e, file=pdb,
e = modeller.Environ()
m = modeller.Model(e, file=pdb,
model_segment=('FIRST:' + chain, 'LAST:' + chain))
# BLAST will get confused if the PDB file contains non-standard ATOM
# records (e.g. HIE rather than HIS)
Expand Down Expand Up @@ -111,29 +111,29 @@ def build_model(pdb, chains):
and loop modeling for the rest.
'''
import modeller
from modeller.automodel import loopmodel, automodel, assess
from modeller.automodel import LoopModel, AutoModel, assess

# --- get gaps
gaps = get_gaps('alignment.pir')
with open('gaps_%s.txt' % pdb, 'w') as out:
out.write(pdb + '_mdl\t' + str(gaps))

# --- set up modeling
env = modeller.environ()
env = modeller.Environ()

env.io.atom_files_directory = ['.', '../atom_files']

class MyLoop(loopmodel):
class MyLoop(LoopModel):
def select_loop_atoms(self):
gaps = get_gaps('alignment.pir')
return modeller.selection(
return modeller.Selection(
self.residue_range(i.split(',')[0], i.split(',')[1])
for i in gaps)

def special_restraints(self, aln):
rsr = self.restraints
wholeSel = modeller.selection(self) - self.select_loop_atoms()
r = modeller.rigid_body(wholeSel)
wholeSel = modeller.Selection(self) - self.select_loop_atoms()
r = modeller.RigidBody(wholeSel)
rsr.rigid_bodies.append(r)

if len(gaps) > 0:
Expand Down Expand Up @@ -164,7 +164,7 @@ def special_restraints(self, aln):
os.system('rm %s_X.*' % (pdb.lower(),))

else:
a = automodel(env, alnfile='alignment.pir',
a = AutoModel(env, alnfile='alignment.pir',
knowns=pdb, sequence=pdb.lower() + '_X',
assess_methods=(assess.DOPE,))
a.very_fast()
Expand All @@ -176,6 +176,6 @@ def special_restraints(self, aln):
os.system('rm %s_X.*' % (pdb.lower(),))

if len(chains) == 1:
mdl = modeller.model(env, file='XXX_mdl')
mdl = modeller.Model(env, file='XXX_mdl')
mdl.rename_segments(segment_ids='A')
mdl.write(file='%s_mdl.pdb' % (pdb))
4 changes: 2 additions & 2 deletions lib/cryptosite/soap.py
Expand Up @@ -12,7 +12,7 @@ def soap_score():
from modeller.scripts import complete_pdb
from modeller import soap_protein_od

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

Expand All @@ -32,7 +32,7 @@ def soap_score():
# Read a model previously generated by Modeller's automodel class
mdl = complete_pdb(env, fil)
# Select all atoms
atmsel = modeller.selection(mdl)
atmsel = modeller.Selection(mdl)

# Assess with the above Scorer
try:
Expand Down
2 changes: 1 addition & 1 deletion test/mock/modeller/__init__.py
@@ -1,6 +1,6 @@
import sys


class environ(object):
class Environ(object):
def __init__(self):
sys.exit(0)
4 changes: 2 additions & 2 deletions test/test_analysis.py
Expand Up @@ -34,8 +34,8 @@ def test_bad(self):

def test_get_coordinates_sc(self):
"""Test get_coordinates_sc() function"""
e = modeller.environ()
m = modeller.model(e)
e = modeller.Environ()
m = modeller.Model(e)
coord = cryptosite.analysis.get_coordinates_sc(
m, os.path.join(TOPDIR, 'test', 'input', 'test_coord.pdb'))
self.assertEqual(len(coord), 4)
Expand Down
10 changes: 5 additions & 5 deletions test/test_cleaning.py
Expand Up @@ -36,8 +36,8 @@ def test_detect_invalid_residue_types_ok(self):
fname = os.path.join(tmpdir, 'test.pdb')
with open(fname, 'w') as fh:
fh.write(pdb_line + '\n')
e = modeller.environ()
m = modeller.model(e, file=fname)
e = modeller.Environ()
m = modeller.Model(e, file=fname)
cleaning._detect_invalid_residue_types(m)

def test_detect_invalid_residue_types_bad(self):
Expand All @@ -53,8 +53,8 @@ def test_detect_invalid_residue_types_bad(self):
ATOM 5 N HSD B 3 18.511 -1.416 15.632 1.00 6.84 C
ATOM 6 C HSD B 3 18.511 -1.416 15.632 1.00 6.84 C
""")
e = modeller.environ()
m = modeller.model(e, file=fname)
e = modeller.Environ()
m = modeller.Model(e, file=fname)
self.assertRaises(cleaning.InvalidResiduesError,
cleaning._detect_invalid_residue_types, m)

Expand Down Expand Up @@ -108,7 +108,7 @@ def mocked_loopmodel_make(self):
with open('input.pdb', 'w') as fh:
fh.write(pdb_line + '\n')
fh.write(pdb_line[:25] + '2' + pdb_line[26:] + '\n')
with utils.mocked_object(modeller.automodel.loopmodel, 'make',
with utils.mocked_object(modeller.automodel.LoopModel, 'make',
mocked_loopmodel_make):
cleaning.build_model('XXX', ['A'])
os.unlink('XXX_mdl.pdb')
Expand Down
4 changes: 2 additions & 2 deletions test/test_soap.py
Expand Up @@ -6,7 +6,7 @@
import modeller
import subprocess
from modeller import soap_protein_od
from modeller.terms import energy_term
from modeller.terms import EnergyTerm

TOPDIR = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
utils.set_search_paths(TOPDIR)
Expand All @@ -17,7 +17,7 @@
# the SOAP potentials installed (even if we do have them, they are slow to
# read in and use a lot of memory) and b) we can make sure any exceptions
# are handled properly by the soap script
class MockScorer(energy_term):
class MockScorer(EnergyTerm):
name = 'MockScorer'

def __init__(self):
Expand Down

0 comments on commit 9893336

Please sign in to comment.