forked from ptools/ptools-legacy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ptools.py
58 lines (46 loc) · 1.08 KB
/
ptools.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
52
53
54
55
56
# -*- coding: utf-8 -*-
from _ptools import *
one_letter_residue_dict = {
"ALA": "A",
"CYS": "C",
"ASP": "D",
"GLU": "E",
"PHE": "F",
"GLY": "G",
"HIS": "H",
"HIE": "H",
"HSP": "H",
"HSE": "H",
"HSD": "H",
"ILE": "I",
"LYS": "K",
"LEU": "L",
"MET": "M",
"ASN": "N",
"PRO": "P",
"GLN": "Q",
"ARG": "R",
"SER": "S",
"THR": "T",
"VAL": "V",
"TRP": "W",
"TYR": "Y",
"---": "-",
}
def rigidToSeq(rigid):
"""use residu names from the structure to extract the sequence
This function needs CA atoms to be present. A missing CA atom will result in
a missing letter in the sequence.
"""
rca = rigid.CA().CreateRigid() #restrict to the CA atoms.
seq = []
for i in range(len(rca)):
at = rca.CopyAtom(i)
seq.append(one_letter_residue_dict[at.residType])
return "".join(seq)
def getPDB(pdbname):
import urllib2
pdb = urllib2.urlopen("http://www.rcsb.org/pdb/files/%s.pdb"%pdbname)
#content = pdb.read()
rigid = Rigidbody(pdb)
return rigid