http://www.edcenter.sdsu.edu/repository/Mbcw/pdb2vrml.html
PDB to VRML 2.0 File Converter
 
Here at the Edcenter we have the luxury of operating on 3 platforms (PC, MAC and UNIX).  The PDB to VRML 2.0 File Converter has only been created for use in UNIX.

Examples of PDB to VRML File Conversion

All the software necessary for file conversion:

  • You can download (.pdb) molecular files from the Protein Data Base:

  • or
    If you have Chime 2.0 you can directly save the molecules you are viewing. (see tutorials)
  • After downloading installing the PDB to VRML Converter onto the UNIX Machine you are ready to convert the file.  The molecule has to be incorporated into a Perl script, which happens to be the choice of language that the creator programmed in. If you don't know perl, don't worry, the changes that need to made are simple:
  • In the directory of the converter that you downloades there should be a file: "test.pl"  Which looks as follows:

      use PDB2VRML;

      $pdb = PDB2VRML->new();

      $pdb->readPDB( 'filename.pdb' );
      $pdb->centerAtom();
      $pdb->genBonds();
      $pdb->setStyle( 'BallAndStick' );
      $pdb->setColor( 'byAtom' );
      $pdb->printVRML();

    The "filename.pdb" entry is the name of the (.pdb) file that you want to convert over so just change that line to the desired and then save the file as "filename.pl".  The (.pl) is the file extension of a Perl file.  After that just make the following entry on the command line at the promptto convert over to VRML 2.0 (.wrl):

    >> perl filename.pl > filename.wrl

    The filename that you call the VRML file is arbitrary and only stated like it was for simplicity.  You now have a VRML version of the molecule on your UNIX platform.  If you want to view the file in Windows or Macintosh then all you have to do is FTP it over.
     

  • As you can see, from the function calls in the Perl Script above, you can also change the visual representation of the molecular structure including Style, Color, etc.

  •  
     
    FUNCTIONS
    new()  
    Creates a new and empty converter object. 
         $pdb1 = PDB2VRML->new(); 
         $pdb2 = $pdb1->new();
    readPDB()  
    Reads all atoms and connects from the given PDB file. The subroutine returns 'undef' on error. Currently only the ATOM, HETATM, and CONECT records are read. 
         $pdb->readPDB( 'fileName' ); 
    printVRML()  
    Prints the molecular structure in the current style in the VRML format on <stdout>. 
         $pdb->printVRML(); 
    centerAtoms() 
    Shift the molecules center of geometry into the origin of the coordinate system. 
         $pdb->centerAtoms(); 
    genBonds() 
    Create additional bonds between the atoms. A maximum distance for the 2 atom types of a potentially connected atom pair is computed. If the actual distance is shorter, a new bond is created. The algorithm applied distributes the atoms over a 3D grid. Therefore, the order of the generated bonds is not very deterministic. 
        $pdb->genBonds(); 
    setStyle() 
    Sets the style for the VRML representation of the molecular structure. Default is 'Wireframe'. Currently supported styles are: 
        Wireframe, BallAndWire, 
        Stick, BallAndStick, CPK 
        $pdb->setStyle( 'Wireframe' ); 
    setColor()  
    Set the overall color of the molecular structure. If the color is set to 'byAtom', the color the for atoms and bonds is defined by the atom type. Default is 'byAtom'. Currently supported colors are: 
        byAtom, yellow, blue, red, green, white, brown, grey, purple 
        $pdb->setColor( 'blue' ); 
    setStickRadius()  
    Defines the radius in Angstrom for the cylinders in the 'Stick' and 'BallAndStick' style. Default is 0.15 . 
        $pdb->setStickRadius( 0.15 ); 
    setBallRadius()  
    Defines the factor which is multiplied with the VDW radius for the spheres in the 'BallAndWire' and 'BallAndStick' style. Default is 0.2 . 
        $pdb->setBallRadius( 0.2 ); 
    setCompression() 
    Turns on/off compression of the output. If turned on, all leading whitespaces are removed. This produces a less readable but approx. 20% smaller output, the speed is increased by 10% as well. 
        $pdb->setCompression( 1 );