How to use the lightdock.mathutil.lrandom.MTGenerator function in lightdock

To help you get started, we’ve selected a few lightdock examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github brianjimenez / lightdock / bin / simulation / docking_mpi.py View on Github external
def set_gso(number_of_glowworms, adapters, scoring_functions, initial_positions, seed,
            step_translation, step_rotation, configuration_file=None, 
            use_anm=False, nmodes_step=0.1, anm_rec=DEFAULT_NMODES_REC, anm_lig=DEFAULT_NMODES_LIG,
            local_minimization=False):
    """Creates a lightdock GSO simulation object"""

    bounding_box = get_default_box(use_anm, anm_rec, anm_lig)

    random_number_generator = MTGenerator(seed)
    if configuration_file:
        gso_parameters = GSOParameters(configuration_file)
    else:
        gso_parameters = GSOParameters()
    builder = LightdockGSOBuilder()
    if not use_anm:
        anm_rec = anm_lig = 0
    gso = builder.create_from_file(number_of_glowworms, random_number_generator, gso_parameters,
                                   adapters, scoring_functions, bounding_box, initial_positions,
                                   step_translation, step_rotation, nmodes_step, local_minimization)
    return gso
github brianjimenez / lightdock / lightdock / prep / poses.py View on Github external
def calculate_initial_poses(receptor, ligand, num_clusters, num_glowworms,
                            seed, receptor_restraints, ligand_restraints, 
                            rec_translation, lig_translation,
                            dest_folder, ftdock_file='', nm_mode=False, nm_seed=0, rec_nm=0, lig_nm=0,
                            is_membrane=False):
    """Calculates the starting points for each of the glowworms using the center of swarms
    and FTDock poses.
    """
    # Random number generator for poses
    rng = MTGenerator(seed)

    # Random number generator for NM
    if nm_mode:
        rng_nm = NormalGenerator(nm_seed, mu=DEFAULT_EXTENT_MU, sigma=DEFAULT_EXTENT_SIGMA)
    else:
        rng_nm = None
    
    # Calculate swarm centers
    swarm_centers, receptor_diameter, ligand_diameter = calculate_surface_points(receptor, 
                                                                                 ligand, 
                                                                                 num_clusters,
                                                                                 distance_step=1.0,
                                                                                 is_membrane=is_membrane)
    # Filter swarms far from the restraints
    if receptor_restraints:
        swarm_centers = apply_restraints(swarm_centers, receptor_restraints,
github brianjimenez / lightdock / bin / simulation / relightdock.py View on Github external
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)
    scoring_function = DFIRE()
    log.info("Loaded DFIRE scoring function")

    bounding_box = BoundingBox([Boundary(-MAX_TRANSLATION, MAX_TRANSLATION),
                                Boundary(-MAX_TRANSLATION, MAX_TRANSLATION),
                                Boundary(-MAX_TRANSLATION, MAX_TRANSLATION),
                                Boundary(-MAX_ROTATION, MAX_ROTATION),
                                Boundary(-MAX_ROTATION, MAX_ROTATION),
                                Boundary(-MAX_ROTATION, MAX_ROTATION),
                                Boundary(-MAX_ROTATION, MAX_ROTATION)])
    random_number_generator = MTGenerator(GSO_SEED)
    gso_parameters = GSOParameters(configuration_file)
    log.info("Parameters read")

    positions = []
    for i in range(num_glowworms):
        coordinates = [translations[i][0], translations[i][1], translations[i][2], rotations[i].w, rotations[i].x, rotations[i].y, rotations[i].z]
        positions.append(DockingLandscapePosition(scoring_function, coordinates, adapter.receptor_model, adapter.ligand_model))
    log.info("%d positions loaded" % len(positions))

    swarm = Swarm(positions, gso_parameters)
    for i, glowworm in enumerate(swarm.glowworms):
        glowworm.luciferin = luciferin[i]
        glowworm.vision_range = vision_range[i]
        glowworm.scoring = scoring[i]
    for i, glowworm in enumerate(swarm.glowworms):
        glowworm.search_neighbors(swarm.glowworms)
github brianjimenez / lightdock / bin / simulation / docking_multiprocessing.py View on Github external
def set_gso(number_of_glowworms, adapters, scoring_functions, initial_positions, seed,
            step_translation, step_rotation, configuration_file=None, 
            use_anm=False, nmodes_step=0.1, anm_rec=DEFAULT_NMODES_REC, anm_lig=DEFAULT_NMODES_LIG,
            local_minimization=False):
    """Creates a lightdock GSO simulation object"""

    bounding_box = get_default_box(use_anm, anm_rec, anm_lig)

    random_number_generator = MTGenerator(seed)
    if configuration_file:
        gso_parameters = GSOParameters(configuration_file)
    else:
        gso_parameters = GSOParameters()
    builder = LightdockGSOBuilder()
    if not use_anm:
        anm_rec = anm_lig = 0
    gso = builder.create_from_file(number_of_glowworms, random_number_generator, gso_parameters,
                                   adapters, scoring_functions, bounding_box, initial_positions,
                                   step_translation, step_rotation, nmodes_step, local_minimization,
                                   anm_rec, anm_lig)
    return gso
github brianjimenez / lightdock / lightdock / gso / initializer.py View on Github external
def __init__(self, adapters, scoring_functions, number_of_glowworms, gso_parameters,
                 dimensions, initial_population_file, step_translation, step_rotation,
                 random_number_generator, step_nmodes, anm_rec, anm_lig):
        super(LightdockFromFileInitializer, self).__init__(scoring_functions, number_of_glowworms, gso_parameters)
        self.dimensions = dimensions
        self.initial_population_file = initial_population_file
        self.adapters = adapters
        self.step_translation = step_translation
        self.step_rotation = step_rotation
        self.step_nmodes = step_nmodes
        # Patch to not mess with old simulations
        self.random_number_generator = MTGenerator(random_number_generator.seed)
        self.anm_rec = anm_rec
        self.anm_lig = anm_lig