Newer
Older
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
# ##### BEGIN GPL LICENSE BLOCK #####
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# ##### END GPL LICENSE BLOCK #####
bl_info = {
"name": "Import/Export: PDB format",
"author": "Mariusz Maximus & Jong89",
"version": (0, 9, 0),
"blender": (2, 6, 0),
"api": 35616,
"location": "File > Import/Export > PDB",
"description": "Import PDB files",
"warning": "",
"wiki_url": "http://blenderartists.org/forum/showthread.php?t=194336",
"tracker_url": "http://blenderartists.org/forum/showthread.php?t=194336",
"category": "Import-Export"}
# @todo write the wiki page
# To support reload properly, try to access a package var,
# if it's there, reload everything
if "bpy" in locals():
import imp
if "import_pdb" in locals():
imp.reload(import_pdb)
import bpy
from bpy.props import (StringProperty,
BoolProperty,
IntProperty,
FloatProperty,
)
from bpy_extras.io_utils import ImportHelper
class ImportPDB(bpy.types.Operator, ImportHelper):
"""Import from PDB file format (.pdb)"""
bl_idname = 'import_scene.pdb'
bl_label = 'Import PDB'
bl_options= {'REGISTER', 'UNDO'}
filename_ext = ".pdb"
filter_glob = StringProperty(default="*.pdb", options={'HIDDEN'})
filepath = StringProperty(
name="File Path",
description="Filepath used for importing the PDB file",
maxlen= 1024,
)
multi_models = BoolProperty(
name="Import all models",
description="Import all alternative structures listed in file",
default=False,
)
multimers = BoolProperty(
name="Import Biomolecules",
description="Import all file-listed biomolecules and multimers, "
"disable to import default biomolecule with all chains",
default=False,
)
retain_alts = BoolProperty(
name="Retain Alternative Atoms",
description="Select to retain alternative atoms. "
"Some PDB files label coordinates of entries "
"in multiple models as alternates" ,
default=False,
)
atom_subdivisions = IntProperty(
name="Atom Subdivisions",
description="Number of icosphere subdivisions for the atoms",
min=1, max=6,
default=3,
)
atom_size = FloatProperty(
name="Atom Size",
description="Multiplier for the van der Waals radius of the atoms",
min=0, max=5,
default=1,
)
scene_scale = FloatProperty(
name="Scene Scale Factor",
description="Number of Blender units equivalent to 1 angstrom",
min=0, max=10,
default=1,
)
def execute(self, context):
from . import import_pdb
import_pdb.load_pdb(self.filepath, context,
self.atom_size,
self.scene_scale,
self.atom_subdivisions,
self.retain_alts,
self.multi_models,
self.multimers)
return {'FINISHED'}
def invoke(self, context, event):
wm = context.window_manager
wm.fileselect_add(self)
return {'RUNNING_MODAL'}
def menu_func(self, context):
self.layout.operator(ImportPDB.bl_idname, text='Protein Databank (.pdb)')
def register():
bpy.utils.register_module(__name__)
bpy.types.INFO_MT_file_import.append(menu_func)
def unregister():
bpy.utils.unregister_module(__name__)
bpy.types.INFO_MT_file_import.remove(menu_func)
if __name__ == '__main__':
register()