Tuesday, June 16, 2009

DNA 2



fig 1. The pdbReader.mel interface with the DNA pdb file loaded.

The interface has a sample row from the PDB you're loading. Below this are fields for you to enter the atomic symbol and the X, Y, and Z coordinates of the atoms in the file. There are default numbers in these fields, but you may have to change them depending on how the particular PDB file you're using has been written. It's safe to assume that the default numbers are NOT correct for your file. The simplest way to figure out what to put into these fields is to count over from the left in the example row and plug in the appropriate coordinates. So our example would look like this:

ATOM 5 O5* C A 1 18.935 34.195 25.617 1.00 64.35 1BNA 6
1 2 3 4 5 6 7 8 9 10 11 12 13

Weird spacing can make it a bit tricky to tell where one column ends and the next begins. Be prepared to try this a few times before you get it right.

In this example row, the atom is column 3 (O for oxygen), and the X, Y and Z coordinates are columns 7, 8, and 9, respectively.

How do I know that the atom is in column 3 and not column 4? After all, "C" could stand for carbon. In this case, I've looked at the rest of the PDB file and noticed that column 4 contains ONLY "C","G","A", or "T". Since this is DNA we're dealing with, I surmised that the author of the file is using these symbols to indicate base pairs (Cytosine, Guanine, Adenine, and Thymine, respectively) and not atomic symbols. Therefore, I guessed that O5* stands for a particular oxygen atom in the structure. A little background info on your molecule's structure can go a long way in figuring this stuff out (as well as quite a bit of trial and error). Getting the right numbers into the right fields is the hard part; the rest is easy.

You can adjust the number of sections and spans in the spheres pdbReade.mel will create with the fields at the bottom of the interface. However, it's best to keep the resolution of the spheres as low as possible. If it's a big model, you don't want to bring your machine to a grinding halt because each of the 3,000 or so spheres has 8 sections and 16 spans.

Try running the script with our DNA pdb file loaded and see what happens. Type "3" in the Atom Field and "7," "8," and "9" in the X, Y, and Z fields. Make sure you hit enter after you put each of these values in. Occasionally, I've typed in the correct number, forgotten to hit enter, and gotten very strange results.

If you look at the original PDB file you may find a group of rows at the end of the file that start with "HETATM". The script can read these rows but you may notice that the columns are shifted and thus the numbers the script are using for X,Y,and Z, are now off. The best way to fix this is to cut and paste these rows into another file and save that as a separate PDB which you can add to the scene once you have the molecule loaded. You may not need or want this data, ask you local science nerd if you're not sure. The DNA PDB file we're using for this example does not have these rows.

Go ahead and run the script.

Calculating the molecular structure can take some time if it's a big model. Even on a fast machine, I've waited up to 5 minutes while it was building the molecule. This particular DNA structure is not big, so it should be quick.



fig 2: DNA successfully loaded into Maya as NURBS spheres.

Once it's done, you may see nothing on your screen. The molecule may be very large and behind the camera, so zoom out to see if there is something there or not (Shift-A will focus the camera on the whole scene, of course).

If you look in the outliner, you'll see that the spheres are arranged in groups according to atomic symbol (nitrogen, carbon, oxygen, hydrogen and phosphorus). A phong shader has been automatically created and assigned for each type of atom. Congratulations - you've got your DNA. Save the model as dna1.mb, and now let's have some fun with it.



fig 3: The Outliner shows the atoms in groups.

Part Two: Space Filling Models Using Particles

There are several ways scientists represent molecular structure. These include wireframe, stick, ball and stick, space-filling, ribbon, and backbone. If you open a PDB file in Chime or one of the other PDB displaying programs I've mentioned, there are usually display modes that allow you to chose from one of these types of representations. The pdbReader.mel script only brings molecules in as spheres, which is pretty close to the space-filling representation. There are no options for adding sticks or for an alternative representation. In this section, I'll show you how to convert the model into a particle object which you can then render as blobby surfaces. Later, I'll talk about another script you can use that will generate bonds between the atoms if you need to create a "ball and stick" version of the model.

Save your file as dna2.mb and make sure you have downloaded and installed the jPivToParticle script from www.highend3d.com (under the MEL scripts section>dynamics/FX) in your scripts directory. Select all the groups in the outliner and ungroup everything so that the outliner lists all the spheres in the model. Select them all and then type in the command line jPivToParticle "DNA_"; . The script will take a moment to run. It will rename all the spheres DNA_1, DNA_2, DNA_3, etc. and will add a particle object. The script places a particle at each of the pivot points for all the spheres. Select all the NURBS spheres and either hide them or delete them. Save this file, and then save it again as dna3.mel. We want to have one version of the model saved at that last stage.



fig 4: DNA as blobby surfaces

Center the pivot and move the object to the center of the grid. Scale it down a bit if you want to. I'm fond of rendering my molecule particle objects as a blobby surfaces. To do this, set the particle render type to blobby surface and hit the "Add attributes for current render type" button in the attribute editor for the particle shape node. Play with the radius and threshold attributes until you get something you like.

One trick I like is to add a radiusPP attribute and then write a short creation expression to randomize the per-particle radius. To do this, go to the attribute editor for the particle shape node, scroll down and hit the "General" button under "Add Dynamic Attributes." In the dialog box, choose the particle tab and select radiusPP from the list. In the particle shape node per particle array attributes list in the attribute editor, you'll now see a new field for radiusPP. Right-click on the field and choose "Creation expression." In the expression editor, type an expression like particleShape1.radiusPP=rand(.5,1.5);. If you rewind and play the animation a bit you should see a randomization of the sizes of the particles. If you include this technique in an animation, just remember to render starting on frame 1 or higher instead of 0 so you don't have any weird resizing at the beginning of the animation.

This technique spices up the look of the model. But it also (artistically) compensates for the fact that by using the jPivToParticle script to turn the model into a single particle object, we've lost the relative sizes of the individual carbon, hydrogen, phosphorus, and oxygen atoms. We've also lost the individual shading for the atoms as well. What this means is that we've reduced our technical accuracy for the sake of aesthetics, but in some cases that might be OK (depending on what you're trying to show in your animation). Adjusting the threshold on the blobby surface render attributes will add that blobby look; when combined with an interesting shader and some lighting effects, this can yield some cool (but less accurate) results.



fig 5: DNA as a single particle object, rendered as blobby surfaces.

No comments:

Post a Comment