Skip to content

Commit

Permalink
Squashed 'modules/pmi/' changes from a3f39aa119..26c9da6a01
Browse files Browse the repository at this point in the history
26c9da6a01 Remove unused imports
7f61f63121 Close NestOR rmf file

git-subtree-dir: modules/pmi
git-subtree-split: 26c9da6a01b10318c9c4ed97ee1aebd57dc4a4e0
  • Loading branch information
benmwebb committed Mar 25, 2024
1 parent 2992b43 commit 45c11de
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions modules/pmi/pyext/src/macros.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import math

import pickle
import RMF


class _MockMPIValues(object):
Expand Down Expand Up @@ -427,9 +426,10 @@ def execute_macro(self):
if self.rmf_output_objects is not None:
self.rmf_output_objects.append(sw)

output = IMP.pmi.output.Output(atomistic=self.vars["atomistic"])

if not self.nest:
print("Setting up stat file")
output = IMP.pmi.output.Output(atomistic=self.vars["atomistic"])
low_temp_stat_file = globaldir + \
self.vars["stat_file_name_suffix"] + "." + \
str(myindex) + ".out"
Expand Down Expand Up @@ -529,6 +529,15 @@ def execute_macro(self):
if self._rmf_restraints:
output.add_restraints_to_rmf(rmfname, self._rmf_restraints)

if not self.test_mode and self.nest:
print("Setting up NestOR rmf files")
nestor_rmf_fname = str(self.nestor_rmf_fname) + '_' + \
str(self.replica_exchange_object.get_my_index()) + '.rmf3'

output.init_rmf(nestor_rmf_fname, output_hierarchies,
geometries=self.vars["geometries"],
listofobjects=self.rmf_output_objects)

ntimes_at_low_temp = 0

if myindex == 0 and not self.nest:
Expand Down Expand Up @@ -584,6 +593,7 @@ def execute_macro(self):
for rstrnt in self.nestor_restraints:
likelihood_for_sample *= rstrnt.get_likelihood()
sampled_likelihoods.append(likelihood_for_sample)
output.write_rmf(nestor_rmf_fname)

if not self.test_mode and not self.nest:
if i % self.vars["nframes_write_coordinates"] == 0:
Expand Down Expand Up @@ -612,16 +622,7 @@ def execute_macro(self):
"wb") as lif:
pickle.dump(sampled_likelihoods, lif)

nestor_rmf_fname = str(self.nestor_rmf_fname) + '_' + \
str(self.replica_exchange_object.get_my_index()) + '.rmf3'

self.rmf_h = RMF.create_rmf_file(nestor_rmf_fname)
IMP.rmf.add_hierarchy(self.rmf_h, self.root_hier)
try:
IMP.rmf.save_frame(self.rmf_h)
except Exception as e:
print(e)
pass
output.close_rmf(nestor_rmf_fname)

for p, state in IMP.pmi.tools._all_protocol_outputs(self.root_hier):
p.add_replica_exchange(state, self)
Expand Down

0 comments on commit 45c11de

Please sign in to comment.