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
示例#2
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
示例#3
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