# Path: pdbtools/data/common.py
# CHARGE_DICT = {"ASP":   -1.,
#                "CYS":   -1.,
#                "GLU":   -1.,
#                "TYR":   -1.,
#                "CTERM": -1.,
#                "ARG":    1.,
#                "HIS":    1.,
#                "LYS":    1.,
#                "NTERM":  1.}
# 
# TITR_ATOM = {"ASP":"CG ",
#              "GLU":"CD ",
#              "TYR":"OH ",
#              "ARG":"CZ ",
#              "HIS":"NE2",
#              "LYS":"NZ "}
# 
# Path: pdbtools/helper/geometry.py
# def calcDistances(coord):
#     """
#     Calculate all distances in coord.
#     """
# 
#     num_points = len(coord)
#     d = [[0. for j in range(num_points)] for i in range(num_points)]
#     for i in range(num_points):
#         d[i][i] = 0.
#         for j in range(i+1,num_points):
#             d[i][j] = dist(coord[i],coord[j])
#             d[j][i] = d[i][j]
# 
#     return d


from .data.common import CHARGE_DICT, TITR_ATOM
from .helper.geometry import calcDistances

# Copyright 2007, Michael J. Harms
# This program is distributed under General Public License v. 3.  See the file
# COPYING for a copy of the license.

__description__ = \
"""
pdb_ion-dist.py

Calculates the distribution of distances between titratable residues (from
titratable atoms in pdb_data.common) for acid/acid, acid/base, and base/base
interactions.
"""
__author__ = "Michael J. Harms"
__date__ = "080303"


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 list(TITR_ATOM.keys()) and

# Path: pdbtools/data/common.py
# CHARGE_DICT = {"ASP":   -1.,
#                "CYS":   -1.,
#                "GLU":   -1.,
#                "TYR":   -1.,
#                "CTERM": -1.,
#                "ARG":    1.,
#                "HIS":    1.,
#                "LYS":    1.,
#                "NTERM":  1.}
# 
# TITR_ATOM = {"ASP":"CG ",
#              "GLU":"CD ",
#              "TYR":"OH ",
#              "ARG":"CZ ",
#              "HIS":"NE2",
#              "LYS":"NZ "}
# 
# Path: pdbtools/helper/geometry.py
# def calcDistances(coord):
#     """
#     Calculate all distances in coord.
#     """
# 
#     num_points = len(coord)
#     d = [[0. for j in range(num_points)] for i in range(num_points)]
#     for i in range(num_points):
#         d[i][i] = 0.
#         for j in range(i+1,num_points):
#             d[i][j] = dist(coord[i],coord[j])
#             d[j][i] = d[i][j]
# 
#     return d


# Path: pdbtools/iondist.py
from .data.common import CHARGE_DICT, TITR_ATOM
from .helper.geometry import calcDistances


# Copyright 2007, Michael J. Harms
# This program is distributed under General Public License v. 3.  See the file
# COPYING for a copy of the license.

__description__ = \
"""
pdb_ion-dist.py

Calculates the distribution of distances between titratable residues (from
titratable atoms in pdb_data.common) for acid/acid, acid/base, and base/base
interactions.
"""
__author__ = "Michael J. Harms"
__date__ = "080303"


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 list(TITR_ATOM.keys()) and

                    l[13:16] == TITR_ATOM[l[17:20]]]