-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Scripts to generate template coords, fix pdb4amber
Add two scripts used in RESISTOR for the star-protocol. - gen-templ-coords.sh is for generating template coordinates. - p4a-undo.py is for fixing the numbering and chain ID of a structure after pdb4amber has "fixed" deficiencies.
- Loading branch information
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
# Generates template coordinates from a PDB file's atom records. | ||
# Can be used to generate template coordinates for, e.g., a small molecule ligand. | ||
# | ||
# ./gen-templ-coords.sh sch7.pdb 38Z | ||
# (script) (structure) (residue ID in structure) | ||
|
||
if [[ $# -ne 2 ]]; then | ||
echo "Expecting 2 parameters: <structure-file> and <residue ID>" >&2 | ||
exit 1 | ||
fi | ||
|
||
echo $2 $(wc --lines < $1) | ||
tr --squeeze-repeats ' ' < $1 | cut --delimiter=' ' --fields=3,7,8,9 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import sys | ||
|
||
# This script "fixes" residue numbers and chain IDs after using Ambertool's | ||
# pdb4amber program to ensure an input structure PDB file can be used with | ||
# ambertools. One of the things pdb4amber does is change all residue numbering | ||
# to start at 1, and gives every chain the same chain ID. This script undoes | ||
# those two changes. | ||
|
||
# python p4a-undo.py structure.pdb renumfile.txt | ||
|
||
def main(args): | ||
if len(args) != 2: | ||
print('expected two arguments: <pdb file> <renum file>', file=sys.stderr) | ||
exit(1) | ||
|
||
with open(args[1]) as renum_lines: | ||
renum_dict = { | ||
line.split()[4] : (line.split()[2], line.split()[1]) | ||
for line in renum_lines | ||
} | ||
|
||
with open(args[0]) as pdb_lines: | ||
for line in pdb_lines: | ||
if not line.strip(): | ||
continue | ||
if line[:4] != 'ATOM' and line[:4] != 'HETA' and line[:3] != 'TER': | ||
print(line, end='') | ||
continue | ||
|
||
res_name = line[17:20].strip() | ||
res_num = line[22:26].strip() | ||
old_num = renum_dict[res_num][0].rjust(4) | ||
chain = renum_dict[res_num][1] | ||
print(f'{line[:21]}{chain}{old_num}{line[26:]}'.strip()) | ||
|
||
if __name__ == '__main__': | ||
main(sys.argv[1:]) | ||
|