You are here

Creating a vector1 of AtomID objects

20 posts / 0 new
Last post
Creating a vector1 of AtomID objects
#1

I'm am unsure of how to do this. AtomID() does not fit any of the standard types in __init__.Vector1().

For a double, you can do:

vec1 = rosetta.utility.vector1_double()
vec1.append(doubleX)

Post Situation: 
Mon, 2011-07-18 06:24
msellers

I assume the problem is that there isn't an interface, (or we don't know the interface), for doing C++ templating in python. In C++:

utility::vector1< core::id::AtomID > my_vector;

You may be able to circumvent this by extracting an AtomID vector from the code and modifying it - set a local variable equal to a return value that is a vector1, empty it, then put your own stuff in it? This is almost certainly not the best way to do it but it's the first I can think of.

The only function I can find that returns the right type is protocols::constraints_additional::SequenceProfileConstraint.atom_IDs().

Mon, 2011-07-18 07:09
smlewis

TypeError: No Python class registered for C++ class utility::vector1 >

Is the error I receive when I extract the vector.

Mon, 2011-07-18 08:49
msellers

The forum ate your code. Looking into the raw code of your post, it looks like this:

TypeError: No Python class registered for C++ class utility::vector1< core::id::AtomID, std::allocator< core::id::AtomID > >

I guess that means you need a manual wrapper class to get this to work. I've informed Sergey but I don't know that this can be fixed remotely (or quickly).

Mon, 2011-07-18 08:58
smlewis

Thanks.

When I use the method pose.conformation().set_xyz(AtomID(),xyzVector) on 10,000 atoms, it takes about 60seconds. There are a few other method calls besides setting the internal and xyz coordinates. So, I am trying to use .batch_set_xyz() and that requires two vector1's.

Since that isn't working right now, I will try and set the external and internal coords manually. Hopefuly that doesn't break anything.

Mon, 2011-07-18 11:55
msellers

If you've got 10,000 atoms, why not read them in as a PDB? What format are they in already? set_xyz is not really set up to be used on that many residues, since it refolds after each one...

Mon, 2011-07-18 12:02
smlewis

Using:

pycoord = pose.residue(_residueNumber).xyz(_atomSpecies)
pycoord.x = 1.0
pycoord.y = 1.0
pycoord.z = 1.0
idx = pose.residue(_residueNumber).atom_index(_atomSpecies)
id = AtomID(idx,_residueNumber)
pose.atom_tree().set_xyz(id,pycoord)

takes about 0.4-0.6 seconds for all atoms. Not that I want to move them all to 1 1 1, but you get the idea.

Mon, 2011-07-18 12:06
msellers

Ok, I fixed this. In revisions starting with 43345 it should be possible to write this:

rosetta.Vector1( [rosetta.core.id.AtomID()] )

msellers, on which platform do you run this? Also, do you have access to developer versions?

Mon, 2011-07-18 18:49
Sergey

Great, thanks. I have only have academic access to the Rosetta source and it's running on Linux. I'm trying to avoid the conformation().set_xyz() slowdown, by setting atom.xyz() and atom_tree.set_xyz() instead. However, with Pyrosetta 2.0 I cannot get to this point.

I keep receiving: kinematics::Atom bad method call in Atom hierarchy!
ERROR:: Exit from: src/core/kinematics/tree/Atom_.cc line: 754

when I try to do a spin or randomize move.

Tue, 2011-07-19 06:58
msellers

Tracing upwards from that error, I have to guess that you are trying to do something involving a jump (as spin or randomize would), except that the jump is set up wrong. That error is triggered when you try to do something involving a Jump on a class "BondedAtom", which as far as I can tell just means a standard atom that isn't involved in a Jump.

I would look for an error where the Jump you are trying to spin or randomize doesn't match the one in the FoldTree/AtomTree; perhaps it got out-of-date somehow...?

Tue, 2011-07-19 07:51
smlewis

Sergey,

It would also be useful to create a vector1 of xyzVectors.

Tue, 2011-07-19 13:52
msellers

- got it! I will look it up, but it would be after a bit of time.

Tue, 2011-07-19 20:01
Sergey

Thanks. Yeah, to do the .batch_set_xyz() you need both a vector1 of AtomID's and a vector1 of xyzVectors.

Thu, 2011-07-21 11:47
msellers

BUMP

Wed, 2011-09-07 07:45
msellers

The following functions for creating Vector1 is added:

rosetta.utility.vector1_xyzVector_bool
rosetta.utility.vector1_xyzVector_char
rosetta.utility.vector1_xyzVector_double
rosetta.utility.vector1_xyzVector_float
rosetta.utility.vector1_xyzVector_int
rosetta.utility.vector1_xyzVector_long
rosetta.utility.vector1_xyzVector_uchar
rosetta.utility.vector1_xyzVector_uint
rosetta.utility.vector1_xyzVector_ulong

Here the links to a new binary:
http://graylab.jhu.edu/pyrosetta/downloads/release/PyRosetta.MacOSX.Lion...
http://graylab.jhu.edu/pyrosetta/downloads/release/PyRosetta.MacOSX.Snow...
http://graylab.jhu.edu/pyrosetta/downloads/release/PyRosetta.ScientificL...

Regarding the '.batch_set_xyz()': I have not quite get what you mean, could you please elaborate this?

Thu, 2011-09-08 19:18
Sergey

Sergey,

.batch_set_xyz() is a method in Pose.cc that takes a vector of AtomID objects and a vector of XYZVectors, and calls a similar method in Conformation.cc to change the position of each atom. I haven't tried it yet, but I am assuming it is much faster than .set_xyz() becuase it does not rebuild the internal coordinates (?) after each atom is moved. The batch method sets all coordinates in the list and then updates the internal things and fires events, etc.

Right now looping over .set_xyz() for around 10,000 atoms takes upwards of 30seconds. I'm hoping this will save a lot of time.

Thanks a lot for rebuilding these!

Fri, 2011-09-09 04:59
msellers

Oh, - but its already binded, just construct Pose object and you should be able to use pose.batch_set_xyz and pose.batch_get_xyz etc.

Fri, 2011-09-09 16:28
Sergey

Yes, the 'batch...' methods have been binded for a while, but we could never construct their arguements in an IVector form. With this release incorporating IVector_xyzVector... and IVector_AtomID, you have fixed that.

Happy to report that the batch methods are working nice and quick. Thanks.

Mon, 2011-09-12 06:48
msellers

That was it, my jump was set incorrectly. Thanks.

Tue, 2011-07-19 08:31
msellers

OK, new binaries are ready (only for ScientificLinux and Mac for now):

http://graylab.jhu.edu/pyrosetta/downloads/release/PyRosetta-r43353.linu...
http://graylab.jhu.edu/pyrosetta/downloads/release/PyRosetta-r43382.darw...

Use the same password and user name that you used to download other releases.

Tue, 2011-07-19 20:03
Sergey