質問編集履歴
2
成功したfor文追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -251,3 +251,21 @@
|
|
251
251
|
92 return structure
|
252
252
|
|
253
253
|
```
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
PDBParserのせいでは無かったようです。
|
258
|
+
|
259
|
+
以下で上手くいきました。
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
```ここに言語を入力
|
264
|
+
|
265
|
+
for filenames in glob.glob("complex.*.pdb"):
|
266
|
+
|
267
|
+
id=os.path.splitext(filenames)[0]
|
268
|
+
|
269
|
+
pdb=PDBParser().get_structure(id,filenames)
|
270
|
+
|
271
|
+
```
|
1
PDBParserについて追記しました。
test
CHANGED
File without changes
|
test
CHANGED
@@ -19,3 +19,235 @@
|
|
19
19
|
...: pdb=PDBParser().get_structure(lignames,filenames)
|
20
20
|
|
21
21
|
```
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
追記です。
|
26
|
+
|
27
|
+
Pythonについての質問です。
|
28
|
+
|
29
|
+
教えていただいたコマンドにて以下の様にいくつかのファイルをカレントディレクトリに置いてそれぞれ、id、filenamesを得ることが出来ました。
|
30
|
+
|
31
|
+
しかし、PDBParser().get_structure(lignames,filenames)に入力すると何故かcomplex.7.pdbしか処理されませんでした。
|
32
|
+
|
33
|
+
PDBParserの仕様によるものだと思うのですが、どなたか原因をご教授ください。
|
34
|
+
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
|
39
|
+
```ここに言語を入力
|
40
|
+
|
41
|
+
In [8]: for filenames in glob.glob("complex.*.pdb"):
|
42
|
+
|
43
|
+
...: id, ext=os.path.splitext(filenames)
|
44
|
+
|
45
|
+
...: print(id)
|
46
|
+
|
47
|
+
...:
|
48
|
+
|
49
|
+
...:
|
50
|
+
|
51
|
+
...:
|
52
|
+
|
53
|
+
complex.10
|
54
|
+
|
55
|
+
complex.1-2
|
56
|
+
|
57
|
+
complex.4
|
58
|
+
|
59
|
+
complex.5
|
60
|
+
|
61
|
+
complex.8
|
62
|
+
|
63
|
+
complex.3
|
64
|
+
|
65
|
+
complex.6
|
66
|
+
|
67
|
+
complex.2
|
68
|
+
|
69
|
+
complex.9
|
70
|
+
|
71
|
+
complex.7
|
72
|
+
|
73
|
+
|
74
|
+
|
75
|
+
```
|
76
|
+
|
77
|
+
```ここに言語を入力
|
78
|
+
|
79
|
+
In [9]: for filenames in glob.glob("complex.*.pdb"):
|
80
|
+
|
81
|
+
...: id, ext=os.path.splitext(filenames)
|
82
|
+
|
83
|
+
...: print(filenames)
|
84
|
+
|
85
|
+
...:
|
86
|
+
|
87
|
+
...:
|
88
|
+
|
89
|
+
...:
|
90
|
+
|
91
|
+
...:
|
92
|
+
|
93
|
+
complex.10.pdb
|
94
|
+
|
95
|
+
complex.1-2.pdb
|
96
|
+
|
97
|
+
complex.4.pdb
|
98
|
+
|
99
|
+
complex.5.pdb
|
100
|
+
|
101
|
+
complex.8.pdb
|
102
|
+
|
103
|
+
complex.3.pdb
|
104
|
+
|
105
|
+
complex.6.pdb
|
106
|
+
|
107
|
+
complex.2.pdb
|
108
|
+
|
109
|
+
complex.9.pdb
|
110
|
+
|
111
|
+
complex.7.pdb
|
112
|
+
|
113
|
+
|
114
|
+
|
115
|
+
```
|
116
|
+
|
117
|
+
以下のサイトよりPDBParserのクラス内容です。
|
118
|
+
|
119
|
+
https://biopython.org/DIST/docs/api/Bio.PDB.PDBParser%27-pysrc.html#PDBParser.get_structure
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
```ここに言語を入力
|
124
|
+
|
125
|
+
1 # Copyright (C) 2002, Thomas Hamelryck (thamelry@binf.ku.dk)
|
126
|
+
|
127
|
+
2 # This code is part of the Biopython distribution and governed by its
|
128
|
+
|
129
|
+
3 # license. Please see the LICENSE file that should have been included
|
130
|
+
|
131
|
+
4 # as part of this package.
|
132
|
+
|
133
|
+
5
|
134
|
+
|
135
|
+
6 """Parser for PDB files."""
|
136
|
+
|
137
|
+
7
|
138
|
+
|
139
|
+
8 from __future__ import print_function
|
140
|
+
|
141
|
+
9
|
142
|
+
|
143
|
+
10 import warnings
|
144
|
+
|
145
|
+
11
|
146
|
+
|
147
|
+
12 try:
|
148
|
+
|
149
|
+
13 import numpy
|
150
|
+
|
151
|
+
14 except ImportError:
|
152
|
+
|
153
|
+
15 from Bio import MissingPythonDependencyError
|
154
|
+
|
155
|
+
16 raise MissingPythonDependencyError(
|
156
|
+
|
157
|
+
17 "Install NumPy if you want to use the PDB parser.")
|
158
|
+
|
159
|
+
18
|
160
|
+
|
161
|
+
19 from Bio.File import as_handle
|
162
|
+
|
163
|
+
20
|
164
|
+
|
165
|
+
21 from Bio.PDB.PDBExceptions import PDBConstructionException
|
166
|
+
|
167
|
+
22 from Bio.PDB.PDBExceptions import PDBConstructionWarning
|
168
|
+
|
169
|
+
23
|
170
|
+
|
171
|
+
24 from Bio.PDB.StructureBuilder import StructureBuilder
|
172
|
+
|
173
|
+
25 from Bio.PDB.parse_pdb_header import _parse_pdb_header_list
|
174
|
+
|
175
|
+
26
|
176
|
+
|
177
|
+
27
|
178
|
+
|
179
|
+
28 # If PDB spec says "COLUMNS 18-20" this means line[17:20]
|
180
|
+
|
181
|
+
29
|
182
|
+
|
183
|
+
30
|
184
|
+
|
185
|
+
31 -class PDBParser(object):
|
186
|
+
|
187
|
+
32 """Parse a PDB file and return a Structure object."""
|
188
|
+
|
189
|
+
33
|
190
|
+
|
191
|
+
34 + def __init__(self, PERMISSIVE=True, get_header=False,
|
192
|
+
|
193
|
+
35 structure_builder=None, QUIET=False):
|
194
|
+
|
195
|
+
...
|
196
|
+
|
197
|
+
65
|
198
|
+
|
199
|
+
66 # Public methods
|
200
|
+
|
201
|
+
67
|
202
|
+
|
203
|
+
68 - def get_structure(self, id, file):
|
204
|
+
|
205
|
+
69 """Return the structure.
|
206
|
+
|
207
|
+
70
|
208
|
+
|
209
|
+
71 Arguments:
|
210
|
+
|
211
|
+
72 - id - string, the id that will be used for the structure
|
212
|
+
|
213
|
+
73 - file - name of the PDB file OR an open filehandle
|
214
|
+
|
215
|
+
74
|
216
|
+
|
217
|
+
75 """
|
218
|
+
|
219
|
+
76 with warnings.catch_warnings():
|
220
|
+
|
221
|
+
77 if self.QUIET:
|
222
|
+
|
223
|
+
78 warnings.filterwarnings("ignore", category=PDBConstructionWarning)
|
224
|
+
|
225
|
+
79
|
226
|
+
|
227
|
+
80 self.header = None
|
228
|
+
|
229
|
+
81 self.trailer = None
|
230
|
+
|
231
|
+
82 # Make a StructureBuilder instance (pass id of structure as parameter)
|
232
|
+
|
233
|
+
83 self.structure_builder.init_structure(id)
|
234
|
+
|
235
|
+
84
|
236
|
+
|
237
|
+
85 with as_handle(file, mode='rU') as handle:
|
238
|
+
|
239
|
+
86 self._parse(handle.readlines())
|
240
|
+
|
241
|
+
87
|
242
|
+
|
243
|
+
88 self.structure_builder.set_header(self.header)
|
244
|
+
|
245
|
+
89 # Return the Structure instance
|
246
|
+
|
247
|
+
90 structure = self.structure_builder.get_structure()
|
248
|
+
|
249
|
+
91
|
250
|
+
|
251
|
+
92 return structure
|
252
|
+
|
253
|
+
```
|