本文整理汇总了Python中Bio.PDB.StructureBuilder.StructureBuilder.init_chain方法的典型用法代码示例。如果您正苦于以下问题:Python StructureBuilder.init_chain方法的具体用法?Python StructureBuilder.init_chain怎么用?Python StructureBuilder.init_chain使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bio.PDB.StructureBuilder.StructureBuilder
的用法示例。
在下文中一共展示了StructureBuilder.init_chain方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: residues_to_struct
# 需要导入模块: from Bio.PDB.StructureBuilder import StructureBuilder [as 别名]
# 或者: from Bio.PDB.StructureBuilder.StructureBuilder import init_chain [as 别名]
def residues_to_struct(name_residues_list, structID):
"""
Build a structure from a list of (chain name, residues) - each as
a chain.
"""
builder = StructureBuilder()
builder.init_structure(structID)
builder.init_model(0)
for (name, residues) in name_residues_list:
builder.init_chain(name)
for res in residues:
builder.chain.add(res)
return builder.get_structure()
示例2: __init__
# 需要导入模块: from Bio.PDB.StructureBuilder import StructureBuilder [as 别名]
# 或者: from Bio.PDB.StructureBuilder.StructureBuilder import init_chain [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)
示例3: set_structure
# 需要导入模块: from Bio.PDB.StructureBuilder import StructureBuilder [as 别名]
# 或者: from Bio.PDB.StructureBuilder.StructureBuilder import init_chain [as 别名]
def set_structure(self, pdb_object):
"""Check what object the user is providing and build a structure."""
# This is duplicated from the PDBIO class
if pdb_object.level == "S":
structure = pdb_object
else:
sb = StructureBuilder()
sb.init_structure('pdb')
sb.init_seg(' ')
# Build parts as necessary
if pdb_object.level == "M":
sb.structure.add(pdb_object)
self.structure = sb.structure
else:
sb.init_model(0)
if pdb_object.level == "C":
sb.structure[0].add(pdb_object)
else:
sb.init_chain('A')
if pdb_object.level == "R":
try:
parent_id = pdb_object.parent.id
sb.structure[0]['A'].id = parent_id
except ValueError:
pass
sb.structure[0]['A'].add(pdb_object)
else:
# Atom
sb.init_residue('DUM', ' ', 1, ' ')
try:
parent_id = pdb_object.parent.parent.id
sb.structure[0]['A'].id = parent_id
except ValueError:
pass
sb.structure[0]['A'].child_list[0].add(pdb_object)
# Return structure
structure = sb.structure
self.structure = structure
示例4: set_structure
# 需要导入模块: from Bio.PDB.StructureBuilder import StructureBuilder [as 别名]
# 或者: from Bio.PDB.StructureBuilder.StructureBuilder import init_chain [as 别名]
def set_structure(self, pdb_object):
"""Check what the user is providing and build a structure."""
if pdb_object.level == "S":
structure = pdb_object
else:
sb = StructureBuilder()
sb.init_structure('pdb')
sb.init_seg(' ')
# Build parts as necessary
if pdb_object.level == "M":
sb.structure.add(pdb_object.copy())
self.structure = sb.structure
else:
sb.init_model(0)
if pdb_object.level == "C":
sb.structure[0].add(pdb_object.copy())
else:
sb.init_chain('A')
if pdb_object.level == "R":
try:
parent_id = pdb_object.parent.id
sb.structure[0]['A'].id = parent_id
except Exception:
pass
sb.structure[0]['A'].add(pdb_object.copy())
else:
# Atom
sb.init_residue('DUM', ' ', 1, ' ')
try:
parent_id = pdb_object.parent.parent.id
sb.structure[0]['A'].id = parent_id
except Exception:
pass
sb.structure[0]['A'].child_list[0].add(pdb_object.copy())
# Return structure
structure = sb.structure
self.structure = structure
示例5: set_structure
# 需要导入模块: from Bio.PDB.StructureBuilder import StructureBuilder [as 别名]
# 或者: from Bio.PDB.StructureBuilder.StructureBuilder import init_chain [as 别名]
def set_structure(self, pdb_object):
# Check what the user is providing and build a structure appropriately
if pdb_object.level == "S":
structure = pdb_object
else:
sb = StructureBuilder()
sb.init_structure("pdb")
sb.init_seg(" ")
# Build parts as necessary
if pdb_object.level == "M":
sb.structure.add(pdb_object)
self.structure = sb.structure
else:
sb.init_model(0)
if pdb_object.level == "C":
sb.structure[0].add(pdb_object)
else:
sb.init_chain("A")
if pdb_object.level == "R":
try:
parent_id = pdb_object.parent.id
sb.structure[0]["A"].id = parent_id
except Exception:
pass
sb.structure[0]["A"].add(pdb_object)
else:
# Atom
sb.init_residue("DUM", " ", 1, " ")
try:
parent_id = pdb_object.parent.parent.id
sb.structure[0]["A"].id = parent_id
except Exception:
pass
sb.structure[0]["A"].child_list[0].add(pdb_object)
# Return structure
structure = sb.structure
self.structure = structure
示例6: StructureDecoder
# 需要导入模块: from Bio.PDB.StructureBuilder import StructureBuilder [as 别名]
# 或者: from Bio.PDB.StructureBuilder.StructureBuilder import init_chain [as 别名]
class StructureDecoder(object):
"""Class to pass the data from mmtf-python into a Biopython data structure."""
def __init__(self):
"""Initialize the class."""
self.this_type = ""
def init_structure(self, total_num_bonds, total_num_atoms,
total_num_groups, total_num_chains, total_num_models,
structure_id):
"""Initialize the structure object.
:param total_num_bonds: the number of bonds in the structure
:param total_num_atoms: the number of atoms in the structure
:param total_num_groups: the number of groups in the structure
:param total_num_chains: the number of chains in the structure
:param total_num_models: the number of models in the structure
:param structure_id: the id of the structure (e.g. PDB id)
"""
self.structure_bulder = StructureBuilder()
self.structure_bulder.init_structure(structure_id=structure_id)
self.chain_index_to_type_map = {}
self.chain_index_to_seq_map = {}
self.chain_index_to_description_map = {}
self.chain_counter = 0
def set_atom_info(self, atom_name, serial_number, alternative_location_id,
x, y, z, occupancy, temperature_factor, element, charge):
"""Create an atom object an set the information.
:param atom_name: the atom name, e.g. CA for this atom
:param serial_number: the serial id of the atom (e.g. 1)
:param alternative_location_id: the alternative location id for the atom, if present
:param x: the x coordiante of the atom
:param y: the y coordinate of the atom
:param z: the z coordinate of the atom
:param occupancy: the occupancy of the atom
:param temperature_factor: the temperature factor of the atom
:param element: the element of the atom, e.g. C for carbon. According to IUPAC. Calcium is Ca
:param charge: the formal atomic charge of the atom
"""
# MMTF uses "\x00" (the NUL character) to indicate to altloc, so convert
# that to the space required by StructureBuilder
if alternative_location_id == "\x00":
alternative_location_id = " "
# Atom_name is in twice - the full_name is with spaces
self.structure_bulder.init_atom(str(atom_name), [x, y, z],
temperature_factor, occupancy,
alternative_location_id, str(atom_name),
serial_number=serial_number,
element=str(element).upper())
def set_chain_info(self, chain_id, chain_name, num_groups):
"""Set the chain information.
:param chain_id: the asym chain id from mmCIF
:param chain_name: the auth chain id from mmCIF
:param num_groups: the number of groups this chain has
"""
# A Bradley - chose to use chain_name (auth_id) as it complies
# with current Biopython. Chain_id might be better.
self.structure_bulder.init_chain(chain_id=chain_name)
if self.chain_index_to_type_map[self.chain_counter] == "polymer":
self.this_type = " "
elif self.chain_index_to_type_map[self.chain_counter] == "non-polymer":
self.this_type = "H"
elif self.chain_index_to_type_map[self.chain_counter] == "water":
self.this_type = "W"
self.chain_counter += 1
def set_entity_info(self, chain_indices, sequence, description, entity_type):
"""Set the entity level information for the structure.
:param chain_indices: the indices of the chains for this entity
:param sequence: the one letter code sequence for this entity
:param description: the description for this entity
:param entity_type: the entity type (polymer,non-polymer,water)
"""
for chain_ind in chain_indices:
self.chain_index_to_type_map[chain_ind] = entity_type
self.chain_index_to_seq_map[chain_ind] = sequence
self.chain_index_to_description_map[chain_ind] = description
def set_group_info(self, group_name, group_number, insertion_code,
group_type, atom_count, bond_count, single_letter_code,
sequence_index, secondary_structure_type):
"""Set the information for a group
:param group_name: the name of this group, e.g. LYS
:param group_number: the residue number of this group
:param insertion_code: the insertion code for this group
:param group_type: a string indicating the type of group (as found in the chemcomp dictionary.
Empty string if none available.
:param atom_count: the number of atoms in the group
:param bond_count: the number of unique bonds in the group
#.........这里部分代码省略.........