16 flexible_residues = list()
18 for fr
in flex_dict[
"Flexible residues"]:
19 chain_id = fr[
'chain_identifier']
20 residue_id = fr[
'residue_seq_number']
24 residue_indexes=[residue_id]
26 flexible_residues.append(
27 sel.get_selected_particles(
False)[0]
29 for bnd
in flex_dict[
"Bonds"]:
34 chain_ids=[a1[
'chain_identifier']],
35 residue_indexes=[a1[
'residue_seq_number']],
40 chain_ids=[a2[
'chain_identifier']],
41 residue_indexes=[a2[
'residue_seq_number']],
44 p1 = sel1.get_selected_particles()[0]
45 p2 = sel2.get_selected_particles()[0]
51 return flexible_residues, bonds
61 name: str =
"WriteRMFFrame"
63 model = root_hier.get_model()
64 super().__init__(model, name)
65 self.restraints = restraints
66 fileName, fileExtension = os.path.splitext(filename)
67 fn = pathlib.Path(fileName +
".0.rmf3")
68 if pathlib.Path(fn).exists():
70 fn = pathlib.Path(fileName +
".{:d}.rmf3".format(i))
73 self._rmf_filename = str(fn)
74 self._rh = RMF.create_rmf_file(str(fn))
79 def do_update(self, arg0):
91 restraint_filename: str =
None,
92 name: str =
"WriteDCDFrame",
93 output_objects: typing.List =
None,
94 multi_state: bool =
False
96 model = root_hier.get_model()
97 super().__init__(model, name)
100 self._pdb_basename = filename
101 if restraint_filename
is None:
102 restraint_filename = os.path.splitext(filename)[0] +
".rst.txt"
103 self._restraint_filename = restraint_filename
104 self.restraints = restraints
105 self._hier = root_hier
107 self.output_objects = output_objects
108 self.multi_state = multi_state
110 def do_update(self, arg0):
111 with open(self._restraint_filename,
"a+")
as fp:
112 fp.write(
"%s\t" % self.frame)
113 fp.write(
"\t".join([
"{:.3f}".format(r.evaluate(
False))
for r
in self.restraints]))
115 if isinstance(self.output_objects, list):
116 for obj
in self.output_objects:
117 fp.write(str(obj) +
"\t")
119 lead = os.path.splitext(self._pdb_basename)[0]
120 if not self.multi_state:
123 hiers = self._hier.get_children()
124 for i, hier
in enumerate(hiers):
125 out_fn = lead +
"_state_" + str(i) +
"_" +
"{:04d}".format(self.frame) +
".pdb"
RMF::FrameID save_frame(RMF::FileHandle file, std::string name="")
Save the current state of the linked objects as a new RMF frame.
A decorator for a particle which has bonds.
void write_pdb(const Selection &mhd, TextOutput out, unsigned int model=1)
Bond create_bond(Bonded a, Bonded b, Bond o)
Connect the two wrapped particles by a custom bond.
The standard decorator for manipulating molecular structures.
A decorator for wrapping a particle representing a molecular bond.
void add_hierarchies(RMF::NodeHandle fh, const atom::Hierarchies &hs)
void add_restraints(RMF::NodeHandle fh, const Restraints &hs)
A decorator for a residue.
Shared optimizer state that is invoked upon commitment of new coordinates.
Functionality for loading, creating, manipulating and scoring atomic structures.
Select hierarchy particles identified by the biological name.
A restraint is a term in an IMP ScoringFunction.