Skip to main content

Posts

Molecular Dynamics

The two words in the title literally means: Molecular : of or relating to molecules Dynamics : the pattern or history of growth, change, and development in any field Thus Molecular Dynamics tells you about a pattern or history of growth, change and development of molecules in any environment. It is a computational method which allows one to understand time dependent movement of atoms and molecules. These movements of molecules are predicted based on the Newton's law of motion. The resulting forces on these atoms and molecules and their potential energy are defined with the help of different molecular mechanics force fields. The Force fields consists of defined parameters like bond length, bond angles, torsions, Vander Waal forces etc. These force fields are specific for the kind of molecules treated. Thus, the force fields vary in nature depending on the parameters included and the type of target molecules. So, it is always advisabl...

Combining boxes of different solutes

Returning to xleap again. The box I require this time has little tricky requirements. 1) The box should satisfy the molarity ratio for the solute: solvent. 2) Should be big enough that QMMM calculations can be carried out easily 3) combine sets of molecule-pairs which are interconvertible following a proton transfer. I have a pair of molecules say p(H)--i which can be converted to another set called P--I(H) following a proton transfer from p to i.So, p(H)--i <---> P-I(H) To fulfill condition (1), I initially created one molar box for p(H)--i called "PIN" and other box for P--I(H) called "PII" For condition (2) and (3), I created a bigger box with 7 PIN and 1 PII boxes. The idea is: after proton transfer from I to P, during the QMMM calculation, P--I(H) pair coming from "PII" should convert to p(H)--i pair like other pairs from "PIN" and the whole box should become homogeneous with 8 p(H)--i pairs. We begin with: PIN with ...

Using Dictionary to edit ptraj input file

Recently I have been working on Linear combination of Distance (LCOD). One has to extract a set of structures (may vary from 100 to 1000 to any bigger number depending on requirement, accuracy) from a very long trajectory. If one is looking for very specific orientation, then it is necessary to go through the whole trajectory and choose the required frames and select that geometry, which is very tedious and time taking job. But more often a random selection from the trajectory is done to take care of all the diversity in the trajectory. In Amber, one can use ptraj to select a frame from trajectory and created its restart file to launch LCOD calculation. To launch such 100 or 1000 calculation one need to modify or create 100 or 1000 such input files to feed to ptraj with the frame number and the name of the restart file. I am using a dictionary in python to do so. Beginning with 2 lists: one having frame numbers to be selected another with name of the restart files correspondin...

Column subtractor - Python

I am still struggling with the after effects of Linux reinstallation on my system. Two major problems: 1) Firefox and openoffice is still not in English. Its giving me hard time. 2) The functions in openoffice  version of excel is not working. I am yet to sort that out. In the mean time, I desperately needed it to do simple task. subtracting values of one column from one in another column and write the difference in next column. So, I had input in this form: ------------------ 0    2.179139    0.951816 1    2.314531    1.006480 2    2.191692    0.951938 3    2.079704    0.952747 4    2.092761    0.939545 5    2.362056    0.984791 6    2.153595    0.957934 7    2.213173    0.951768 8    2.175687   ...
For some reason our administrator decided to update OS of my desktop. He installed latest version Ubuntu 11.10. My first impression was not very good. I did not find it userfriendly. Main problem is accessing different windows you open. Say, you open a firefox window with many work related tabs opned in it. This window will minimize to the left sidebar under firefox icon that also is the desktop icon to access firefox. Now, if you want open another firefox window which should have pages not work related but say personal like gmail or youtube, you click on the same icon. Instead of what you wish, the same firefox window with work related pages which you minimized few moments back reappears. So, to distinguish work related pages from personal pages is not so stright forward. One option is you open your personal page in one of the tabs in work related firefox window and then drag and drop that tab out of the window. Then it allows you to have another firefox window. But why is needs...

Gnuplot to plot histogram

GNUPLOT can be used to generate histograms. The script below allows one to plot variations in angle from 0° to 180°. Each histogram box width correspond to 3° (covered here under bw option). To execute this script; type this in the terminal: gnuplot histogram.p You should be in the folder where below script is saved in a file name "histogram.p" and a dat file (here, it is N---H-O.dat) should be present. histogram.p ------------------ set term gif set output "angle_N---H-O.gif" set xrange [0.0:180.0] set boxwidth 2.0 absolute set style fill solid 1.0 border -1 set xtics 10 set title "molecule 3.0A Angle N---H-O" set ylabel "occurance" set xlabel "angle" bw = 3   # substitute what you want bin(x,width)=width*floor(x/width) plot 'N---H-O.dat' using (bin($2,bw)):(1.0) smooth freq with boxes ------------------ The dat file is an input file with data in the format: 0    23.680344 1    73.766251 2    67.4...

Editing multiple files simultanoeusly

I needed to delete all the lines in a set of files except for for the first forty. Since the number of files was big, I used this script in python to do the job: -------------------------------- !/usr/bin/python #script to read files and delete lines import os listing=os.listdir(" /home/kjoshi/Documents/PY/useful/file_edit ") for infile in listing:  print infile  if infile == "files_line_delete.py":    print "This is NOT a good file"  else:   fi=open(infile).readlines()   fo=open(infile +'_output','w')   del fi[40: ]   fo.writelines(fi) --------------------------------- Task is simple. Keep all the files needed to be edited in one folder along with this script. Substitute the path shown in bold with proper path of your folder. Using command $python files_line_delete.py you get output files with each file having first forty lines.