You are here

Best way to store a pose by Pyrosetta for Pyrosetta

1 post / 0 new
Best way to store a pose by Pyrosetta for Pyrosetta
#1

A pose can have a constraint set, a modifiable residue set, an unnoticed `pose.pdb_info().obsolete() == True` case, virtual residues, energies and a few more. Therefore when saving to disk none of the following truly work as they save coordinates:

pose.dump_pdb('foo.pdb')
pose.dump_scored_pdb('foo.pdb', pyrosetta.get_fa_scorefxn())
pose.dump_cif('foo.cif')
pose.dump_mmtf('foo.mmtf')
pyrosetta.io.poses_to_silent([pose], 'foo.silent')

So I was hoping for an all-in-one

Manually...

I know one can address some of extras manually, e.g.

pose.pdb_info().obsolete(False)
pyrosetta.rosetta.core.scoring.constraints.ConstraintIO.write_constraints('foo.cst',
                                                                          pose.constraint_set(),
                                                                          pose)
# nothing to be done for
# pose.conformation().modifiable_residue_type_set_for_conf().????()

But that is rather a lot of effort and would not catch some corner cases, say fixing protonation on a catalytic triad does not get dumped cleanly.

pyrosetta.rosetta.protocols.simple_moves.MutateResidue(target=10, new_res='CYZ').apply(mutant)  # nucleophile
pyrosetta.rosetta.protocols.simple_moves.MutateResidue(target=20, new_res='HIS_D').apply(mutant)  # base in HID, not HIE

PackedPose

PackedPose IO-type mover seems relevant for cereal-based serialisation to pickle, but in my normal installation it is not available (relavant post I found here). —is this the solution for preserving data?

pyrosetta.distributed.packed_pose.core.PackedPose
#AttributeError: module 'pyrosetta.distributed' has no attribute 'packed_pose'
pyrosetta.version()
# PyRosetta-4 2020 [Rosetta PyRosetta4.Release.python37.linux 2020.49+release.fac69dd63b19b7d5dac246655b6c15158b98365e 2020-12-01T20:40:56] retrieved from: http://www.pyrosetta.org[...]

io.serialisation

There is also, a serialisation submodule in `io`, which can add a pose to a BUFFER object, a pybind11 of a structure defined in the `serialize_pose` header file (not the `pyrosetta.rosetta.std.stringbuf()` one, i.e. the one passed to `pyrosetta.rosetta.std.ostream` say). In the `serialize_pose` file the write_binary comments say it's writing to file, but I am guessing it requires `memcpy` function calls to do which I don't think I can access in Python.

b = pyrosetta.rosetta.core.io.serialization.BUFFER(1024)   # no idea what the size is.
pyrosetta.rosetta.core.io.serialization.write_binary(pose, b)
# b.write(str, int) -> int
# b.read(str, int) -> int  # char * and str work differently, but a `ctypes.c_char_p` is not accepted.

 

Category: 
Post Situation: 
Wed, 2021-04-07 06:50
matteoferla