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("4CUP", cif_filename) self.mmcif_atoms = list(mmcif_struct.get_atoms()) self.mmtf_atoms = list(mmtf_struct.get_atoms()) self.check_atoms() mmcif_chains = list(mmcif_struct.get_chains()) mmtf_chains = list(mmtf_struct.get_chains()) self.assertEqual(len(mmcif_chains), len(mmtf_chains)) for i, e in enumerate(mmcif_chains): self.mmcif_res = list(mmcif_chains[i].get_residues()) self.mmtf_res = list(mmtf_chains[i].get_residues()) self.check_residues() self.mmcif_res = list(mmcif_struct.get_residues()) self.mmtf_res = list(mmtf_struct.get_residues()) self.check_residues() self.assertEqual( sum(1 for _ in mmcif_struct.get_models()), sum(1 for _ in mmtf_struct.get_models()), )
def test_multi_model_write(self): """Test multiple models are written out correctly to MMTF.""" parser = PDBParser() struc = parser.get_structure("1SSU_mod", "PDB/1SSU_mod.pdb") io = MMTFIO() io.set_structure(struc) filenumber, filename = tempfile.mkstemp() os.close(filenumber) try: io.save(filename) struc_back = MMTFParser.get_structure(filename) dict_back = mmtf.parse(filename) self.assertEqual(dict_back.num_models, 2) self.assertEqual(dict_back.num_chains, 4) self.assertEqual(dict_back.num_groups, 4) self.assertEqual(dict_back.num_atoms, 4) self.assertEqual(list(dict_back.x_coord_list), [-1.058, -0.025, 7.024, 6.259]) self.assertEqual(dict_back.chain_id_list, ["A", "B", "A", "B"]) self.assertEqual(dict_back.chain_name_list, ["A", "B", "A", "B"]) self.assertEqual(dict_back.chains_per_model, [2, 2]) self.assertEqual(len(dict_back.group_list), 1) self.assertEqual(len(dict_back.group_id_list), 4) self.assertEqual(len(dict_back.group_type_list), 4) self.assertEqual(dict_back.groups_per_chain, [1, 1, 1, 1]) self.assertEqual(len(dict_back.entity_list), 4) finally: os.remove(filename)
def loop_parsing(file_type, proteins, rep=10): cwd = os.getcwd() if file_type == 'mmtf': parser = MMTFParser() elif file_type == 'fast_cif': parser = FastMMCIFParser() elif file_type == 'cif': parser = MMCIFParser() else: parser = PDBParser() for p in proteins: if file_type == "fast_cif": file_type = "cif" directory = "%s/%s/%s.%s" % (cwd, file_type, p, file_type) try: if file_type == 'mmtf': protein = parser.get_structure(directory) else: protein = parser.get_structure(random.randint(0, 100), directory) except Exception: print("Having trouble parsing %s" % (p)) break return
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()]))
def test_selection_write(self): """Test the use of a Select subclass when writing MMTF files.""" struc = MMTFParser.get_structure("PDB/4CUP.mmtf") io = MMTFIO() io.set_structure(struc) filenumber, filename = tempfile.mkstemp() os.close(filenumber) class CAonly(Select): """Accepts only CA residues.""" def accept_atom(self, atom): if atom.name == "CA" and atom.element == "C": return 1 try: io.save(filename, CAonly()) struc_back = MMTFParser.get_structure(filename) dict_back = mmtf.parse(filename) self.assertEqual(dict_back.num_atoms, 116) self.assertEqual(len(dict_back.x_coord_list), 116) self.assertEqual(set(dict_back.alt_loc_list), {"\x00", "A", "B"}) finally: os.remove(filename)
def test_write(self): """Test a simple structure object is written out correctly to MMTF.""" parser = MMCIFParser() struc = parser.get_structure("1A8O", "PDB/1A8O.cif") io = MMTFIO() io.set_structure(struc) filenumber, filename = tempfile.mkstemp() os.close(filenumber) try: io.save(filename) struc_back = MMTFParser.get_structure(filename) dict_back = mmtf.parse(filename) self.assertEqual(dict_back.structure_id, "1A8O") self.assertEqual(dict_back.num_models, 1) self.assertEqual(dict_back.num_chains, 2) self.assertEqual(dict_back.num_groups, 158) self.assertEqual(dict_back.num_atoms, 644) self.assertEqual(len(dict_back.x_coord_list), 644) self.assertEqual(len(dict_back.y_coord_list), 644) self.assertEqual(len(dict_back.z_coord_list), 644) self.assertEqual(len(dict_back.b_factor_list), 644) self.assertEqual(len(dict_back.occupancy_list), 644) self.assertEqual(dict_back.x_coord_list[5], 20.022) self.assertEqual(set(dict_back.ins_code_list), {"\x00"}) self.assertEqual(set(dict_back.alt_loc_list), {"\x00"}) self.assertEqual(list(dict_back.atom_id_list), list(range(1, 645))) self.assertEqual(list(dict_back.sequence_index_list), list(range(70)) + [-1] * 88) self.assertEqual(dict_back.chain_id_list, ["A", "B"]) self.assertEqual(dict_back.chain_name_list, ["A", "A"]) self.assertEqual(dict_back.chains_per_model, [2]) self.assertEqual(len(dict_back.group_list), 21) self.assertEqual(len(dict_back.group_id_list), 158) self.assertEqual(len(dict_back.group_type_list), 158) self.assertEqual(dict_back.groups_per_chain, [70, 88]) self.assertEqual(len(dict_back.entity_list), 2) self.assertEqual(dict_back.entity_list[0]["type"], "polymer") self.assertEqual(dict_back.entity_list[0]["chainIndexList"], [0]) self.assertEqual( dict_back.entity_list[0]["sequence"], "MDIRQGPKEPFRDYVDRFYKTLRAEQASQEVKNWMTETLLVQNANPDCKTILKALGPGATLEEMMTACQG", ) self.assertEqual(dict_back.entity_list[1]["type"], "water") self.assertEqual(dict_back.entity_list[1]["chainIndexList"], [1]) self.assertEqual(dict_back.entity_list[1]["sequence"], "") finally: os.remove(filename)
def read_inputs(in_file, file_format, curr_model, chains): # Infer file format from extension file_format = file_format or os.path.basename(in_file).rsplit(".", 1)[-1] # Handle stdin if in_file == "-": contents = sys.stdin.read() struct_file = StringIO(contents) try: # Redirect stdin from pipe back to terminal sys.stdin = open("/dev/tty", "r") except: print( "Piping structures not supported on this system (no /dev/tty)") return None, None else: struct_file = in_file # Use Biopython parser by default get_coords = get_coords_biopython if file_format.lower() == "pdb": from Bio.PDB import PDBParser p = PDBParser() struc = p.get_structure("", struct_file) elif file_format.lower() in ("mmcif", "cif"): from Bio.PDB.MMCIFParser import MMCIFParser p = MMCIFParser() struc = p.get_structure("", struct_file) elif file_format.lower() == "mmtf": from Bio.PDB.mmtf import MMTFParser struc = MMTFParser.get_structure(struct_file) elif file_format.lower() in ("mae", "maegz"): from schrodinger import structure struc = list(structure.StructureReader(struct_file)) get_coords = get_coords_schrodinger else: print("Unrecognised file format") return None, None coords, info = get_coords(struc, chains) if coords is None or curr_model > len(coords): print("Nothing to show") return None, None return np.array(coords), info
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()]))
def test_1A80(self): """Parse 1A8O.mmtf""" with warnings.catch_warnings(): warnings.simplefilter('ignore', PDBConstructionWarning) structure = MMTFParser.get_structure("PDB/1A8O.mmtf")
def test_4ZHL(self): """Parse 4ZHL.mmtf""" with warnings.catch_warnings(): warnings.simplefilter('ignore', PDBConstructionWarning) structure = MMTFParser.get_structure("PDB/4ZHL.mmtf")
from Bio.PDB.mmtf import MMTFParser # read structure from file structure = MMTFParser.get_structure("PDB/4CUP.mmtf") # read structure from PDB structure = MMTFParser.get_structure_from_url("4CUP")
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()]))
def test_parser(): """Simply test that """ with warnings.catch_warnings(): warnings.simplefilter('ignore', PDBConstructionWarning) structure = MMTFParser.get_structure("PDB/4CUP.mmtf")
def test_cif(self): """Parse MMTF file.""" with warnings.catch_warnings(): warnings.simplefilter('ignore', PDBConstructionWarning) structure = MMTFParser.get_structure("PDB/1EJG.mmtf") print(structure)
def view_protein(in_file, file_format=None, curr_model=1, chains=[], box_size=100.0): if box_size < 10.0 or box_size > 400.0: print("Box size must be between 10 and 400") return zoom_speed = 1.1 trans_speed = 1.0 rot_speed = 0.1 spin_speed = 0.01 action_count = 500 auto_spin = False cycle_models = False # Infer file format from extension if file_format is None: file_format = os.path.basename(in_file).rsplit(".", 1)[-1] # Handle stdin if in_file == "-": contents = sys.stdin.read() struct_file = StringIO(contents) try: # Redirect stdin from pipe back to terminal sys.stdin = open("/dev/tty", "r") except: print( "Piping structures not supported on this system (no /dev/tty)") return else: struct_file = in_file if file_format.lower() == "pdb": from Bio.PDB import PDBParser p = PDBParser() struc = p.get_structure("", struct_file) elif file_format.lower() in ("mmcif", "cif"): from Bio.PDB.MMCIFParser import MMCIFParser p = MMCIFParser() struc = p.get_structure("", struct_file) elif file_format.lower() == "mmtf": from Bio.PDB.mmtf import MMTFParser struc = MMTFParser.get_structure(struct_file) else: print("Unrecognised file format") return # Get backbone coordinates coords = [] connections = [] atom_counter, res_counter = 0, 0 chain_ids = [] for mi, model in enumerate(struc): model_coords = [] for chain in model: chain_id = chain.get_id() if len(chains) > 0 and chain_id not in chains: continue if mi == 0: chain_ids.append(chain_id) for res in chain: if mi == 0: res_counter += 1 res_n = res.get_id()[1] for atom in res: if mi == 0: atom_counter += 1 if atom.get_name() in ( "N", "CA", "C", # Protein "P", "O5'", "C5'", "C4'", "C3'", "O3'", # Nucleic acid ): if mi == 0 and len(model_coords) > 0: # Determine if the atom is connected to the previous atom connections.append(chain_id == last_chain_id and (res_n == (last_res_n + 1) or res_n == last_res_n)) model_coords.append(atom.get_coord()) last_chain_id, last_res_n = chain_id, res_n model_coords = np.array(model_coords) if mi == 0: if model_coords.shape[0] == 0: print("Nothing to show") return coords_mean = model_coords.mean(0) model_coords -= coords_mean # Center on origin of first model coords.append(model_coords) coords = np.array(coords) if curr_model > len(struc): print("Can't find that model") return info_str = "{} with {} models, {} chains ({}), {} residues, {} atoms".format( os.path.basename(in_file), len(struc), len(chain_ids), "".join(chain_ids), res_counter, atom_counter) # Make square bounding box of a set size and determine zoom x_min, x_max = float(coords[curr_model - 1, :, 0].min()), float(coords[curr_model - 1, :, 0].max()) y_min, y_max = float(coords[curr_model - 1, :, 1].min()), float(coords[curr_model - 1, :, 1].max()) x_diff, y_diff = x_max - x_min, y_max - y_min box_bound = float(np.max([x_diff, y_diff])) + 2.0 zoom = box_size / box_bound x_min = zoom * (x_min - (box_bound - x_diff) / 2.0) x_max = zoom * (x_max + (box_bound - x_diff) / 2.0) y_min = zoom * (y_min - (box_bound - y_diff) / 2.0) y_max = zoom * (y_max + (box_bound - y_diff) / 2.0) # See https://stackoverflow.com/questions/13207678/whats-the-simplest-way-of-detecting-keyboard-input-in-python-from-the-terminal/13207724 fd = sys.stdin.fileno() oldterm = termios.tcgetattr(fd) newattr = termios.tcgetattr(fd) newattr[3] = newattr[3] & ~termios.ICANON & ~termios.ECHO termios.tcsetattr(fd, termios.TCSANOW, newattr) oldflags = fcntl.fcntl(fd, fcntl.F_GETFL) fcntl.fcntl(fd, fcntl.F_SETFL, oldflags | os.O_NONBLOCK) canvas = Canvas() trans_x, trans_y = 0.0, 0.0 rot_x, rot_y = 0.0, 0.0 try: while True: os.system("clear") points = [] for x_start, y_start, x_end, y_end in ( (x_min, y_min, x_max, y_min), (x_max, y_min, x_max, y_max), (x_max, y_max, x_min, y_max), (x_min, y_max, x_min, y_min), ): for x, y in line(x_start, y_start, x_end, y_end): points.append([x, y]) rot_mat_x = np.array([ [1.0, 0.0, 0.0], [0.0, np.cos(rot_x), -np.sin(rot_x)], [0.0, np.sin(rot_x), np.cos(rot_x)], ], dtype=np.float32) rot_mat_y = np.array([ [np.cos(rot_y), 0.0, np.sin(rot_y)], [0.0, 1.0, 0.0], [-np.sin(rot_y), 0.0, np.cos(rot_y)], ], dtype=np.float32) trans_coords = coords[curr_model - 1] + np.array( [trans_x, trans_y, 0.0], dtype=np.float32) zoom_rot_coords = zoom * np.matmul( rot_mat_y, np.matmul(rot_mat_x, trans_coords.T)).T for i in range(coords.shape[1] - 1): if connections[i]: x_start, x_end = float(zoom_rot_coords[i, 0]), float( zoom_rot_coords[i + 1, 0]) y_start, y_end = float(zoom_rot_coords[i, 1]), float( zoom_rot_coords[i + 1, 1]) if x_min < x_start < x_max and x_min < x_end < x_max and y_min < y_start < y_max and y_min < y_end < y_max: for x, y in line(x_start, y_start, x_end, y_end): points.append([x, y]) print(info_str) print( "W/A/S/D rotates, T/F/G/H moves, I/O zooms, U spins, P cycles models, Q quits" ) canvas.clear() for x, y in points: canvas.set(x, y) print(canvas.frame()) counter = 0 while True: if auto_spin or cycle_models: counter += 1 if counter == action_count: if auto_spin: rot_y += spin_speed if cycle_models: curr_model += 1 if curr_model > len(struc): curr_model = 1 break try: k = sys.stdin.read(1) if k: if k.upper() == "O": zoom /= zoom_speed elif k.upper() == "I": zoom *= zoom_speed elif k.upper() == "F": trans_x -= trans_speed elif k.upper() == "H": trans_x += trans_speed elif k.upper() == "G": trans_y -= trans_speed elif k.upper() == "T": trans_y += trans_speed elif k.upper() == "S": rot_x -= rot_speed elif k.upper() == "W": rot_x += rot_speed elif k.upper() == "A": rot_y -= rot_speed elif k.upper() == "D": rot_y += rot_speed elif k.upper() == "U": auto_spin = not auto_spin elif k.upper() == "P" and len(struc) > 1: cycle_models = not cycle_models elif k.upper() == "Q": return break except IOError: pass finally: termios.tcsetattr(fd, termios.TCSAFLUSH, oldterm) fcntl.fcntl(fd, fcntl.F_SETFL, oldflags)
def test_1A80(self): """Parse 1A8O.mmtf.""" with warnings.catch_warnings(): warnings.simplefilter("ignore", PDBConstructionWarning) structure = MMTFParser.get_structure("PDB/1A8O.mmtf")
def test_parser(): """Simply test that """ with warnings.catch_warnings(): warnings.simplefilter('ignore', PDBConstructionWarning) structure = MMTFParser.get_structure("PDB/4CUP.mmtf")
# Benchmark the parsing of a MMTF file given as an argument import sys import time from Bio.PDB.mmtf import MMTFParser mmtf_filepath = sys.argv[1] start = time.time() MMTFParser.get_structure(mmtf_filepath) end = time.time() print(end - start)