-
Notifications
You must be signed in to change notification settings - Fork 13
/
silentsketchextractcaprotein
executable file
·55 lines (37 loc) · 1.63 KB
/
silentsketchextractcaprotein
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/env python
import os
import sys
# if you pip installed this is wrong but you have silent_tools installed anyways
silent_tools_dir = os.path.dirname(os.path.realpath(__file__))
if silent_tools_dir not in sys.path:
sys.path.append(silent_tools_dir)
import silent_tools
from silent_tools import eprint
# Don't throw an error when someone uses head
from signal import signal, SIGPIPE, SIG_DFL
signal(SIGPIPE, SIG_DFL)
if (len(sys.argv) == 1):
eprint("")
eprint('silentsketchextractcaprotein by bcov - a tool to allow you extract the CA atoms from a protein silent file')
eprint("Usage:")
eprint(" cat list_of_tags.list | silentslice myfile.silent > new.silent")
eprint(" or")
eprint(" silentslice myfile.silent tag1 tag2 tag3 > new.silent")
sys.exit(1)
silent_file = sys.argv[1]
silent_index = silent_tools.get_silent_index( silent_file )
with open(silent_file, errors='ignore') as sf:
for tag in silent_index['tags']:
if ( tag not in silent_index['index'] ):
eprint("silentsketchextractcaprotein: Unable to find tag: %s"%tag)
continue
structure = silent_tools.get_silent_structure_file_open( sf, silent_index, tag )
sequence = "".join(silent_tools.get_sequence_chunks(structure))
try:
cas = silent_tools.sketch_get_cas_protein_struct(structure)
except:
eprint("silentsketchextractcaprotein: %s corrupt"%(tag))
lines = silent_tools.write_pdb_atoms( cas, sequence, ["CA"] )
with open(tag + ".pdb", "w") as f:
f.write("".join(lines))
print(tag)