Esempio n. 1
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
Esempio n. 2
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
        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(
                "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(
Esempio n. 4
0
        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))
        modes.append(nm)
Esempio n. 5
0
        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))
        modes.append(nm)
        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 = []
    for structure in get_lightdock_structures(args.ligand_structures):
        log.info("Reading %s ligand 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)))
    ligand = Complex.from_structures(structures)
            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)
        log.info('Points written to %s' % output_file_name)

        points = [point for point in ellipsoid.poles]
        points.append(ellipsoid.center)
    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 = []
    for structure in get_lightdock_structures(args.ligand_structures):
        log.info("Reading %s ligand 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)))
    ligand = Complex.from_structures(structures)

    # Output file
    translations, rotations, receptor_ids, ligand_ids, \
        rec_extents, lig_extents = parse_output_file(args.lightdock_output, num_anm_rec, num_anm_lig)

    found_conformations = len(translations)