예제 #1
0
    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_FastDFIRE_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 = 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]))
예제 #3
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]))
예제 #4
0
 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()
예제 #5
0
 def test_calculate_PyDockDNA_3MFK_with_hydrogens(self):
     atoms, residues, chains = parse_complex_from_file(self.golden_data_path + '3mfk_homodimer.pdb.H')
     receptor = Complex(chains, atoms, structure_file_name=(self.golden_data_path + '3mfk_homodimer.pdb.H'))
     atoms, residues, chains = parse_complex_from_file(self.golden_data_path + '3mfk_dna.pdb')
     ligand = Complex(chains, atoms, structure_file_name=(self.golden_data_path + '3mfk_dna.pdb'))
     adapter = CPyDockDNAAdapter(receptor, ligand)
     assert_almost_equal(688.1703668834168, self.dna(adapter.receptor_model, adapter.receptor_model.coordinates[0],
                                                     adapter.ligand_model, adapter.ligand_model.coordinates[0]))
 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_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 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]))
예제 #9
0
    def test_calculate_phi_psi(self):
        atoms, residues, chains = parse_complex_from_file(self.golden_data_path + '1PPElig.pdb')
        protein = Complex(chains, atoms)
        # psi: angle #0:1@n,ca,c #0:2@n
        # phi: angle #0:1@c #0:2@n,ca,c

        phi_angles = [-105.92428251619579, -134.402235889132, -58.32268858533758, -85.62997439535678, -129.666484600813,
                      -77.00076813772478, -142.09891098624075, -82.10672119029674, -163.14606891327375,
                      -109.37900096123484, -138.72905680654182, -59.09699793329797, -60.06774387010816,
                      -74.41030551527874, -99.82766540256617, -92.6495110068149, 54.969041241310705,
                      -104.60151419194615, -67.57074855137641, -123.83574594954692, -85.90313254423194,
                      -87.7781803331676, -66.345484249271, -64.51513795752882, 108.23656098935888, -129.62530277139578,
                      -71.90658189461674, -170.4460918036806]
        psi_angles = [138.38576328505278, 105.22472788100255, 106.42882930892199, 150.65572151747787, 72.08329638522976,
                      130.19890858175336, 115.48238807519739, 132.48041144914038, 163.35191386073618,
                      151.17756189538443, -28.310569696143393, 162.66293554938997, -32.25480696024475,
                      -20.28436719199857, -11.444789534534305, 163.38578466073147, 150.2534549328882,
                      -128.53524744082424, 20.01260634937939, 151.96710290169335, 159.55519588393594,
                      115.07091589216549, 152.8911959270869, -24.04765297807205, -14.890186424782046, 15.86273088398991,
                      152.7552784042674, 146.11762131430552]

        for i in range(1, len(protein.residues)):
            phi, psi = calculate_phi_psi(protein.residues[i], protein.residues[i - 1])
            assert_almost_equals(phi_angles[i - 1], math.degrees(phi))
            assert_almost_equals(psi_angles[i - 1], math.degrees(psi))
예제 #10
0
 def test_parse_complex_from_file(self):
     atoms, residues, chains = parse_complex_from_file(self.golden_data_path + '1PPE_l_u.pdb')
     assert 224 == len(atoms)
     assert 31 == len(residues)
     assert 2 == len(chains)
     assert 29 == len(chains[0].residues)
     assert 2 == len(chains[1].residues)
예제 #11
0
 def test_calculate_chi_angles(self):
     # Command in chimera: angle #0:28@n,ca,cb,sg
     atoms, residues, chains = parse_complex_from_file(self.golden_data_path + '1PPElig.pdb')
     protein = Complex(chains, atoms)
     for residue in protein.residues:
         if residue.name == 'ARG' and residue.number == 1:
             chi_angles = calculate_chi_angles(residue)
             for key, value in chi_angles.iteritems():
                 if value:
                     if key == 'x1':
                         # angle #0:1@n,ca,cb,cg
                         assert_almost_equals(-173.216, round(math.degrees(value), 3))
                     if key == 'x2':
                         # angle #0:1@ca,cb,cg,cd
                         assert_almost_equals(171.375, round(math.degrees(value), 3))
                     if key == 'x3':
                         # angle #0:1@cb,cg,cd,ne
                         assert_almost_equals(62.852, round(math.degrees(value), 3))
                     if key == 'x4':
                         # angle #0:1@cg,cd,ne,cz
                         assert_almost_equals(100.22, round(math.degrees(value), 2))
         if residue.name == 'VAL' and residue.number == 2:
             # angle #0:2@n,ca,cb,cg1
             chi_angles = calculate_chi_angles(residue)
             for key, value in chi_angles.iteritems():
                 if value:
                     if key == 'x1':
                         # angle #0:1@n,ca,cb,cg
                         assert_almost_equals(-173.629, round(math.degrees(value), 3))
         if residue.name == 'CYS' and residue.number == 28:
             chi_angles = calculate_chi_angles(residue)
             for key, value in chi_angles.iteritems():
                 if value:
                     if key == 'x1':
                         assert_almost_equals(-60.2554, round(math.degrees(value), 4))
예제 #12
0
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
예제 #13
0
 def test_write_pdb_to_file(self):
     atoms, residues, chains = parse_complex_from_file(self.golden_data_path + '1PPE_l_u.pdb')
     protein = Complex(chains)
     assert atoms == protein.atoms
     
     write_pdb_to_file(protein, self.test_path + '1PPE_l_u.pdb.parsed', protein.atom_coordinates[0])
     
     assert filecmp.cmp(self.golden_data_path + '1PPE_l_u.pdb.parsed', self.test_path + '1PPE_l_u.pdb.parsed')
예제 #14
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 test_LightDockGSOBuilder_using_FromFileInitializer(self):
     builder = LightdockGSOBuilder()
     number_of_glowworms = 5
     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 = MJ3hAdapter(receptor, ligand)
     scoring_function = MJ3h()
     gso = builder.create_from_file(number_of_glowworms, self.random_number_generator, 
                                    self.gso_parameters, [adapter], [scoring_function], self.bounding_box,
                                    self.golden_data_path+'initial_positions_1PPE.txt',
                                    0.5, 0.5, 0.5, False, 10, 10)
     
     assert 5 == gso.swarm.get_size()
     
     gso.report(self.test_path + 'report.out')
     assert filecmp.cmp(self.golden_data_path + 'report_lightdockbuilder.out',
                        self.test_path + 'report.out')
 def test_evaluate_objective_function_rotation_y_axis_180_translation_10(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()
     coordinates = Coordinates([10.,0.,0.,0.,0.,1.,0.])
     landscape_position = DockingLandscapePosition(scoring_function, coordinates, 
                                                   adapter.receptor_model, 
                                                   adapter.ligand_model)
     
     assert_almost_equal(6.39, landscape_position.evaluate_objective_function())
예제 #17
0
    def test_get_restraints(self):
        input_file = os.path.join(self.golden_data_path, '2UUY_lig.pdb')
        atoms, residues, chains = parse_complex_from_file(input_file)
        structure = Complex(chains)
        restraints = {'active':['B.ALA.21'], 'passive':['B.GLY.75'], 'blocked':[]}
        
        residues = get_restraints(structure, restraints)

        assert len(residues['active']) == 1 and len(residues['passive']) == 1
        assert residues['active'][0].name == 'ALA' and residues['active'][0].number == 21
        assert residues['passive'][0].name == 'GLY' and residues['passive'][0].number == 75
예제 #18
0
 def test_calculate_PyDock_1AY7(self):
     atoms, residues, 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, residues, 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]))
예제 #19
0
 def test_calculate_DNA_3MFK_with_hydrogens(self):
     atoms, residues, chains = parse_complex_from_file(
         self.golden_data_path + '3mfk_homodimer.pdb.H')
     receptor = Complex(chains,
                        atoms,
                        structure_file_name=(self.golden_data_path +
                                             '3mfk_homodimer.pdb.H'))
     atoms, residues, chains = parse_complex_from_file(
         self.golden_data_path + '3mfk_dna.pdb')
     ligand = Complex(chains,
                      atoms,
                      structure_file_name=(self.golden_data_path +
                                           '3mfk_dna.pdb'))
     adapter = DNAAdapter(receptor, ligand)
     assert_almost_equal(
         688.1703668834168,
         self.dna(adapter.receptor_model,
                  adapter.receptor_model.coordinates[0],
                  adapter.ligand_model,
                  adapter.ligand_model.coordinates[0]))
예제 #20
0
    def test_read_write(self):
        pdb_file = self.golden_data_path / 'nm_dna' / '1DIZ_lig.pdb.H'
        _, _, chains = parse_complex_from_file(pdb_file)
        molecule = Complex(chains)

        nmodes = calculate_nmodes(pdb_file, n_modes=10, molecule=molecule)
        write_nmodes(nmodes, self.test_path / 'test_nm')

        expected_nmodes = read_nmodes(self.golden_data_path / 'nm_dna' / 'lightdock_lig.nm.npy')
        other_nmodes = read_nmodes(self.test_path / 'test_nm.npy')

        assert np.allclose(expected_nmodes, other_nmodes)
예제 #21
0
    def test_parse_pdb_noh(self):
        atoms_to_ignore = ['H']
        atoms, _, chains = parse_complex_from_file(
            self.golden_data_path / '1PPE_lig.pdb.H', atoms_to_ignore)
        protein = Complex(chains)
        assert atoms == protein.atoms

        write_pdb_to_file(protein, self.test_path / 'parsed_1PPE_lig.pdb.H',
                          protein.atom_coordinates[0])

        assert filecmp.cmp(self.golden_data_path / 'parsed_1PPE_lig.pdb.H',
                           self.test_path / 'parsed_1PPE_lig.pdb.H')
예제 #22
0
 def test_repr(self):
     atoms, _, chains = parse_complex_from_file(self.golden_data_path /
                                                '1PPElig.pdb')
     ligand = Complex(chains, atoms)
     adapter = MJ3hAdapter(self.receptor, ligand)
     scoring_function = MJ3h()
     coordinates = Coordinates([0., 0., 0., 1., 0., 0., 0.])
     landscape_position = DockingLandscapePosition(scoring_function,
                                                   coordinates,
                                                   adapter.receptor_model,
                                                   adapter.ligand_model)
     expected = "( 0.0000000,  0.0000000,  0.0000000,  1.0000000,  0.0000000,  0.0000000,  0.0000000)    0    0"
     assert expected == str(landscape_position)
 def test_distance2_same_landscape_position(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()
     coordinates = Coordinates([0., 0., 0., 1., 0., 0., 0.])
     landscape_position1 = DockingLandscapePosition(scoring_function, coordinates, 
                                                   adapter.receptor_model, 
                                                   adapter.ligand_model)
     landscape_position2 = DockingLandscapePosition(scoring_function, coordinates, 
                                                   adapter.receptor_model, 
                                                   adapter.ligand_model)
     assert_almost_equal(0.0, landscape_position1.distance2(landscape_position2))
예제 #24
0
    def test_calculate_anm_dna(self):
        pdb_file = os.path.join(self.golden_data_path, 'nm_dna',
                                '1DIZ_lig.pdb.H')
        atoms, residues, chains = parse_complex_from_file(pdb_file)
        molecule = Complex(chains)

        nmodes = calculate_nmodes(pdb_file, n_modes=10, molecule=molecule)

        expected_nmodes = read_nmodes(
            os.path.join(self.golden_data_path, 'nm_dna',
                         'lightdock_lig.nm.npy'))

        assert np.allclose(expected_nmodes, nmodes)
예제 #25
0
 def test_distance2_same_landscape_position(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()
     coordinates = Coordinates([0., 0., 0., 1., 0., 0., 0.])
     landscape_position1 = DockingLandscapePosition(scoring_function, coordinates, 
                                                   adapter.receptor_model, 
                                                   adapter.ligand_model)
     landscape_position2 = DockingLandscapePosition(scoring_function, coordinates, 
                                                   adapter.receptor_model, 
                                                   adapter.ligand_model)
     assert_almost_equal(0.0, landscape_position1.distance2(landscape_position2))
예제 #26
0
    def test_get_restraints_with_error(self):
        input_file = self.golden_data_path / '2UUY_lig.pdb'
        _, _, chains = parse_complex_from_file(input_file)
        structure = Complex(chains)
        restraints = {
            'active': ['B.VAL.21'],
            'passive': ['B.GLY.75'],
            'blocked': []
        }

        residues = get_restraints(structure, restraints)

        assert residues is not None
예제 #27
0
    def test_get_restraints_with_error(self):
        input_file = os.path.join(self.golden_data_path, '2UUY_lig.pdb')
        atoms, residues, chains = parse_complex_from_file(input_file)
        structure = Complex(chains)
        restraints = {
            'active': ['B.VAL.21'],
            'passive': ['B.GLY.75'],
            'blocked': []
        }

        residues = get_restraints(structure, restraints)

        assert False
 def test_evaluate_objective_function_no_movement(self):
     """The result of this test must be the same value as testing the MJ3h function.
     Translation is 0 and Quaternion [1,0,0,0] means no rotation.
     """
     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()
     coordinates = Coordinates([0.,0.,0.,1.,0.,0.,0.])
     landscape_position = DockingLandscapePosition(scoring_function, coordinates, 
                                                   adapter.receptor_model, 
                                                   adapter.ligand_model)
     
     assert_almost_equal(2.02, landscape_position.evaluate_objective_function())
예제 #29
0
    def test_evaluate_objective_function_rotation_y_axis_180(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()
        coordinates = Coordinates([0., 0., 0., 0., 0., 1., 0.])
        landscape_position = DockingLandscapePosition(scoring_function,
                                                      coordinates,
                                                      adapter.receptor_model,
                                                      adapter.ligand_model)

        assert_almost_equal(-1.4,
                            landscape_position.evaluate_objective_function())
예제 #30
0
 def test_evaluate_objective_function_no_movement(self):
     """The result of this test must be the same value as testing the MJ3h function.
     Translation is 0 and Quaternion [1,0,0,0] means no rotation.
     """
     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()
     coordinates = Coordinates([0.,0.,0.,1.,0.,0.,0.])
     landscape_position = DockingLandscapePosition(scoring_function, coordinates, 
                                                   adapter.receptor_model, 
                                                   adapter.ligand_model)
     
     assert_almost_equal(2.02, landscape_position.evaluate_objective_function())
예제 #31
0
 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])
예제 #32
0
    def test_LightDockGSOBuilder_using_FromFileInitializer(self):
        builder = LightdockGSOBuilder()
        number_of_glowworms = 5
        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 = MJ3hAdapter(receptor, ligand)
        scoring_function = MJ3h()
        gso = builder.create_from_file(
            number_of_glowworms, self.random_number_generator,
            self.gso_parameters, [adapter], [scoring_function],
            self.bounding_box,
            self.golden_data_path + 'initial_positions_1PPE.txt', 0.5, 0.5,
            0.5, False, 10, 10)

        assert 5 == gso.swarm.get_size()

        gso.report(self.test_path + 'report.out')
        assert filecmp.cmp(
            self.golden_data_path + 'report_lightdockbuilder.out',
            self.test_path + 'report.out')
예제 #33
0
 def test_move_step_rot_full_step_trans_full(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=10.0)
     adapter2 = MJ3hAdapter(self.receptor, ligand)
     coordinates2 = Coordinates([10.,0.,0.,1.,0.,0.,0.])
     landscape_position2 = DockingLandscapePosition(scoring_function, coordinates2, 
                                                   adapter2.receptor_model, 
                                                   adapter2.ligand_model)
     
     landscape_position1.move(landscape_position2)
     
     assert landscape_position1 == landscape_position2
 def test_move_step_rot_full_step_trans_full(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=10.0)
     adapter2 = MJ3hAdapter(self.receptor, ligand)
     coordinates2 = Coordinates([10.,0.,0.,1.,0.,0.,0.])
     landscape_position2 = DockingLandscapePosition(scoring_function, coordinates2, 
                                                   adapter2.receptor_model, 
                                                   adapter2.ligand_model)
     
     landscape_position1.move(landscape_position2)
     
     assert landscape_position1 == landscape_position2
예제 #35
0
    def test_clone(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()
        coordinates = Coordinates([0.,0.,0.,1.,0.,0.,0.])
        landscape_position_1 = DockingLandscapePosition(scoring_function, coordinates, 
                                                        adapter.receptor_model, 
                                                        adapter.ligand_model)
        
        landscape_position_2 = landscape_position_1.clone()

        assert landscape_position_1.translation.all() == landscape_position_2.translation.all()
        assert landscape_position_1.rotation == landscape_position_2.rotation

        landscape_position_2.translation[0] = 5.0

        assert_almost_equal(5.0, landscape_position_2.translation[0])
        assert_almost_equal(0.0, landscape_position_1.translation[0])
예제 #36
0
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)

    # Load parameters
    parameters = DesolvationParameters()

    x = []
    y = []
    z = []
    atom_names = []
    atom_radius = []
    for atom in molecule.atoms:
        x.append(atom.x)
        y.append(atom.y)
        z.append(atom.z)
        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])
    x = np.array(x)
    y = np.array(y)
    z = np.array(z)
    num_residues = len(molecule.residues)
    num_atoms = len(molecule.atoms)
    residue_ids = [residue.number for residue in molecule.residues]
    num_atoms_per_residue = [
        len(residue.atoms) for residue in molecule.residues
    ]

    # Calculate SASA with ACCESS
    start_time = timeit.default_timer()
    res_atmarea, res_area, res_scarea = access.access1(num_residues, num_atoms,
                                                       residue_ids,
                                                       num_atoms_per_residue,
                                                       atom_names, x, y, z,
                                                       atom_radius, 1)
    elapsed = timeit.default_timer() - start_time

    return sum(res_atmarea), elapsed
예제 #37
0
 def test_calculate_chi_angles(self):
     # Command in chimera: angle #0:28@n,ca,cb,sg
     atoms, residues, chains = parse_complex_from_file(
         self.golden_data_path + '1PPElig.pdb')
     protein = Complex(chains, atoms)
     for residue in protein.residues:
         if residue.name == 'ARG' and residue.number == 1:
             chi_angles = calculate_chi_angles(residue)
             for key, value in chi_angles.items():
                 if value:
                     if key == 'x1':
                         # angle #0:1@n,ca,cb,cg
                         assert_almost_equals(-173.216,
                                              round(math.degrees(value), 3))
                     if key == 'x2':
                         # angle #0:1@ca,cb,cg,cd
                         assert_almost_equals(171.375,
                                              round(math.degrees(value), 3))
                     if key == 'x3':
                         # angle #0:1@cb,cg,cd,ne
                         assert_almost_equals(62.852,
                                              round(math.degrees(value), 3))
                     if key == 'x4':
                         # angle #0:1@cg,cd,ne,cz
                         assert_almost_equals(100.22,
                                              round(math.degrees(value), 2))
         if residue.name == 'VAL' and residue.number == 2:
             # angle #0:2@n,ca,cb,cg1
             chi_angles = calculate_chi_angles(residue)
             for key, value in chi_angles.items():
                 if value:
                     if key == 'x1':
                         # angle #0:1@n,ca,cb,cg
                         assert_almost_equals(-173.629,
                                              round(math.degrees(value), 3))
         if residue.name == 'CYS' and residue.number == 28:
             chi_angles = calculate_chi_angles(residue)
             for key, value in chi_angles.items():
                 if value:
                     if key == 'x1':
                         assert_almost_equals(-60.2554,
                                              round(math.degrees(value), 4))
예제 #38
0
def read_input_structure(pdb_file_name,
                         ignore_oxt=True,
                         ignore_hydrogens=False,
                         verbose_parser=False):
    """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')
        log.info('Ignoring OXT atoms')
    if ignore_hydrogens:
        atoms_to_ignore.append('H')
        log.info('Ignoring Hydrogen atoms')

    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, verbose_parser)
        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
예제 #39
0
 def test_distance2_minus_10A_translation_y(self):
     atoms, _, chains = parse_complex_from_file(self.golden_data_path /
                                                '1PPElig.pdb')
     ligand = Complex(chains, atoms)
     adapter = MJ3hAdapter(self.receptor, ligand)
     scoring_function = MJ3h()
     coordinates = Coordinates([0., 0., 0., 1., 0., 0., 0.])
     landscape_position1 = DockingLandscapePosition(scoring_function,
                                                    coordinates,
                                                    adapter.receptor_model,
                                                    adapter.ligand_model)
     adapter2 = MJ3hAdapter(self.receptor, ligand)
     adapter2.ligand_model.translate([0.0, -10.0, 0.0])
     landscape_position2 = DockingLandscapePosition(scoring_function,
                                                    coordinates,
                                                    adapter2.receptor_model,
                                                    adapter2.ligand_model)
     assert_almost_equal(100.0,
                         landscape_position1.distance2(landscape_position2))
     assert_almost_equal(10.0,
                         landscape_position1.distance(landscape_position2))
    def test_move_step_rot_full_step_trans_half(self):
        atoms, residues, chains = parse_complex_from_file(self.golden_data_path + '1PPElig.pdb')
        ligand = Complex(chains, atoms)
        adapter = TOBIAdapter(self.receptor, ligand)
        scoring_function = TOBI()
        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)
        adapter2 = TOBIAdapter(self.receptor, ligand)
        coordinates2 = Coordinates([10.,0.,0.,1.,0.,0.,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()
        
        assert (expected_translation == landscape_position1.translation).all()
        assert expected_rotation == landscape_position1.rotation
예제 #41
0
    def test_move_step_rot_full_step_trans_half(self):
        atoms, residues, chains = parse_complex_from_file(self.golden_data_path + '1PPElig.pdb')
        ligand = Complex(chains, atoms)
        adapter = TOBIAdapter(self.receptor, ligand)
        scoring_function = TOBI()
        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)
        adapter2 = TOBIAdapter(self.receptor, ligand)
        coordinates2 = Coordinates([10.,0.,0.,1.,0.,0.,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()
        
        assert (expected_translation == landscape_position1.translation).all()
        assert expected_rotation == landscape_position1.rotation
예제 #42
0
    def test_calculate_phi_psi(self):
        atoms, residues, chains = parse_complex_from_file(
            self.golden_data_path + '1PPElig.pdb')
        protein = Complex(chains, atoms)
        # psi: angle #0:1@n,ca,c #0:2@n
        # phi: angle #0:1@c #0:2@n,ca,c

        phi_angles = [
            -105.92428251619579, -134.402235889132, -58.32268858533758,
            -85.62997439535678, -129.666484600813, -77.00076813772478,
            -142.09891098624075, -82.10672119029674, -163.14606891327375,
            -109.37900096123484, -138.72905680654182, -59.09699793329797,
            -60.06774387010816, -74.41030551527874, -99.82766540256617,
            -92.6495110068149, 54.969041241310705, -104.60151419194615,
            -67.57074855137641, -123.83574594954692, -85.90313254423194,
            -87.7781803331676, -66.345484249271, -64.51513795752882,
            108.23656098935888, -129.62530277139578, -71.90658189461674,
            -170.4460918036806
        ]
        psi_angles = [
            138.38576328505278, 105.22472788100255, 106.42882930892199,
            150.65572151747787, 72.08329638522976, 130.19890858175336,
            115.48238807519739, 132.48041144914038, 163.35191386073618,
            151.17756189538443, -28.310569696143393, 162.66293554938997,
            -32.25480696024475, -20.28436719199857, -11.444789534534305,
            163.38578466073147, 150.2534549328882, -128.53524744082424,
            20.01260634937939, 151.96710290169335, 159.55519588393594,
            115.07091589216549, 152.8911959270869, -24.04765297807205,
            -14.890186424782046, 15.86273088398991, 152.7552784042674,
            146.11762131430552
        ]

        for i in range(1, len(protein.residues)):
            phi, psi = calculate_phi_psi(protein.residues[i],
                                         protein.residues[i - 1])
            assert_almost_equals(phi_angles[i - 1], math.degrees(phi))
            assert_almost_equals(psi_angles[i - 1], math.degrees(psi))
예제 #43
0
    def test_move_step_rot_half_step_trans_half_and_anm(self):
        atoms, _, 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., 1., 1., 1., 1.])
        landscape_position1 = DockingLandscapePosition(scoring_function,
                                                       coordinates1,
                                                       adapter.receptor_model,
                                                       adapter.ligand_model,
                                                       step_translation=5.0,
                                                       step_rotation=0.5,
                                                       step_nmodes=0.5,
                                                       num_rec_nmodes=2,
                                                       num_lig_nmodes=2)
        adapter2 = MJ3hAdapter(self.receptor, ligand)
        coordinates2 = Coordinates(
            [10., 0., 0., 0., 0., 1., 0., 0., 0., 0., 0.])
        landscape_position2 = DockingLandscapePosition(scoring_function,
                                                       coordinates2,
                                                       adapter2.receptor_model,
                                                       adapter2.ligand_model,
                                                       num_rec_nmodes=2,
                                                       num_lig_nmodes=2)

        landscape_position1.move(landscape_position2)

        expected_translation = np.array([5., 0., 0.])
        expected_rotation = Quaternion(0.707106781, 0.0, 0.707106781, 0.0)
        expected_anm = np.array([0.64644661, 0.64644661])
        assert np.allclose(expected_translation,
                           landscape_position1.translation)
        assert expected_rotation == landscape_position1.rotation
        assert np.allclose(expected_anm, landscape_position1.rec_extent)
        assert np.allclose(expected_anm, landscape_position1.lig_extent)
예제 #44
0
    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)
예제 #45
0
from lightdock.pdbutil.PDBIO import parse_complex_from_file
from lightdock.structure.complex import Complex
from lightdock.rotamer.predictor import get_interface_residues, calculate_chi_angles, steric_energy
from lightdock.rotamer.library import InterfaceSurfaceLibrary


def usage():
    print("Usage: %s receptor.pdb ligand.pdb" % sys.argv[0])


if __name__ == "__main__":
    if len(sys.argv[1:]) != 2:
        usage()
        raise SystemExit('Wrong command line')

    atoms, residues, chains = parse_complex_from_file(sys.argv[1])
    receptor = Complex(chains, atoms)
    atoms, residues, chains = parse_complex_from_file(sys.argv[2])
    ligand = Complex(chains, atoms)
    adapter = DFIREAdapter(receptor, ligand)

    # 5A of cutoff to be in the same line as the ASA value used in the original paper
    receptor_residue_indexes, ligand_residue_indexes, dist_matrix, atom_indexes = get_interface_residues(
        adapter.receptor_model, adapter.ligand_model, max_cutoff=5.)
    rotamer_library = InterfaceSurfaceLibrary()

    print("%d receptor interface residues" % len(receptor_residue_indexes))
    receptor_residues = []
    for residue_index in receptor_residue_indexes:
        residue = receptor.residues[residue_index]
        chi_angles = calculate_chi_angles(residue)
 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)
        args = parse_command_line()

        atoms_to_ignore = []
        if args.noxt:
            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 as e:
            log.error(
예제 #48
0
                if len(coord) > 7:
                    nm_rec = np.array(
                        [float(x) for x in coord[7:7 + DEFAULT_NMODES_REC]])
                    nm_lig = np.array(
                        [float(x) for x in coord[7:7 + DEFAULT_NMODES_LIG]])
                return translation, q, nm_rec, nm_lig
    return None


if __name__ == "__main__":
    # Parse arguments
    glowworm_id, num_steps, receptor_pdb, ligand_pdb = parse_command_line()

    # Read receptor
    log.info("Reading %s receptor PDB file..." % receptor_pdb)
    atoms, residues, chains = parse_complex_from_file(receptor_pdb)
    receptor = Complex(chains, atoms)
    log.info("%s atoms, %s residues read." % (len(atoms), len(residues)))

    # Read ligand
    log.info("Reading %s ligand PDB file..." % ligand_pdb)
    atoms, residues, chains = parse_complex_from_file(ligand_pdb)
    ligand = Complex(chains, atoms)
    log.info("%s atoms, %s residues read." % (len(atoms), len(residues)))

    try:
        nm_path = os.path.abspath(os.path.dirname(receptor_pdb))
        nmodes_rec = read_nmodes(
            os.path.join(nm_path, DEFAULT_REC_NM_FILE + '.npy'))
    except:
        nmodes_rec = None
예제 #49
0
    parser.add_argument("scoring_function", help="scoring function")
    parser.add_argument("receptor", help="PDB receptor")
    parser.add_argument("ligand", help="PDB ligand")
    script_args = parser.parse_args()
    return script_args


if __name__ == "__main__":
    args = parse_command_line()

    try:
        scoring_function_module = "lightdock.scoring.%s.driver" % args.scoring_function
        module = importlib.import_module(scoring_function_module)
    except ImportError:
        raise SystemExit("Scoring function not found or not available")

    atoms, residues, chains = parse_complex_from_file(args.receptor)
    receptor = Complex(chains, atoms, structure_file_name=args.receptor)
    atoms, residues, chains = parse_complex_from_file(args.ligand)
    ligand = Complex(chains, atoms, structure_file_name=args.ligand)

    CurrentScoringFunction = getattr(module, "DefinedScoringFunction")
    CurrentModelAdapter = getattr(module, "DefinedModelAdapter")

    adapter = CurrentModelAdapter(receptor, ligand)
    scoring_function = CurrentScoringFunction()

    energy = scoring_function(adapter.receptor_model,  adapter.receptor_model.coordinates[0],
                              adapter.ligand_model, adapter.ligand_model.coordinates[0])
    print(args.scoring_function, ': ', energy)
        args = parse_command_line()

        atoms_to_ignore = []
        if args.noxt:
            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)
예제 #51
0
    """
    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.")
예제 #52
0
    starting_file = sys.argv[1]
    receptor_file = sys.argv[2]
    ligand_file = sys.argv[3]
    steps = int(sys.argv[4])
    configuration_file = sys.argv[5]

    log.info("Starting file: %s" % starting_file)
    log.info("Receptor: %s" % receptor_file)
    log.info("Ligand: %s" % ligand_file)
    log.info("Steps: %d" % steps)
    log.info("Configuration file: %s" % configuration_file)
    print

    # Read structures (already in the center)
    log.info("Reading %s receptor PDB file..." % receptor_file)
    atoms, residues, chains = parse_complex_from_file(receptor_file)
    receptor = Complex(chains, atoms)
    log.info("%s atoms, %s residues read." % (len(atoms), len(residues)))

    log.info("Reading %s ligand PDB file..." % ligand_file)
    atoms, residues, chains = parse_complex_from_file(ligand_file)
    ligand = Complex(chains, atoms)
    log.info("%s atoms, %s residues read." % (len(atoms), len(residues)))

    # Start from results positions
    log.info("Reading calculated data from %s" % starting_file)
    translations, rotations, luciferin, neighbors, vision_range, scoring = parse_output_file(starting_file)
    num_glowworms = len(translations)
    log.info("%d glowworms loaded" % num_glowworms)

    adapter = DFIREAdapter(receptor, ligand)
예제 #53
0
 def test_parse_multi_model_from_file(self):
     atoms, residues, chains = parse_complex_from_file(
         self.golden_data_path / 'multi_model.pdb')
     assert len(atoms) == 11
     assert len(residues) == 1
     assert len(chains) == 1
    """
    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.")
예제 #55
0
    try:
        pdb_structure = sys.argv[1]
        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))
예제 #56
0
 def test_parse_multi_model_from_file(self):
     atoms, residues, chains = parse_complex_from_file(self.golden_data_path + 'multi_model.pdb')
     assert 11 == len(atoms)
     assert 1 == len(residues)
     assert 1 == len(chains)
    parser.add_argument("scoring_function", help="scoring function")
    parser.add_argument("receptor", help="PDB receptor")
    parser.add_argument("ligand", help="PDB ligand")
    script_args = parser.parse_args()
    return script_args


if __name__ == "__main__":
    args = parse_command_line()

    try:
        scoring_function_module = "lightdock.scoring.%s.driver" % args.scoring_function
        module = importlib.import_module(scoring_function_module)
    except ImportError:
        raise SystemExit("Scoring function not found or not available")

    atoms, residues, chains = parse_complex_from_file(args.receptor)
    receptor = Complex(chains, atoms, structure_file_name=args.receptor)
    atoms, residues, chains = parse_complex_from_file(args.ligand)
    ligand = Complex(chains, atoms, structure_file_name=args.ligand)

    CurrentScoringFunction = getattr(module, "DefinedScoringFunction")
    CurrentModelAdapter = getattr(module, "DefinedModelAdapter")

    adapter = CurrentModelAdapter(receptor, ligand)
    scoring_function = CurrentScoringFunction()

    energy = scoring_function(adapter.receptor_model,  adapter.receptor_model.coordinates[0],
                              adapter.ligand_model, adapter.ligand_model.coordinates[0])
    print args.scoring_function, ': ', energy
예제 #58
0
from lightdock.pdbutil.PDBIO import parse_complex_from_file
from lightdock.structure.complex import Complex
from lightdock.rotamer.predictor import get_interface_residues, calculate_chi_angles, steric_energy
from lightdock.rotamer.library import InterfaceSurfaceLibrary


def usage():
    print "Usage: %s receptor.pdb ligand.pdb" % sys.argv[0]


if __name__ == "__main__":
    if len(sys.argv[1:]) != 2:
        usage()
        raise SystemExit('Wrong command line')

    atoms, residues, chains = parse_complex_from_file(sys.argv[1])
    receptor = Complex(chains, atoms)
    atoms, residues, chains = parse_complex_from_file(sys.argv[2])
    ligand = Complex(chains, atoms)
    adapter = DFIREAdapter(receptor, ligand)

    # 5A of cutoff to be in the same line as the ASA value used in the original paper
    receptor_residue_indexes, ligand_residue_indexes, dist_matrix, atom_indexes = get_interface_residues(adapter.receptor_model,
                                                                                                         adapter.ligand_model,
                                                                                                         max_cutoff=5.)
    rotamer_library = InterfaceSurfaceLibrary()

    print "%d receptor interface residues" % len(receptor_residue_indexes)
    receptor_residues = []
    for residue_index in receptor_residue_indexes:
        residue = receptor.residues[residue_index]
예제 #59
0
    try:
        pdb_structure = sys.argv[1]
        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))