Skip to main content

Posts

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.

Creating multiple folders and subfolders

The task was to create a set of folders say 1,2,3,4 and in each of these four folders create four sub folders. Thus 16 folders were to be created and in each of these 16 folders a common set of files were to be copied. I used c shell scripting to do the job. I needed two lists. One list for primary folders list1: 1 2 3 4 and another list for the subfolders. list2: 5 6 7 8 It worked as: ------------------- bash-3.2$ csh r410comp2% r410comp2%foreach f (`cat ../list1`) foreach? echo $f foreach? mkdir "$f" foreach? cd "$f" foreach? foreach g (`cat ../../list2`) foreach? echo $g foreach? mkdir "$f"_"$g" foreach? cd "$f"_"$g" foreach? cp /home/kjoshi/W/work/complex/2_ion/umbrella/6/6_75/u_6_75.in . foreach? cp /home/kjoshi/W/work/complex/2_ion/umbrella/6/6_75/amber11_intel_ref_md . foreach?cp /home/kjoshi/W/work/complex/2_ion/umbrella/6/6_75/2_ion.inpcrd . foreach?cp /home/kjoshi/W/work/complex/2_io...

Column exchange script in Python

This script allows one to exchange two columns in a file.And it do so for all the files in a directory. The python script is : ---------------------------- #script to read and execute column exchange for all files in the directory import os listing=os.listdir(" /home/K/Documents/PY/column_exchange ") for infile in listing:  print infile  if infile !="column_interchange_script.py":   fi=open(infile).readlines()   fo=open(infile +'_output','w')   space="   "   for line in fi:    first,second=line.split()    fo.write('%s%s%s\n'%(second,space,first))  else:    print "This is not interesting file"     ----------------------------------------------------    Some expert might simplify it a lot more, but for new python user like me, this is a big leap. So, how does it work: Create a directory where in all the files for which column exchange need to be done are stored. Kee...

xleap to generate prmtop and inpcrd files

Now that we have the lib file with the information for all the molecules we need to include and also the corresponding combined pdb file, creating prmtop and inpcrd files should not be a difficult task. So, to begin with we have a lib file name: molecule.lib a pdb file for 4 molecules name: four.pdb The  task is to generate a prmtop and inpcrd file. Initiate xleap using: $AMBERHOME/exe/xleap -s -f $AMBERHOME/dat/leap/cmd/leaprc.ff99 In xleap window > source leaprc.gaff # load the lib file by: > loadoff molecule.lib I am not sure but some times it helps to also load the frcmod files we created for the four molecules the information of which is stored in the lib file. > loadamberparams aldehyde.frcmod # Load the pdb file: > P=loadpdb four.pdb You should see some thing like this in the xleap window now: ------------------- > P=loadpdb four.pdb Loading PDB file: ./four.pdb Warning: name change in pdb file residue 1 ;  this residue i...

Using Packmol

Packmol is a software that allows you to generate a single combined PDB file for all the molecules you are considering. It is a free software and can be downloaded from this link: http://www.ime.unicamp.br/~martinez/packmol/ The installation guide is also provided on the page and its really easy to follow. http://www.ime.unicamp.br/~martinez/packmol/ You can also find some examples but I tried on my own. Anyway what you need is an input file which looks like: ------------------ tolerance 2.0 output trial.pdb add_amber_ter filetype pdb structure 2a.pdb   number 1   inside cube 0. 0. 0. 10. end structure structure 2d.pdb   number 1   inside cube 0. 0. 0. 10. end structure --------------------------------- IT includes some information like: how close the molecules considered can be.(tolerance) name of output pdb file "add_amber_ter" adds term "TER" after every molecule thus defining the start and end of every molecule. After mentioning the...

Rigorous method to create lib file

Sometimes you totally fail to go ahead with the prepin and frcmod files you have generated from the newly generated PDB file even after you follow the procedure given in previous two posts. And you keep wondering? In such a case you need a more detailed procedure. First take a look at the pdb file. For example: Here is one such pdb file generated from the gabedit that troubled me for some time. --------------- HEADER    PROTEIN COMPND    UNNAMED AUTHOR    GENERATED BY GABEDIT 2.3.8 at Tue Jul 26 16:53:48 2011 ATOM  1      C   C     1       -2.907  -0.997  -0.385  1.00  300.00          C 0.0000   ATOM  2      N   N     1       -2.060  -0.981  -1.189  1.00  300.00 ...