src/proteingnn/util.py
def pdb2distance_map(pdb: AnyPath) -> torch.Tensor:
    """Get the distance map between CA atoms from pdb."""
    pdb = Path(pdb)
    parser = PDB.PDBParser(PERMISSIVE=True, QUIET=True)
    structure = parser.get_structure(pdb.stem, pdb)
    chain = structure[0]['A']

    coors = []
    for resid in range(1, len(chain)+1):
        residue = chain[resid]

        ca = [atom for atom in residue.get_atoms() if atom.get_name() == 'CA']
        assert len(ca) == 1
        ca = ca[0]

        coor = ca.get_vector().get_array()
        coors.append(coor)

    n_residues = len(coors)
    coors = torch.tensor(coors)

    dist_mat = torch.broadcast_to(coors, (n_residues, n_residues, 3))
    dist_mat = dist_mat - dist_mat.transpose(0, 1)
    dist_mat = ((dist_mat ** 2).sum(dim=-1)) ** 0.5
    return dist_mat
Get the distance map between CA atoms from pdb.
Get the distance map between CA atoms from pdb.
Get the distance map between CA atoms from pdb .
def pdb2distance_map(pdb: AnyPath) -> torch.Tensor:
    pdb = Path(pdb)
    parser = PDB.PDBParser(PERMISSIVE=True, QUIET=True)
    structure = parser.get_structure(pdb.stem, pdb)
    chain = structure[0]['A']
    coors = []
    for resid in range(1, len(chain)+1):
        residue = chain[resid]
        ca = [atom for atom in residue.get_atoms() if atom.get_name() == 'CA']
        assert len(ca) == 1
        ca = ca[0]
        coor = ca.get_vector().get_array()
        coors.append(coor)
    n_residues = len(coors)
    coors = torch.tensor(coors)
    dist_mat = torch.broadcast_to(coors, (n_residues, n_residues, 3))
    dist_mat = dist_mat - dist_mat.transpose(0, 1)
    dist_mat = ((dist_mat ** 2).sum(dim=-1)) ** 0.5
    return dist_mat
def pdb2distance_map ( pdb : AnyPath ) -> torch . Tensor : pdb = Path ( pdb ) parser = PDB . PDBParser ( PERMISSIVE = True , QUIET = True ) structure = parser . get_structure ( pdb . stem , pdb ) chain = structure [ 0 ] [ 'A' ] coors = [ ] for resid in range ( 1 , len ( chain ) + 1 ) : residue = chain [ resid ] ca = [ atom for atom in residue . get_atoms ( ) if atom . get_name ( ) == 'CA' ] assert len ( ca ) == 1 ca = ca [ 0 ] coor = ca . get_vector ( ) . get_array ( ) coors . append ( coor ) n_residues = len ( coors ) coors = torch . tensor ( coors ) dist_mat = torch . broadcast_to ( coors , ( n_residues , n_residues , 3 ) ) dist_mat = dist_mat - dist_mat . transpose ( 0 , 1 ) dist_mat = ( ( dist_mat ** 2 ) . sum ( dim = - 1 ) ) ** 0.5 return dist_mat
Get the distance map between CA atoms from pdb.
Get the distance map between CA atoms from pdb .
"""Get the distance map between CA atoms from pdb."""
pdb
AnyPath