Wednesday, November 20, 2013

perl and bash scripts

killjobs.sh
for ((i=1082042;i<1082096 br="" i="">do
qdel $i.login1
done

echo "all jobs done!"
---------------------------------------------------------------------------

makefile.sh
i=0

for ((i=0;i<20 br="" i="">do
mkdir ch3oh-o2$i
cat inputpart1 o2part$i inputpart2 >> input-o2-$i
cat inputpart1-pro o2part$i inputpart2 >> input-o2-$i-pro
mv input-o2-$i ch3oh-o2$i/input
mv input-o2-$i-pro ch3oh-o2$i/input-pro
cp cpmdrun.pbs plumed.dat plumed-pro.dat ch3oh-o2$i
done

#for ((i=0;i<10 br="" i="">#do
#cd ch3oh-oxy$i
#qsub cpmdrun.pbs
#cd ..
#done

rm o2part*
echo "all jobs done!"
--------------------------------------------------------------------------------------------
read-o2.pl

#! /usr/bin/perl -w
my @line=0;
my $i=0;
open FILE1, "20noatomo2methanol.xyz" or die $!;
@line=;
for ($i=0;$i<20 br="" i="">open FILE2, "> o2part$i";
print FILE2 $line[2*$i];
print FILE2 $line[2*$i+1];
close FILE2;
}
close FILE1;
------------------------------------------------------------------------------------------------------


use-findall.sh

i=0
mkdir all-fourfiles
for ((i=0;i<4 br="" i="">do
./find-1214161820.pl ch3oh-o2$i/production/TRAJEC.xyz
mv requiredTimestepsCordinates.xyz all-fourfiles/coordinate$i.xyz
done


echo "all jobs done!"
------------------------------------------------------------------------------------------------------

sum_wham.sh

#!/bin/bash


metafile=wham_metafile
fesout=fes.out

rm -rf $metafile $fesout
points=1000  #there are 500 points/COLVAR, we'll not count the 1st 50 for equilibration.

## important note!  Umbrella sampling uses a potential like
##  V = 1/2 kappa (CV - CV(0))^2 but UWALL/LWALL don't have the 1/2 in there. So if you are using
##  UWALL/LWALL to do your umbrella sampling, then you need to multiply your K value by 2!

for file in shortp? longp? longp??; do


tail -n $points $file/COLVAR | awk '{print $1,$2}' > $file/whamcv;

## get kappa value - multiply by 2
kappa=`grep UMBRELLA $file/plumed.dat  | head -n 1 | awk '{print $5}'`
## get umbrella center
PV=`grep UMBRELLA $file/plumed.dat  | head -n 1 | awk '{print $7}'`
echo $file/whamcv $PV $kappa >> wham_metafile
done;

first=`sort -n -k2 wham_metafile | awk '{print $2}' | head -n 1 `
last=`sort -n -k2 wham_metafile | awk '{print $2}' | tail -n 1 `
num=`wc -l wham_metafile | awk '{print $1}'`
tol=$1


wham $first $last $num 0.0001 300 0 $metafile $fesout$tol

--------------------------------------------------------------------------------------------------
read-operate.pl ! to generate the z direction small changes




#! /usr/bin/perl -w
use warnings;
use strict;

my $i=0;

my @total;
my @data1;
my @data2;
my @data3;
my @data4;
my @data5;
my @data6;

open FILE, 'cgeo.xyz' or die "without such a file, $!";
while () {
$total[$i]=$_;
$i++;
}

#print $total[0];

@data1=split /\s+ /, $total[0];
@data2=split /\s+ /, $total[1];
@data3=split /\s+ /, $total[2];
@data4=split /\s+ /, $total[3];
@data5=split /\s+ /, $total[4];
@data6=split /\s+ /, $total[5];

#my $test=pop @data1;

#print scalar $data1[1];
#print scalar @data1;

for($i=1;$i<61 file="" i="">

$data1[3]=$data1[3]+0.0529;
$data2[3]=$data2[3]+0.0529;
$data3[3]=$data3[3]+0.0529;
$data4[3]=$data4[3]+0.0529;
$data5[3]=$data5[3]+0.0529;
$data6[3]=$data6[3]+0.0529;
open DATA, ">clongp$i";
print DATA "@data1\n";
print DATA "@data2\n";
print DATA "@data3\n";
print DATA "@data4\n";
print DATA "@data5\n";
print DATA "@data6\n";
close (DATA);
}

@data1=split /\s+ /, $total[0];
@data2=split /\s+ /, $total[1];
@data3=split /\s+ /, $total[2];
@data4=split /\s+ /, $total[3];
@data5=split /\s+ /, $total[4];
@data6=split /\s+ /, $total[5];

for($i=1;$i<11 file="" i="">

$data1[3]=$data1[3]-0.0529;
$data2[3]=$data2[3]-0.0529;
$data3[3]=$data3[3]-0.0529;
$data4[3]=$data4[3]-0.0529;
$data5[3]=$data5[3]-0.0529;
$data6[3]=$data6[3]-0.0529;
open DATA, ">clongp-$i";
print DATA "@data1\n";
print DATA "@data2\n";
print DATA "@data3\n";
print DATA "@data4\n";
print DATA "@data5\n";
print DATA "@data6\n";

close (DATA);
}




#print @total;
#print "@data1";
$i=0;
open FILEH, 'hgeo.xyz' or die "without such a file, $!";
while () {
$total[$i]=$_;
$i++;
}

#print $total[0];

@data1=split /\s+ /, $total[0];
@data2=split /\s+ /, $total[1];
@data3=split /\s+ /, $total[2];
@data4=split /\s+ /, $total[3];
@data5=split /\s+ /, $total[4];
@data6=split /\s+ /, $total[5];

#my $test=pop @data1;

#print scalar $data1[1];
#print scalar @data1;

for($i=1;$i<61 br="" i="">$data1[3]=$data1[3]+0.0529;
$data2[3]=$data2[3]+0.0529;
$data3[3]=$data3[3]+0.0529;
$data4[3]=$data4[3]+0.0529;
$data5[3]=$data5[3]+0.0529;
$data6[3]=$data6[3]+0.0529;
open DATA, ">hlongp$i";
print DATA "@data1\n";
print DATA "@data2\n";
print DATA "@data3\n";
print DATA "@data4\n";
print DATA "@data5\n";
print DATA "@data6\n";
close (DATA);
}

@data1=split /\s+ /, $total[0];
@data2=split /\s+ /, $total[1];
@data3=split /\s+ /, $total[2];
@data4=split /\s+ /, $total[3];
@data5=split /\s+ /, $total[4];
@data6=split /\s+ /, $total[5];

for($i=1;$i<11 br="" i="">$data1[3]=$data1[3]-0.0529;
$data2[3]=$data2[3]-0.0529;
$data3[3]=$data3[3]-0.0529;
$data4[3]=$data4[3]-0.0529;
$data5[3]=$data5[3]-0.0529;
$data6[3]=$data6[3]-0.0529;
open DATA, ">hlongp-$i";
print DATA "@data1\n";
print DATA "@data2\n";
print DATA "@data3\n";
print DATA "@data4\n";
print DATA "@data5\n";
print DATA "@data6\n";

close (DATA);
}


No comments:

Post a Comment