[chimera-dev] [Chimera-users] Parsing a new 3D file format

Elaine Meng meng at cgl.ucsf.edu
Tue Jan 6 11:12:22 PST 2015


Hi Rodrigo,
Another possibility is to write (or get from somewhere) a separate program to convert your file from AIMAII to a format that Chimera already knows.

I don't know if this will help, but I found a page with downloadable perl script that is supposed to convert atoms and critical points (depending on the command options used) from an AIMII sum file to XYZ format.  I haven't tried the program, and I don't know if the resulting XYZ is acceptable to Chimera or not, but it might get you further.

The original page is in Russian:
<http://limor1.nioch.nsc.ru/quant/program/mgp2xyz/>

Google translate to English:
<http://translate.google.com/translate?hl=en&sl=ru&u=http://limor1.nioch.nsc.ru/quant/program/mgp2xyz/&prev=search>

There might be some problems with chemical perception if the atoms + critical points are all treated as the same molecule in Chimera.  You might want to create two molecules (possibly two separate input files, if you are doing format conversion outside of Chimera), one with the atoms and one with the critical points.
Elaine
----------
Elaine C. Meng, Ph.D. 
UCSF Computer Graphics Lab (Chimera team) and Babbitt Lab
Department of Pharmaceutical Chemistry
University of California, San Francisco

On Jan 6, 2015, at 8:24 AM, ros <rodrigogalindo at gmail.com> wrote:

> Dear Eric! Thank you for your detailed explanation and the time to write it!
> It will be my first time messing with the inner workings of chimera,
> but I will try it.
> I will use your advice as my starting point and ask following
> questions in the chimera-dev list.
> 
> Thank you again and have a good day,
> 
> Rodrigo.
> 
> On Mon, Jan 5, 2015 at 8:43 PM, Eric Pettersen <pett at cgl.ucsf.edu> wrote:
>> Hi Rodrigo,
>> There is code in Chimera to read XYZ files, which are somewhat similar, so
>> you could base you code off of that.  The XYZ-reading code is in <your
>> Chimera>/share/ReadXYZ/__init__.py, the readXYZ() function.  On a Mac,
>> "<your Chimera>" is actually Chimera.app/Contents/Resources.  Anyway, there
>> is a lot of error-checking in that code so it may be hard to see the most
>> relevant parts for your purposes.  Here's a digest version:
>> 
>> import objects/functions we will be using
>> from chimera import Molecule, Element, Coord, connectMolecule
>> 
>> create a new empty molecule
>> m = Molecule()
>> 
>> create a residue named UNK in that molecule, with sequence position 1, no
>> chain ID, and no insertion code
>> r = m.newResidue("UNK", " ", 1, " ")
>> 
>> assign a name to the molecule for display in the model panel and so forth
>> m.name = "molecule_name"
>> 
>> create the appropriate chemical element
>> element = Element(text or integer)
>> 
>> make a new atom with the appropriate name and element
>> a = m.newAtom("atom_name", element)
>> 
>> add the atom to the residue
>> r.addAtom(a)
>> 
>> assign the atom's xyz coordinate
>> a.setCoord(Coord(x, y, z))
>> 
>> assign a serial number to the atom
>> a.serialNumber = serial
>> 
>> make appropriate bonds between the atoms
>> connectMolecule(m)
>> 
>> return a list of models (Molecules) to open
>> return [m]
>> 
>> Geez, that already was a lot.  Anyway, let's ignore the file's "critical
>> points" for a second so that we can finish with getting this open in
>> Chimera.  Basically, you will package this as an extension to Chimera that
>> doesn't put anything in the Tools menu (or model panel) but just adds to the
>> file types that Chimera knows how to open with the File->Open dialog and
>> with the "open" command (ala "open coords.xyz").  To do so, in the same
>> folder as your file-reading code you will need a file named
>> ChimeraExtension.py that has this in it:
>> 
>> ----
>> def aimallOpen(fileName):
>> from ReadAimall import readAimall
>> return readAimall(fileName)
>> 
>> import chimera
>> chimera.fileInfo.register("AIMAll mgpviz", aimallOpen, [".mgpviz"],
>> ["mpgviz"],
>> category=chimera.FileInfo.STRUCTURE)
>> ----
>> The above code assumes that the folder containing your code is named
>> "ReadAimall", that the file-reading function is named "readAimall", that it
>> is in a file named "__init__.py" in the folder, and that the files are
>> ".mgpviz" files. The second list in the register call (["mpgviz"]) allows
>> the file type to be specified with a "mpgviz:" prefix in an "open" command
>> should the file not actually have a .mgpviz suffix.
>> You can then get Chimera to find this extension by adding the folder above
>> the ReadAimall folder to the list in the Locations section of Chimera's
>> Tools preferences (remember to click Save afterward), i.e. you add the
>> folder containing new tools (in this case, the folder above ReadAimall)
>> rather than each tool folder itself.
>> 
>> Okay, back to the critical points.  Depending somewhat on what you want to
>> learn from them, I see four possible options:  1) fake atoms;  2) markers;
>> 3) sphere shapes;  4) bond colors.  In the below, I tend to put the critical
>> points in their own model, since having fake atoms mixed into a real
>> molecule will mess up things like hydrogen bond finding, aromatic ring
>> determination, etc.
>> 
>> Fake Atoms
>> In this scenario, you would create a second Molecule as you read the file
>> and add the critical points as atoms to that.  You include the additional
>> Molecule in the list of models you return ("return [m, m2]").   You would
>> not call connectMolecule() on the second Molecule, but might add pseudobonds
>> from the critical points to the appropriate atoms (you can't add regular
>> bonds between models).  The second molecule will have the same ID and sub-ID
>> # as the first one, and will move in tandem with it.  It will show up in the
>> model panel.
>> 
>> Markers
>> Markers are what the Volume Tracer tool uses to mark volume data.  They're
>> really fake atoms, but have their own little support infrastructure.  A
>> simple example of using them is in the markeruse.py script on our Scripts
>> page: http://plato.cgl.ucsf.edu/trac/chimera/wiki/Scripts .  They would have
>> the same limitation in that they could only connect to the "real" atoms via
>> pseudobonds.  Also, they would only move in tandem with the real molecule as
>> long as both models are "active" (which is usually the case unless you
>> specifically do something to make their active states different).
>> 
>> Sphere Shapes
>> These are shapes (surfaces, really) created by the "shape" command.
>> Probably the easiest way to create them is something like:
>> 
>> from chimera import runCommand
>> runCommand("shape sphere radius rad center x,y,z modelName 'critical points'
>> modelId 100")
>> 
>> which would put them all in model #100.  If you wanted them in the same
>> model number as the molecule, that would require fancier code.  You could
>> look at Aniso/__init__.py or at sphere_shape() in Shape/shapecmd.py for
>> examples of that.
>> 
>> Bond Colors
>> If the critical points are really associated with bonds and are trying to
>> convey properties of the bonds, you could vary the thickness or color of the
>> bonds instead.  To find the Bond object b between Atoms a1 and a2, you would
>> do this:
>> 
>> b = a1.atomsMap(a2)
>> 
>> To change the bond radius, you would show it as stick and change the radius:
>> 
>> b.drawMode = chimera.Bond.Stick
>> b.radius = radius
>> 
>> To change the color, you would make sure it wasn't in "halfbond" mode (each
>> half colored the same as its endpoint atom) and then set the color:
>> 
>> b.halfbond = False
>> b.color = chimera.MaterialColor(red, green, blue, opacity)
>> 
>> red / green / blue / opacity all in the range 0-1.
>> So finally, this is really a developer-oriented subject, so I have directed
>> follow ups to chimera-dev instead of chimera-users.  Feel free to ask
>> additional questions there…
>> 
>> --Eric
>> 
>> 
>>                        Eric Pettersen
>>                        UCSF Computer Graphics Lab
>>                        http://www.cgl.ucsf.edu
>> 
>> 
>> On Jan 5, 2015, at 1:33 PM, ros <rodrigogalindo at gmail.com> wrote:
>> 
>> Hello!
>> 
>> I would like to ask for advice and starting directions to be able to
>> parse a new file format in Chimera so I can use Chimera's tools and
>> generate images.
>> 
>> The file format that I want to be able to open is generated from the
>> Atoms in Molecules program AIMAll ( http://aim.tkgristmill.com/ )
>> 
>> The AIMAll program of course can also do visualization and is very
>> good at it.  I am attaching an example of how a molecule looks.  The
>> problem is that if you want to work with big biomolecules (like DNA),
>> the program is not very good to cloak/hide/select atoms so you have to
>> click atom by atom to hide it and make some sense of the
>> visualization.  So, I will try to make a parser (or something that you
>> would recommend) to open the file in Chimera and use Chimera's masking
>> rules to select/deselect, hide/show atoms, which is very powerful.
>> 
>> The text output generated by AIMAll has an XYZ list for each atom like this:
>> 
>> Nuclear Charges and Cartesian Coordinates:
>> -------------------------------------------------------------------------------
>> Atom      Charge                X                  Y                  Z
>> -------------------------------------------------------------------------------
>> C1         6.0           0.0000000000E+00   2.3265459100E+00
>> 0.0000000000E+00
>> C2         6.0           0.0000000000E+00   0.0000000000E+00
>> 1.7647056500E+00
>> C3         6.0           0.0000000000E+00   0.0000000000E+00
>> -1.7647056500E+00
>> H4         1.0           1.6866221200E+00   3.4814514700E+00
>> 0.0000000000E+00
>> H5         1.0          -1.6866221200E+00   3.4814514700E+00
>> 0.0000000000E+00
>> C6         6.0          -2.0148478600E+00  -1.1632729600E+00
>> 0.0000000000E+00
>> H7         1.0          -2.1717143500E+00  -3.2013833400E+00
>> 0.0000000000E+00
>> H8         1.0          -3.8583364700E+00  -2.8006813000E-01
>> 0.0000000000E+00
>> C9         6.0           2.0148478600E+00  -1.1632729600E+00
>> 0.0000000000E+00
>> H10        1.0           2.1717143500E+00  -3.2013833400E+00
>> 0.0000000000E+00
>> H11        1.0           3.8583364700E+00  -2.8006813000E-01
>> 0.0000000000E+00
>> H12        1.0           0.0000000000E+00   0.0000000000E+00
>> 3.8040484300E+00
>> H13        1.0           0.0000000000E+00   0.0000000000E+00
>> -3.8040484300E+00
>> 
>> 
>> That is easy, I think.  But as you can see from the attached image, I
>> want to be able to visualize the green spheres (which are called
>> critical points and represents special properties of the electron
>> density, extracted from quantum mechanical calculations).  Those
>> points are represented in the output file as:
>> 
>> CP# 16     Coords =  5.97894312844235E-20  1.21974356425640E+00
>> -9.60854463947958E-01
>>          Type = (3,-1) BCP C1 C3
>>          Rho =  2.4067790431E-01
>>          GradRho =  3.5016504866E-18 -2.7948129921E-14  1.7716730860E-14
>>          HessRho_EigVals = -4.4278076226E-01 -4.3836581782E-01
>> 3.5682199801E-01
>>          HessRho_EigVec1 =  1.0000000000E+00  0.0000000000E+00
>> 0.0000000000E+00
>>          HessRho_EigVec2 =  0.0000000000E+00 -6.1321358320E-01
>> 7.8991714842E-01
>>          HessRho_EigVec3 =  0.0000000000E+00  7.8991714842E-01
>> 6.1321358320E-01
>>          DelSqRho = -5.2432458207E-01
>>          Bond Ellipticity =  1.0071370222E-02
>>          V = -2.5219393995E-01
>>          G =  6.0556397216E-02
>> CP# 18     Coords =  1.05289204670721E+00  3.04112062239339E+00
>> 1.96757752864282E-18
>>          Type = (3,-1) BCP H4 C1
>>          Rho =  2.9524693796E-01
>>          GradRho =  1.0061396161E-16 -1.6479873022E-16  1.6660693347E-18
>>          HessRho_EigVals = -7.9444808957E-01 -7.8708168641E-01
>> 4.1039750300E-01
>>          HessRho_EigVec1 = -5.7017191910E-01  8.2152539989E-01
>> 0.0000000000E+00
>>          HessRho_EigVec2 =  0.0000000000E+00  0.0000000000E+00
>> 1.0000000000E+00
>>          HessRho_EigVec3 =  8.2152539989E-01  5.7017191910E-01
>> 0.0000000000E+00
>>          DelSqRho = -1.1711322730E+00
>>          Bond Ellipticity =  9.3591342377E-03
>>          V = -3.7782718105E-01
>>          G =  4.2522056404E-02
>> 
>> etc etc etc
>> 
>> First line indicates the critical point number followed by the XYZ
>> coordinate of the point, and the second line shows which atoms are
>> involved between that critical point.  The rest is the electronic
>> properties of the critical point (nothing to visualize there)
>> 
>> So, I am guessing that the critical points can be represented as dummy
>> atoms in Chimera following the XYZ coordinates?
>> 
>> The idea is that first the molecule coordinates are parsed and the
>> molecule is displayed and then display the critical points of each
>> atom.  If possible, show lines joining atoms that have a critical
>> point between them...
>> 
>> I know it is a difficult task, but maybe you can provide some starting
>> directions?  Anything will help because right now is double clicking
>> 1000+ atoms!
>> 
>> Thank you so much and have a good day,
>> 
>> Rodrigo.
> 
> _______________________________________________
> Chimera-dev mailing list
> Chimera-dev at cgl.ucsf.edu
> http://www.rbvi.ucsf.edu/mailman/listinfo/chimera-dev
> 





More information about the Chimera-dev mailing list