Skip to content

Commit 8e33476

Browse files
committed
Update to be consistent with vmd-python interface
1 parent ce68936 commit 8e33476

File tree

18 files changed

+54
-230
lines changed

18 files changed

+54
-230
lines changed

Dabble/builder.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,17 +27,7 @@
2727
import os
2828
import tempfile
2929

30-
try:
31-
# Pylint hates vmd
32-
# pylint: disable=import-error, unused-import
33-
import vmd
34-
import molecule
35-
import trans
36-
from atomsel import atomsel
37-
# pylint: enable=import-error, unused-import
38-
except ImportError:
39-
from vmd import atomsel, molecule, trans
40-
atomsel = atomsel.atomsel
30+
from vmd import atomsel, molecule, trans
4131

4232
from Dabble import fileutils
4333
from Dabble import molutils

Dabble/fileutils.py

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,7 @@
2424
import os
2525
import tempfile
2626

27-
try:
28-
# pylint: disable=import-error, unused-import
29-
import vmd
30-
import molecule
31-
from atomsel import atomsel
32-
# pylint: enable=import-error, unused-import
33-
except ImportError:
34-
from vmd import molecule, atomsel
35-
atomsel = atomsel.atomsel
36-
27+
from vmd import molecule, atomsel
3728
from Dabble.param import AmberWriter, CharmmWriter
3829

3930
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
@@ -244,14 +235,14 @@ def write_final_system(out_fmt, out_name, molid, **kwargs):
244235

245236
temp_mol = molecule.load('mae', mae_name)
246237
write_psf_name = mae_name.replace('.mae', '')
247-
writer = AmberWriter(molid=temp_mol,
248-
tmp_dir=kwargs['tmp_dir'],
249-
forcefield=kwargs['forcefield'],
250-
lipid_sel=kwargs.get('lipid_sel'),
251-
hmr=kwargs.get('hmassrepartition'),
252-
extra_topos=tops,
253-
extra_params=pars)
254-
writer.write(write_psf_name)
238+
writeit = AmberWriter(molid=temp_mol,
239+
tmp_dir=kwargs['tmp_dir'],
240+
forcefield=kwargs['forcefield'],
241+
lipid_sel=kwargs.get('lipid_sel'),
242+
hmr=kwargs.get('hmassrepartition'),
243+
extra_topos=tops,
244+
extra_params=pars)
245+
writeit.write(write_psf_name)
255246

256247
return out_name
257248

@@ -335,7 +326,8 @@ def check_out_type(value, forcefield, hmr=False):
335326
out_fmt = 'dms'
336327
elif ext == 'psf' and "charmm" in forcefield:
337328
out_fmt = 'charmm'
338-
elif ext == 'prmtop' and forcefield in ["amber","charmm","charmm36","charmm36m"]:
329+
elif ext == 'prmtop' and forcefield in ["amber", "charmm",
330+
"charmm36", "charmm36m"]:
339331
out_fmt = 'amber'
340332
else:
341333
raise ValueError("%s is an unsupported format with %s forcefield"

Dabble/molutils.py

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,10 @@
2121
"""
2222

2323
from __future__ import print_function
24-
import numpy as np
2524
import os
2625
import tempfile
27-
28-
try:
29-
# pylint: disable=import-error, unused-import
30-
import vmd
31-
import molecule
32-
from atomsel import atomsel
33-
# pylint: enable=import-error
34-
except ImportError:
35-
from vmd import molecule, atomsel
36-
atomsel = atomsel.atomsel
26+
import numpy as np
27+
from vmd import molecule, atomsel
3728

3829
from Dabble import fileutils
3930
# pylint: disable=no-member
@@ -595,4 +586,3 @@ def num_lipids_remaining(molid, lipid_sel):
595586
return np.unique(atomsel_remaining(molid, lipid_sel).get('fragment')).size
596587

597588
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
598-

Dabble/param/amber.py

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,16 +30,7 @@
3030
import warnings
3131
from subprocess import check_output
3232
from pkg_resources import resource_filename
33-
34-
try:
35-
# pylint: disable=import-error, unused-import
36-
import vmd
37-
import molecule
38-
from atomsel import atomsel
39-
# pylint: enable=import-error, unused-import
40-
except ImportError:
41-
from vmd import molecule, atomsel
42-
atomsel = atomsel.atomsel
33+
from vmd import molecule, atomsel
4334

4435
from networkx.drawing.nx_pydot import write_dot
4536
from parmed.tools import chamber, parmout, HMassRepartition, checkValidity

Dabble/param/ambermatcher.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,7 @@
3030
from networkx.algorithms import isomorphism
3131
from networkx.drawing.nx_pydot import write_dot
3232
from pkg_resources import resource_filename
33-
34-
try:
35-
# pylint: disable=import-error, unused-import
36-
import vmd
37-
from atomsel import atomsel
38-
# pylint: enable=import-error, unused-import
39-
except ImportError:
40-
from vmd import atomsel
41-
atomsel = atomsel.atomsel
33+
from vmd import atomsel
4234

4335
from . import MoleculeMatcher
4436
logger = logging.getLogger(__name__) # pylint: disable=invalid-name

Dabble/param/charmm.py

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,7 @@
2626
import os
2727
import tempfile
2828
from pkg_resources import resource_filename
29-
30-
try:
31-
# pylint: disable=import-error, unused-import
32-
import vmd
33-
import molecule
34-
from atomsel import atomsel
35-
from VMD import evaltcl
36-
# pylint: enable=import-error, unused-import
37-
except ImportError:
38-
from vmd import atomsel, evaltcl, molecule
39-
atomsel = atomsel.atomsel
29+
from vmd import atomsel, evaltcl, molecule
4030

4131
from Dabble.param import CharmmMatcher
4232

@@ -81,8 +71,7 @@ class CharmmWriter(object):
8171

8272
#==========================================================================
8373

84-
def __init__(self, tmp_dir, molid, lipid_sel="lipid", extra_topos=None,
85-
override_defaults=False):
74+
def __init__(self, tmp_dir, molid, lipid_sel="lipid", **kwargs):
8675

8776
# Create TCL temp file and directory
8877
self.tmp_dir = tmp_dir
@@ -93,7 +82,7 @@ def __init__(self, tmp_dir, molid, lipid_sel="lipid", extra_topos=None,
9382
self.molid = molid
9483
self.psf_name = ""
9584
# Default parameter sets
96-
if override_defaults:
85+
if kwargs.get("override_defaults", False):
9786
self.topologies = []
9887
else:
9988
self.topologies = [
@@ -112,8 +101,8 @@ def __init__(self, tmp_dir, molid, lipid_sel="lipid", extra_topos=None,
112101
os.path.join("charmm_parameters",
113102
top))
114103

115-
if extra_topos:
116-
self.topologies.extend(extra_topos)
104+
if kwargs.get("extra_topos"):
105+
self.topologies.extend(kwargs.get("extra_topos"))
117106

118107
# Initialize graph matcher with topologies we know about
119108
self.matcher = CharmmMatcher(self.topologies)

Dabble/param/charmmmatcher.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,7 @@
2727
import networkx as nx
2828
from networkx.drawing.nx_pydot import write_dot
2929
from networkx.algorithms import isomorphism
30-
31-
try:
32-
# pylint: disable=import-error, unused-import
33-
import vmd
34-
from atomsel import atomsel
35-
# pylint: enable=import-error, unused-import
36-
except ImportError:
37-
from vmd import atomsel
38-
atomsel = atomsel.atomsel
30+
from vmd import atomsel
3931

4032
from . import MoleculeMatcher
4133
logger = logging.getLogger(__name__) # pylint: disable=invalid-name

Dabble/param/moleculematcher.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,7 @@
2929

3030
import networkx as nx
3131
from networkx.algorithms import isomorphism
32-
try:
33-
# pylint: disable=import-error, unused-import
34-
import vmd
35-
from atomsel import atomsel
36-
# pylint: enable=import-error, unused-import
37-
except ImportError:
38-
from vmd import atomsel
39-
atomsel = atomsel.atomsel
32+
from vmd import atomsel
4033

4134
logger = logging.getLogger(__name__) # pylint: disable=invalid-name
4235

convert_step5_to_dabble.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,9 @@
66

77
from __future__ import print_function
88
import os
9-
try:
10-
import vmd
11-
import molecule
12-
from atomsel import atomsel
13-
except ModuleNotFoundError:
14-
from vmd import atomsel, molecule
15-
atomsel = atomsel.atomsel
16-
17-
thedir = os.path.abspath(raw_input("Which directory contains step5_assembly.{psf,crd}? > "))
9+
from vmd import atomsel, molecule
10+
11+
thedir = os.path.abspath(input("Which directory contains step5_assembly.{psf,crd}? > "))
1812
if not os.path.isdir(thedir):
1913
raise ValueError("%s not a valid directory" % thedir)
2014

get_restraint_mask.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,7 @@
2323
2424
"""
2525
from __future__ import print_function
26-
try:
27-
import vmd, molecule
28-
from atomsel import atomsel
29-
except ImportError:
30-
from vmd import atomsel, molecule
31-
atomsel = atomsel.atomsel
26+
from vmd import atomsel, molecule
3227

3328
import itertools
3429
import readline

0 commit comments

Comments
 (0)