質問編集履歴
2
成功したfor文追記しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -124,4 +124,13 @@
|
|
124
124
|
90 structure = self.structure_builder.get_structure()
|
125
125
|
91
|
126
126
|
92 return structure
|
127
|
+
```
|
128
|
+
|
129
|
+
PDBParserのせいでは無かったようです。
|
130
|
+
以下で上手くいきました。
|
131
|
+
|
132
|
+
```ここに言語を入力
|
133
|
+
for filenames in glob.glob("complex.*.pdb"):
|
134
|
+
id=os.path.splitext(filenames)[0]
|
135
|
+
pdb=PDBParser().get_structure(id,filenames)
|
127
136
|
```
|
1
PDBParserについて追記しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -8,4 +8,120 @@
|
|
8
8
|
In [5]: for filenames in glob.glob("complex.*.pdb"):
|
9
9
|
...: for lignames in glob.glob("complex.*.pdb"):
|
10
10
|
...: pdb=PDBParser().get_structure(lignames,filenames)
|
11
|
+
```
|
12
|
+
|
13
|
+
追記です。
|
14
|
+
Pythonについての質問です。
|
15
|
+
教えていただいたコマンドにて以下の様にいくつかのファイルをカレントディレクトリに置いてそれぞれ、id、filenamesを得ることが出来ました。
|
16
|
+
しかし、PDBParser().get_structure(lignames,filenames)に入力すると何故かcomplex.7.pdbしか処理されませんでした。
|
17
|
+
PDBParserの仕様によるものだと思うのですが、どなたか原因をご教授ください。
|
18
|
+
|
19
|
+
|
20
|
+
```ここに言語を入力
|
21
|
+
In [8]: for filenames in glob.glob("complex.*.pdb"):
|
22
|
+
...: id, ext=os.path.splitext(filenames)
|
23
|
+
...: print(id)
|
24
|
+
...:
|
25
|
+
...:
|
26
|
+
...:
|
27
|
+
complex.10
|
28
|
+
complex.1-2
|
29
|
+
complex.4
|
30
|
+
complex.5
|
31
|
+
complex.8
|
32
|
+
complex.3
|
33
|
+
complex.6
|
34
|
+
complex.2
|
35
|
+
complex.9
|
36
|
+
complex.7
|
37
|
+
|
38
|
+
```
|
39
|
+
```ここに言語を入力
|
40
|
+
In [9]: for filenames in glob.glob("complex.*.pdb"):
|
41
|
+
...: id, ext=os.path.splitext(filenames)
|
42
|
+
...: print(filenames)
|
43
|
+
...:
|
44
|
+
...:
|
45
|
+
...:
|
46
|
+
...:
|
47
|
+
complex.10.pdb
|
48
|
+
complex.1-2.pdb
|
49
|
+
complex.4.pdb
|
50
|
+
complex.5.pdb
|
51
|
+
complex.8.pdb
|
52
|
+
complex.3.pdb
|
53
|
+
complex.6.pdb
|
54
|
+
complex.2.pdb
|
55
|
+
complex.9.pdb
|
56
|
+
complex.7.pdb
|
57
|
+
|
58
|
+
```
|
59
|
+
以下のサイトよりPDBParserのクラス内容です。
|
60
|
+
https://biopython.org/DIST/docs/api/Bio.PDB.PDBParser%27-pysrc.html#PDBParser.get_structure
|
61
|
+
|
62
|
+
```ここに言語を入力
|
63
|
+
1 # Copyright (C) 2002, Thomas Hamelryck (thamelry@binf.ku.dk)
|
64
|
+
2 # This code is part of the Biopython distribution and governed by its
|
65
|
+
3 # license. Please see the LICENSE file that should have been included
|
66
|
+
4 # as part of this package.
|
67
|
+
5
|
68
|
+
6 """Parser for PDB files."""
|
69
|
+
7
|
70
|
+
8 from __future__ import print_function
|
71
|
+
9
|
72
|
+
10 import warnings
|
73
|
+
11
|
74
|
+
12 try:
|
75
|
+
13 import numpy
|
76
|
+
14 except ImportError:
|
77
|
+
15 from Bio import MissingPythonDependencyError
|
78
|
+
16 raise MissingPythonDependencyError(
|
79
|
+
17 "Install NumPy if you want to use the PDB parser.")
|
80
|
+
18
|
81
|
+
19 from Bio.File import as_handle
|
82
|
+
20
|
83
|
+
21 from Bio.PDB.PDBExceptions import PDBConstructionException
|
84
|
+
22 from Bio.PDB.PDBExceptions import PDBConstructionWarning
|
85
|
+
23
|
86
|
+
24 from Bio.PDB.StructureBuilder import StructureBuilder
|
87
|
+
25 from Bio.PDB.parse_pdb_header import _parse_pdb_header_list
|
88
|
+
26
|
89
|
+
27
|
90
|
+
28 # If PDB spec says "COLUMNS 18-20" this means line[17:20]
|
91
|
+
29
|
92
|
+
30
|
93
|
+
31 -class PDBParser(object):
|
94
|
+
32 """Parse a PDB file and return a Structure object."""
|
95
|
+
33
|
96
|
+
34 + def __init__(self, PERMISSIVE=True, get_header=False,
|
97
|
+
35 structure_builder=None, QUIET=False):
|
98
|
+
...
|
99
|
+
65
|
100
|
+
66 # Public methods
|
101
|
+
67
|
102
|
+
68 - def get_structure(self, id, file):
|
103
|
+
69 """Return the structure.
|
104
|
+
70
|
105
|
+
71 Arguments:
|
106
|
+
72 - id - string, the id that will be used for the structure
|
107
|
+
73 - file - name of the PDB file OR an open filehandle
|
108
|
+
74
|
109
|
+
75 """
|
110
|
+
76 with warnings.catch_warnings():
|
111
|
+
77 if self.QUIET:
|
112
|
+
78 warnings.filterwarnings("ignore", category=PDBConstructionWarning)
|
113
|
+
79
|
114
|
+
80 self.header = None
|
115
|
+
81 self.trailer = None
|
116
|
+
82 # Make a StructureBuilder instance (pass id of structure as parameter)
|
117
|
+
83 self.structure_builder.init_structure(id)
|
118
|
+
84
|
119
|
+
85 with as_handle(file, mode='rU') as handle:
|
120
|
+
86 self._parse(handle.readlines())
|
121
|
+
87
|
122
|
+
88 self.structure_builder.set_header(self.header)
|
123
|
+
89 # Return the Structure instance
|
124
|
+
90 structure = self.structure_builder.get_structure()
|
125
|
+
91
|
126
|
+
92 return structure
|
11
127
|
```
|