Platform: Mac, Mac OS X, Mac Other Category. The GeoViz toolkit is a project derived from the GeoVISTA Studio project.This is alpha quality code, expect things to randomly break, code to be refactored at any time, etc. Explore what makes a reaction happen by colliding atoms and molecules. Design experiments with different reactions. Jmol is one of the best chemical structure drawing software that is based on open-source java viewer. Jmol is an interactive and powerful web browser applet with featured for crystals, chemicals, biomolecules, and materials. This software can conveniently run on Windows, Mac OS X, and Linux/Unix systems. Get this software downloaded online. Lumo requires Mac OS 10.6 or higher, 64-bit processor, and an OpenCL capable compute device. Lumo is routinely run on MacBook Pros and MacBook Airs. For analysis of larger systems, it is recommended to have at least 4GB of system RAM. There is a movie of Lumo in action on the website.
This is the second installment of the Applescript Tutorials for Scientists, one response I got from the first article was to suggest a few reference books or articles.
Getting Started with AppleScript is a comprehensive overview of Applescript that is part of the Apple Developers reference library. I’m not sure if you need to be signed up as a developer to read it but since you can be an online member for free it might be worth signing up.
A gentle introduction to Mac OS X is available from Learning Mac OS X but this does not cover using the Terminal. O'Reilly is a very well-respected publisher of books about UNIX and open source technologies; their 'MacDevCenter' has a great series of hands-on tutorials about Learning the Mac OS X Terminal. There are several advanced features on Discovery Studio Visualizer including the ability to show ligand binding sites in proteins and create a surface around the ligand.- Functionality for building small molecules, and protein and nucleic acid structures. Molecular builder/editor for Windows, Linux, and Mac OS X.-Free, Open Source: Easy to.
There is also the Applescript Users list which gives you access to an extensive network of scripting experts.
The MacScripter website offers a great place to find help, tutorials, scripting additions, etc.
There are also a range of excellent books, a couple that I’d suggest looking at are AppleScript: The Definitive Guide (ISBN 0-596-00557-1) by Matt Neuburg, and AppleScript Handbook (ISBN 0-9744344-9-3) by Danny Goodman.
There is also the excellent built in help which of course we can access with AppleScript 🙂
Open up Script Editor and type:-
Now click “Run” This should open up the Help Viewer application and run a search for “AppleScript”
Applescript and UNIX
Beneath the beautiful Mac OS X interface lies an industrial-strength UNIX system, many of the key UNIX-based scientific applications are now available under Mac OS X. While many users feel very comfortable in the command-line environment AppleScript offers a means to access the UNIX foundations without the need to remember a series of UNIX commands. However as you might expect there are a few things that you you need to be aware of when linking AppleScript and UNIX.
Applescript uses the colon “:” as a separator for directories however UNIX uses POSIX (Portable Operating System for UNIX) file paths in which the slash “/” is used as the directory separator. This could cause obvious problems, however one of the additions to AppleScript 1.8 was the ability to interconvert the two file reference systems.
Open up Script Editor and type/copy :-
The first line allows the user to select a file, the second line converts the file reference to text and then it is displayed. The fouth line converts the Apple file reference to the POSIX path and then displays it. Of course you need to be able to do the reverse translation and the “POSIX file” command converts the POSIX path to a Mac OS X path as shown below.
Here is a very simple example of how this can be used, this takes a Macintosh Path to a folder, converts it to the POSIX path. The script then runs the Shell command “ls” to list the contents of the directory and displays the result.
Whilst this works perfectly in most cases there are a couple of issues you should be aware of, a file or folder name may contain characters which need to be escaped to be passed to a shell command. Use quoted form to get the quoted form of a string. For example if a directory name contains a space.
The default shell for Mac OS X is BASH and I don’t want to get into a debate about the relative merits of the different shells that are available, the important thing to remember when running a “Do shell script” command is that do shell script always uses /bin/sh to interpret your command, not your default shell. So commands that work fine in the Terminal may not work when called using the “Do shell script” command. In addition when you use just a command name instead of a complete path, the shell uses a list of directories (known as your PATH) to try and find the complete path to the command. For security and portability reasons, do shell script ignores the configuration files that an interactive shell would read, so you don’t get the customizations you would have in Terminal. You need to use the full path to the command. Compare the results of these two applescripts:
Should give you something like “/usr/bin:/bin:/usr/sbin:/sbin”
On the other hand this applescript
Will give you the complete PATH as defined in your .profile.
This script gets a list of all the applications in the Applications folder, then finds those applications that contain the capital letter “B”, then sorts them into reverse alphabetical order and displays the result. The “ ” is the pipe command, the pipe command is one of the most important commands in UNIX because it allows us to create powerful functions in a single statement. The pipe command is represented with the character and it is used to gconnecth the output from one command and send it as input to another command. On a Mac keyboard it is on the right-hand side next to the return key.
Here is a fun feature:-
Run this script and then paste into a text editor, (I used BBEdit) and you should see this months calendar. Replace “cal” with “cal 10 1492” and you can see the month in 1492 when Christopher Columbus landed on a Caribbean Island.
Tiger introduced Spotlight, a wonderful searching mechanism that indexes the contents of all the files on your Mac without any effort, it also provides a means to search that information. However you can also search the metadata using UNIX, mdfind provides a command line search interface, we can interact with this using Applescript.
As you might expect as a chemist I have a lot of documents containing chemical information the following script uses mdfind to identify all files that contain the word “ketone’, it displays all the file names and then a count of how many files, too many.
I remember that I downloaded the file I want last week so I can limit the search.
Now I only find two files. OK so I could do that with Spotlight, well download ChemSpotlight and install it. ChemSpotlight is a Spotlight metadata importer plugin for Mac OS X, which reads common chemical file formats (MDL .mol, .mdl, .sd, .sdf, Tripos .mol2, Protein Data Bank .pdb, Chemical Markup Language .cml, and XYZ) using the Open Babel chemistry library, it then adds molecular formulas (complete with subscripts in the Finder), molecular weight, and a variety of other chemical information.
Now if we modify the mdfind script as shown below, this script now searches your hard drive for all chemical structure files that contain a molecule with a molecular weight less that 250.
ChemSpotlight adds a variety of metadata as shown in the table below, all of which can be searched using mdfind.
Metadata Field Notes
net_sourceforge_openbabel_Chirality True/False (1/0)
net_sourceforge_openbabel_Dimension 0D/2D/3D depending on the coordinates found
net_sourceforge_openbabel_DisplayFormula Formula with subscripts for Finder gGet Infoh windows
net_sourceforge_openbabel_Formula Chemical formula in standard gHill Orderh
net_sourceforge_openbabel_Mass Standard molecular weight in a.m.u. (g/mol)
net_sourceforge_openbabel_ExactMass Molecular mass of most common isotopes for mass spectra
net_sourceforge_openbabel_NumAtoms Number of atoms in the molecule
net_sourceforge_openbabel_NumBonds Number of bonds in the molecule
net_sourceforge_openbabel_NumMols Number of molecules in the file
net_sourceforge_openbabel_NumResidues Number of biomolecule residues
net_sourceforge_openbabel_SMILES Daylight SMILES string for this molecule
net_sourceforge_openbabel_InChI IUPAC/NIST canonical identifier
net_sourceforge_openbabel_Sequence Biomolecule residue sequence
This is the mechanism by which iBabel searches chemical information, of course iBabel was built using Applescript Studio which allows the construction of rich user interfaces, and hopefully that will be the subject of a future tutorial. However we can use Applescript to provide a limited user interface, the following script asks the user to choose a file, it then uses the UNIX commandline tool OpenBabel to convert the file to the format chosen in the second dialog box and then saves it to the desktop. You will need to have installed OpenBabel or better/easier ChemSpotlight. You could have yet another dialog box asking to choose where to save the file but I think you can see why Applescript Studio would be a better option.