[chimera-dev] Extension to export VTK format files

Tom Goddard goddard at sonic.net
Wed Aug 7 10:46:05 PDT 2013


Hi Shawn,

  The solvent excluded surfaces produced by the surface command or menu Actions / Surface / Show are instances of Python class MSMSModel defined in share/MolecularSurface/msurf.py.  They are a subclass of SurfaceModel and the only type of Chimera surface which has a direct association between surface vertices and nearest atoms.  That association is given by s.atomMap which maps vertex number (0 based) to Python atom object.

  The MultiScale surfaces are a plain SurfaceModel.  I'd suggest adapting your current code to use


           for piece in m.surfacePieces:
		if hasattr(m, 'surfacePieceAtomsAndBonds'):
		   atoms, bonds = m.surfacePieceAtomsAndBonds([piece], create = False)
		   # Now export associated atom (closest among atoms) for each vertex.
		   …
                # Now add triangles for surface piece even if it has no associated atoms


  I didn't study your code closely but it seems you will handle molecules that belong to multiscale surfaces twice.  Not sure if that will create duplicates in your vtk output.

	Tom


On Aug 6, 2013, at 5:30 PM, Shawn Waldon  wrote:

> Hi Tom,
> 
> Thanks for the feedback.  I wrote my code mainly to work with Multiscale models, but I was trying to use an interface that would also work on surfaces generated by the surf command.  Apparently I failed to test that last one adequately since I was assuming that Multiscale models with a resolution of 0 produced not only the same surface but also the same type of datastructure.
> 
> What is the best way to get the molecule information (or tell if it exists) for the other kind of surface?
> 
> I'll start working on the things that you've pointed out.
> 
> Thanks for your help,
> 
> Shawn
> 
> 
> On Tue, Aug 6, 2013 at 4:30 PM, Tom Goddard wrote:
> Hi Shawn,
> 
>   If I export VTK with a surface open the export code throws an error.  For instance use command "shape sphere" to make a surface, or make a surface of a PDB model with Actions / Surface / show, then try export vtk.  Not sure your code that handles surface pieces is intended to work with, maybe Multiscale surfaces?  The surfacePieceAtomsAndBonds() method is not present for most surfaces.  Then your code only looks at the first atom (assumes the atom list is non-empty), and writes data associating all atoms of the molecule with the surface.  That will be wrong for multiscale models with more than one chain because you will associate all atoms of all chains to the surface piece for each chain.
> 
>   This stuff will need to be fixed so the code doesn't throw errors whenever a scene is exported with a surface.
> 
> 	Tom
> 
> 
> 
> On Aug 6, 2013, at 12:19 PM, Shawn Waldon  wrote:
> 
>> Hi Tom,
>> 
>> Here is a picture of what I get when I follow your directions and open the file with Paraview.  Did you hit apply on the left after open created the data source?  Paraview is a little funny about opening things, it allows you to set up parameters on the reader (not relevant for .vtk files) before actually reading the data.  You have to click the apply button on the left before the data is actually read in.  The other thing I changed was the Color by dropdown on the left to color by the position along the protein chain with a red-to-blue color map (essentially the equivalent of chimera's rainbow command, but with Paraview's default color map).  This is impossible with VTK's PDB file reader which throws away all information about the atoms and just keeps the points and lines for the bonds connecting them.
>> 
>> Shawn 
>> 
>> 
>> On Fri, Jul 26, 2013 at 8:06 PM, Tom Goddard  wrote:
>> Hi Shawn,
>> 
>>   I opened PDB 1idi, used your code to export it to VTK, and opened it in Paraview 4.0.1 on a Mac.  Couldn't get it to show anything.  I don't know Paraview and that is probably the issue.  Could you tell me something I could do with this Chimera VTK export?  I'd like to have an idea of what it is good for before putting it into Chimera.
>> 
>> 	Tom
>> 
>> 
>> On Jul 26, 2013, at 11:45 AM, Shawn Waldon  wrote:
>> 
>>> Hi Tom,
>>> 
>>> Here is the export code (and the ChimeraExtension.py file).  Let me know if there is anything that needs fixing.
>>> 
>>> Shawn
>>> 
>>> 
>>> On Fri, Jul 26, 2013 at 1:15 PM, Tom Goddard  wrote:
>>> Hi Shawn,
>>> 
>>>   The SketchBio project looks cool.  We are trying to make it easy to build hypothetical models of hiv, muscle sarcomeres, fibronectin and all manner of large molecular machinery in Chimera.  It is a difficult user interface problem.  Graham Johnson, Sam Hertig and I are trying to move this project along.  We are happy to help your efforts on this problem.
>>> 
>>>   Can you send us your Chimera VTK export code and I'll take a look.  We don't have a list of coding conventions.  I don't really care how you indent your lines, or capitalize your variable names.  Mostly I want the user to know when an error occurs what the nature of the problem is (e.g. export can't handle surfaces) without having to ask us.
>>> 
>>> 	Tom
>>> 
>>> 
>>> 
>>> On Jul 25, 2013, at 1:32 PM, Shawn Waldon wrote:
>>> 
>>>> Hi Tom,
>>>> 
>>>> I don't know exactly how high quality it is.  I haven't found any bugs in my latest version, but that doesn't mean they aren't there.  I am fairly new to python, so there may be some subtleties that I missed.  Also, do you have coding conventions listed somewhere?  I have looked, but I haven't found an official list or anything.  I am willing to fix it up a bit before submitting it if you can point me to a list of things to fix up.
>>>> 
>>>> My use case is that I am writing a higher level modeling tool that uses VTK to do its graphics.  I have been calling Chimera as a subprocess to get a surface to render (and now other data).  See the project website for more details: http://www.sketchbio.org
>>>> 
>>>> Shawn
>>>> 
>>>> 
>>>> On Tue, Jul 16, 2013 at 10:49 PM, Tom Goddard  wrote:
>>>> Hi Shawn,
>>>> 
>>>>   That is interesting.  We could put it in Chimera if the code is solid.  The error reports will come to us so we need high quality code so we have time to do more than reply to bug reports.
>>>> 
>>>>   What use of molecules in VTK motivated you to write this export code?
>>>> 
>>>>     Tom
>>>> 
>>>> 
>>>> On Jul 16, 2013, at 11:30 AM, Shawn Waldon wrote:
>>>> 
>>>>> Hello all,
>>>>> 
>>>>> As part of a project that I am working on, I recently wrote an extension for Chimera that exports the scene as a .vtk file which can be read into the Visualization Toolkit or Paraview.  It exports atoms (points), bonds (lines) and surfaces along with other data associated with them such as the atom and residue names, residue number, position along its chain, b-factor, occupancy, etc. in a format that can be used in VTK-based applications with the default file readers.  I think this could be a good thing to add to Chimera itself, so I was wondering if you would like to have the code for the extension to add to Chimera itself.
>>>>> 
>>>>> I look forward to hearing from you,
>>>>> -- 
>>>>> Shawn Waldon
>>>>> Graduate Research Assistant
>>>>> Department of Computer Science
>>>>> University of North Carolina at Chapel Hill
>>>>> 
>>>>> _______________________________________________
>>>>> Chimera-dev mailing list
>>>>> Chimera-dev at cgl.ucsf.edu
>>>>> http://www.rbvi.ucsf.edu/mailman/listinfo/chimera-dev
>>>> 
>>>> 
>>>> 
>>>> -- 
>>>> Shawn Waldon
>>>> Graduate Research Assistant
>>>> Department of Computer Science
>>>> University of North Carolina at Chapel Hill
>>>> 
>>> 
>>> 
>>> 
>>> 
>>> -- 
>>> Shawn Waldon
>>> Graduate Research Assistant
>>> Department of Computer Science
>>> University of North Carolina at Chapel Hill
>>> 
>>> <ExportVTK.zip>
>> 
>> 
>> 
>> 
>> -- 
>> Shawn Waldon
>> Graduate Research Assistant
>> Department of Computer Science
>> University of North Carolina at Chapel Hill
>> 
>> <Screen Shot 2013-08-06 at 3.19.09 PM.png>
> 
> 
> 
> 
> -- 
> Shawn Waldon
> Graduate Research Assistant
> Department of Computer Science
> University of North Carolina at Chapel Hill
> swaldon at cs.unc.edu

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-dev/attachments/20130807/c605b249/attachment.html>


More information about the Chimera-dev mailing list