# Path: pdbtools/helper/container.py
# class PdbContainerError(Exception):
# class Fragment:
# class Chain:
# class Structure:
#     def __init__(self,atom_lines,n_terminus=False,c_terminus=False):
#     def _renumberAtoms(self,renumber_dict):
#     def write(self,filename=None):
#     def __init__(self,chain_id,atom_lines,seq_lines,frag_dist_cutoff=5.0):
#     def findTermini(self,num_compare=10):
#     def findFragments(self,dist_cutoff=5.0):
#     def _renumberAtoms(self,renumber_dict):
#     def write(self,filename=None):
#     def __init__(self,pdb_id,seq_lines,atom_lines,frag_dist_cutoff=5.0):
#     def findChains(self,frag_dist_cutoff=5.0):
#     def renumberAtoms(self):
#     def write(self,filename=None):
#     def dumpStructures(self):
#     def dumpNumberConversion(self,output_file):
#     def loadNumberConversion(self,input_file,current_numbering):
# def main():
# 
# Path: pdbtools/helper/cmdline.py
# def initializeParser(description,version):
# def addOption(short_flag,long_flag,action,default,help,**kwargs):
# def parseArgs(args):
# def parseCommandLine():
# def readFile(some_file):
# 
# Path: pdbtools/helper/geometry.py
# def dist(c1,c2=[0.,0.,0.]):
# def dist_sq(c1,c2=[0.,0.,0.]):
# def calcDistances(coord):
# def crossProduct(u,v):
# def dotProduct(u,v):
# def findAngle(u,v):
# def genRotMatrix(axis,theta):
# def arbRot(vector,axis,theta):
# def arbRotCoord(coord,axis,theta):
# def calcGlyCbeta(Ncoord,CAcoord,COcoord):
# def calcHXT(C_coord,O_coord,OXT_coord):
# def calcHG(CB_coord,SG_coord):
# def calcDihedrals(prevCO,currN,currCA,currCO,nextN,cutoff=6.5):
# def calcHN(prevCO,prevO,currN,currCA):
#     A = [prevCO[i] - currCA[i] for i in range(3)]
#     B = [currN[i] - currCA[i] for i in range(3)]
#     C = [currCO[i] - currCA[i] for i in range(3)]
#     D = [nextN[i] - currCA[i] for i in range(3)]
#     V1 = crossProduct(A,B)
#     V2 = crossProduct(C,B)
#     V3 = crossProduct(C,D)
# 
# Path: pdbtools/atom_renumber.py
# def pdbAtomRenumber(pdb,renumber_het=True):
#     """
#     Renumber all atoms in pdb file, starting from 1.
#     """
# 
#     entries_to_renumber = ["ATOM  ","TER   ","ANISOU"]
#     if renumber_het == True:
#         entries_to_renumber.append("HETATM")
# 
#     out = []
#     counter = 1
#     for line in pdb:
#         # For and ATOM record, update residue number
#         if line[0:6] in entries_to_renumber:
#             out.append("%s%5s%s" % (line[0:6],counter,line[11:]))
#             counter += 1
#         else:
# 
#             # reset the counter for a new model
#             if line[0:6] == "ENDMDL":
#                 counter = 1
# 
#             out.append(line)
# 
#     return out
# 
# Path: pdbtools/disulfide.py
# def pdbDisulfide(pdb,disulfide_cutoff=4.0):
#     """
#     Finds all disulfides in pdb file based on disulfide cutoff distance (A).
#     """
# 
#     pdb, skipped = stripACS(pdb)
# 
#     # Grab sg_atoms, coordinates, and residue numbers
#     sg_atoms = [l for l in pdb if l[0:6] == "ATOM  " and l[13:16] == "SG "]
#     coord = [[float(sg[30+8*i:38+8*i]) for i in range(3)] for sg in sg_atoms]
#     cys_resid = [l[21:26] for l in sg_atoms]
# 
#     # Define all cys within disulfide_cutoff angstroms of each other as in
#     # disulfide bonds
#     cutoff_squared = disulfide_cutoff**2
# 
#     # Find disulfide
#     free_cys = cys_resid[:]
#     disulfide = []
#     num_cys = len(cys_resid)
#     for i in range(num_cys):
#         for j in range(i+1,num_cys):
#             r = sum([(coord[i][k] - coord[j][k])**2 for k in range(3)])
#             if r < cutoff_squared:
# 
#                 # This is a hack (in a sense).  If more than two cysteines are
#                 # close to one another (as in a Cys-Fe cluster), this will
#                 # treat them all as disulfide bonded.  If I don't have the ugly
#                 # try...except statements, the code breaks because each cys has
#                 # multiple binding partners.
#                 try:
#                     free_cys.remove(cys_resid[i])
#                     disulfide.append(cys_resid[i])
#                 except ValueError:
#                     pass
#                 try:
#                     free_cys.remove(cys_resid[j])
#                     disulfide.append(cys_resid[j])
#                 except ValueError:
#                     pass
# 
#     return free_cys, disulfide


import time, os
from math import sqrt
from .helper import container, cmdline, geometry
from .atom_renumber import pdbAtomRenumber
from .disulfide import pdbDisulfide
#!/usr/bin/env python

# 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__ = "Adds polar hydrogens to a pdb file for a UHBD calculation."
__author__ = "Michael J. Harms"
__date__ = "070727"


#from .charmm import interface
### HACK HACK HACK


# Path: pdbtools/helper/container.py
# class PdbContainerError(Exception):
# class Fragment:
# class Chain:
# class Structure:
#     def __init__(self,atom_lines,n_terminus=False,c_terminus=False):
#     def _renumberAtoms(self,renumber_dict):
#     def write(self,filename=None):
#     def __init__(self,chain_id,atom_lines,seq_lines,frag_dist_cutoff=5.0):
#     def findTermini(self,num_compare=10):
#     def findFragments(self,dist_cutoff=5.0):
#     def _renumberAtoms(self,renumber_dict):
#     def write(self,filename=None):
#     def __init__(self,pdb_id,seq_lines,atom_lines,frag_dist_cutoff=5.0):
#     def findChains(self,frag_dist_cutoff=5.0):
#     def renumberAtoms(self):
#     def write(self,filename=None):
#     def dumpStructures(self):
#     def dumpNumberConversion(self,output_file):
#     def loadNumberConversion(self,input_file,current_numbering):
# def main():
# 
# Path: pdbtools/helper/cmdline.py
# def initializeParser(description,version):
# def addOption(short_flag,long_flag,action,default,help,**kwargs):
# def parseArgs(args):
# def parseCommandLine():
# def readFile(some_file):
# 
# Path: pdbtools/helper/geometry.py
# def dist(c1,c2=[0.,0.,0.]):
# def dist_sq(c1,c2=[0.,0.,0.]):
# def calcDistances(coord):
# def crossProduct(u,v):
# def dotProduct(u,v):
# def findAngle(u,v):
# def genRotMatrix(axis,theta):
# def arbRot(vector,axis,theta):
# def arbRotCoord(coord,axis,theta):
# def calcGlyCbeta(Ncoord,CAcoord,COcoord):
# def calcHXT(C_coord,O_coord,OXT_coord):
# def calcHG(CB_coord,SG_coord):
# def calcDihedrals(prevCO,currN,currCA,currCO,nextN,cutoff=6.5):
# def calcHN(prevCO,prevO,currN,currCA):
#     A = [prevCO[i] - currCA[i] for i in range(3)]
#     B = [currN[i] - currCA[i] for i in range(3)]
#     C = [currCO[i] - currCA[i] for i in range(3)]
#     D = [nextN[i] - currCA[i] for i in range(3)]
#     V1 = crossProduct(A,B)
#     V2 = crossProduct(C,B)
#     V3 = crossProduct(C,D)
# 
# Path: pdbtools/atom_renumber.py
# def pdbAtomRenumber(pdb,renumber_het=True):
#     """
#     Renumber all atoms in pdb file, starting from 1.
#     """
# 
#     entries_to_renumber = ["ATOM  ","TER   ","ANISOU"]
#     if renumber_het == True:
#         entries_to_renumber.append("HETATM")
# 
#     out = []
#     counter = 1
#     for line in pdb:
#         # For and ATOM record, update residue number
#         if line[0:6] in entries_to_renumber:
#             out.append("%s%5s%s" % (line[0:6],counter,line[11:]))
#             counter += 1
#         else:
# 
#             # reset the counter for a new model
#             if line[0:6] == "ENDMDL":
#                 counter = 1
# 
#             out.append(line)
# 
#     return out
# 
# Path: pdbtools/disulfide.py
# def pdbDisulfide(pdb,disulfide_cutoff=4.0):
#     """
#     Finds all disulfides in pdb file based on disulfide cutoff distance (A).
#     """
# 
#     pdb, skipped = stripACS(pdb)
# 
#     # Grab sg_atoms, coordinates, and residue numbers
#     sg_atoms = [l for l in pdb if l[0:6] == "ATOM  " and l[13:16] == "SG "]
#     coord = [[float(sg[30+8*i:38+8*i]) for i in range(3)] for sg in sg_atoms]
#     cys_resid = [l[21:26] for l in sg_atoms]
# 
#     # Define all cys within disulfide_cutoff angstroms of each other as in
#     # disulfide bonds
#     cutoff_squared = disulfide_cutoff**2
# 
#     # Find disulfide
#     free_cys = cys_resid[:]
#     disulfide = []
#     num_cys = len(cys_resid)
#     for i in range(num_cys):
#         for j in range(i+1,num_cys):
#             r = sum([(coord[i][k] - coord[j][k])**2 for k in range(3)])
#             if r < cutoff_squared:
# 
#                 # This is a hack (in a sense).  If more than two cysteines are
#                 # close to one another (as in a Cys-Fe cluster), this will
#                 # treat them all as disulfide bonded.  If I don't have the ugly
#                 # try...except statements, the code breaks because each cys has
#                 # multiple binding partners.
#                 try:
#                     free_cys.remove(cys_resid[i])
#                     disulfide.append(cys_resid[i])
#                 except ValueError:
#                     pass
#                 try:
#                     free_cys.remove(cys_resid[j])
#                     disulfide.append(cys_resid[j])
#                 except ValueError:
#                     pass
# 
#     return free_cys, disulfide


# Path: pdbtools/addH.py
import time, os
from math import sqrt
from .helper import container, cmdline, geometry
from .atom_renumber import pdbAtomRenumber
from .disulfide import pdbDisulfide

#!/usr/bin/env python

# 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__ = "Adds polar hydrogens to a pdb file for a UHBD calculation."
__author__ = "Michael J. Harms"
__date__ = "070727"


#from .charmm import interface
### HACK HACK HACK


class PdbAddHError(Exception):