Accelrys Materials Studio (MS) is a commercial program, so I think I should be extra-careful writing about it. Let's start with the usual disclaimer: I am not connected in any way with Accelrys and what I write is what I think about Materials Studio (MS) as a sporadic user, and do not reflect in any way the opinion of my laboratory and of the people working there. Being a sporadic user, I honestly cannot tell too much about the use MS, so I will not. Let me just say that I consider MS is a really nice piece of software for certain things, for example the 3D editor is amazing, and a pain for others. Plus, is Windows only. Personally I see MS a product tuned more for the industry than for academic research, where flexibility and portability should be taken in much higher consideration (again, my personal opinion).
There is one aspect in the last versions of MS that is worthy to explore and that can improve tremendously the flexibility of MS: perl scripting. Now it is possible to program in perl within MS, which make possible to use and combine almost all the functions you can access via the graphical interface. Furthermore, perl scripting make finally easy to make MS interact with the "external" world, meaning you can export your results as you prefer and also add new capabilities to MS. I have recently give a small introductory seminar to perl scripting in MS to my colleagues, and I have thought that it could be useful to collect in Chembytes those scripts and those I will make for the next meetings. All the script you will find here are made by me or published with the consent of the author and are free to be used and modified. If for any reason this page is illegal (I cannot see why, but I may be wrong), please contact me and I will procede to remove this page and/or all the illegal contents. Also, please note that the script are made to illustrate some procedures, and are far to be complete, efficient or bug free. Take them as a starting point and backup your data before execute the scripts. I am not responsible for any loss of data due to the use of these scripts. Use them at your own risk!
Let's start: what do you need?
Well, the only thing you need to have installed is MS. That assuming you are not interested in Accelrys pipeline pilot.
I strongly recommend you to get a perl installation also outside MS: perl is free and having a perl installation will let you easily create small script to get familiar with the syntax of perl. In Windows you can install ActivePerl from ActiveState or strawberry perl, as suggested in the Perl's official website.
There is another option though: install the standard distribution of perl (and its modules, if required) via cygwin. This will allows to work in a bash terminal under Windows, that is so much better than the standard Windows consolle.
What you should do writing your code
Comment the scripts, use appropriate and meaningful names for your variables and indent the code. These three requirements will make your code much more easy to understand and eventually modify for anyone (yes, also you).
Materials Studio perl environment
To write a new script, just select script from the File->New menu. You can also open an existing script, with File->Open.
By default, when you create a new perl script, the following lines are present:
#!perl use strict; use MaterialsScript qw(:all);
The use of strict is optional, but I would advise you to keep using it, while the MaterialsScript module is required to access to the MS functionalities.
Numbering the atoms
One of the major problems I have encounter in using MS, is find a way to display a label showing the number in the structure for the atoms. Which is the first atom in the structure? and the last? and if I want to calculate a distance between the atoms 10 and 23, which ones I should select? Sure, you can display the cartesian coordinates and then edit the xtd file and try to figure out which atom is which. This script will modify the atom names as ElementSymbol-N, where N is the position of the atom in the structure. The modified document is not saved by the script, so you can save or save as, if you wish to maintain the original file.
Download the script here
Export a MS xtd trajectory as XYZ trajectory.
This script export a xtd trajectory from MS Forcite module as XYZ trajectory. The script creates two text files in the current directory: xtd2mol.txt, which contains a short log and trj.txt, containing the XYZ trajectory. The extension txt is due to the fact that when you create a document, the format of the document must be recognized by MS, and xyz/xmol are not known formats. Therefore, you will have to deal with .txt extension for your files.
Backup copies of the files, are managed by MS in the usual way, appending (N) to the name of the flle, where N is a progressive number.
Download the script here
use the software and the scripts in this wiki at your own risk. The software is freeware and it come without any (as in nothing, nada, niente, rien) WARRANTY. Therefore I cannot be responsible for loss of data, time, bad results or anything else deriving by the use of my software or this wiki.