Hello everybody please help me to write a script to do the below please:
- I want to open a text file named C60_GRM_box.gro (I copied the first lines from this file below) and then extract the second line which is 127240 below;
GRM in vacuum 127240 1GRM C1 1 0.061 0.071 0.000 1GRM C2 2 0.184 0.142 0.000
- Then, I want to subtract 2800 from the number extracted in step one and then divide the result by 60
what I want to do: (the number extracted in step number 1 - 2800)/60 = result
- Finally I want to open another txt file named C60_GRM_box.top (I have copied below all the data in the text file I want to replace part of it) and replace a number (which is the number beside the word G8LE, which is 3000 below) with the result I obtained in step 2, I have pasted all the content of the second file named C60_GRM_box.top below;
; Include forcefield parameters include "/home/abdelaal/Desktop/GROMACS/C60:TAPC/C60_GRM/41/gromos54a7.ff/forcefield.itp" ; Include topology for GRM include "/home/abdelaal/Desktop/GROMACS/C60:TAPC/C60_GRM/41/GRM.itp" ifdef POSRES include "/home/abdelaal/Desktop/GROMACS/C60:TAPC/C60_GRM/41/posrestr.itp" endif ; Include topology for C60 include "/home/abdelaal/Desktop/GROMACS/C60:TAPC/C60_GRM/41/C60.itp" [ system ] ; Name GRM in vacuum [ molecules ] ; Compound #mols GRM 1 G8LE strong text 3000
I don't need to open the files in steps 1 and 3, if I can do all the above without opening the files that would be perfect.