예제 #1
0
    def test_calculate_initial_poses(self):

        file_name = self.golden_data_path / '3p0g' / 'receptor_membrane.pdb'
        _, _, chains = parse_complex_from_file(file_name)
        receptor = Complex(chains, structure_file_name=file_name)
        file_name = self.golden_data_path / '3p0g' / 'ligand.pdb'
        _, _, chains = parse_complex_from_file(file_name)
        ligand = Complex(chains, structure_file_name=file_name)

        rec_translation = receptor.move_to_origin()
        lig_translation = ligand.move_to_origin()

        num_swarms = 100
        num_glowworms = 10
        surface_density = 50.
        restraints = parse_restraints_file(self.golden_data_path / '3p0g' / 'restraints.list')
        receptor_restraints = get_restraints(receptor, restraints['receptor'])
        ligand_restraints = get_restraints(ligand, restraints['ligand'])
        rec_restraints = receptor_restraints['active'] + receptor_restraints['passive']
        lig_restraints = ligand_restraints['active'] + ligand_restraints['passive']

        positions_files = calculate_initial_poses(receptor, ligand, num_swarms, num_glowworms,
                                                  STARTING_POINTS_SEED, rec_restraints, lig_restraints,
                                                  rec_translation, lig_translation, surface_density,
                                                  dest_folder=self.test_path, is_membrane=True)

        assert filecmp.cmp(positions_files[0], self.golden_data_path / '3p0g' / 'init' / 'initial_positions_0.dat')
        assert filecmp.cmp(positions_files[1], self.golden_data_path / '3p0g' / 'init' / 'initial_positions_1.dat')
예제 #2
0
def calculate_starting_positions(receptor,
                                 ligand,
                                 swarms,
                                 glowworms,
                                 starting_points_seed,
                                 receptor_restraints,
                                 ligand_restraints,
                                 rec_translation,
                                 lig_translation,
                                 surface_density,
                                 use_anm=False,
                                 anm_seed=0,
                                 anm_rec=DEFAULT_NMODES_REC,
                                 anm_lig=DEFAULT_NMODES_LIG,
                                 is_membrane=False,
                                 is_transmembrane=False,
                                 write_starting_positions=False,
                                 swarm_radius=DEFAULT_SWARM_RADIUS):
    """Defines the starting positions of each glowworm in the simulation.

    If the init folder already exists, uses the starting positions from this folder.
    """
    log.info("Calculating starting positions...")
    init_folder = DEFAULT_POSITIONS_FOLDER
    if not os.path.isdir(init_folder):
        os.mkdir(init_folder)
        starting_points_files = calculate_initial_poses(
            receptor, ligand, swarms, glowworms, starting_points_seed,
            receptor_restraints, ligand_restraints, rec_translation,
            lig_translation, surface_density, init_folder, use_anm, anm_seed,
            anm_rec, anm_lig, is_membrane, is_transmembrane,
            write_starting_positions, swarm_radius)
        log.info(f"Generated {len(starting_points_files)} positions files")
    else:
        if receptor_restraints:
            log.warning(
                f"Folder {init_folder} already exists and restraints apply. Please check for consistency."
            )
        else:
            log.warning(
                f"Folder {init_folder} already exists, skipping calculation")

        pattern = str(
            Path(DEFAULT_POSITIONS_FOLDER) /
            Path(f"{DEFAULT_STARTING_PREFIX}*.dat"))
        starting_points_files = glob.glob(pattern)
        for starting_point_file in starting_points_files:
            if not check_starting_file(starting_point_file, glowworms, use_anm,
                                       anm_rec, anm_lig):
                raise LightDockError(
                    f"Error reading starting coordinates from file {starting_point_file}"
                )
    log.info("Done.")
    return starting_points_files
예제 #3
0
def calculate_starting_positions(receptor,
                                 ligand,
                                 swarms,
                                 glowworms,
                                 starting_points_seed,
                                 receptor_restraints,
                                 ligand_restraints,
                                 rec_translation,
                                 lig_translation,
                                 ftdock_file=None,
                                 use_anm=False,
                                 anm_seed=0,
                                 anm_rec=DEFAULT_NMODES_REC,
                                 anm_lig=DEFAULT_NMODES_LIG,
                                 is_membrane=False):
    """Defines the starting positions of each glowworm in the simulation.

    If the init_folder already exists, uses the starting positions from this folder.
    """
    log.info("Calculating starting positions...")
    init_folder = DEFAULT_POSITIONS_FOLDER
    if not os.path.isdir(init_folder):
        os.mkdir(init_folder)
        starting_points_files = calculate_initial_poses(
            receptor, ligand, swarms, glowworms, starting_points_seed,
            receptor_restraints, ligand_restraints, rec_translation,
            lig_translation, init_folder, ftdock_file, use_anm, anm_seed,
            anm_rec, anm_lig, is_membrane)
        log.info("Generated %d positions files" % len(starting_points_files))
    else:
        if receptor_restraints:
            log.warning(
                "Folder %s already exists and restraints apply. Check for consistency, possible error!"
                % init_folder)
        else:
            log.warning("Folder %s already exists, skipping calculation" %
                        init_folder)

        pattern = os.path.join(DEFAULT_POSITIONS_FOLDER,
                               "%s*.dat" % DEFAULT_STARTING_PREFIX)
        starting_points_files = glob.glob(pattern)
        if len(starting_points_files) != swarms:
            raise LightDockError(
                "The number of initial positions files does not correspond with the number of swarms"
            )
        for starting_point_file in starting_points_files:
            if not check_starting_file(starting_point_file, glowworms, use_anm,
                                       anm_rec, anm_lig):
                raise LightDockError(
                    "Error reading starting coordinates from file %s" %
                    starting_point_file)
    log.info("Done.")
    return starting_points_files
예제 #4
0
    def test_calculate_initial_poses(self):

        atoms, residues, chains = parse_complex_from_file(
            os.path.join(self.golden_data_path, '3p0g',
                         'receptor_membrane.pdb'))
        receptor = Complex(chains)
        atoms, residues, chains = parse_complex_from_file(
            os.path.join(self.golden_data_path, '3p0g', 'ligand.pdb'))
        ligand = Complex(chains)

        rec_translation = receptor.move_to_origin()
        lig_translation = ligand.move_to_origin()

        num_swarms = 10
        num_glowworms = 10
        seed = 324324
        restraints = parse_restraints_file(
            os.path.join(self.golden_data_path, '3p0g', 'restraints.list'))
        receptor_restraints = get_restraints(receptor, restraints['receptor'])
        ligand_restraints = get_restraints(ligand, restraints['ligand'])
        rec_restraints = receptor_restraints['active'] + receptor_restraints[
            'passive']
        lig_restraints = ligand_restraints['active'] + ligand_restraints[
            'passive']

        positions_files = calculate_initial_poses(receptor,
                                                  ligand,
                                                  num_swarms,
                                                  num_glowworms,
                                                  seed,
                                                  rec_restraints,
                                                  lig_restraints,
                                                  rec_translation,
                                                  lig_translation,
                                                  dest_folder=self.test_path,
                                                  is_membrane=True)

        assert filecmp.cmp(
            positions_files[0],
            os.path.join(self.golden_data_path, '3p0g', 'init',
                         'initial_positions_0.dat'))
        assert filecmp.cmp(
            positions_files[1],
            os.path.join(self.golden_data_path, '3p0g', 'init',
                         'initial_positions_1.dat'))
예제 #5
0
def calculate_starting_positions(receptor, ligand, swarms, glowworms, starting_points_seed,
    receptor_restraints, ligand_restraints, rec_translation, lig_translation, ftdock_file=None, 
    use_anm=False, anm_seed=0, anm_rec=DEFAULT_NMODES_REC, anm_lig=DEFAULT_NMODES_LIG,
    is_membrane=False):
    """Defines the starting positions of each glowworm in the simulation.

    If the init_folder already exists, uses the starting positions from this folder.
    """
    log.info("Calculating starting positions...")
    init_folder = DEFAULT_POSITIONS_FOLDER
    if not os.path.isdir(init_folder):
        os.mkdir(init_folder)
        starting_points_files = calculate_initial_poses(receptor, ligand,
                                                        swarms, glowworms,
                                                        starting_points_seed, 
                                                        receptor_restraints, ligand_restraints,
                                                        rec_translation, lig_translation,
                                                        init_folder,
                                                        ftdock_file, use_anm,
                                                        anm_seed, anm_rec, anm_lig,
                                                        is_membrane)
        log.info("Generated %d positions files" % len(starting_points_files))
    else:
        if receptor_restraints:
            log.warning("Folder %s already exists and restraints apply. Check for consistency, possible error!" % init_folder)
        else:
            log.warning("Folder %s already exists, skipping calculation" % init_folder)

        pattern = os.path.join(DEFAULT_POSITIONS_FOLDER, "%s*.dat" % DEFAULT_STARTING_PREFIX)
        starting_points_files = glob.glob(pattern)
        if len(starting_points_files) != swarms:
            raise LightDockError("The number of initial positions files does not correspond with the number of swarms")
        for starting_point_file in starting_points_files:
            if not check_starting_file(starting_point_file, glowworms, use_anm, anm_rec, anm_lig):
                raise LightDockError("Error reading starting coordinates from file %s" % starting_point_file)
    log.info("Done.")
    return starting_points_files