Example #1
0
def structures_clash_MDanalysis(structure1, MDatoms):
    '''determines whether two structures have any clashing atoms
    the smallest structure should be the first argument to allow
    this function to run quickly as possible'''
    if verbose:
        print "using MDAnalysis to find clash between structures", structure1.struct_id, "and", structure2.struct_id
    struct1_com = pdb.center_of_mass(
        structure1)  # find center of mass of structure1
    struct1_rad = pdb.molecular_radius(structure1)  # find molecular radius
    clashing = False
    for atom2 in MDatoms:  # for every atom in structure2
        atom2_radius = radii[pdb.find_element(atom2.name)]
        if numpy.linalg.norm(
                numpy.array(struct1_com) -
                numpy.array(atom2.pos)) < struct1_rad + atom2_radius:
            # then we have to check this atom against every struct1 atom
            for atom1 in structure1.get_atoms(
            ):  # for every atom in structure1
                atom1_radius = radii[
                    atom1.element]  # radii[atom2.resname][atom2.name]
                atom_dist = atom2_radius + atom1_radius
                if numpy.linalg.norm(
                        numpy.array(atom1.coords) -
                        numpy.array(atom2.pos)) < atom_dist:
                    return True
    return clashing
Example #2
0
def structures_clash(structure1, structure2, tolerance=0.0):
    '''determines whether two structures have any clashing atoms
    the smallest structure should be the first argument to allow
    this function to run quickly as possible
    Input:
     - structure1: a Structure() object, probably representing the receptor
     - structure2: a Structure() object, probably representing the ligand
     - tolerance: float, The distance, in Angstroms, to subtract from the addition of 
         the radii before a clash is rejected.
    Output:
     - clashing: a boolean representing whether the structures are clashing or 
         not.
  '''
    if verbose:
        print "searching for clashes between structures", structure1.struct_id, "and", structure2.struct_id
    struct1_com = pdb.center_of_mass(
        structure1)  # find center of mass of structure1
    struct1_rad = pdb.molecular_radius(structure1)  # find molecular radius
    clashing = False

    for atom2 in structure2.atoms:  # for every atom in structure2
        if atom2.radius == '0.0':
            atom2_radius = pdb.radii[
                atom2.
                element]  # if not included, then retrieve a standard radius for this atom
            if verbose:
                print "using dictionary on atom2. atom2.radius:", atom2.radius
        else:
            atom2_radius = float(atom2.radius)

        # the statement below saves some computation time by being a semi-divide and conquer method. Could be better but I'm sure it will work just fine
        if np.linalg.norm(np.array(struct1_com) -
                          np.array(atom2.coords)) < struct1_rad + atom2_radius:
            # then we have to check this atom against every struct1 atom
            for atom1 in structure1.get_atoms(
            ):  # for every atom in structure1
                if atom1.radius == '0.0':
                    atom1_radius = pdb.radii[
                        atom1.
                        element]  # if not included, then retrieve a standard radius for this atom
                    if verbose:
                        print "using dictionary on atom1. atom1.radius:", atom1.radius
                else:
                    atom1_radius = float(atom1.radius)
                atom_dist = atom2_radius + atom1_radius
                if np.linalg.norm(
                        np.array(atom1.coords) -
                        np.array(atom2.coords)) < atom_dist - tolerance:
                    return True
    return clashing
Example #3
0
def structures_clash(structure1, structure2, tolerance=0.0):
    '''determines whether two structures have any clashing atoms
    the smallest structure should be the first argument to allow
    this function to run quickly as possible'''
    if verbose:
        print "searching for clashes between structures", structure1.struct_id, "and", structure2.struct_id
    struct1_com = pdb.center_of_mass(
        structure1)  # find center of mass of structure1
    struct1_rad = pdb.molecular_radius(structure1)  # find molecular radius
    clashing = False

    for atom2 in structure2.atoms:  # for every atom in structure2
        #try:
        #atom2_radius = float(radii[atom2.resname][atom2.name])
        #except KeyError:
        # look in the pdb for the radius itself
        if atom2.radius == '0.0':
            atom2_radius = radii[
                atom2.
                element]  # if not included, then retrieve a standard radius for this atom
            print "using dictionary on atom2. atom2.radius:", atom2.radius
        else:
            atom2_radius = float(atom2.radius)

        # the statement below saves some computation time by being a semi-divide and conquer method. Could be better but I'm sure it will work just fine
        if numpy.linalg.norm(
                numpy.array(struct1_com) -
                numpy.array(atom2.coords)) < struct1_rad + atom2_radius:
            # then we have to check this atom against every struct1 atom
            for atom1 in structure1.get_atoms(
            ):  # for every atom in structure1
                if atom1.radius == '0.0':
                    atom1_radius = radii[
                        atom1.
                        element]  # if not included, then retrieve a standard radius for this atom
                    print "using dictionary on atom1. atom1.radius:", atom1.radius
                else:
                    atom1_radius = float(atom1.radius)
                #print atom1_radius
                atom_dist = atom2_radius + atom1_radius
                if numpy.linalg.norm(
                        numpy.array(atom1.coords) -
                        numpy.array(atom2.coords)) < atom_dist - tolerance:
                    #print numpy.linalg.norm(numpy.array(atom1.coords) - numpy.array(atom2.coords))
                    # then we have a clash
                    return True
    return clashing