Wednesday, June 20, 2012

Subsetting in R

Following are some example of subsetting in R I have used recently.


> head(crystal)
    V1     V2      V3      V4
1 1ACJ PHE120 290.980 289.101
2 1ACJ PHE153 307.673 283.814
3 1ACJ PHE155 296.153  89.152
4 1ACJ PHE186 311.606 292.186
5 1ACJ PHE187 298.920 270.613
6 1ACJ PHE197  66.678 323.351

>subset(crystal, crystal$V2=="PHE330" & grepl("^2A",crystal$V1))

http://www.ats.ucla.edu/stat/r/faq/subset_R.htm
http://stackoverflow.com/questions/2125231/subsetting-in-r-using-or-condition-with-strings

Monday, June 11, 2012

Charmm2lammps

Charmm2lammps.pl is a useful little code which takes in forcefield [top/par], psf and pdb files in Charmm format and converts them to Lammps data and sample input file. This is extremely useful for running simulations in the much better written MD code, LAMMPS. While trying to simulate a polymer chain I came across a very interesting feature in charmm2lammps; it really expects the force constant in the forcefield parameter file to be non-zero. This works just fine when you never want to specify angle/dihedral parameters to free chains. But when you want to control the parameters in between runs, it is a good idea to define all the angle and dihedrals and then decide to turn them off/on in LAMMPS by setting the force constant to 0/nonzero.

Sunday, June 10, 2012

Compiling C programs on Ubuntu

On Ubuntu, it turns out, this does not work
gcc -lm code.c
but this does
gcc code.c -lm