Skip to content

Commit

Permalink
docs added and bug fix for matthews_coef function in mr_util
Browse files Browse the repository at this point in the history
  • Loading branch information
Felix Simkovic committed May 5, 2017
1 parent 291f656 commit c848a2b
Show file tree
Hide file tree
Showing 18 changed files with 129 additions and 58 deletions.
13 changes: 13 additions & 0 deletions docs/api/command_line.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Command line subpackage
=======================

.. automodule:: simbad.command_line
:members:
:undoc-members:
:show-inheritance:

.. toctree::
:glob:

generated/simbad.command_line.*

1 change: 1 addition & 0 deletions docs/api/generated/simbad.command_line.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ Submodules
.. toctree::

simbad.command_line.simbad_contaminant
simbad.command_line.simbad_create_lattice_db
simbad.command_line.simbad_lattice
simbad.command_line.simbad_main

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
simbad.command_line.simbad_create_lattice_db module
===================================================

.. automodule:: simbad.command_line.simbad_create_lattice_db
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/api/generated/simbad.parsers.molrep_parser.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
simbad.parsers.molrep_parser module
===================================

.. automodule:: simbad.parsers.molrep_parser
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/api/generated/simbad.parsers.phaser_parser.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
simbad.parsers.phaser_parser module
===================================

.. automodule:: simbad.parsers.phaser_parser
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/api/generated/simbad.parsers.refmac_parser.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
simbad.parsers.refmac_parser module
===================================

.. automodule:: simbad.parsers.refmac_parser
:members:
:undoc-members:
:show-inheritance:
4 changes: 3 additions & 1 deletion docs/api/generated/simbad.parsers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,7 @@ Submodules

.. toctree::

simbad.parsers.database_parser
simbad.parsers.molrep_parser
simbad.parsers.phaser_parser
simbad.parsers.refmac_parser

2 changes: 1 addition & 1 deletion docs/api/generated/simbad.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,5 @@ Submodules
.. toctree::

simbad.constants
simbad.main
simbad.version

7 changes: 7 additions & 0 deletions docs/api/generated/simbad.util.molrep_util.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
simbad.util.molrep_util module
==============================

.. automodule:: simbad.util.molrep_util
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/api/generated/simbad.util.phaser_util.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
simbad.util.phaser_util module
==============================

.. automodule:: simbad.util.phaser_util
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/api/generated/simbad.util.pyrvapi_results.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
simbad.util.pyrvapi_results module
==================================

.. automodule:: simbad.util.pyrvapi_results
:members:
:undoc-members:
:show-inheritance:
7 changes: 7 additions & 0 deletions docs/api/generated/simbad.util.refmac_util.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
simbad.util.refmac_util module
==============================

.. automodule:: simbad.util.refmac_util
:members:
:undoc-members:
:show-inheritance:
9 changes: 4 additions & 5 deletions docs/api/generated/simbad.util.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ Submodules
.. toctree::

simbad.util.anomalous_util
simbad.util.argparse_util
simbad.util.clusterize
simbad.util.config_util
simbad.util.exit_util
simbad.util.logging_util
simbad.util.molrep_util
simbad.util.mr_util
simbad.util.mtz_util
simbad.util.options_processor
simbad.util.phaser_util
simbad.util.pyrvapi_results
simbad.util.refmac_util
simbad.util.simbad_util
simbad.util.version
simbad.util.worker
simbad.util.workers_util

7 changes: 7 additions & 0 deletions docs/api/generated/simbad.version.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
simbad.version module
=====================

.. automodule:: simbad.version
:members:
:undoc-members:
:show-inheritance:
38 changes: 1 addition & 37 deletions simbad/rotsearch/amore_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@ def matthews_coef(self, model, cell_parameters, space_group, min_solvent_content
"""

# Get the molecular weight of the input model
molecular_weight = self.rwcontents(model)
molecular_weight = simbad_util.molecular_weight(model)

cmd = ["matthews_coef"]
key = """CELL {0}
Expand Down Expand Up @@ -498,42 +498,6 @@ def rotfun(self, logs_dir, shres, intrad, pklim, npic, rotastep):
logfile = os.path.join(self.work_dir, logs_dir, '{0}.log'.format(self.name))
simbad_util.run_job(cmd, logfile=logfile, stdin=key)

def rwcontents(self, model):
"""Function to run ``rwcontents`` to get the molecular weight of a model
Parameters
----------
model : str
Path to input model
Returns
-------
float
Molecular weight of input model
"""

cmd = ['rwcontents',
'xyzin', model]

logfile = 'rwcontents_{0}.log'.format(self.name)
simbad_util.run_job(cmd, logfile=logfile)

# Exctract molecular weight from log file
molecular_weight = None
with open(logfile, 'r') as f:
for line in f:
if line.startswith(" Molecular Weight of protein"):
molecular_weight = float(line.split()[-1])
if not molecular_weight:
msg = "Cannot find Molecular weight in logfile {0}".format(logfile)
logger.debug(msg)
raise RuntimeError(msg)

# Clean up
os.remove(logfile)

return molecular_weight

def sortfun(self):
"""A function to prepare files for amore rotation function
Expand Down
22 changes: 10 additions & 12 deletions simbad/util/mr_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,14 +335,13 @@ def get_mtz_info(self, mtz):
The predicted solvent content of the protein
"""
# Extract crystal data from input mtz
self._cell_parameters, self._resolution, self._space_group = mtz_util.crystal_data(mtz)
self._space_group, _, self._cell_parameters = mtz_util.crystal_data(mtz)

# Extract column labels from input mtz
self._f, self._sigf, self._dano, self._sigdano, self._free = mtz_util.get_labels(mtz)

# Get solvent content
self._solvent = self.matthews_coef(self._cell_parameters, self._space_group)
return

def multiprocessing(self, results, time_out=60, nproc=2):
"""Code to run MR and refinement in parallel
Expand Down Expand Up @@ -511,26 +510,25 @@ def matthews_coef(self, cell_parameters, space_group):
solvent content of the protein
"""

cmd = ["matthews_coef"]
key = """CELL {0}
symm {1}
auto""".format(cell_parameters,
space_group)
symm {1}
auto""".format(cell_parameters,
space_group)

logfile = 'matt_coef.log'
ret = simbad_util.run_job(cmd, logfile=logfile, stdin=key)
if ret != 0:
msg = "matthews_coef exited with non-zero return code. Log is {0}".format(logfile)
if ret and ret != 0:
msg = "matthews_coef exited with non-zero return code ({0}). Log is {1}".format(ret, logfile)
logger.critical(msg)
raise RuntimeError(msg)

# Determine if the model can fit in the unit cell
solvent_content = 0.5
with open(logfile, 'r') as f:
for line in f:
if line.startswith(' 1'):
solvent_content = (float(line.split()[2]) / 100)
for line in open(logfile, 'r'):
if line.startswith(' 1'):
solvent_content = (float(line.split()[2]) / 100)
break

os.remove(logfile)
return solvent_content
Expand Down
2 changes: 0 additions & 2 deletions simbad/util/mtz_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@
logger.setLevel(logging.DEBUG)




# TODO: Get rid of this function completely
def set_crystal_data(optd):
"""Set crystallographic parameters from mtz file"""
Expand Down
33 changes: 33 additions & 0 deletions simbad/util/simbad_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,39 @@ def run_job(cmd, logfile=None, directory=None, stdin=None):
return p.returncode


def molecular_weight(self, model):
"""Function to run ``rwcontents`` to get the molecular weight of a model
Parameters
----------
model : str
Path to input model
Returns
-------
float
Molecular weight of input model
"""
cmd = ['rwcontents', 'xyzin', model]
logfile = 'rwcontents_{0}.log'.format(self.name)
run_job(cmd, logfile=logfile)

# Exctract molecular weight from log file
molecular_weight = None
with open(logfile, 'r') as f:
for line in f:
if line.startswith(" Molecular Weight of protein"):
molecular_weight = float(line.split()[-1])
if not molecular_weight:
msg = "Cannot find Molecular weight in logfile {0}".format(logfile)
logger.debug(msg)
raise RuntimeError(msg)

os.remove(logfile)
return molecular_weight


def tmp_file_name(delete=True, directory=None, suffix=""):
"""Return a filename for a temporary file
Expand Down

0 comments on commit c848a2b

Please sign in to comment.