How to use the lightdock.constants.DEFAULT_NMODES_REC 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 / post / lgd_local_minimization.py View on Github external
rec_extents = []
    lig_extents = []

    data_file = open(lightdock_output)
    lines = data_file.readlines()
    data_file.close()

    counter = 0
    for line in lines:
        if line[0] == '(':
            counter += 1
            last = line.index(')')
            coord = line[1:last].split(',')
            translations.append([float(coord[0]),float(coord[1]),float(coord[2])])
            rotations.append(Quaternion(float(coord[3]),float(coord[4]),float(coord[5]),float(coord[6])))
            if len(coord) == (7 + DEFAULT_NMODES_REC + DEFAULT_NMODES_LIG):
                rec_extents.append(np.array([float(x) for x in coord[7:7+DEFAULT_NMODES_REC]]))
                lig_extents.append(np.array([float(x) for x in coord[-DEFAULT_NMODES_LIG:]]))
            raw_data = line[last+1:].split()
            receptor_id = int(raw_data[0])
            ligand_id = int(raw_data[1])
            receptor_ids.append(receptor_id)
            ligand_ids.append(ligand_id)
    log.info("Read %s coordinate lines" % counter)
    return translations, rotations, receptor_ids, ligand_ids, rec_extents, lig_extents
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,
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)
github brianjimenez / lightdock / lightdock / prep / simulation.py View on Github external
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,
github brianjimenez / lightdock / lightdock / prep / simulation.py View on Github external
def load_starting_positions(swarms, glowworms, use_anm, anm_rec=DEFAULT_NMODES_REC, anm_lig=DEFAULT_NMODES_LIG):
    """Gets the list of starting positions of this simulation"""
    pattern = os.path.join(DEFAULT_POSITIONS_FOLDER, "%s*.dat" % DEFAULT_STARTING_PREFIX)
    starting_points_files = sorted(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 swarm_id in range(len(starting_points_files)):
        starting_point_file = os.path.join(DEFAULT_POSITIONS_FOLDER, "%s_%d.dat" % (DEFAULT_STARTING_PREFIX, swarm_id))
        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)
    return starting_points_files
github brianjimenez / lightdock / bin / post / lgd_generate_conformations.py View on Github external
# Lightdock output file
    parser.add_argument("lightdock_output", help="lightdock output file",
                        type=CommandLineParser.valid_file, metavar="lightdock_output")
    # Number of glowworms
    parser.add_argument("glowworms", help="number of glowworms", type=CommandLineParser.valid_integer_number)
    # Optional, setup file
    parser.add_argument("--setup", "-setup", "-s", help="Simulation setup file",
                            dest="setup_file", metavar="setup_file", type=CommandLineParser.valid_file, 
                            default=None)

    args = parser.parse_args()

    # Load setup configuration if provided
    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 = []
github brianjimenez / lightdock / bin / post / lgd_top.py View on Github external
parser.add_argument("lightdock_ranking_file", help="LightDock ranking file",
                        type=CommandLineParser.valid_file, metavar="lightdock_ranking_file")
    # Number of structures to generate
    parser.add_argument("top", help="number of structures to generate", type=CommandLineParser.valid_integer_number,
                        metavar="top")
    # Optional, setup file
    parser.add_argument("--setup", "-setup", "-s", help="Simulation setup file",
                            dest="setup_file", metavar="setup_file", type=CommandLineParser.valid_file, 
                            default=None)

    args = parser.parse_args()

    # Load setup configuration if provided
    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 = []
github brianjimenez / lightdock / bin / post / lgd_local_minimization.py View on Github external
def calculate_scoring(optimization_vector):
    #print optimization_vector
    translation = optimization_vector[:3]
    rotation = optimization_vector[3:7]
    q = Quaternion(rotation[0], rotation[1], rotation[2], rotation[3])
    nm_ext_rec = optimization_vector[7:7+DEFAULT_NMODES_REC]
    nm_ext_lig = optimization_vector[-DEFAULT_NMODES_LIG:]
    receptor_pose, ligand_pose = move_molecules(translation, q, nm_ext_rec, nm_ext_lig)
    energy = -1. * scoring_function(adapters.receptor_model, receptor_pose, adapters.ligand_model, ligand_pose)
    print energy
    return energy
github brianjimenez / lightdock / lightdock / util / parser.py View on Github external
dest="noxt", action='store_true', default=False)
        # Dealing with hydrogen atoms
        parser.add_argument("--noh", help="Remove Hydrogen atoms",
                            dest="noh", action='store_true', default=False)
        # Verbose PDB parser
        parser.add_argument("--verbose_parser", help="PDB parsing verbose mode",
                            dest="verbose_parser", action='store_true', default=False)
        # Normal modes
        parser.add_argument("-anm", "--anm", help="Activates the use of ANM backbone flexibility",
                            dest="use_anm", action='store_true', default=False)
        # Normal modes extent seed
        parser.add_argument("--seed_anm", help="Random seed used in ANM intial extent",
                            dest="anm_seed", type=int, default=STARTING_NM_SEED)
        parser.add_argument("-anm_rec", "--anm_rec", help="Number of ANM modes for receptor", 
                            type=SetupCommandLineParser.valid_natural_number,
                            dest="anm_rec", default=DEFAULT_NMODES_REC)
        parser.add_argument("-anm_lig", "--anm_lig", help="Number of ANM modes for ligand", 
                            type=SetupCommandLineParser.valid_natural_number,
                            dest="anm_lig", default=DEFAULT_NMODES_LIG)
        # Restraints file
        parser.add_argument("-rst", "--rst", help="Restraints file", 
                            dest="restraints", type=CommandLineParser.valid_file,
                            metavar="restraints", default=None)
        # Membrane setup
        parser.add_argument("-membrane", "--membrane", help="Enables the extra filter for membrane restraints", 
                            dest="membrane", action='store_true', default=False)

        self.args = parser.parse_args()
github brianjimenez / lightdock / bin / post / lgd_generate_trajectory.py View on Github external
if len(coord) > 7:
                        rec_extent = np.array([float(x) for x in coord[7:7+num_anm_rec]])
                        lig_extent = np.array([float(x) for x in coord[-num_anm_lig:]])
                    return translation, rotation, rec_extent, lig_extent
                num_glowworms += 1
    return None


if __name__ == "__main__":
    # Parse arguments
    args = parse_command_line()

    # Load setup configuration if provided
    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']
    
    # Read receptor
    log.info("Reading %s receptor PDB file..." % args.receptor_pdb)
    atoms, residues, chains = parse_complex_from_file(args.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..." % args.ligand_pdb)
    atoms, residues, chains = parse_complex_from_file(args.ligand_pdb)
    ligand = Complex(chains, atoms)
    log.info("%s atoms, %s residues read." % (len(atoms), len(residues)))