OpenStructure
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
stage
lib64
python2.7
site-packages
ost
io
repository.py
Go to the documentation of this file.
1
import
os.path
2
import
string
3
import
os
4
5
from
ost
import
io
6
7
class
ModelRepository
:
8
"""
9
Model repository. A model repository abstracts the way that PDB files are
10
loaded. Instead of explicitly specifying the PDB filename, only the PDB
11
id (and optionally a chain) needs to be specified. The actual files are then
12
resolved by the repository.
13
14
Usage
15
-----
16
The usage pattern of the model repository is simple. After construction,
17
models may be loaded by passing in a model id and optionally a number of
18
chain names (see documentation for io.LoadPDB).
19
20
Example:
21
import string
22
repos=repository.ModelRepository('path_to_pdbs',
23
file_pattern='pdb%(id)s.ent.gz',
24
transform=string.lower)
25
# load 1ake (note that the name is transformed by string.lower)
26
m=repos.Load('1AKE')
27
"""
28
def
__init__
(self, directory=None,
29
file_pattern=
'%(id)s.pdb'
,transform=str):
30
"""
31
Construct new model repository
32
"""
33
if
directory==
None
:
34
self.
directory_
=os.getenv(
'PDB_PATH'
,
''
)
35
else
:
36
self.
directory_
=directory;
37
self.
file_pattern_
=file_pattern
38
self.
transform_
=transform
or
string.__init__
39
def
FilenameForModel
(self, pdb_id, chain):
40
pdb_id=self.
transform_
(pdb_id)
41
basename=self.
file_pattern_
% {
'id'
: pdb_id,
'chain'
:chain,
'dir'
: pdb_id[1:3]}
42
return
os.path.join(self.
directory_
, basename)
43
44
def
Load
(self, pdb_id, chains='', calpha_only=False, fault_tolerant=False):
45
return
io.LoadPDB(self.
FilenameForModel
(pdb_id, chains),
46
chains, calpha_only=calpha_only,
47
fault_tolerant=fault_tolerant)
48
49
def
LoadMulti
(self, pdb_id, chains=""):
50
return
io.LoadMultiPDB(self.
FilenameForModel
(pdb_id, chains))
51
ost::io.repository.ModelRepository.transform_
transform_
Definition:
repository.py:38
ost::io.repository.ModelRepository.LoadMulti
def LoadMulti
Definition:
repository.py:49
ost::io.repository.ModelRepository
Definition:
repository.py:7
ost::io.repository.ModelRepository.FilenameForModel
def FilenameForModel
Definition:
repository.py:39
ost::io.repository.ModelRepository.file_pattern_
file_pattern_
Definition:
repository.py:37
ost::io.repository.ModelRepository.directory_
directory_
Definition:
repository.py:34
ost::io.repository.ModelRepository.Load
def Load
Definition:
repository.py:44
ost::io.repository.ModelRepository.__init__
def __init__
Definition:
repository.py:29
Generated by
1.8.5