def dist_pairs(input_file, model_number, pairs_of_atoms):
    """

    :param model_number:
    :param pairs_of_atoms: list of eqvivalent atoms
    :return: results - a list of tuples[(atom_name, model_number, point1, point2, distance)()]
    """
    atom2point = lambda a: point_3d(a.x, a.y, a.z)
    short_file_name = os.path.basename(input_file)

    results = []
    for pair in pairs_of_atoms:
        point1, point2 = atom2point(pair[0]), atom2point(pair[1])
        # print (point1)
        # print (point2)
        dist = distance.between_points(point1, point2)
        # print (dist)
        curr_result = (
            short_file_name,
            pair[0].atom_name,
            model_number,
            pair[0].resname,
            pair[0].resseq,
            point1,
            point2,
            dist
        )
        results.append(curr_result)
    return results
Beispiel #2
0
def sym_axis(input_file, axis, verbose):
    """
    \b
    calculates the distance of each amino acid from the symmetry axis.
    homomer symmetric axis distance
    """
    _caller = "atoms_pairs command"
    cliutils = cu(click, is_verbose=verbose)

    _axis = validate_trimer_options(cliutils, input_file, axis, verbose)
    mypdb = pdb.from_file(input_file)
    atoms_names = ["CA", "CB"]
    results = []
    vector3d = point_3d(*_axis)
    for atom_name in atoms_names:
        siever = atom_names_siever(atom_name)
        for model in mypdb:
            for chain in model:
                msg = "atom:{:<3} model number:{} ,chain_id: {}"
                cliutils.verbose(msg.format(atom_name, model.model_number,
                                            chain.chain_id),
                                 caller=_caller)
                is_match = lambda atom: siever.is_match(atom, atom_name)
                current_results = symetric_axis_distance.dist_from_vector(
                    input_file=input_file,
                    model_number=model.model_number,
                    chain_id=chain.chain_id,
                    atoms=filter(is_match, chain),
                    vector3d=vector3d)
                results.extend(current_results)
    symetric_axis_distance.print_results(results)
Beispiel #3
0
def dist_from_vector(input_file, model_number, chain_id, atoms, vector3d):
    short_file_name = os.path.basename(input_file)
    results = []
    for atom in atoms:
        point = point_3d(atom.x, atom.y, atom.z)
        dist = distance.between_point_and_vector(point, vector3d)
        curr_result = (short_file_name, atom.atom_name, model_number, chain_id,
                       atom.resname, atom.resseq, point, dist)
        results.append(curr_result)
        return results
 def test_distance_between_point_and_vector(self):
     point_a = point_3d(*self.coordinates[1])
     vector = point_3d(*self.coordinates[3])
     distance_a_b = distance.between_point_and_vector(point_a, vector)
     self.assertTrue(distance_a_b - 1 < 0.00000000001)
 def test_distance_between_points(self):
     point_a = point_3d(*self.coordinates[0])
     point_b = point_3d(*self.coordinates[1])
     distance_a_b = distance.between_points(point_a, point_b)
     self.assertEqual(distance_a_b, math.sqrt(3))
 def test_vector(self):
     vector = point_3d(*self.coordinates[3])
     self.assertEqual(vector.is_vector(), True)
     vector = point_3d(*self.coordinates[4])
     self.assertEqual(vector.is_vector(), True)
 def test_point(self):
     point = point_3d(*self.coordinates[0])
     self.assertEqual(point.y, 0)
     self.assertEqual(str(point), str((0.0, 0.0, 0.0)))
     self.assertEqual(point.is_vector(), False)