Пример #1
0
def main():
    from argparse import ArgumentParser

    parser = ArgumentParser()

    parser.add_argument("--ftfile-line",
                        "-n",
                        type=int,
                        default=0,
                        help="0 indexed")
    parser.add_argument("--limit",
                        "-l",
                        type=int,
                        default=None,
                        help="limit for number of ft lines read")
    parser.add_argument("ligand", help="ligand used for docking")
    parser.add_argument("ft_file",
                        help="ftresults file to draw transformations from.")
    parser.add_argument(
        "rot_file",
        help="Rotation file used during PIPER run to make ft_file.")
    parser.add_argument("--ft_limit",
                        help="Speficy how many ftfile lines to read")

    args = parser.parse_args()

    rotations = read_rotations(args.rot_file)

    #read ft_files
    ftresults = read_ftresults(args.ft_file, args.limit)

    #get center information for original ligands
    lig_orig = parsePDB(args.ligand)
    lig_center = np.mean(lig_orig.getCoords(), axis=0)
    lig_name = args.ligand
    lig_base = lig_name.rsplit('/', 1)[-1][:-4]

    #apply ft lines to the aligned ligands
    coords_apply = apply_ftresults_atom_group(lig_orig,
                                              ftresults,
                                              rotations,
                                              center=lig_center)

    #create new atom group for translated ligand
    lig_new = AtomGroup('%s.%s.pdb' % (lig_base, args.ftfile_line))

    #only choose one coordinate set (0 indexed)
    coords_apply.setACSIndex(args.ftfile_line)
    lig_new.setCoords(coords_apply.getCoords())
    lig_new.setNames(lig_orig.getNames())
    lig_new.setResnames(lig_orig.getResnames())
    lig_new.setResnums(lig_orig.getResnums())

    #write new ligand file
    writePDB("%s.%s.pdb" % (lig_base, args.ftfile_line), lig_new)
Пример #2
0
def AddAtoms(initial_residue,
             atoms2add,
             atomnames_of_2_letters,
             residue_data,
             zmatrix,
             verbose=True):
    """
    This function returns a mutated residue with the atoms added.
    This function gets a residue and a list of atomnames to add to the mutation.
    :rtype : object
    :param initial_residue:
    :param atoms2add: 
    :param atomnames_of_2_letters: 
    :param residue_data: 
    :param zmatrix: 
    :param verbose: 
    """
    if verbose:
        print('Adding new atoms:')
    new_atoms_elements = []
    for atom in atoms2add:
        if verbose:
            print(" # {}".format(atom))
        if atom[:2] in atomnames_of_2_letters:
            new_atoms_elements.append(atom[:2])
        else:
            new_atoms_elements.append(atom[0])

    new_atoms = AtomGroup('New atoms')
    number_of_new_atoms = len(atoms2add)
    new_atoms.setNames(list(atoms2add))
    new_atoms.setElements(new_atoms_elements)
    new_atoms.setResnames([residue_data['fin_resname']] * number_of_new_atoms)
    new_atoms.setResnums([residue_data['resnum']] * number_of_new_atoms)
    new_atoms.setChids([residue_data['chain']] * number_of_new_atoms)
    new_atoms.setAltlocs([''] * number_of_new_atoms)
    new_atoms.setBetas([0] * number_of_new_atoms)
    new_atoms.setIcodes([''] * number_of_new_atoms)
    new_atoms.setOccupancies([1] * number_of_new_atoms)
    new_atoms.setSegnames([''] * number_of_new_atoms)
    new_atoms.setSerials([0] * number_of_new_atoms)
    temporary_coords = np.ones([len(atoms2add), 3])
    new_atoms.setCoords(temporary_coords)
    incomplete_residue = initial_residue + new_atoms
    for atom in new_atoms.iterAtoms():
        atom_new_coordinates = GenerateCoordinatesFromZmatrix(
            incomplete_residue, [atom.getName()], zmatrix)
        atom.setCoords(atom_new_coordinates)
        incomplete_residue = initial_residue + new_atoms
    if verbose:
        print('Done')
    return initial_residue + new_atoms
Пример #3
0
def AddHfromPRO(initial_residue, zmatrix, mutation):
    new_atom = AtomGroup('Hydrogen')
    new_atom.setNames(['H'])
    new_atom.setElements(['H'])
    new_atom.setResnames([zmatrix.Name])
    new_atom.setResnums([mutation['resnum']])
    new_atom.setChids([mutation['chain']])
    new_atom.setAltlocs([''])
    new_atom.setBetas([0])
    new_atom.setIcodes([''])
    new_atom.setOccupancies([1])
    new_atom.setSegnames([''])
    new_atom.setSerials([0])
    new_atom.setCoords(ModifyCoordinatesPRO(initial_residue, zmatrix, 'H', 'CD'))
    return initial_residue + new_atom
Пример #4
0
def DefineNewAtom(atom_name, element, coordinates, resname, resnum, chain_id):
    """
    This function creates a new AtomGroup instance containing one atom.
    """
    new_atom = AtomGroup()
    new_atom.setNames([atom_name])
    new_atom.setElements([element])
    new_atom.setCoords([coordinates])
    new_atom.setResnames(resname)
    new_atom.setResnums(resnum)
    new_atom.setChids(chain_id)
    new_atom.setAltlocs([''])
    new_atom.setBetas([0])
    new_atom.setIcodes([''])
    new_atom.setOccupancies([1])
    new_atom.setSegnames([''])
    new_atom.setSerials([0])
    # new_atom.setAnisous([[0.0, 0.0, 0.0]])
    return new_atom