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
def __init__(self): self.path = Path(__file__).absolute().parent self.test_path = self.path / 'scratch_gso' self.golden_data_path = self.path / 'golden_data' self.gso_parameters = GSOParameters() self.gso_parameters.initial_vision_range = 3.0 self.gso_parameters.max_vision_range = 3.0
def setUp(self): self.gso_parameters = GSOParameters() self.objective_function = J1() self.landscape_position1 = [ LandscapePosition(self.objective_function, Coordinates([0.0, 0.0])) ] self.landscape_position2 = [ LandscapePosition(self.objective_function, Coordinates([1.0, 1.0])) ] self.landscape_position3 = [ LandscapePosition(self.objective_function, Coordinates([2.0, 2.0])) ] self.landscape_position4 = [ LandscapePosition(self.objective_function, Coordinates([0.5, 0.5])) ] self.landscape_position5 = [ LandscapePosition(self.objective_function, Coordinates([5.0, 5.0])) ] self.landscape_position6 = [ LandscapePosition(self.objective_function, Coordinates([0.0, 1.0])) ] self.landscape_position7 = [ LandscapePosition(self.objective_function, Coordinates([0.1, 0.0])) ] self.landscape_position8 = [ LandscapePosition(self.objective_function, Coordinates([0.0, 0.1])) ] self.landscape_position9 = [ LandscapePosition(self.objective_function, Coordinates([0.2, 0.0])) ]
def setUp(self): self.golden_data_path = os.path.normpath(os.path.dirname(os.path.realpath(__file__))) + '/golden_data/' self.gso_parameters = GSOParameters() self.objective_function = J1() self.bounding_box = BoundingBox([Boundary(1, 2), Boundary(10, 15)]) self.number_of_glowworms = 50 self.random_number_generator = MTGenerator(324324)
def __init__(self): self.golden_data_path = Path( __file__).absolute().parent / 'golden_data' self.gso_parameters = GSOParameters() self.objective_function = J1() self.bounding_box = BoundingBox([Boundary(1, 2), Boundary(10, 15)]) self.number_of_glowworms = 50 self.random_number_generator = MTGenerator(324324)
def setUp(self): self.gso_parameters = GSOParameters() self.objective_function = J1() self.landscape_position1 = LandscapePosition(self.objective_function, Coordinates([0.0, 0.0])) self.landscape_position2 = LandscapePosition(self.objective_function, Coordinates([1.0, 1.0])) self.positions = [[self.landscape_position1, self.landscape_position2]]
def test_create_from_interface(self): objective_function = J1() gso_parameters = GSOParameters() number_of_glowworms = 50 initializer = Initializer(objective_function, number_of_glowworms, gso_parameters) swarm = initializer.generate_glowworms() assert swarm.get_size() > 0
def test_read_gso_parameters(self): parameteres = GSOParameters() assert_almost_equals(0.4, parameteres.rho) assert_almost_equals(0.6, parameteres.gamma) assert_almost_equals(0.08, parameteres.beta) assert_almost_equals(5.0, parameteres.initial_luciferin) assert_almost_equals(0.2, parameteres.initial_vision_range) assert_almost_equals(5.0, parameteres.max_vision_range) assert 5 == parameteres.max_neighbors
def test_generate_landscape_positions_without_coordinates(self): objective_function = J1() gso_parameters = GSOParameters() number_of_glowworms = 50 initializer = FromFileInitializer( [objective_function], number_of_glowworms, gso_parameters, 2, self.golden_data_path + 'initial_positions_empty.txt') swarm = initializer.generate_glowworms() assert swarm.get_size() > 0
def test_generate_landscape_positions_num_glowworms_different(self): objective_function = J1() gso_parameters = GSOParameters() number_of_glowworms = 50 initializer = FromFileInitializer( [objective_function], number_of_glowworms, gso_parameters, 2, self.golden_data_path / 'initial_positions_redux.txt') swarm = initializer.generate_glowworms() assert swarm.get_size() > 0
def test_read_gso_parameters_with_file(self): parameteres = GSOParameters(self.golden_data_path + 'glowworm.conf') assert_almost_equals(0.1, parameteres.rho) assert_almost_equals(0.2, parameteres.gamma) assert_almost_equals(0.6, parameteres.beta) assert_almost_equals(0.3, parameteres.initial_luciferin) assert_almost_equals(0.4, parameteres.initial_vision_range) assert_almost_equals(0.5, parameteres.max_vision_range) assert 7 == parameteres.max_neighbors
def test_create_swarm(self): objective_function = J1() gso_parameters = GSOParameters() number_of_glowworms = 50 initializer = FromFileInitializer( [objective_function], number_of_glowworms, gso_parameters, 2, self.golden_data_path + 'initial_positions.txt') swarm = initializer.generate_glowworms() assert number_of_glowworms == swarm.get_size() assert "(0.617171, -2.85014) 5.00000000 0 0.200 0.00000000" == str( swarm.glowworms[-1])
def test_generate_landscape_positions_num_glowworms_different(self): gso_parameters = GSOParameters() number_of_glowworms = 10 seed = 324324 random_number_generator = MTGenerator(seed) initializer = LightdockFromFileInitializer( self.adapter, self.scoring_function, number_of_glowworms, gso_parameters, 7, self.golden_data_path / 'initial_positions_1PPE.txt', 0.5, 0.5, random_number_generator, 0.5, 10, 10) swarm = initializer.generate_glowworms() assert swarm.get_size() > 0
def setup(self): self.path = os.path.dirname(os.path.realpath(__file__)) self.test_path = self.path + '/scratch/' try: shutil.rmtree(self.test_path) except: pass os.mkdir(self.test_path) self.golden_data_path = os.path.normpath( os.path.dirname(os.path.realpath(__file__))) + '/golden_data/' self.gso_parameters = GSOParameters() self.gso_parameters.initial_vision_range = 3.0 self.gso_parameters.max_vision_range = 3.0
def test_create_swarm(self): gso_parameters = GSOParameters() number_of_glowworms = 5 seed = 324324 random_number_generator = MTGenerator(seed) initializer = LightdockFromFileInitializer( [self.adapter], [self.scoring_function], number_of_glowworms, gso_parameters, 7, self.golden_data_path / 'initial_positions_1PPE.txt', 0.5, 0.5, random_number_generator, 0.5, 10, 10) swarm = initializer.generate_glowworms() assert number_of_glowworms == swarm.get_size()
def __init__(self): self.path = Path(__file__).absolute().parent self.test_path = self.path / 'scratch_lightdockbuilder' self.golden_data_path = self.path / 'golden_data' self.gso_parameters = GSOParameters() self.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) ]) self.random_number_generator = MTGenerator(324324)
def test_create_swarm(self): objective_function = J1() gso_parameters = GSOParameters() number_of_glowworms = 15 seed = 324324 random_number_generator = MTGenerator(seed) bounding_box = BoundingBox([Boundary(1, 2), Boundary(10, 15)]) initializer = RandomInitializer([objective_function], number_of_glowworms, gso_parameters, bounding_box, random_number_generator) swarm = initializer.generate_glowworms() assert number_of_glowworms == swarm.get_size() for glowworm in swarm.glowworms: coordinates = glowworm.landscape_positions[0].coordinates assert coordinates[0] < 2 and coordinates[0] >= 1 assert coordinates[1] < 15 and coordinates[1] >= 10
def setUp(self): self.path = os.path.dirname(os.path.realpath(__file__)) self.test_path = self.path + '/scratch/' try: shutil.rmtree(self.test_path) except: pass os.mkdir(self.test_path) self.golden_data_path = os.path.normpath( os.path.dirname(os.path.realpath(__file__))) + '/golden_data/' self.gso_parameters = GSOParameters() self.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) ]) self.random_number_generator = MTGenerator(324324)
def test_read_gso_parameters_wrong_file(self): parameteres = GSOParameters(self.golden_data_path + 'no_file.conf') assert False
#!/usr/bin/env python3 # coding: utf-8 from lightdock.gso.parameters import GSOParameters from lightdock.gso.searchspace.benchmark_ofunctions import J2 from lightdock.gso.algorithm import GSOBuilder from lightdock.gso.boundaries import Boundary, BoundingBox from lightdock.mathutil.lrandom import MTGenerator gso_parameters = GSOParameters() objective_function = J2() bounding_box = BoundingBox([Boundary(-4.0, 4.0), Boundary(-4.0, 4.0)]) number_of_glowworms = 200 random_number_generator = MTGenerator(324324324) builder = GSOBuilder() gso = builder.create(number_of_glowworms, random_number_generator, gso_parameters, objective_function, bounding_box) gso.swarm.save(0, '.', file_name='gso_0.out') for glowworm in gso.swarm.glowworms: print(glowworm.landscape_positions[0]) print('Step 1') gso.run(100) print('Step 100')
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)
def test_read_gso_parameters_wrong_file(self): parameters = GSOParameters(self.golden_data_path / 'no_file.conf') assert parameters is not None
def test_read_gso_parameters_wrong_parameters(self): parameteres = GSOParameters(self.golden_data_path + 'wrong_glowworm.conf') assert False
def test_read_gso_parameters_wrong_parameters(self): parameters = GSOParameters(self.golden_data_path / 'wrong_glowworm.conf') assert parameters is not None