Skip to content

Commit

Permalink
Merge pull request #106 from rigdenlab/anode
Browse files Browse the repository at this point in the history
Anode update
  • Loading branch information
hlasimpk committed Jul 12, 2019
2 parents 1718d94 + 0a884f1 commit 90a3a66
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 29 deletions.
7 changes: 5 additions & 2 deletions simbad/mr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -369,8 +369,11 @@ def submit_jobs(self, results, nproc=1, process_all=False, submit_nproc=None, su

if self.anomalous_data_present():
try:
anode = anomalous_util.AnodeSearch(self.mtz, self.output_dir, self.mr_program)
anode.run(result)
work_dir = os.path.join(self.output_dir, result.pdb_code, "anomalous")
anode = anomalous_util.AnodeSearch(self.mtz, work_dir)
input_model = os.path.join(self.output_dir, result.pdb_code, "mr",
self.mr_program, "{0}_mr_output.pdb".format(result.pdb_code))
anode.run(input_model)
a = anode.search_results()
score.dano_peak_height = a.dano_peak_height
score.nearest_atom = a.nearest_atom
Expand Down
55 changes: 28 additions & 27 deletions simbad/mr/anomalous_util.py
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#!/usr/bin/env ccp4-python

"""Class to run an anomalous phased fourier on MR results"""

__author__ = "Adam Simpkin"
Expand Down Expand Up @@ -35,30 +37,17 @@ class AnodeSearch(object):
>>> anomalous_search.run("<model>")
"""

def __init__(self, mtz, output_dir, mr_program):
def __init__(self, mtz, work_dir):
self._mtz = None
self._mr_program = None
self._space_group = None
self._resolution = None
self._cell_parameters = None
self._output_dir = None

self.name = None
self.mtz_labels = None
self.mr_program = mr_program
self.mtz = mtz
self.output_dir = output_dir
self.work_dir = None

@property
def mr_program(self):
"""The molecular replacement program to use"""
return self._mr_program

@mr_program.setter
def mr_program(self, mr_program):
"""Define the molecular replacement program to use"""
self._mr_program = mr_program
self.work_dir = work_dir

@property
def mtz(self):
Expand All @@ -71,27 +60,25 @@ def mtz(self, mtz):
self._mtz = mtz

@property
def output_dir(self):
def work_dir(self):
"""The path to the working directory"""
return self._output_dir
return self._work_dir

@output_dir.setter
def output_dir(self, output_dir):
@work_dir.setter
def work_dir(self, work_dir):
"""Define the working directory"""
self._output_dir = output_dir
self._work_dir = work_dir

def run(self, model):
def run(self, input_model):
"""Function to run SFALL/CAD/FFT to create phased anomalous fourier map"""
self.work_dir = os.path.join(self.output_dir, model.pdb_code, "anomalous")
os.mkdir(self.work_dir)
if not os.path.isdir(self.work_dir):
os.mkdir(self.work_dir)

self._space_group, self._resolution, cell_parameters = simbad.util.mtz_util.crystal_data(self.mtz)
self._cell_parameters = " ".join(map(str, cell_parameters))
self.mtz_labels = simbad.util.mtz_util.GetLabels(self.mtz)

input_model = os.path.join(self.output_dir, model.pdb_code, "mr",
self.mr_program, "{0}_mr_output.pdb".format(model.pdb_code))
self.name = model.pdb_code
self.name = os.path.basename(input_model).split('.')[0]

cwd = os.getcwd()
os.chdir(self.work_dir)
Expand Down Expand Up @@ -143,4 +130,18 @@ def cleanup(self):
for i in ["{0}_fa.hkl", "{0}_fa.ins", "{0}_fa.res", "{0}.hkl", "{0}.pha", "{0}.sca"]:
f = os.path.join(self.work_dir, i.format(self.name))
if os.path.isfile(f):
os.remove(f)
os.remove(f)

if __name__ == "__main__":
import argparse

parser = argparse.ArgumentParser(description="Wrapper for running ANODE", prefix_chars="-")
group = parser.add_argument_group()

group.add_argument("-xyzin", type=str, help="Path to the input xyz file")
group.add_argument("-hklin", type=str, help="Path to the input hkl file")
group.add_argument("-work_dir", type=str, help="Path to the working directory")
args = parser.parse_args()

anomalous_search = AnodeSearch(os.path.abspath(args.hklin), os.path.abspath(args.work_dir))
anomalous_search.run(os.path.abspath(args.xyzin))

0 comments on commit 90a3a66

Please sign in to comment.