本文整理汇总了Python中Bio.PDB.MMCIFParser.MMCIFParser.get_structure方法的典型用法代码示例。如果您正苦于以下问题:Python MMCIFParser.get_structure方法的具体用法?Python MMCIFParser.get_structure怎么用?Python MMCIFParser.get_structure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bio.PDB.MMCIFParser.MMCIFParser
的用法示例。
在下文中一共展示了MMCIFParser.get_structure方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_filehandle
# 需要导入模块: from Bio.PDB.MMCIFParser import MMCIFParser [as 别名]
# 或者: from Bio.PDB.MMCIFParser.MMCIFParser import get_structure [as 别名]
def test_filehandle(self):
"""Test if the parser can handle file handle as well as filename"""
parser = MMCIFParser()
structure = parser.get_structure("example", "PDB/1A8O.cif")
self.assertEqual(len(structure), 1)
structure = parser.get_structure("example", open("PDB/1A8O.cif"))
self.assertEqual(len(structure), 1)
示例2: testModels
# 需要导入模块: from Bio.PDB.MMCIFParser import MMCIFParser [as 别名]
# 或者: from Bio.PDB.MMCIFParser.MMCIFParser import get_structure [as 别名]
def testModels(self):
"""Test file with multiple models"""
parser = MMCIFParser(QUIET=1)
f_parser = FastMMCIFParser(QUIET=1)
with warnings.catch_warnings():
warnings.simplefilter('ignore', PDBConstructionWarning)
structure = parser.get_structure("example", "PDB/1LCD.cif")
f_structure = f_parser.get_structure("example", "PDB/1LCD.cif")
self.assertEqual(len(structure), 3)
self.assertEqual(len(f_structure), 3)
for ppbuild in [PPBuilder(), CaPPBuilder()]:
# ==========================================================
# Check that serial_num (model column) is stored properly
self.assertEqual(structure[0].serial_num, 1)
self.assertEqual(structure[1].serial_num, 2)
self.assertEqual(structure[2].serial_num, 3)
# First try allowing non-standard amino acids,
polypeptides = ppbuild.build_peptides(structure[0], False)
self.assertEqual(len(polypeptides), 1)
pp = polypeptides[0]
# Check the start and end positions
self.assertEqual(pp[0].get_id()[1], 1)
self.assertEqual(pp[-1].get_id()[1], 51)
# Check the sequence
s = pp.get_sequence()
self.assertTrue(isinstance(s, Seq))
self.assertEqual(s.alphabet, generic_protein)
# Here non-standard MSE are shown as M
self.assertEqual("MKPVTLYDVAEYAGVSYQTVSRVVNQASHVSAKTREKVEAAMAELNYIPNR",
str(s))
# ==========================================================
# Now try strict version with only standard amino acids
polypeptides = ppbuild.build_peptides(structure[0], True)
self.assertEqual(len(polypeptides), 1)
pp = polypeptides[0]
# Check the start and end positions
self.assertEqual(pp[0].get_id()[1], 1)
self.assertEqual(pp[-1].get_id()[1], 51)
# Check the sequence
s = pp.get_sequence()
self.assertTrue(isinstance(s, Seq))
self.assertEqual(s.alphabet, generic_protein)
self.assertEqual("MKPVTLYDVAEYAGVSYQTVSRVVNQASHVSAKTREKVEAAMAELNYIPNR",
str(s))
# This structure contains several models with multiple lengths.
# The tests were failing.
structure = parser.get_structure("example", "PDB/2OFG.cif")
self.assertEqual(len(structure), 3)
示例3: test_conversion
# 需要导入模块: from Bio.PDB.MMCIFParser import MMCIFParser [as 别名]
# 或者: from Bio.PDB.MMCIFParser.MMCIFParser import get_structure [as 别名]
def test_conversion(self):
"""Parse 1A8O.cif, write 1A8O.pdb, parse again and compare"""
cif_parser = MMCIFParser(QUIET=1)
cif_struct = cif_parser.get_structure("example", "PDB/1LCD.cif")
pdb_writer = PDBIO()
pdb_writer.set_structure(cif_struct)
filenumber, filename = tempfile.mkstemp()
pdb_writer.save(filename)
pdb_parser = PDBParser(QUIET=1)
pdb_struct = pdb_parser.get_structure('example_pdb', filename)
# comparisons
self.assertEqual(len(pdb_struct), len(cif_struct))
pdb_atom_names = [a.name for a in pdb_struct.get_atoms()]
cif_atom_names = [a.name for a in cif_struct.get_atoms()]
self.assertEqual(len(pdb_atom_names), len(cif_atom_names))
self.assertSequenceEqual(pdb_atom_names, cif_atom_names)
pdb_atom_elems = [a.element for a in pdb_struct.get_atoms()]
cif_atom_elems = [a.element for a in cif_struct.get_atoms()]
self.assertSequenceEqual(pdb_atom_elems, cif_atom_elems)
示例4: test_with_anisotrop
# 需要导入模块: from Bio.PDB.MMCIFParser import MMCIFParser [as 别名]
# 或者: from Bio.PDB.MMCIFParser.MMCIFParser import get_structure [as 别名]
def test_with_anisotrop(self):
parser = MMCIFParser()
fast_parser = FastMMCIFParser()
structure = parser.get_structure("example", "PDB/4CUP.cif")
f_structure = fast_parser.get_structure("example", "PDB/4CUP.cif")
self.assertEqual(len(structure), 1)
self.assertEqual(len(f_structure), 1)
s_atoms = list(structure.get_atoms())
f_atoms = list(f_structure.get_atoms())
self.assertEqual(len(s_atoms), len(f_atoms))
for atoms in [s_atoms, f_atoms]:
atom_names = ['N', 'CA', 'C', 'O', 'CB']
self.assertSequenceEqual([a.get_name() for a in atoms[:5]], atom_names)
self.assertSequenceEqual([a.get_id() for a in atoms[:5]], atom_names)
self.assertSequenceEqual([a.get_fullname() for a in atoms[:5]], atom_names)
self.assertSequenceEqual([a.get_occupancy() for a in atoms[:5]], [1., 1., 1., 1., 1.])
self.assertIsInstance(atoms[0].get_coord(), numpy.ndarray)
coord = numpy.array([50.346, 19.287, 17.288], dtype=numpy.float32)
numpy.testing.assert_array_equal(atoms[0].get_coord(), coord)
self.assertEqual(atoms[0].get_bfactor(), 32.02)
ansiou = numpy.array([0.4738, -0.0309, -0.0231, 0.4524, 0.0036, 0.2904], dtype=numpy.float32)
numpy.testing.assert_array_equal(atoms[0].get_anisou(), ansiou)
ansiou = numpy.array([1.1242, 0.2942, -0.0995, 1.1240, -0.1088, 0.8221], dtype=numpy.float32)
atom_937 = list(f_structure[0]['A'])[114]['CB']
numpy.testing.assert_array_equal(atom_937.get_anisou(), ansiou)
示例5: test_mmtf
# 需要导入模块: from Bio.PDB.MMCIFParser import MMCIFParser [as 别名]
# 或者: from Bio.PDB.MMCIFParser.MMCIFParser import get_structure [as 别名]
def test_mmtf(self):
"""Parse mmCIF file."""
with warnings.catch_warnings():
mmcif_parser = MMCIFParser()
warnings.simplefilter('ignore', PDBConstructionWarning)
structure = mmcif_parser.get_structure("MICR", "PDB/1EJG.cif")
print(structure)
示例6: test_insertions
# 需要导入模块: from Bio.PDB.MMCIFParser import MMCIFParser [as 别名]
# 或者: from Bio.PDB.MMCIFParser.MMCIFParser import get_structure [as 别名]
def test_insertions(self):
"""Test file with residue insertion codes"""
parser = MMCIFParser(QUIET=1)
with warnings.catch_warnings():
warnings.simplefilter("ignore", PDBConstructionWarning)
structure = parser.get_structure("example", "PDB/4ZHL.cif")
for ppbuild in [PPBuilder(), CaPPBuilder()]:
# First try allowing non-standard amino acids,
polypeptides = ppbuild.build_peptides(structure[0], False)
self.assertEqual(len(polypeptides), 2)
pp = polypeptides[0]
# Check the start and end positions (first segment only)
self.assertEqual(pp[0].get_id()[1], 16)
self.assertEqual(pp[-1].get_id()[1], 244)
# Check the sequence
refseq = (
"IIGGEFTTIENQPWFAAIYRRHRGGSVTYVCGGSLISPCWVISATHCFIDYPKKEDYIVYLGR"
"SRLNSNTQGEMKFEVENLILHKDYSADTLAYHNDIALLKIRSKEGRCAQPSRTIQTIALPSMY"
"NDPQFGTSCEITGFGKEQSTDYLYPEQLKMTVVKLISHRECQQPHYYGSEVTTKMLCAADPQW"
"KTDSCQGDSGGPLVCSLQGRMTLTGIVSWGRGCALKDKPGVYTRVSHFLPWIRSHTKE"
)
s = pp.get_sequence()
self.assertTrue(isinstance(s, Seq))
self.assertEqual(s.alphabet, generic_protein)
self.assertEqual(refseq, str(s))
示例7: test_compare_to_mmcif
# 需要导入模块: from Bio.PDB.MMCIFParser import MMCIFParser [as 别名]
# 或者: from Bio.PDB.MMCIFParser.MMCIFParser import get_structure [as 别名]
def test_compare_to_mmcif(self):
"""Compre the MMTF and mmCIF parsed structrues"""
def test_atoms(parse_mmtf):
"""Test that all atoms in self.mmtf_atoms and self.mmcif_atoms are equivalent"""
parse_mmtf.assertEqual(len(parse_mmtf.mmcif_atoms), len(parse_mmtf.mmtf_atoms))
for i, e in enumerate(parse_mmtf.mmcif_atoms):
mmtf_atom = parse_mmtf.mmtf_atoms[i]
mmcif_atom = parse_mmtf.mmcif_atoms[i]
parse_mmtf.assertEqual(mmtf_atom.name, mmcif_atom.name) # eg. CA, spaces are removed from atom name
parse_mmtf.assertEqual(mmtf_atom.fullname, mmcif_atom.fullname) # e.g. " CA ", spaces included
parse_mmtf.assertAlmostEqual(mmtf_atom.coord[0], mmcif_atom.coord[0], places=3)
parse_mmtf.assertAlmostEqual(mmtf_atom.coord[1], mmcif_atom.coord[1], places=3)
parse_mmtf.assertAlmostEqual(mmtf_atom.coord[2], mmcif_atom.coord[2], places=3)
parse_mmtf.assertEqual(mmtf_atom.bfactor, mmcif_atom.bfactor)
parse_mmtf.assertEqual(mmtf_atom.occupancy, mmcif_atom.occupancy)
parse_mmtf.assertEqual(mmtf_atom.altloc, mmcif_atom.altloc)
parse_mmtf.assertEqual(mmtf_atom.full_id,
mmcif_atom.full_id) # (structure id, model id, chain id, residue id, atom id)
parse_mmtf.assertEqual(mmtf_atom.id, mmcif_atom.name) # id of atom is the atom name (e.g. "CA")
# self.assertEqual(mmtf_atom.serial_number,mmcif_atom.serial_number) # mmCIF serial number is none
def test_residues(parse_mmtf):
"""Test that all residues in self.mmcif_res and self.mmtf_res are equivalent"""
parse_mmtf.assertEqual(len(parse_mmtf.mmcif_res), len(parse_mmtf.mmtf_res))
for i, e in enumerate(parse_mmtf.mmcif_res):
mmcif_r = parse_mmtf.mmcif_res[i]
mmtf_r = parse_mmtf.mmtf_res[i]
parse_mmtf.assertEqual(mmtf_r.level, mmcif_r.level)
parse_mmtf.assertEqual(mmtf_r.disordered, mmcif_r.disordered)
parse_mmtf.assertEqual(mmtf_r.resname, mmcif_r.resname)
parse_mmtf.assertEqual(mmtf_r.segid, mmcif_r.segid)
parse_mmtf.mmcif_atoms = [x for x in mmcif_r.get_atom()]
parse_mmtf.mmtf_atoms = [x for x in mmtf_r.get_atom()]
test_atoms(parse_mmtf=parse_mmtf)
with warnings.catch_warnings():
warnings.simplefilter('ignore', PDBConstructionWarning)
mmtf_struct = MMTFParser.get_structure("PDB/4CUP.mmtf")
mmcif_parser = MMCIFParser()
mmcif_struct = mmcif_parser.get_structure("example", "PDB/4CUP.cif")
self.mmcif_atoms = [x for x in mmcif_struct.get_atoms()]
self.mmtf_atoms = [x for x in mmtf_struct.get_atoms()]
test_atoms(self)
mmcif_chains = [x for x in mmcif_struct.get_chains()]
mmtf_chains = [x for x in mmtf_struct.get_chains()]
self.assertEqual(len(mmcif_chains), len(mmtf_chains))
for i, e in enumerate(mmcif_chains):
self.mmcif_res = [x for x in mmcif_chains[i].get_residues()]
self.mmtf_res = [x for x in mmtf_chains[i].get_residues()]
test_residues(self)
self.mmcif_res = [x for x in mmcif_struct.get_residues()]
self.mmtf_res = [x for x in mmtf_struct.get_residues()]
test_residues(self)
self.assertEqual(len([x for x in mmcif_struct.get_models()]), len([x for x in mmtf_struct.get_models()]))
示例8: test_parser
# 需要导入模块: from Bio.PDB.MMCIFParser import MMCIFParser [as 别名]
# 或者: from Bio.PDB.MMCIFParser.MMCIFParser import get_structure [as 别名]
def test_parser(self):
"""Extract polypeptides from 1A80."""
parser = MMCIFParser()
structure = parser.get_structure("example", "PDB/1A8O.cif")
self.assertEqual(len(structure), 1)
for ppbuild in [PPBuilder(), CaPPBuilder()]:
#==========================================================
# Check that serial_num (model column) is stored properly
self.assertEqual(structure[0].serial_num, 1)
#First try allowing non-standard amino acids,
polypeptides = ppbuild.build_peptides(structure[0], False)
self.assertEqual(len(polypeptides), 1)
pp = polypeptides[0]
# Check the start and end positions
self.assertEqual(pp[0].get_id()[1], 151)
self.assertEqual(pp[-1].get_id()[1], 220)
# Check the sequence
s = pp.get_sequence()
self.assertTrue(isinstance(s, Seq))
self.assertEqual(s.alphabet, generic_protein)
#Here non-standard MSE are shown as M
self.assertEqual("MDIRQGPKEPFRDYVDRFYKTLRAEQASQEVKNWMTETLLVQ"
"NANPDCKTILKALGPGATLEEMMTACQG", str(s))
#==========================================================
#Now try strict version with only standard amino acids
#Should ignore MSE 151 at start, and then break the chain
#at MSE 185, and MSE 214,215
polypeptides = ppbuild.build_peptides(structure[0], True)
self.assertEqual(len(polypeptides), 3)
#First fragment
pp = polypeptides[0]
self.assertEqual(pp[0].get_id()[1], 152)
self.assertEqual(pp[-1].get_id()[1], 184)
s = pp.get_sequence()
self.assertTrue(isinstance(s, Seq))
self.assertEqual(s.alphabet, generic_protein)
self.assertEqual("DIRQGPKEPFRDYVDRFYKTLRAEQASQEVKNW", str(s))
#Second fragment
pp = polypeptides[1]
self.assertEqual(pp[0].get_id()[1], 186)
self.assertEqual(pp[-1].get_id()[1], 213)
s = pp.get_sequence()
self.assertTrue(isinstance(s, Seq))
self.assertEqual(s.alphabet, generic_protein)
self.assertEqual("TETLLVQNANPDCKTILKALGPGATLEE", str(s))
#Third fragment
pp = polypeptides[2]
self.assertEqual(pp[0].get_id()[1], 216)
self.assertEqual(pp[-1].get_id()[1], 220)
s = pp.get_sequence()
self.assertTrue(isinstance(s, Seq))
self.assertEqual(s.alphabet, generic_protein)
self.assertEqual("TACQG", str(s))
示例9: setUp
# 需要导入模块: from Bio.PDB.MMCIFParser import MMCIFParser [as 别名]
# 或者: from Bio.PDB.MMCIFParser.MMCIFParser import get_structure [as 别名]
def setUp(self):
# Silence!
warnings.simplefilter('ignore', PDBConstructionWarning)
pdbparser = PDBParser(QUIET=1)
cifparser = MMCIFParser(QUIET=1)
modpath = os.path.abspath(os.path.dirname(__file__))
pdb_file = os.path.join(modpath, "PDB", "1LCD.pdb")
cif_file = os.path.join(modpath, "PDB", "1LCD.cif")
self.pdbo = pdbparser.get_structure('pdb', pdb_file)
self.cifo = cifparser.get_structure('pdb', cif_file)
示例10: check_mmtf_vs_cif
# 需要导入模块: from Bio.PDB.MMCIFParser import MMCIFParser [as 别名]
# 或者: from Bio.PDB.MMCIFParser.MMCIFParser import get_structure [as 别名]
def check_mmtf_vs_cif(self, mmtf_filename, cif_filename):
"""Compare parsed structures for MMTF and CIF files."""
with warnings.catch_warnings():
warnings.simplefilter('ignore', PDBConstructionWarning)
mmtf_struct = MMTFParser.get_structure(mmtf_filename)
mmcif_parser = MMCIFParser()
mmcif_struct = mmcif_parser.get_structure("example", cif_filename)
self.mmcif_atoms = [x for x in mmcif_struct.get_atoms()]
self.mmtf_atoms = [x for x in mmtf_struct.get_atoms()]
self.check_atoms()
mmcif_chains = [x for x in mmcif_struct.get_chains()]
mmtf_chains = [x for x in mmtf_struct.get_chains()]
self.assertEqual(len(mmcif_chains), len(mmtf_chains))
for i, e in enumerate(mmcif_chains):
self.mmcif_res = [x for x in mmcif_chains[i].get_residues()]
self.mmtf_res = [x for x in mmtf_chains[i].get_residues()]
self.check_residues()
self.mmcif_res = [x for x in mmcif_struct.get_residues()]
self.mmtf_res = [x for x in mmtf_struct.get_residues()]
self.check_residues()
self.assertEqual(len([x for x in mmcif_struct.get_models()]), len([x for x in mmtf_struct.get_models()]))
示例11: test_parsers
# 需要导入模块: from Bio.PDB.MMCIFParser import MMCIFParser [as 别名]
# 或者: from Bio.PDB.MMCIFParser.MMCIFParser import get_structure [as 别名]
def test_parsers(self):
"""Extract polypeptides from 1A80."""
parser = MMCIFParser()
fast_parser = FastMMCIFParser()
structure = parser.get_structure("example", "PDB/1A8O.cif")
f_structure = fast_parser.get_structure("example", "PDB/1A8O.cif")
self.assertEqual(len(structure), 1)
self.assertEqual(len(f_structure), 1)
for ppbuild in [PPBuilder(), CaPPBuilder()]:
# ==========================================================
# Check that serial_num (model column) is stored properly
self.assertEqual(structure[0].serial_num, 1)
self.assertEqual(f_structure[0].serial_num, structure[0].serial_num)
# First try allowing non-standard amino acids,
polypeptides = ppbuild.build_peptides(structure[0], False)
f_polypeptides = ppbuild.build_peptides(f_structure[0], False)
self.assertEqual(len(polypeptides), 1)
self.assertEqual(len(f_polypeptides), 1)
pp = polypeptides[0]
f_pp = f_polypeptides[0]
# Check the start and end positions
self.assertEqual(pp[0].get_id()[1], 151)
self.assertEqual(pp[-1].get_id()[1], 220)
self.assertEqual(f_pp[0].get_id()[1], 151)
self.assertEqual(f_pp[-1].get_id()[1], 220)
# Check the sequence
s = pp.get_sequence()
f_s = f_pp.get_sequence()
self.assertEqual(s, f_s) # enough to test this
self.assertTrue(isinstance(s, Seq))
self.assertEqual(s.alphabet, generic_protein)
# Here non-standard MSE are shown as M
self.assertEqual("MDIRQGPKEPFRDYVDRFYKTLRAEQASQEVKNWMTETLLVQ"
"NANPDCKTILKALGPGATLEEMMTACQG", str(s))
# ==========================================================
# Now try strict version with only standard amino acids
# Should ignore MSE 151 at start, and then break the chain
# at MSE 185, and MSE 214,215
polypeptides = ppbuild.build_peptides(structure[0], True)
self.assertEqual(len(polypeptides), 3)
# First fragment
pp = polypeptides[0]
self.assertEqual(pp[0].get_id()[1], 152)
self.assertEqual(pp[-1].get_id()[1], 184)
s = pp.get_sequence()
self.assertTrue(isinstance(s, Seq))
self.assertEqual(s.alphabet, generic_protein)
self.assertEqual("DIRQGPKEPFRDYVDRFYKTLRAEQASQEVKNW", str(s))
# Second fragment
pp = polypeptides[1]
self.assertEqual(pp[0].get_id()[1], 186)
self.assertEqual(pp[-1].get_id()[1], 213)
s = pp.get_sequence()
self.assertTrue(isinstance(s, Seq))
self.assertEqual(s.alphabet, generic_protein)
self.assertEqual("TETLLVQNANPDCKTILKALGPGATLEE", str(s))
# Third fragment
pp = polypeptides[2]
self.assertEqual(pp[0].get_id()[1], 216)
self.assertEqual(pp[-1].get_id()[1], 220)
s = pp.get_sequence()
self.assertTrue(isinstance(s, Seq))
self.assertEqual(s.alphabet, generic_protein)
self.assertEqual("TACQG", str(s))
s_atoms = list(structure.get_atoms())
f_atoms = list(f_structure.get_atoms())
for atoms in [s_atoms, f_atoms]:
self.assertEqual(len(atoms), 644)
atom_names = ['N', 'CA', 'C', 'O', 'CB']
self.assertSequenceEqual([a.get_name() for a in atoms[:5]], atom_names)
self.assertSequenceEqual([a.get_id() for a in atoms[:5]], atom_names)
self.assertSequenceEqual([a.get_fullname() for a in atoms[:5]], atom_names)
self.assertSequenceEqual([a.get_occupancy() for a in atoms[:5]], [1., 1., 1., 1., 1.])
self.assertIsInstance(atoms[0].get_coord(), numpy.ndarray)
coord = numpy.array([19.594, 32.367, 28.012], dtype=numpy.float32)
numpy.testing.assert_array_equal(atoms[0].get_coord(), coord)
self.assertEqual(atoms[0].get_bfactor(), 18.03)
for atom in atoms:
self.assertIsNone(atom.get_anisou())