-
Notifications
You must be signed in to change notification settings - Fork 0
/
check_for_glyc.py
executable file
·51 lines (42 loc) · 1.49 KB
/
check_for_glyc.py
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
#!/usr/bin/env python3
import atomium as at
import sys
if len(sys.argv) != 2:
print('Usage: check_for_glyc.py {model-name}')
sys.exit(1)
model = at.open(sys.argv[1]).model
potential_glycosylations = []
for chain in model.chains():
for res in chain:
if res.name == 'ASN' and res.next.next.name in ['THR', 'SER']:
rc, rn = res.id.split('.')
potential_glycosylations.append(f'view /{rc}:{rn}')
print(f'Found {len(potential_glycosylations)} potential glycosylation sites.')
for glyc in potential_glycosylations:
print(f'\t{glyc.replace("view ", "")}')
with open(f'{sys.argv[1][:-4]}_glycs.html', 'w') as f:
f.write('''
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Glycosylation sites</title>
<style>.hidden {visibility: hidden; display: none;}</style>
</head>
<body>
<div style="display: flex; flex-direction: column;">''')
for glyc in potential_glycosylations:
f.write(f'<a href="cxcmd:{glyc}">{glyc}</a>')
f.write(''' </div>
</body>
<script>
document.querySelectorAll('a').forEach((glycLink) => {
glycLink.addEventListener('click', (e) => {
e.target.classList.add('hidden');
})
});
</script>
</html>''')
print(f'Open {sys.argv[1][:-4]}_glycs.html in chimeraX to view them.')