Skip to content

Commit

Permalink
Merge pull request #122 from rigdenlab/uglymol_change
Browse files Browse the repository at this point in the history
Removed generation of map files following uglymol update
  • Loading branch information
hlasimpk committed Jan 13, 2020
2 parents a915094 + 3b8eb89 commit 0548bc9
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 105 deletions.
2 changes: 0 additions & 2 deletions simbad/command_line/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -603,8 +603,6 @@ def make_output_dir(run_dir, output_dir, csv, mr_program):
os.path.join(mr_workdir, "refine", "{0}_refinement_output.pdb".format(pdb_code)),
os.path.join(mr_workdir, "refine", "{0}_refinement_output.mtz".format(pdb_code)),
os.path.join(mr_workdir, "refine", "{0}_ref.log".format(pdb_code)),
os.path.join(mr_workdir, "refine", "{0}_refmac_2fofcwt.map".format(pdb_code)),
os.path.join(mr_workdir, "refine", "{0}_refmac_fofcwt.map".format(pdb_code)),
]
for f in files_to_copy:
shutil.copy(f, pdb_output_path)
Expand Down
67 changes: 1 addition & 66 deletions simbad/mr/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,6 @@ def generate_script(self, result):
ref_logfile = os.path.join(ref_workdir, "{0}_ref.log".format(result.pdb_code))
ref_pdbout = os.path.join(ref_workdir, "{0}_refinement_output.pdb".format(result.pdb_code))

diff_mapout1 = os.path.join(ref_workdir, "{0}_refmac_2fofcwt.map".format(result.pdb_code))
diff_mapout2 = os.path.join(ref_workdir, "{0}_refmac_fofcwt.map".format(result.pdb_code))

if isinstance(result, (AmoreRotationScore, PhaserRotationScore)):
pdb_struct = PdbStructure.from_file(result.dat_path)
mr_pdbin = os.path.join(self.output_dir, result.pdb_code + ".pdb")
Expand Down Expand Up @@ -478,22 +475,13 @@ def generate_script(self, result):

if self.refine_program == "refmac5":
ref_cmd += ["-refinement_type", self.refine_type]

# ====
# Create a run script - prefix __needs__ to contain mr_program so we can find log
# Leave order of this as SGE does not like scripts with numbers as first char
# ====
prefix, stem = self.mr_program + "_", result.pdb_code

fft_cmd1, fft_stdin1 = self.fft(ref_hklout, diff_mapout1, "2mfo-dfc")
run_stdin_1 = tmp_file(directory=self.output_dir, prefix=prefix, stem=stem, suffix="_1.stdin")
with open(run_stdin_1, "w") as f_out:
f_out.write(fft_stdin1)

fft_cmd2, fft_stdin2 = self.fft(ref_hklout, diff_mapout2, "mfo-dfc")
run_stdin_2 = tmp_file(directory=self.output_dir, prefix=prefix, stem=stem, suffix="_2.stdin")
with open(run_stdin_2, "w") as f_out:
f_out.write(fft_stdin2)

ccp4_scr = os.environ["CCP4_SCR"]
if self.tmp_dir:
tmp_dir = os.path.join(self.tmp_dir)
Expand All @@ -507,8 +495,6 @@ def generate_script(self, result):
[EXPORT, "CCP4_SCR=" + tmp_dir],
mr_cmd + [os.linesep],
ref_cmd + [os.linesep],
fft_cmd1 + ["<", run_stdin_1, os.linesep],
fft_cmd2 + ["<", run_stdin_2, os.linesep],
[EXPORT, "CCP4_SCR=" + ccp4_scr],
]
run_script = Script(directory=self.output_dir, prefix=prefix, stem=stem)
Expand Down Expand Up @@ -576,57 +562,6 @@ def anomalous_data_present(self):
else:
return False

@staticmethod
def fft(hklin, mapout, map_type):
"""Function to run fft to generate difference maps for uglymol
Parameters
----------
hklin : str
Path to input HKL file
mapout : str
Path to output MAP file
map_type : str
Define type of run, either mfo-dfc or 2mfo-dfc
Returns
-------
list
cmd
str
stdin
Raises
------
ValueError
Unknown map type
"""

cmd = [CMD_PREFIX, "fft", "hklin", hklin, "mapout", mapout]
if map_type == "2mfo-dfc":
stdin = (
"title Sigmaa style 2mfo-dfc map calculated with refmac coefficients"
+ os.linesep
+ "labi F1=FWT PHI=PHWT"
+ os.linesep
+ "end"
+ os.linesep
)
elif map_type == "mfo-dfc":
stdin = (
"title Sigmaa style mfo-dfc map calculated with refmac coefficients"
+ os.linesep
+ "labi F1=DELFWT PHI=PHDELWT"
+ os.linesep
+ "end"
+ os.linesep
)
else:
msg = "Unknown map type!"
raise ValueError(msg)
return cmd, stdin

def summarize(self, csv_file):
"""Summarize the search results
Expand Down
2 changes: 1 addition & 1 deletion simbad/mr/anomalous_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def work_dir(self, work_dir):
self._work_dir = work_dir

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

Expand Down
48 changes: 16 additions & 32 deletions simbad/util/pyrvapi_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,11 @@ def create_lattice_results_tab(self, lattice_results, lattice_mr_results, result
ref_pdb = os.path.join(mr_workdir, "{0}_refinement_output.pdb".format(pdb_code))
ref_mtz = os.path.join(mr_workdir, "{0}_refinement_output.mtz".format(pdb_code))
ref_log = os.path.join(mr_workdir, "{0}_ref.log".format(pdb_code))
ref_map = os.path.join(mr_workdir, "{0}_refmac_2fofcwt.map".format(pdb_code))
diff_map = os.path.join(mr_workdir, "{0}_refmac_fofcwt.map".format(pdb_code))

pdb, mtz, map_, dmap, mr_log, ref_log = list(self.adjust_paths_of_files([ref_pdb, ref_mtz, ref_map, diff_map, mr_log, ref_log]))
pdb, mtz, mr_log, ref_log = list(self.adjust_paths_of_files([ref_pdb, ref_mtz, mr_log, ref_log]))

self.store_entry_in_rvapi_meta(i + 1, "latt", pdb_code, pdb, mtz, map_, dmap, False)
self.output_result_files(download_sec, dmap, map_, mtz, pdb)
self.store_entry_in_rvapi_meta(i + 1, "latt", pdb_code, pdb, mtz, False)
self.output_result_files(download_sec, mtz, pdb)
self.output_log_files(logfile_sec, mr_log, ref_log)

except KeyError:
Expand All @@ -382,16 +380,14 @@ def create_lattice_results_tab(self, lattice_results, lattice_mr_results, result
ref_pdb = os.path.join(self.work_dir, "latt", "mr_search", "mr_models", "{}.pdb".format(pdb_code))
ref_mtz = None
ref_log = None
ref_map = None
diff_map = None
pdb, mtz, map_, dmap, mr_log, ref_log = list(self.adjust_paths_of_files([ref_pdb, ref_mtz, ref_map, diff_map, mr_log, ref_log]))
pdb, mtz, mr_log, ref_log = list(self.adjust_paths_of_files([ref_pdb, ref_mtz, mr_log, ref_log]))

if i == 0:
best = True
else:
best = False

self.store_entry_in_rvapi_meta(i + 1, "latt", pdb_code, pdb, mtz, map_, dmap, best)
self.store_entry_in_rvapi_meta(i + 1, "latt", pdb_code, pdb, mtz, best)
except KeyError:
logger.debug("No result found at position %s", (i + 1))

Expand Down Expand Up @@ -471,13 +467,11 @@ def create_contaminant_results_tab(self, contaminant_results, contaminant_mr_res
ref_pdb = os.path.join(mr_workdir, "{0}_refinement_output.pdb".format(pdb_code))
ref_mtz = os.path.join(mr_workdir, "{0}_refinement_output.mtz".format(pdb_code))
ref_log = os.path.join(mr_workdir, "{0}_ref.log".format(pdb_code))
ref_map = os.path.join(mr_workdir, "{0}_refmac_2fofcwt.map".format(pdb_code))
diff_map = os.path.join(mr_workdir, "{0}_refmac_fofcwt.map".format(pdb_code))

pdb, mtz, map_, dmap, mr_log, ref_log = list(self.adjust_paths_of_files([ref_pdb, ref_mtz, ref_map, diff_map, mr_log, ref_log]))
pdb, mtz, mr_log, ref_log = list(self.adjust_paths_of_files([ref_pdb, ref_mtz, mr_log, ref_log]))

self.store_entry_in_rvapi_meta(i + 1, "cont", pdb_code, pdb, mtz, map_, dmap, False)
self.output_result_files(download_sec, dmap, map_, mtz, pdb)
self.store_entry_in_rvapi_meta(i + 1, "cont", pdb_code, pdb, mtz, False)
self.output_result_files(download_sec, mtz, pdb)
self.output_log_files(logfile_sec, mr_log, ref_log)

except KeyError:
Expand Down Expand Up @@ -559,13 +553,11 @@ def create_morda_db_results_tab(self, morda_db_results, morda_db_mr_results, res
ref_pdb = os.path.join(mr_workdir, "{0}_refinement_output.pdb".format(pdb_code))
ref_mtz = os.path.join(mr_workdir, "{0}_refinement_output.mtz".format(pdb_code))
ref_log = os.path.join(mr_workdir, "{0}_ref.log".format(pdb_code))
ref_map = os.path.join(mr_workdir, "{0}_refmac_2fofcwt.map".format(pdb_code))
diff_map = os.path.join(mr_workdir, "{0}_refmac_fofcwt.map".format(pdb_code))

pdb, mtz, map_, dmap, mr_log, ref_log = list(self.adjust_paths_of_files([ref_pdb, ref_mtz, ref_map, diff_map, mr_log, ref_log]))
pdb, mtz, mr_log, ref_log = list(self.adjust_paths_of_files([ref_pdb, ref_mtz, mr_log, ref_log]))

self.store_entry_in_rvapi_meta(i + 1, "full", pdb_code, pdb, mtz, map_, dmap, False)
self.output_result_files(download_sec, dmap, map_, mtz, pdb)
self.store_entry_in_rvapi_meta(i + 1, "full", pdb_code, pdb, mtz, False)
self.output_result_files(download_sec, mtz, pdb)
self.output_log_files(logfile_sec, mr_log, ref_log)

except KeyError:
Expand Down Expand Up @@ -640,9 +632,7 @@ def display_summary_tab(self):
mr_log = os.path.join(mr_workdir, "{0}_mr.log".format(pdb_code))
ref_log = os.path.join(mr_workdir, "{0}_ref.log".format(pdb_code))
ref_pdb = os.path.join(mr_workdir, "{0}_refinement_output.pdb".format(pdb_code))
ref_map = os.path.join(mr_workdir, "{0}_refmac_2fofcwt.map".format(pdb_code))
ref_mtz = os.path.join(mr_workdir, "{0}_refinement_output.mtz".format(pdb_code))
diff_map = os.path.join(mr_workdir, "{0}_refmac_fofcwt.map".format(pdb_code))

msg = "The best search model found by SIMBAD was {0}. \
This gave an R/Rfact of {1:.3f} and an R/Rfree of {2:.3f}. \
Expand All @@ -666,11 +656,11 @@ def display_summary_tab(self):
logfile_sec = section_title.replace(" ", "_") + uid
pyrvapi.rvapi_add_section(logfile_sec, section_title, tab, 0, 0, 1, 1, False)

pdb, mtz, map_, dmap, mr_log, ref_log = list(self.adjust_paths_of_files([ref_pdb, ref_mtz, ref_map, diff_map, mr_log, ref_log]))
pdb, mtz, mr_log, ref_log = list(self.adjust_paths_of_files([ref_pdb, ref_mtz, mr_log, ref_log]))
for e in self.rvapi_meta.results:
if e["name"] == pdb_code and e["source"] == source:
e["best"] = True
self.output_result_files(download_sec, dmap, map_, mtz, pdb)
self.output_result_files(download_sec, mtz, pdb)
self.output_log_files(logfile_sec, mr_log, ref_log)

def display_citation_tab(self):
Expand Down Expand Up @@ -701,17 +691,13 @@ def display_citation_tab(self):
pyrvapi.rvapi_add_data("bibtex_file", "Citations as BIBTEX", self.fix_path(bibtex_file), "text", self.citation_tab_id, 2, 0, 1, 1, True)

@staticmethod
def output_result_files(sec, diff_map, ref_map, ref_mtz, ref_pdb):
def output_result_files(sec, ref_mtz, ref_pdb):
"""Function to display the result files for the result
Parameters
----------
sec : str
Section the output results files will be added to
diff_map : str
Path to the difference map
ref_map : str
Path to the refined map
ref_mtz : str
Path to the refined mtz
ref_pdb : str
Expand All @@ -728,8 +714,6 @@ def output_result_files(sec, diff_map, ref_map, ref_mtz, ref_pdb):

pyrvapi.rvapi_add_data1(os.path.join(sec, data), title, ref_pdb, "xyz", 2, 0, 1, 1, 1)
pyrvapi.rvapi_append_to_data(data, ref_mtz, "hkl:map")
pyrvapi.rvapi_append_to_data(data, ref_map, "hkl:ccp4_map")
pyrvapi.rvapi_append_to_data(data, diff_map, "hkl:ccp4_dmap")

@staticmethod
def output_log_files(sec, mr_log, ref_log):
Expand Down Expand Up @@ -936,6 +920,6 @@ def adjust_paths_of_files(self, files):
else:
yield ""

def store_entry_in_rvapi_meta(self, rank, source, name, pdb, mtz, map_, dmap, best):
entry = {"rank": rank, "source": source, "best": best, "name": name, "pdb": pdb, "mtz": mtz, "map": map_, "dmap": dmap}
def store_entry_in_rvapi_meta(self, rank, source, name, pdb, mtz, best):
entry = {"rank": rank, "source": source, "best": best, "name": name, "pdb": pdb, "mtz": mtz}
self.rvapi_meta.add(entry)
4 changes: 0 additions & 4 deletions simbad/util/simbad_results.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ def __init__(self):
self.ref_pdb_annotation = None
self.ref_mtz_annotation = None
self.ref_log = None
self.ref_map = None
self.diff_map = None


class SimbadResults(object):
Expand Down Expand Up @@ -113,8 +111,6 @@ def get_files(self, search_type, num_results=10):
fc.ref_mtz_annotation = 'MTZ #{0} from REFMAC-refined result of the {1} search'.format(
i + 1, ID2STR[search_type])
fc.ref_log = os.path.join(mr_workdir, 'refine', '{0}_ref.log'.format(pdb_code))
fc.ref_map = os.path.join(mr_workdir, 'refine', '{0}_refmac_2fofcwt.map'.format(pdb_code))
fc.diff_map = os.path.join(mr_workdir, 'refine', '{0}_refmac_fofcwt.map'.format(pdb_code))
results.append(fc)
except KeyError:
logger.debug("No result found at position %s", (i + 1))
Expand Down

0 comments on commit 0548bc9

Please sign in to comment.