Code:
for (@test)
{
$last = `awk '/OXT/{print \$4}' $_`;
$lastnum = `awk '/OXT/{print \$5}' $_`;
system("sed -i -e '/O ${last} ${lastnum}/{s/-0.51000\$/-0.25500/;}' $_");
system("sed -i -e '/OXT ${last} ${lastnum}/{s/-0.67000\$/-0.25500/;}' $_");
}
Thanks guys for your help. The variables are saving the awk output correctly, but when I try to use it in the following
sed commands to replace the values shown, it fails.
This is what I want in the end: Find the line that contains OXT and grab the 4th and 5th values and save them to the variables indicated. Then I want to locate the lines that contain OXT followed by the 4th column value (GLY in this case) and by the 5th column value (319 in this case) and replace the number in the last column with the value shown in my
sed line. Then I need to make the same replacement with the line that contains O followed by the 4th column value (GLY) and then by the 5th column value (319).
Below is a segment of a single file that I need to make the 2 replacement in. The bolded values are the numbers I need to replace with the values shown in the
sed line. The thing is, the line that contains the O might not be next to the OXT line. It could be a random numbers of lines above. Each file in my set is the amino acid sequence and connectivity of different proteins. So the format of each file is uniform, but the actual data is different. Each file will have a single line that contains OXT, which is always located in the last amino acid residue. So I get the residue abberviation and number of the last amino acid by storing the 4th and 5th column value. Then I need to locate the O (oxygen) that is also located in the last residue (GLY 319) in the example file below and make the replacement of the last column value for this line and the line that contains OXT.
Pardon my poor programming mannerisms and improper
perl usage, but I can better understand what is going on when I use awk and
sed in my
Perl script.
Code:
ATOM 4539 HCB LEU 318 -7.05103 -5.58173 17.60062 H_ 1 0 0.09000
ATOM 4540 HCB LEU 318 -7.27904 -5.68284 15.87021 H_ 1 0 0.09000
ATOM 4541 CG LEU 318 -7.65157 -7.53041 16.94206 C_3 4 0 -0.09000
ATOM 4542 HCG LEU 318 -6.58580 -7.79332 16.96207 H_ 1 0 0.09000
ATOM 4543 CD1 LEU 318 -8.26957 -8.08733 18.25040 C_3 4 0 -0.27000
ATOM 4544 HCD1 LEU 318 -9.36063 -8.06637 18.20792 H_ 1 0 0.09000
ATOM 4545 HCD1 LEU 318 -7.95865 -9.12417 18.39911 H_ 1 0 0.09000
ATOM 4546 HCD1 LEU 318 -7.94214 -7.50413 19.11073 H_ 1 0 0.09000
ATOM 4547 CD2 LEU 318 -8.24821 -8.25377 15.71317 C_3 4 0 -0.27000
ATOM 4548 HCD2 LEU 318 -7.75464 -7.91803 14.79952 H_ 1 0 0.09000
ATOM 4549 HCD2 LEU 318 -8.10485 -9.33270 15.79871 H_ 1 0 0.09000
ATOM 4550 HCD2 LEU 318 -9.31410 -8.05348 15.62518 H_ 1 0 0.09000
ATOM 4551 N GLY 319 -8.71770 -2.77439 16.71834 N_R 3 0 -0.47000
ATOM 4552 HN GLY 319 -8.69152 -2.87454 15.75858 H___A 1 0 0.31000
ATOM 4553 CA GLY 319 -8.48831 -1.42062 17.17743 C_3 4 0 -0.02000
ATOM 4554 HCA GLY 319 -9.23650 -1.16420 17.93092 H_ 1 0 0.09000
ATOM 4555 HCA GLY 319 -8.65103 -0.75119 16.33306 H_ 1 0 0.09000
ATOM 4556 C GLY 319 -7.14757 -1.08823 17.71950 C_R 3 0 0.51000
ATOM 4557 O GLY 319 -6.15276 -1.84709 17.63535 O_2 1 2 -0.51000
ATOM 4558 OXT GLY 319 -7.00093 -0.12662 18.51114 O_2 1 2 -0.67000
45 FORMAT CONECT (a6,12i6)