Exemple #1
0
def pdbWaterContact(pdb, water_radii=1.4):
    """
    Residues are considered neighbors if *any* atom of theirs approaches closer
    than vdw1 + vd2 + water.
    """

    # Grab atoms
    atoms = [l for l in pdb if l[0:4] == "ATOM"]

    # Grab coordinates and calculate distance matrix
    coord = [[float(l[30 + 8 * i:38 + 8 * i]) for i in range(3)]
             for l in atoms]
    dist = geometry.calcDistances(coord)

    # Grab list of unique residues
    residues = []
    for line in atoms:
        if line[21:26] not in residues:
            residues.append(line[21:26])
    neighbors = dict([(r, []) for r in residues])

    wat_sep = 2 * water_radii
    for i in range(len(atoms)):
        for j in range(i + 1, len(atoms)):
            max_sep = wat_sep + \
                      common.VDW_DICT[atoms[i][13:16]] + \
                      common.VDW_DICT[atoms[j][13:16]]

            if dist[i][j] <= max_sep:
                if atoms[j][21:26] not in neighbors[atoms[i][21:26]]:
                    neighbors[atoms[i][21:26]].append(atoms[j][21:26])
                    neighbors[atoms[j][21:26]].append(atoms[i][21:26])

    return neighbors
def pdbWaterContact(pdb,water_radii=1.4):
    """
    Residues are considered neighbors if *any* atom of theirs approaches closer
    than vdw1 + vd2 + water.
    """

    # Grab atoms
    atoms = [l for l in pdb if l[0:4] == "ATOM"]

    # Grab coordinates and calculate distance matrix
    coord = [[float(l[30+8*i:38+8*i]) for i in range(3)] for l in atoms]
    dist = geometry.calcDistances(coord)    

    # Grab list of unique residues
    residues = []
    for line in atoms:
        if line[21:26] not in residues:
            residues.append(line[21:26])
    neighbors = dict([(r,[]) for r in residues])

    wat_sep = 2*water_radii
    for i in range(len(atoms)):
        for j in range(i+1,len(atoms)):
            max_sep = wat_sep + \
                      common.VDW_DICT[atoms[i][13:16]] + \
                      common.VDW_DICT[atoms[j][13:16]]

            if dist[i][j] <= max_sep:
                if atoms[j][21:26] not in neighbors[atoms[i][21:26]]:
                    neighbors[atoms[i][21:26]].append(atoms[j][21:26])
                    neighbors[atoms[j][21:26]].append(atoms[i][21:26])

    return neighbors
def pdbContact(pdb,all=False):
    """
    Generate array of all atom-atom distances in a pdb file.  Defaults to only 
    look at CA atoms
    """

    # Remove non-CA atoms
    if not all:
        pdb = [l for l in pdb if l[0:4] == "ATOM" and l[13:16] == "CA "]
    else:
        pdb = [l for l in pdb if l[0:4] == "ATOM"]

    coord = [[float(l[30+8*i:38+8*i]) for i in range(3)] for l in pdb]

    dist = geometry.calcDistances(coord)

    return dist    
Exemple #4
0
def pdbContact(pdb, all=False):
    """
    Generate array of all atom-atom distances in a pdb file.  Defaults to only 
    look at CA atoms
    """

    # Remove non-CA atoms
    if not all:
        pdb = [l for l in pdb if l[0:4] == "ATOM" and l[13:16] == "CA "]
    else:
        pdb = [l for l in pdb if l[0:4] == "ATOM"]

    coord = [[float(l[30 + 8 * i:38 + 8 * i]) for i in range(3)] for l in pdb]

    dist = geometry.calcDistances(coord)

    return dist
Exemple #5
0
def pdbContact(pdb,all=False):
    """
    Generate array of all atom-atom distances in a pdb file.  Defaults to only 
    look at CA atoms
    """

    pdb = other.getPolymerAtoms(pdb)
    pdb = other.removeRotamers(pdb)

    # Remove non-CA atoms
    if not all:
        pdb = [l for l in pdb if l[13:15] == "CA"]


    coord = [[float(l[30+8*i:38+8*i]) for i in range(3)] for l in pdb]

    dist = geometry.calcDistances(coord)

    return dist    
Exemple #6
0
def pdbIonDist(pdb, hist_step, remove_resid="TYR"):
    """
    Calculate ij distances between all titratable atoms in pdb (except residues
    in skip_resid) then bin according to hist_step.  The output histogram is 
    a 3 x N nested list where N is the length required to cover all distances 
    in pdb using hist_step and the 3 overarching lists hold acid/acid, 
    acid/base, and base/base interactions in 0, 1, and 2 respectively.  
    """

    pdb = [l for l in pdb if l[0:4] == "ATOM"]
    titr_atom = [
        l for l in pdb if l[17:20] not in remove_resid
        and l[17:20] in TITR_ATOM.keys() and l[13:16] == TITR_ATOM[l[17:20]]
    ]

    # Extract coordinates and charges for each titratable atom
    coord = [[float(l[30 + 8 * i:38 + 8 * i]) for i in xrange(3)]
             for l in titr_atom]
    charge = [CHARGE_DICT[l[17:20]] for l in titr_atom]

    # Calculate all ij distances
    dist = calcDistances(coord)
    N = len(coord)

    # Initialize histogram by finding maximum distance that will have to be
    # counted.
    max_dist_bin = max([max([dist[i][j] for j in range(N)]) for i in range(N)])
    max_dist_bin = int(round(max_dist_bin / hist_step)) + 1
    histogram = [[0 for j in xrange(max_dist_bin)] for i in xrange(3)]

    # Populate histogram
    #   Interaction types:
    #   acid/acid            --> 0 (-1 + -1)/2 + 1
    #   acid/base, base/acid --> 1 (-1 +  1)/2 + 1
    #   base/base            --> 2 ( 1 +  1)/2 + 2
    for i in xrange(N):
        for j in xrange(i + 1, N):
            interaction_type = int((charge[i] + charge[j]) / 2 + 1)
            dist_bin = int(round(dist[i][j] / hist_step))
            histogram[interaction_type][dist_bin] += 1

    return histogram
def pdbIonDist(pdb,hist_step,remove_resid="TYR"):
    """
    Calculate ij distances between all titratable atoms in pdb (except residues
    in skip_resid) then bin according to hist_step.  The output histogram is 
    a 3 x N nested list where N is the length required to cover all distances 
    in pdb using hist_step and the 3 overarching lists hold acid/acid, 
    acid/base, and base/base interactions in 0, 1, and 2 respectively.  
    """

    pdb = [l for l in pdb if l[0:4] == "ATOM"] 
    titr_atom = [l for l in pdb
                 if l[17:20] not in remove_resid and 
                    l[17:20] in TITR_ATOM.keys() and
                    l[13:16] == TITR_ATOM[l[17:20]]]

    # Extract coordinates and charges for each titratable atom
    coord = [[float(l[30+8*i:38+8*i]) for i in xrange(3)] for l in titr_atom]
    charge = [CHARGE_DICT[l[17:20]] for l in titr_atom]

    # Calculate all ij distances
    dist = calcDistances(coord)
    N = len(coord)

    # Initialize histogram by finding maximum distance that will have to be
    # counted.
    max_dist_bin = max([max([dist[i][j] for j in range(N)])
                        for i in range(N)])
    max_dist_bin = int(round(max_dist_bin/hist_step)) + 1
    histogram = [[0 for j in xrange(max_dist_bin)] for i in xrange(3)]

    # Populate histogram
    #   Interaction types:
    #   acid/acid            --> 0 (-1 + -1)/2 + 1
    #   acid/base, base/acid --> 1 (-1 +  1)/2 + 1
    #   base/base            --> 2 ( 1 +  1)/2 + 2
    for i in xrange(N):
        for j in xrange(i+1,N):
            interaction_type = int((charge[i] + charge[j])/2 + 1)
            dist_bin = int(round(dist[i][j]/hist_step))
            histogram[interaction_type][dist_bin] += 1

    return histogram