Skip to content
Snippets Groups Projects
Select Git revision
  • bd44721cfd87b6c9def4a5ad3cb1dff10bcb552b
  • main default protected
  • index_out_issue
  • 3.2
  • 0.3.1
  • 0.2.11
  • 0.2.10
  • 0.2.9
  • 0.2.8
  • 0.2.7
  • 0.2.6
  • 0.2.5
  • 0.2.4
  • 0.2.2
  • 0.2.1
  • 0.1.23
  • 0.1.22
  • 0.1.21
  • 0.1.20
  • 0.1.19
  • 0.1.18
  • 0.1.17
  • 0.1.16
23 results

test2.py

Blame
  • test2.py 897 B
    import Bio.PDB
    import Bio.PDB.Atom
    import numpy as np
    
    
    def main():
        structure = Bio.PDB.PDBParser().get_structure("4pqv", "tests/4pqv_A.pdb")
        residues = list(structure.get_residues())
        res1 = residues[8]
        res2 = residues[3]
        atoms1 = list(res1.get_atoms())
        atoms2 = list(res2.get_atoms())
        min_dist = 999
        min_atom1 = Bio.PDB.Atom.Atom("dummy", np.zeros(3), 0, 1, 1, "dummy", 0)
        min_atom2 = Bio.PDB.Atom.Atom("dummy", np.zeros(3), 0, 1, 1, "dummy", 0)
        for a1 in atoms1:
            for a2 in atoms2:
                if np.linalg.norm(a1.get_coord() - a2.get_coord()) < min_dist:
                    min_dist = np.linalg.norm(a1.get_coord() - a2.get_coord())
                    min_atom1 = a1
                    min_atom2 = a2
    
        print(
            f"Minimal distance: {min_dist:.2f}, Coordinate1: {min_atom1}, Coordinate2: {min_atom2}"
        )
    
    
    if __name__ == "__main__":
        main()