So I'm doing some molecular dynamic simulations for my final year university project. I am new to coding and have been asked to convert some code from BASH to python. The BASH script essentially takes a number of data files: ...x.dat where x is the number of simulations run. I am looking at the distances between carbons (c1 & c10) and generating a histogram based on distance between these 2 carbons over 30nanoseconds. The first 10ns has to be removed from the data for reasons I won't go into. The BASH script looks like this:
!/bin/bash
# number of runs to process
x=1
int=1
X=6
# code (modify name of files if appropriate)
for x in `seq $x $int $X`; do
sed '2,2501d' wt_atas_fpps_C1_C10_r$x.dat > wt_atas_fpps_c1_c10_af10_r$x.dat
awk '{$1=$3=""; print $0}' wt_atas_fpps_c1_c10_af10_r$x.dat > tmp.dat
sed '1d' tmp.dat > wt_atas_fpps_c1_c10_af10_onlydist_r$x.dat
rm tmp.dat
perl ./histogram.pl -i wt_atas_fpps_c1_c10_af10_onlydist_r$x.dat -o hist_wt_atas_fpps_c1_c10_af10_r$x.dat -min 2.0 -max 12 -col 1 -int 0.1 -freq
done
The data file looks like this:
#Frame C1-C10-d sdih
1 4.5218 79.2201
2 4.9504 78.0684
3 4.5568 138.0529
4 4.6582 65.7324
5 4.4398 119.6567
6 4.6302 105.3040
7 5.5387 146.4703
8 4.6112 90.8193
9 5.0781 106.4628
10 5.3428 139.9808
11 4.4887 132.3399
12 5.1901 95.9297
13 4.7968 128.4568
14 5.8146 100.8803
15 5.3278 105.8811
Up to 7500 (so 7501 rows in total). I think the Bash script essentially removes rows 2-2501 to get rid of the first 10ns. It then removes the columns 1 & 3 to get only the distance column. The header is then removed by deleting the first row to have a file with only distances. A perl histogram script is then run to generate a histogram.
My question is how do I replicate this in python? I can't find an easy way to remove certain columns or rows for this kind of file .