本文整理汇总了Python中Bio.PDB.StructureBuilder.StructureBuilder.set_header方法的典型用法代码示例。如果您正苦于以下问题:Python StructureBuilder.set_header方法的具体用法?Python StructureBuilder.set_header怎么用?Python StructureBuilder.set_header使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bio.PDB.StructureBuilder.StructureBuilder
的用法示例。
在下文中一共展示了StructureBuilder.set_header方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: PDBParser
# 需要导入模块: from Bio.PDB.StructureBuilder import StructureBuilder [as 别名]
# 或者: from Bio.PDB.StructureBuilder.StructureBuilder import set_header [as 别名]
class PDBParser(object):
"""Parse a PDB file and return a Structure object."""
def __init__(self, PERMISSIVE=True, get_header=False,
structure_builder=None, QUIET=False):
"""Create a PDBParser object.
The PDB parser call a number of standard methods in an aggregated
StructureBuilder object. Normally this object is instanciated by the
PDBParser object itself, but if the user provides his/her own
StructureBuilder object, the latter is used instead.
Arguments:
- PERMISSIVE - Evaluated as a Boolean. If false, exceptions in
constructing the SMCRA data structure are fatal. If true (DEFAULT),
the exceptions are caught, but some residues or atoms will be missing.
THESE EXCEPTIONS ARE DUE TO PROBLEMS IN THE PDB FILE!.
- structure_builder - an optional user implemented StructureBuilder class.
- QUIET - Evaluated as a Boolean. If true, warnings issued in constructing
the SMCRA data will be suppressed. If false (DEFAULT), they will be shown.
These warnings might be indicative of problems in the PDB file!
"""
if structure_builder is not None:
self.structure_builder = structure_builder
else:
self.structure_builder = StructureBuilder()
self.header = None
self.trailer = None
self.line_counter = 0
self.PERMISSIVE = bool(PERMISSIVE)
self.QUIET = bool(QUIET)
# Public methods
def get_structure(self, id, file):
"""Return the structure.
Arguments:
- id - string, the id that will be used for the structure
- file - name of the PDB file OR an open filehandle
"""
with warnings.catch_warnings():
if self.QUIET:
warnings.filterwarnings("ignore", category=PDBConstructionWarning)
self.header = None
self.trailer = None
# Make a StructureBuilder instance (pass id of structure as parameter)
self.structure_builder.init_structure(id)
with as_handle(file, mode='rU') as handle:
self._parse(handle.readlines())
self.structure_builder.set_header(self.header)
# Return the Structure instance
structure = self.structure_builder.get_structure()
return structure
def get_header(self):
"""Return the header."""
return self.header
def get_trailer(self):
"""Return the trailer."""
return self.trailer
# Private methods
def _parse(self, header_coords_trailer):
"""Parse the PDB file (PRIVATE)."""
# Extract the header; return the rest of the file
self.header, coords_trailer = self._get_header(header_coords_trailer)
# Parse the atomic data; return the PDB file trailer
self.trailer = self._parse_coordinates(coords_trailer)
def _get_header(self, header_coords_trailer):
"""Get the header of the PDB file, return the rest (PRIVATE)."""
structure_builder = self.structure_builder
i = 0
for i in range(0, len(header_coords_trailer)):
structure_builder.set_line_counter(i + 1)
line = header_coords_trailer[i]
record_type = line[0:6]
if record_type == "ATOM " or record_type == "HETATM" or record_type == "MODEL ":
break
header = header_coords_trailer[0:i]
# Return the rest of the coords+trailer for further processing
self.line_counter = i
coords_trailer = header_coords_trailer[i:]
header_dict = _parse_pdb_header_list(header)
return header_dict, coords_trailer
def _parse_coordinates(self, coords_trailer):
"""Parse the atomic data in the PDB file (PRIVATE)."""
local_line_counter = 0
structure_builder = self.structure_builder
current_model_id = 0
# Flag we have an open model
model_open = 0
#.........这里部分代码省略.........
示例2: PDBParser
# 需要导入模块: from Bio.PDB.StructureBuilder import StructureBuilder [as 别名]
# 或者: from Bio.PDB.StructureBuilder.StructureBuilder import set_header [as 别名]
class PDBParser(object):
"""
Parse a PDB file and return a Structure object.
"""
def __init__(self, PERMISSIVE=True, get_header=False,
structure_builder=None, QUIET=False):
"""
The PDB parser call a number of standard methods in an aggregated
StructureBuilder object. Normally this object is instanciated by the
PDBParser object itself, but if the user provides his/her own
StructureBuilder object, the latter is used instead.
Arguments:
o PERMISSIVE - Evaluated as a Boolean. If false, exceptions in
constructing the SMCRA data structure are fatal. If true (DEFAULT),
the exceptions are caught, but some residues or atoms will be missing.
THESE EXCEPTIONS ARE DUE TO PROBLEMS IN THE PDB FILE!.
o structure_builder - an optional user implemented StructureBuilder class.
o QUIET - Evaluated as a Boolean. If true, warnings issued in constructing
the SMCRA data will be suppressed. If false (DEFAULT), they will be shown.
These warnings might be indicative of problems in the PDB file!
"""
if structure_builder is not None:
self.structure_builder = structure_builder
else:
self.structure_builder = StructureBuilder()
self.header = None
self.trailer = None
self.line_counter = 0
self.PERMISSIVE = bool(PERMISSIVE)
self.QUIET = bool(QUIET)
# Public methods
def get_structure(self, id, file):
"""Return the structure.
Arguments:
o id - string, the id that will be used for the structure
o file - name of the PDB file OR an open filehandle
"""
if self.QUIET:
warning_list = warnings.filters[:]
warnings.filterwarnings("ignore", category=PDBConstructionWarning)
self.header = None
self.trailer = None
# Make a StructureBuilder instance (pass id of structure as parameter)
self.structure_builder.init_structure(id)
with as_handle(file) as handle:
self._parse(handle.readlines())
self.structure_builder.set_header(self.header)
# Return the Structure instance
structure = self.structure_builder.get_structure()
if self.QUIET:
warnings.filters = warning_list
return structure
def get_header(self):
"Return the header."
return self.header
def get_trailer(self):
"Return the trailer."
return self.trailer
# Private methods
def _parse(self, header_coords_trailer):
"Parse the PDB file."
# Extract the header; return the rest of the file
self.header, coords_trailer = self._get_header(header_coords_trailer)
# Parse the atomic data; return the PDB file trailer
self.trailer = self._parse_coordinates(coords_trailer)
def _get_header(self, header_coords_trailer):
"Get the header of the PDB file, return the rest."
structure_builder = self.structure_builder
i = 0
for i in range(0, len(header_coords_trailer)):
structure_builder.set_line_counter(i + 1)
line = header_coords_trailer[i]
record_type = line[0:6]
if record_type == "ATOM " or record_type == "HETATM" or record_type == "MODEL ":
break
header = header_coords_trailer[0:i]
# Return the rest of the coords+trailer for further processing
self.line_counter = i
coords_trailer = header_coords_trailer[i:]
header_dict = _parse_pdb_header_list(header)
return header_dict, coords_trailer
#.........这里部分代码省略.........