35
35
sep = "\n \n =======\n \n "
36
36
37
37
38
- def get_scn_format (datafile , pdb_code = "auto" , chain = "A" , num = 1 ):
39
- """ Gets a PDB ID in sidechainet format
40
- Inputs:
41
- * datafile: str. url to RCSB PDB or relative route in the files system.
42
- * pdb_code: str. 4-letter PDB code. if auto, will take first 4
43
- letters of datafile file name.
44
- * chain: str. the chain in the PDB structure to retrieve
45
- * num: int. the num in the PDB structure to retrieve.
46
- Outputs: dict with
47
- * seq: 1-letter code string
48
- * coords (L, 14, 3)
49
- * mask (whether coords for residue are known or now)
50
- """
51
- data = {"seq" : None , "coords" : None , "mask" : None }
52
- # get pdb code
53
- if pdb_code == "auto" :
54
- pdb_code = datafile .split ("/" )[- 1 ][:4 ].upper ()
55
- # download if URL
56
- download = False
57
- if datafile .startswith ("http" ):
58
- os .system ("wget {0}" .format (datafile ))
59
- download = True
60
- datafile = datafile .split ("/" )[- 1 ]
61
-
62
- # read data
63
- chain = pr .parsePDB (datafile , chain = chain , model = num )
64
- if download :
65
- os .system ("rm {0}" .format (datafile ))
66
- # download seq from PDB API
67
- # data["seq_pdb"] = sidechainnet.utils.download.get_seq_from_pdb(pdb_code, chain=1)
68
- # get coords
69
- keys = ["angles_np" , "coords_np" , "observed_sequence" , "unmodified_sequence" , "is_nonstd" ]
70
- parsed = sidechainnet .utils .measure .get_seq_coords_and_angles (chain )
71
- return {k :v for k ,v in zip (keys , parsed )}
72
-
73
-
74
38
# begin tests
75
39
if __name__ == "__main__" :
76
40
@@ -92,7 +56,12 @@ def get_scn_format(datafile, pdb_code="auto", chain="A", num=1):
92
56
93
57
for i ,filename in enumerate (filenames ):
94
58
95
- data = get_scn_format (filename , chain = "A" , num = 1 )
59
+ # get data
60
+ keys = ["angles_np" , "coords_np" , "observed_sequence" ]
61
+ chain = pr .parsePDB (datafile , chain = chain , model = 1 )
62
+ parsed = sidechainnet .utils .measure .get_seq_coords_and_angles (chain )
63
+ data = {k :v for k ,v in zip (keys , parsed )}
64
+ # get scaffs
96
65
scaffolds = mp_nerf .proteins .build_scaffolds_from_scn_angles (data ["observed_sequence" ],
97
66
torch .from_numpy (data ["angles_np" ]).to (device ))
98
67
0 commit comments