Creating a vector1 of AtomID objects

Member Site Forums PyRosetta PyRosetta – General Creating a vector1 of AtomID objects

Viewing 8 reply threads
  • Author
    • #978

        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()

      • #5862

          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().

        • #5863

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

            Is the error I receive when I extract the vector.

          • #5864

              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).

            • #5865


                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.

              • #5867


                  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)

                  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.

                • #5869

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

                    rosetta.Vector1( [] )

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

                  • #5875

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

                    • #5881

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


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

                      • #5866

                          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…

                        • #5872

                            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 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/ line: 754

                            when I try to do a spin or randomize move.

                          • #5874

                              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…?

                            • #5878


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

                              • #5880

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

                                • #5895

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

                                  • #6023


                                    • #6025

                                        The following functions for creating Vector1 is added:


                                        Here the links to a new binary:

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

                                      • #6027


                                          .batch_set_xyz() is a method in that takes a vector of AtomID objects and a vector of XYZVectors, and calls a similar method in 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!

                                        • #6029

                                            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.

                                          • #6031

                                              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.

                                          Viewing 8 reply threads
                                          • You must be logged in to reply to this topic.