ATOM 1489 CA AARG A 181 21.615 11.671 -0.581 0.50 14.29
ATOM 1490 C AARG A 181 21.176 11.705 0.880 0.50 13.13
ATOM 1491 O AARG A 181 21.097 10.666 1.534 0.50 11.72
ATOM 1492 CB AARG A 181 20.905 10.524 -1.299 0.50 15.58
ATOM 1493 CG AARG A 181 19.464 10.823 -1.680 0.50 18.22
ATOM 1494 CD AARG A 181 19.399 11.628 -2.968 0.50 21.19
ATOM 1495 NE AARG A 181 20.181 10.979 -4.017 0.50 24.97
ATOM 1496 CZ AARG A 181 19.785 10.842 -5.278 0.50 25.56
ATOM 1497 NH1AARG A 181 18.606 11.311 -5.660 0.50 27.74
ATOM 1498 NH2AARG A 181 20.567 10.230 -6.156 0.50 25.96
ATOM 1499 N BARG A 181 23.059 11.454 -0.580 0.50 14.86
ATOM 1500 CA BARG A 181 21.613 11.672 -0.589 0.50 14.84
ATOM 1501 C BARG A 181 21.172 11.705 0.874 0.50 13.78
ATOM 1502 O BARG A 181 21.092 10.664 1.525 0.50 13.73
ATOM 1503 CB BARG A 181 20.908 10.523 -1.319 0.50 18.29
ATOM 1504 CG BARG A 181 19.470 10.822 -1.731 0.50 22.11
ATOM 1505 CD BARG A 181 19.428 11.725 -2.959 0.50 23.55
ATOM 1506 NE BARG A 181 19.985 11.063 -4.138 0.50 24.53
ATOM 1507 CZ BARG A 181 19.322 10.200 -4.904 0.50 23.44
ATOM 1508 NH1BARG A 181 18.062 9.888 -4.628 0.50 21.30
ATOM 1509 NH2BARG A 181 19.926 9.642 -5.944 0.50 24.00
1 2 3 45 6 7 8
####
my $rx_altloc = qr/
^(ATOM.{9} # match only atom records
(.{3}) # capture atom name (and any space included)
(.) # capture alternate location identifier
\w{3} # match the amino acid name
(.{6}) # capture chain and residue number
.+$ [\r\n]) # match the rest of the line
(?:(^ATOM.{9} # make sure the next line(s) is an atom record
(?=\2).{3} # make sure same atom name
(?!\3). # make sure different alternate location
\w{3} # don't care if it's the same residue type
(?=\4).{6} # make sure it's the same chain and residue
.+$ [\r\n])+) # match the rest of the line
(?{
$altloc = $3;
})
/xm;
...
$file_contents =~ s/$rx_altloc/$1/g;
/xm;
####
my $rx_altloc_groupByAlt = qr/
#(?=
(^ATOM.{9}(.{3})(\w)\w{3}(.{6}).+$ [\r\n])
((?:^.+$ [\r\n])*)
#)
(ATOM.{9}\2(?!\3).\w{3}\4.+$ [\r\n])
(?{
$altloc = $3;
})
/xm;
...
$file_contents =~ s/$rx_altloc_groupByAlt//g;