本文整理汇总了Python中Bio.PDB.StructureBuilder.StructureBuilder.set_line_counter方法的典型用法代码示例。如果您正苦于以下问题:Python StructureBuilder.set_line_counter方法的具体用法?Python StructureBuilder.set_line_counter怎么用?Python StructureBuilder.set_line_counter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bio.PDB.StructureBuilder.StructureBuilder
的用法示例。
在下文中一共展示了StructureBuilder.set_line_counter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from Bio.PDB.StructureBuilder import StructureBuilder [as 别名]
# 或者: from Bio.PDB.StructureBuilder.StructureBuilder import set_line_counter [as 别名]
class XBGFParser:
def __init__(self, PERMISSIVE=1, structure_builder=None):
if structure_builder != None:
self.structure_builder = structure_builder
else:
self.structure_builder = StructureBuilder()
self.PERMISSIVE = PERMISSIVE
# public interface
def parse(self, id, file):
self.structure_builder.init_structure(id)
if isinstance(file, basestring):
file=open(file)
self.charges = dict()
self.chain_suffix = 0
self._parse(file.readlines())
self.structure = self.structure_builder.get_structure()
return self._process_structure()
# private methods
def _parse(self, lines):
self.structure_builder.init_model(0)
self.structure_builder.init_seg("")
self.current_chain_id = None
self.current_residue_id = None
self.current_resname = None
for i in range(0, len(lines)):
self.line_counter = i + 1
self.structure_builder.set_line_counter(self.line_counter)
line = lines[i]
if line[0:6] == 'ATOM ':
self._update_atom(line)
def _update_chain(self, line):
chain_id = self._extract_chain(line)
if self.current_chain_id != chain_id:
try:
self.structure_builder.init_chain(chain_id)
self.current_chain_id = chain_id
self.current_residue_id = None
self.current_resname = None
except PDBConstructionException, message:
self._handle_PDB_exception(message)