Dear PyMOL-ers, I have just started dabbling in the chempy module, and I have a couple of questions:
1. If I load in a molecule using the following code... from chempy import io from chempy import protein m = io.pdb.fromFile("/tmp/x.pdb") # Use the load_object call, specifying the type of object as a chempy # model (index 8) cmd.load_object(8,m,"protein") ...there are no bonds displayed. Is there a chempy call I can make on the model object (m) to calculate covalent bonds? 2. I can happily iterate over, or select by index, atoms in a chempy model, using either of the following # Iterate over all atoms for a in m.atom: # do something # Random access a = m.atom[10] Are there corresponding residue and atom arrays, or does chempy represent these aggregates simply by the fields of the Atom object (resn, resi, chain etc)? As far as I can see, the latter is true, but like I said, so far I am only a dabbler. I should mention why I'm doing this, in case anyone has a more elegant solution. Basically I have a C++ library which handles molecules, making selections, identifying h-bonds etc. I wanted a way to dump out a molecule object from my library, and display it in PyMOL with all of its associated selections and bonds. So basically what I do is: 1. Write out a PDB file for my molecule 2. Write out a short Python program which creates PyMOL selections corresponding to my selections, by way of atom indices. Basically this works by grabbing the 'nth' atom from the chempy model, then composing a selection string which is passed to the cmd.select function. Missing out some detail, here is the bare bones: # Function 1: get a PyMOL selection string from a ChemPy atom def atom_sel(a,obj_name): return "/" + obj_name + "//" + a.chain + "/" + a.resi + "/" + a.name # Function 2: create a PyMOL selection from an array of atom indices def make_atom_sel(sel_name,array,model,obj_name): sel_str = "" for i in range(len(array)): sel = atom_sel(model.atom[array[i]],obj_name) sel_str += sel if(i < len(array)-1): sel_str += " or " cmd.select(sel_name, sel_str) # Similar functions exist for creating an h-bond between ith and jth # atoms So to put it all together, given these two functions, the program I execute in order to reconstitute my molecule in PyMOL looks like m = io.pdb.fromFile("/tmp/x.pdb") cmd.load_object(8,m,"protein") make_atom_sel("my_sel", [0,2,5,8,18,22], m, "protein") Gareth -- Gareth Stockwell <gar...@ebi.ac.uk> European Bioinformatics Institute