You are here

How to create an ObjexxFCL FArray?

1 post / 0 new
How to create an ObjexxFCL FArray?
#1

    pyrosetta.rosetta.ObjexxFCL is a Python module wrapped by PyBind11 around a C++ wrapper for Fortran, so I expect this matryoshka to be a problem. The documentation says these are being slowly phased out and it is uncommon finding a method that requires a ObjexxFCL FArray as opposed to a vector. However, I wanted to use one...

    I was looking into the class DecoySetEvaluation in toolbox so I wanted an initialised pyrosetta.rosetta.ObjexxFCL.FArray1_double_t or pyrosetta.rosetta.ObjexxFCL.FArray2_double_t. But no constructor is defined and there seem to be no class methods. Here is a full example:

# init
import pyrosetta
pyrosetta.init(extra_options='-no_optH false -mute all -ignore_unrecognized_res true -load_PDB_components false')

# load a multimodel PDB (& split it) as a proxy for a MCMC mover .dump_poses output
original = pyrosetta.toolbox.rcsb.pose_from_rcsb('1L2Y')
mini = pyrosetta.rosetta.protocols.grafting.return_region(original, 1,20)
n = [pyrosetta.rosetta.protocols.grafting.return_region(original, 1+i,20+i) for i in range(0, original.total_residue(),20)]
# n is a list. Instancemethods use vectors
poses = pyrosetta.rosetta.utility.vector1_core_pose_Pose()
altposes = pyrosetta.rosetta.utility.vector1_std_shared_ptr_const_core_pose_Pose_t()
poses.extend(n) # used by a few methods —such as MCMC movers .dump_poses()
altposes.extend(n) # for: pyrosetta.rosetta.core.io.pdb.dump_multimodel_pdb(altposes, 'test.pdb')


# analyse
dse = pyrosetta.rosetta.protocols.toolbox.DecoySetEvaluation()
dse.reserve(len(poses))
for pose in poses:
    dse.push_back(pose)

# this works fine:
r = pyrosetta.rosetta.utility.vector1_double()
dse.rmsf(r)
print(r)

# this requires an FArray1
weights = xxx(pyrosetta.rosetta.ObjexxFCL.FArray1_double_t, dimension=len(poses))
xxx.fill(weights, 1)
dse.center_all(weights)

    In Fortran an array is declared with dimensions

real, dimension(5) :: myvarname

    There is a Dimension class in the ObjexxFCL module that can be instantiated but it does nothing that I can see, but might be a way in.

    So How does one instantiate a FArray?

    If it is not possible to instantiate a FArray, are there any methods that return one that could be co-opted?

    And also, is it possible to convert a FArray2 to pose?

# this requires a FArray2, but would seem to fill it as a pose that is not a pose
notpose = xxx(pyrosetta.rosetta.ObjexxFCL.FArray2_double_t,...)
dse.compute_average_structure()
pose = xxx.FArray2_to_pose(notpose)

    This is not an insurmountable problem for this example as I have been using some GROMACS utilities that compute the RSMF and the average structure. But it would be nice to know as I have seen ObjexxFCL arrays requirements in a few places...

Category: 
Post Situation: 
Tue, 2020-08-18 03:22
matteoferla