code: def from_structure(structure):
      
  
      try:
          from Bio import PDB
          if isinstance(structure, str):
              p = PDB.PDBParser()
              structure = p.get_structure('S', structure)
          if isinstance(structure, PDB.Structure.Structure):
              for _ in structure.get_chains():
                  atoms = [np.array(atom.get_coord())
                           for atom in structure.get_atoms()]
      except ImportError:
          print("Biopython not found.")
          raise
  
      atoms = np.array(structure)
      try:
          import scipy
          D = scipy.spatial.distance.pdist(atoms, 'euclidean')
          D = scipy.spatial.distance.squareform(D)
      except ImportError:
          print("Scipy not found.")
          raise
      m = np.max(1 / D[D != 0])
      M = np.zeros(D.shape)
      M[D != 0] = 1 / D[D != 0]
      M[D == 0] = m
      return M
docs: Return contact data from a 3D structure (in pdb format).