def test_calculate_starting_points_no_need_to_minimize(self): atoms, residues, chains = parse_complex_from_file( self.golden_data_path + '1PPE_rec.pdb') receptor = Complex(chains, atoms) atoms, residues, chains = parse_complex_from_file( self.golden_data_path + '1PPE_lig.pdb') ligand = Complex(chains, atoms) # Move structures to origin receptor_center = receptor.center_of_coordinates() ligand_center = ligand.center_of_coordinates() receptor_translation = [-1. * c for c in receptor_center] ligand_translation = [-1. * c for c in ligand_center] receptor.translate(receptor_translation) ligand.translate(ligand_translation) poses = FTDockCoordinatesParser.get_list_of_poses( self.golden_data_path + '1PPE.ftdock', ligand_center) assert 10000 == len(poses) for i in range(5): assert self.quaternions[i] == poses[i].q for j in range(3): assert_almost_equal(self.translations[i][j], poses[i].translation[j])
def test_calculate_interface(self): atoms, residues, chains = parse_complex_from_file( self.golden_data_path + '1PPErec.pdb') receptor = Complex(chains, atoms) atoms, residues, chains = parse_complex_from_file( self.golden_data_path + '1PPElig.pdb') ligand = Complex(chains, atoms) adapter = DFIREAdapter(receptor, ligand) receptor_residue_indexes, ligand_residue_indexes, dist_matrix, atom_indexes = get_interface_residues( adapter.receptor_model, adapter.ligand_model, max_cutoff=1.) receptor_residues = [] for residue_index in receptor_residue_indexes: residue = receptor.residues[residue_index] receptor_residues.append("%s.%d" % (residue.name, residue.number)) ligand_residues = [] for residue_index in ligand_residue_indexes: residue = ligand.residues[residue_index] ligand_residues.append("%s.%d" % (residue.name, residue.number)) # Checked according to UCSF chimera expected_receptor = [ 'SER.61', 'ALA.56', 'TYR.59', 'TYR.94', 'GLY.62', 'ILE.63', 'MET.104', 'ILE.106' ] expected_ligand = [ 'LEU.7', 'LEU.8', 'GLU.24', 'HIS.25', 'GLY.26', 'TYR.27', 'CYS.28' ] assert len(set(expected_receptor) & set(receptor_residues)) == 8 assert len(set(expected_ligand) & set(ligand_residues)) == 7
def test_calculate_PyDock_1AY7(self): atoms, _, chains = parse_complex_from_file(self.golden_data_path / '1AY7_rec.pdb.H') receptor = Complex(chains, atoms, structure_file_name=(self.golden_data_path / '1AY7_rec.pdb.H')) atoms, _, chains = parse_complex_from_file(self.golden_data_path / '1AY7_lig.pdb.H') ligand = Complex(chains, atoms, structure_file_name=(self.golden_data_path / '1AY7_lig.pdb.H')) adapter = CPyDockAdapter(receptor, ligand) assert_almost_equal(- 15.923994756, self.pydock(adapter.receptor_model, adapter.receptor_model.coordinates[0], adapter.ligand_model, adapter.ligand_model.coordinates[0]))
def test_null_rotation(self): protein = Complex(chains=self.chains2) q = Quaternion() protein.rotate(q) write_pdb_to_file(protein, self.test_path + 'rotated.pdb', protein.atom_coordinates[0]) assert filecmp.cmp(self.golden_data_path + 'two_residues.pdb', self.test_path + 'rotated.pdb')
def test_calculate_DNA_1AZP(self): atoms, residues, chains = parse_complex_from_file(self.golden_data_path + '1azp_prot.pdb') receptor = Complex(chains, atoms, structure_file_name=(self.golden_data_path + '1azp_prot.pdb')) atoms, residues, chains = parse_complex_from_file(self.golden_data_path + '1azp_dna.pdb') ligand = Complex(chains, atoms, structure_file_name=(self.golden_data_path + '1azp_dna.pdb')) adapter = DDNAAdapter(receptor, ligand) assert_almost_equal(6.915295143021656, self.dna(adapter.receptor_model, adapter.receptor_model.coordinates[0], adapter.ligand_model, adapter.ligand_model.coordinates[0]))
def test_calculate_PISA_1AY7(self): atoms, _, chains = parse_complex_from_file(self.golden_data_path / '1AY7rec.pdb') receptor = Complex(chains, atoms) atoms, _, chains = parse_complex_from_file(self.golden_data_path / '1AY7lig.pdb') ligand = Complex(chains, atoms) adapter = PISAAdapter(receptor, ligand) assert_almost_equal(-0.2141, round(self.pisa(adapter.receptor_model, adapter.receptor_model.coordinates[0], adapter.ligand_model, adapter.ligand_model.coordinates[0]), 4))
def test_calculate_DFIRE2_1AY7(self): atoms, residues, chains = parse_complex_from_file(self.golden_data_path + '1AY7rec.pdb') receptor = Complex(chains, atoms) atoms, residues, chains = parse_complex_from_file(self.golden_data_path + '1AY7lig.pdb') ligand = Complex(chains, atoms) adapter = DFIRE2Adapter(receptor, ligand) assert_almost_equal(-283.19129030999665, self.dfire(adapter.receptor_model, adapter.receptor_model.coordinates[0], adapter.ligand_model, adapter.ligand_model.coordinates[0]))
def test_calculate_DFIRE2_1PPE(self): atoms, residues, chains = parse_complex_from_file(self.golden_data_path + '1PPErec.pdb') receptor = Complex(chains, atoms) atoms, residues, chains = parse_complex_from_file(self.golden_data_path + '1PPElig.pdb') ligand = Complex(chains, atoms) adapter = DFIRE2Adapter(receptor, ligand) assert_almost_equal(-398.7303561600074, self.dfire(adapter.receptor_model, adapter.receptor_model.coordinates[0], adapter.ligand_model, adapter.ligand_model.coordinates[0]))
def test_calculate_DFIRE2_1EAW(self): atoms, residues, chains = parse_complex_from_file(self.golden_data_path + '1EAWrec.pdb') receptor = Complex(chains, atoms) atoms, residues, chains = parse_complex_from_file(self.golden_data_path + '1EAWlig.pdb') ligand = Complex(chains, atoms) adapter = DFIRE2Adapter(receptor, ligand) assert_almost_equal(-488.34640492000244, self.dfire(adapter.receptor_model, adapter.receptor_model.coordinates[0], adapter.ligand_model, adapter.ligand_model.coordinates[0]))
def calculate_membrane_height(parsed_receptor_file, restraints): atoms, residues, chains = parse_complex_from_file(parsed_receptor_file) receptor = Complex(chains, atoms) z_coord = [] for restraint in restraints: chain_id, residue_name, residue_number = restraint.split(".") residue = receptor.get_residue(chain_id, residue_name, residue_number) ca = residue.get_calpha() z_coord.append(ca.z) return min(z_coord)
def setup(self): self.golden_data_path = os.path.normpath( os.path.dirname(os.path.realpath(__file__))) + '/golden_data/' atoms, residues, chains = parse_complex_from_file( self.golden_data_path + '1PPErec.pdb') self.receptor = Complex(chains, atoms) atoms, residues, chains = parse_complex_from_file( self.golden_data_path + '1PPElig.pdb') self.ligand = Complex(chains, atoms) self.adapter = MJ3hAdapter(self.receptor, self.ligand) self.scoring_function = MJ3h()
def __init__(self): self.path = Path(__file__).absolute().parent self.golden_data_path = self.path / 'golden_data' atoms, _, chains = parse_complex_from_file(self.golden_data_path / '1PPErec.pdb') self.receptor = Complex(chains, atoms) atoms, _, chains = parse_complex_from_file(self.golden_data_path / '1PPElig.pdb') self.ligand = Complex(chains, atoms) self.adapter = MJ3hAdapter(self.receptor, self.ligand) self.scoring_function = MJ3h()
def test_rotation_180_degrees_y_axis_origin_is_0(self): """Expected file has been generated with Chimera fixing the rotation to the center of coordinates and modifying the column of atom name to have the same padding as the write_pdb_file function. """ protein = Complex(chains=self.chains2) q = Quaternion(0, 0.0, 1.0, 0) protein.rotate(q) write_pdb_to_file(protein, self.test_path+'rotated.pdb', protein.atom_coordinates[0]) assert filecmp.cmp(self.golden_data_path+'two_residues_y_180.pdb', self.test_path+'rotated.pdb')
def test_translate(self): atom1 = Atom(2, 'C', '', 'A', 'ALA', x=2., y=2., z=2.) atom2 = Atom(2, 'C', '', 'A', 'ALA', x=0., y=0., z=0.) residue = Residue('ALA', 1, [atom1, atom2]) chains = [Chain('A', [residue])] protein = Complex(chains) com = protein.center_of_mass() protein.translate([c * -1 for c in com]) expected_coordinates = np.array([[1, 1, 1], [-1, -1, -1]]) assert (expected_coordinates == protein.atom_coordinates).all()
def test_calculate_starting_points(self): atoms, residues, chains = parse_complex_from_file( self.golden_data_path + '1PPE_rec.pdb') receptor = Complex(chains, atoms) atoms, residues, chains = parse_complex_from_file( self.golden_data_path + '1PPE_lig.pdb') ligand = Complex(chains, atoms) starting_points, rec_diameter, lig_diameter = calculate_surface_points( receptor, ligand, 10, 0.5) create_pdb_from_points(self.test_path + 'points.pdb', starting_points) assert filecmp.cmp(self.golden_data_path + 'starting_points.pdb', self.test_path + 'points.pdb')
def test_translate(self): atom1 = Atom(2, 'C', '', 'A', 'ALA', x=2., y=2., z=2.) atom2 = Atom(2, 'C', '', 'A', 'ALA', x=0., y=0., z=0.) residue = Residue('ALA',1, [atom1, atom2]) chains = [Chain('A',[residue])] protein = Complex(chains) com = protein.center_of_mass() protein.translate([c*-1 for c in com]) expected_coordinates = np.array([[1,1,1],[-1,-1,-1]]) assert (expected_coordinates == protein.atom_coordinates).all()
def test_move_to_origin(self): atom1 = Atom(2, 'C', '', 'A', 'ALA', x=0., y=0., z=0.) atom2 = Atom(2, 'C', '', 'A', 'ALA', x=2., y=2., z=2.) atom3 = Atom(2, 'C', '', 'A', 'ALA', x=4., y=4., z=4.) residue = Residue('ALA',1, [atom1, atom2, atom3]) chains = [Chain('A',[residue])] protein = Complex(chains) protein.move_to_origin() expected_coordinates = np.array([[-2.,-2.,-2.],[0,0,0],[2.,2.,2.]]) assert (expected_coordinates == protein.atom_coordinates).all()
def test_calculate_MJ3h_1AY7(self): atoms, _, chains = parse_complex_from_file(self.golden_data_path / '1AY7rec.pdb') receptor = Complex(chains, atoms) atoms, _, chains = parse_complex_from_file(self.golden_data_path / '1AY7lig.pdb') ligand = Complex(chains, atoms) adapter = MJ3hAdapter(receptor, ligand) assert_almost_equal( -12.92, self.mj3h(adapter.receptor_model, adapter.receptor_model.coordinates[0], adapter.ligand_model, adapter.ligand_model.coordinates[0]))
def test_create_adapter(self): atoms, _, chains = parse_complex_from_file(self.golden_data_path / '1PPErec.pdb') receptor = Complex(chains, atoms) atoms, _, chains = parse_complex_from_file(self.golden_data_path / '1PPElig.pdb') ligand = Complex(chains, atoms) adapter = MJ3hAdapter(receptor, ligand) assert adapter.receptor_model.coordinates[0].coordinates.shape == (223, 3) assert adapter.ligand_model.coordinates[0].coordinates.shape == (29, 3) assert len(adapter.receptor_model.objects) == 223 assert len(adapter.ligand_model.objects) == 29
def test_calculate_DFIRE_1EAW(self): atoms, _, chains = parse_complex_from_file(self.golden_data_path / '1EAWrec.pdb') receptor = Complex(chains, atoms) atoms, _, chains = parse_complex_from_file(self.golden_data_path / '1EAWlig.pdb') ligand = Complex(chains, atoms) adapter = DFIREAdapter(receptor, ligand) assert_almost_equal( -16.2182794457, self.dfire(adapter.receptor_model, adapter.receptor_model.coordinates[0], adapter.ligand_model, adapter.ligand_model.coordinates[0]))
def test_calculate_TOBI_1EAW(self): atoms, _, chains = parse_complex_from_file(self.golden_data_path / '1EAWrec.pdb') receptor = Complex(chains, atoms) atoms, _, chains = parse_complex_from_file(self.golden_data_path / '1EAWlig.pdb') ligand = Complex(chains, atoms) adapter = TOBIAdapter(receptor, ligand) assert_almost_equal( -11.22, self.tobi(adapter.receptor_model, adapter.receptor_model.coordinates[0], adapter.ligand_model, adapter.ligand_model.coordinates[0]))
def test_calculate_MJ3h_1EAW(self): atoms, residues, chains = parse_complex_from_file( self.golden_data_path + '1EAWrec.pdb') receptor = Complex(chains, atoms) atoms, residues, chains = parse_complex_from_file( self.golden_data_path + '1EAWlig.pdb') ligand = Complex(chains, atoms) adapter = MJ3hAdapter(receptor, ligand) assert_almost_equal( -4.22, self.mj3h(adapter.receptor_model, adapter.receptor_model.coordinates[0], adapter.ligand_model, adapter.ligand_model.coordinates[0]))
def test_calculate_TOBI_1AY7(self): atoms, residues, chains = parse_complex_from_file( self.golden_data_path + '1AY7rec.pdb') #@UnusedVariable receptor = Complex(chains, atoms) atoms, residues, chains = parse_complex_from_file( self.golden_data_path + '1AY7lig.pdb') #@UnusedVariable ligand = Complex(chains, atoms) adapter = TOBIAdapter(receptor, ligand) assert_almost_equal( 2.34, self.tobi(adapter.receptor_model, adapter.receptor_model.coordinates[0], adapter.ligand_model, adapter.ligand_model.coordinates[0]))
def test_rotation_180_degrees_y_axis_origin_is_0(self): """Expected file has been generated with Chimera fixing the rotation to the center of coordinates and modifying the column of atom name to have the same padding as the write_pdb_file function. """ protein = Complex(chains=self.chains2) q = Quaternion(0, 0.0, 1.0, 0) protein.rotate(q) write_pdb_to_file(protein, self.test_path + 'rotated.pdb', protein.atom_coordinates[0]) assert filecmp.cmp(self.golden_data_path + 'two_residues_y_180.pdb', self.test_path + 'rotated.pdb')
def test_calculate_FastDFIRE_1AY7(self): atoms, _, chains = parse_complex_from_file(self.golden_data_path / '1AY7rec.pdb') receptor = Complex(chains, atoms) atoms, _, chains = parse_complex_from_file(self.golden_data_path / '1AY7lig.pdb') ligand = Complex(chains, atoms) adapter = DFIREAdapter(receptor, ligand) assert_almost_equal( -20.7459619159, self.dfire(adapter.receptor_model, adapter.receptor_model.coordinates[0], adapter.ligand_model, adapter.ligand_model.coordinates[0]))
def test_move_to_origin(self): atom1 = Atom(2, 'C', '', 'A', 'ALA', x=0., y=0., z=0.) atom2 = Atom(2, 'C', '', 'A', 'ALA', x=2., y=2., z=2.) atom3 = Atom(2, 'C', '', 'A', 'ALA', x=4., y=4., z=4.) residue = Residue('ALA', 1, [atom1, atom2, atom3]) chains = [Chain('A', [residue])] protein = Complex(chains) protein.move_to_origin() expected_coordinates = np.array([[-2., -2., -2.], [0, 0, 0], [2., 2., 2.]]) assert (expected_coordinates == protein.atom_coordinates).all()
def read_input_structure(pdb_file_name, ignore_oxt=True): """Reads the input structure. The arguments pdb_file_name can be a PDB file or a file containing a list of PDB files. ignore_oxt flag avoids saving OXT atoms. """ atoms_to_ignore = [] if ignore_oxt: atoms_to_ignore.append('OXT') structures = [] file_names = [] file_name, file_extension = os.path.splitext(pdb_file_name) if file_extension == DEFAULT_LIST_EXTENSION: file_names.extend(get_pdb_files(pdb_file_name)) else: file_names.append(pdb_file_name) for file_name in file_names: log.info("Reading structure from %s PDB file..." % file_name) atoms, residues, chains = parse_complex_from_file(file_name, atoms_to_ignore) structures.append({'atoms': atoms, 'residues': residues, 'chains': chains, 'file_name': file_name}) log.info("%s atoms, %s residues read." % (len(atoms), len(residues))) # Representatives are now the first structure, but this could change in the future structure = Complex.from_structures(structures) return structure
def test_calculate_min_volume_ellipsoid(self): atoms, _, chains = parse_complex_from_file(self.golden_data_path / '1PPE_l_u.pdb') protein = Complex(chains, atoms) ellipsoid = MinimumVolumeEllipsoid(protein.atom_coordinates[0].coordinates) assert_almost_equal(5.79979144, ellipsoid.center[0]) assert_almost_equal(13.30609275, ellipsoid.center[1]) assert_almost_equal(6.28378695, ellipsoid.center[2]) assert_almost_equal(11.51000999, ellipsoid.radii[0]) assert_almost_equal(17.41300089, ellipsoid.radii[1]) assert_almost_equal(25.1317681, ellipsoid.radii[2]) assert_almost_equal(-0.64868458, ellipsoid.rotation[0][0]) assert_almost_equal(-0.43420895, ellipsoid.rotation[0][1]) assert_almost_equal(0.62503673, ellipsoid.rotation[0][2]) assert_almost_equal(0.75208829, ellipsoid.rotation[1][0]) assert_almost_equal(-0.49144928, ellipsoid.rotation[1][1]) assert_almost_equal(0.43913643, ellipsoid.rotation[1][2]) assert_almost_equal(0.11649688, ellipsoid.rotation[2][0]) assert_almost_equal(0.75494384, ellipsoid.rotation[2][1]) assert_almost_equal(0.64535903, ellipsoid.rotation[2][2]) expected_poles = [[13.266157381855532, 18.303842059830465, -0.91039204503235993], [-1.6665744987943629, 8.3083434397316651, 13.477965942387469], [-7.296322648355452, 21.863699498711949, -1.3628961564119457], [18.89590553141662, 4.7484860008501819, 13.930470053767054], [2.8720188105117521, -5.6669806736857815, -9.9352265853089641], [8.7275640725494164, 32.279166173247916, 22.502800482664075]] assert np.allclose(expected_poles, ellipsoid.poles, ERROR_TOLERANCE)
def test_move_step_rot_half_step_trans_half(self): atoms, residues, chains = parse_complex_from_file( self.golden_data_path + '1PPElig.pdb') ligand = Complex(chains, atoms) adapter = MJ3hAdapter(self.receptor, ligand) scoring_function = MJ3h() coordinates1 = Coordinates([0., 0., 0., 1., 0., 0., 0.]) landscape_position1 = DockingLandscapePosition(scoring_function, coordinates1, adapter.receptor_model, adapter.ligand_model, step_translation=5.0, step_rotation=0.5) adapter2 = MJ3hAdapter(self.receptor, ligand) coordinates2 = Coordinates([10., 0., 0., 0., 0., 1., 0.]) landscape_position2 = DockingLandscapePosition(scoring_function, coordinates2, adapter2.receptor_model, adapter2.ligand_model) landscape_position1.move(landscape_position2) expected_translation = np.array([5., 0., 0.]) expected_rotation = Quaternion(0.707106781, 0.0, 0.707106781, 0.0) assert (expected_translation == landscape_position1.translation).all() assert expected_rotation == landscape_position1.rotation
def calculate_sasa(pdb_file): # Read PDB structure atoms, residues, chains = parse_complex_from_file(pdb_file) molecule = Complex(chains, atoms, structure_file_name=pdb_file) parameters = DesolvationParameters() # Lightdock structure to freesasa structure structure = Structure() for atom in molecule.atoms: structure.addAtom(atom.name, atom.residue_name, atom.residue_number, atom.chain_id, atom.x, atom.y, atom.z) atom_names = [] atom_radius = [] for atom in molecule.atoms: atom_names.append("%-4s" % atom.name) if atom.residue_name == 'CYX': atom.residue_name = 'CYS' atom_radius.append(parameters.radius_per_atom[atom.residue_name + "-" + atom.name]) structure.setRadii(atom_radius) start_time = timeit.default_timer() result = freesasa.calc(structure) elapsed = timeit.default_timer() - start_time return result.totalArea(), elapsed
def __init__(self): self.path = Path(__file__).absolute().parent self.test_path = self.path / 'scratch_docking_landscape' self.golden_data_path = self.path / 'golden_data' atoms, _, chains = parse_complex_from_file(self.golden_data_path / '1PPErec.pdb') self.receptor = Complex(chains, atoms)
def test_clone_complex(self): protein1 = Complex(chains=self.chains) protein2 = protein1.clone() assert protein1.num_atoms == protein2.num_atoms assert protein1.num_residues == protein2.num_residues for atom1, atom2 in zip(protein1.atoms, protein2.atoms): assert atom1 == atom2 assert protein1.atom_coordinates == protein2.atom_coordinates for residue1, residue2 in zip(protein1.residues, protein2.residues): assert residue1 == residue2 protein2.atoms[0].name = 'C' for atom1, atom2 in zip(protein1.atoms[1:], protein2.atoms[1:]): assert atom1 == atom2 assert protein1.atoms[0] != protein2.atoms[0]
def setUp(self): self.path = os.path.dirname(os.path.realpath(__file__)) self.golden_data_path = os.path.normpath( os.path.dirname(os.path.realpath(__file__))) + '/golden_data/' atoms, residues, chains = parse_complex_from_file( self.golden_data_path + '1PPErec.pdb') self.receptor = Complex(chains, atoms)
def test_calculate_starting_points(self): # Receptor file_name = self.golden_data_path / '1PPE_rec.pdb' atoms, _, chains = parse_complex_from_file(file_name) receptor = Complex(chains, atoms, structure_file_name=file_name) # Ligand file_name = self.golden_data_path / '1PPE_lig.pdb' atoms, _, chains = parse_complex_from_file(file_name) ligand = Complex(chains, atoms, structure_file_name=file_name) starting_points, rec_diameter, lig_diameter = calculate_surface_points(receptor, ligand, 50, [0.,0.,0.], 50.) assert_almost_equal(rec_diameter, 50.213210831413676) assert_almost_equal(lig_diameter, 27.855559534857672) create_pdb_from_points(self.test_path / 'points.pdb', starting_points) assert filecmp.cmp(self.golden_data_path / 'starting_points.pdb', self.test_path / 'points.pdb')
def test_calculate_starting_points_no_need_to_minimize(self): atoms, residues, chains = parse_complex_from_file(self.golden_data_path + '1PPE_rec.pdb') receptor = Complex(chains, atoms) atoms, residues, chains = parse_complex_from_file(self.golden_data_path + '1PPE_lig.pdb') ligand = Complex(chains, atoms) # Move structures to origin receptor_center = receptor.center_of_coordinates() ligand_center = ligand.center_of_coordinates() receptor_translation = [-1.*c for c in receptor_center] ligand_translation = [-1.*c for c in ligand_center] receptor.translate(receptor_translation) ligand.translate(ligand_translation) poses = FTDockCoordinatesParser.get_list_of_poses(self.golden_data_path + '1PPE.ftdock', ligand_center) assert 10000 == len(poses) for i in range(5): assert self.quaternions[i] == poses[i].q for j in range(3): assert_almost_equal(self.translations[i][j], poses[i].translation[j])
setup = get_setup_from_file(args.setup_file) if args.setup_file else None num_anm_rec = DEFAULT_NMODES_REC num_anm_lig = DEFAULT_NMODES_LIG if setup and setup['use_anm']: num_anm_rec = setup['anm_rec'] num_anm_lig = setup['anm_lig'] # Receptor structures = [] for structure in get_lightdock_structures(args.receptor_structures): log.info("Reading %s receptor PDB file..." % structure) atoms, residues, chains = parse_complex_from_file(structure) structures.append({'atoms': atoms, 'residues': residues, 'chains': chains, 'file_name': structure}) log.info("%s atoms, %s residues read." % (len(atoms), len(residues))) receptor = Complex.from_structures(structures) # Ligand structures = [] for structure in get_lightdock_structures(args.ligand_structures): log.info("Reading %s ligand PDB file..." % structure) atoms, residues, chains = parse_complex_from_file(structure) structures.append({'atoms': atoms, 'residues': residues, 'chains': chains, 'file_name': structure}) log.info("%s atoms, %s residues read." % (len(atoms), len(residues))) ligand = Complex.from_structures(structures) # Output file translations, rotations, receptor_ids, ligand_ids, \ rec_extents, lig_extents = parse_output_file(args.lightdock_output, num_anm_rec, num_anm_lig) found_conformations = len(translations)
atoms_to_ignore.append('OXT') structures = [] file_names = [] file_name, file_extension = os.path.splitext(args.structure) if file_extension == DEFAULT_LIST_EXTENSION: file_names.extend(get_pdb_files(args.structure)) else: file_names.append(args.structure) for file_name in file_names: log.info("Reading %s PDB file..." % file_name) atoms, residues, chains = parse_complex_from_file(file_name, atoms_to_ignore) structures.append({'atoms': atoms, 'residues': residues, 'chains': chains, 'file_name': file_name}) log.info("%s atoms, %s residues read." % (len(atoms), len(residues))) molecule = Complex.from_structures(structures) try: ellipsoid = MinimumVolumeEllipsoid(molecule.atom_coordinates[0].coordinates) except MinimumVolumeEllipsoidError, e: log.error("Impossible to calculate minimum volume ellipsoid. Reason: %s" % str(e)) raise SystemExit("%s finished with error" % script_name) output_file_name = molecule.structure_file_names[0] + DEFAULT_REFERENCE_POINTS_EXTENSION with open(output_file_name, 'w') as output: for point in ellipsoid.poles: output.write(get_point_respresentation(point) + os.linesep) output.write(get_point_respresentation(ellipsoid.center) + os.linesep) log.info('Points written to %s' % output_file_name) points = [point for point in ellipsoid.poles] points.append(ellipsoid.center)
n_modes = int(sys.argv[2]) factor = float(sys.argv[3]) except: usage() raise SystemExit("Wrong command line") protein = parsePDB(pdb_structure) ca_atoms = protein.select('name CA') protein_anm = ANM('protein ca') protein_anm.buildHessian(ca_atoms) protein_anm.calcModes(n_modes=n_modes) print 'Normal modes calculated' atoms, residues, chains = parse_complex_from_file(pdb_structure) lightdock_structures = [{'atoms': atoms, 'residues': residues, 'chains': chains, 'file_name': pdb_structure}] lightdock_structure = Complex.from_structures(lightdock_structures) print 'Structure read by lightdock' num_atoms_prody = len(protein.protein) num_atoms_lightdock = len(atoms) if num_atoms_prody != num_atoms_lightdock: raise SystemExit("Number of atoms is different") protein_anm_ext, protein_all = extendModel(protein_anm, ca_atoms, protein, norm=True) modes = [] for i in range(n_modes): nm = protein_anm_ext.getEigvecs()[:, i].reshape((num_atoms_lightdock, 3)) modes.append(nm)
def test_center_of_mass_empty_complex(self): protein = Complex([]) com = protein.center_of_mass() assert_almost_equals(0., com[0]) assert_almost_equals(0., com[1]) assert_almost_equals(0., com[2])
Parses command line arguments """ parser = argparse.ArgumentParser(prog='surface_density') parser.add_argument("pdb1", help="PDB file for receptor structure") parser.add_argument("pdb2", help="PDB file for ligand structure") parser.add_argument("points", type=int, default=400, help="The number of points on the surface") args = parser.parse_args() return args if __name__ == "__main__": args = parse_command_line() # Read receptor and calculate max radius atoms, residues, chains = parse_complex_from_file(args.pdb1) structure = Complex(chains, atoms, structure_file_name=args.pdb1) distances_matrix = spatial.distance.squareform(spatial.distance.pdist(structure.representative())) radius1 = np.max(distances_matrix)/2. # Read ligand and calculate max radius atoms, residues, chains = parse_complex_from_file(args.pdb2) structure = Complex(chains, atoms, structure_file_name=args.pdb2) distances_matrix = spatial.distance.squareform(spatial.distance.pdist(structure.representative())) radius2 = np.max(distances_matrix)/2. # Calculate the area of the sphere of radius (Rl + Rr) density_area = (4*np.pi*(radius1+radius2)**2)/args.points if density_area > MIN_SURFACE_DENSITY: log.warning("Surface density is below recommended, please increase the number of points on the surface.")
def test_center_of_mass(self): protein = Complex(chains=self.chains) com = protein.center_of_mass() assert_almost_equals(1.8037228011238935, com[0]) assert_almost_equals(1.7998854581864723, com[1]) assert_almost_equals(1.7960481152490517, com[2])
def test_null_rotation(self): protein = Complex(chains=self.chains2) q = Quaternion() protein.rotate(q) write_pdb_to_file(protein, self.test_path+'rotated.pdb', protein.atom_coordinates[0]) assert filecmp.cmp(self.golden_data_path+'two_residues.pdb', self.test_path+'rotated.pdb')
def test_center_of_coordinates(self): protein = Complex(chains=self.chains) cc = protein.center_of_coordinates() assert_almost_equals(1.75, cc[0]) assert_almost_equals(1.75, cc[1]) assert_almost_equals(1.75, cc[2])
def test_center_of_coordinates_zero_atoms(self): protein = Complex(chains=[]) cc = protein.center_of_coordinates() assert_almost_equals(0.0, cc[0]) assert_almost_equals(0.0, cc[1]) assert_almost_equals(0.0, cc[2])