# 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)


import os, sys
from .helper import cmdline, geometry

                # Now record N, C, and CA entries.  Take only a unique one from
                # each residue to deal with multiple conformations etc.
                if line[13:16] not in resid_contents:
                    resid_contents[line[13:16]] = line
                else:
                    err = "Warning: %s has repeated atoms!\n" % current_residue
                    sys.stderr.write(err)

    # Record the last residue
    try:
        N.append([float(resid_contents["N  "][30+8*i:38+8*i])
                  for i in range(3)])
        CO.append([float(resid_contents["C  "][30+8*i:38+8*i])
                   for i in range(3)])
        CA.append([float(resid_contents["CA "][30+8*i:38+8*i])
                   for i in range(3)])
        residue_list.append(current_residue)

    except KeyError:
        err = "Residue %s has missing atoms: skipping.\n" % current_residue
        sys.stderr.write(err)


    # Calculate phi and psi for each residue.  If the calculation fails, write
    # that to standard error and move on.
    labels = []
    dihedrals = []
    for i in range(1,len(residue_list)-1):
        try:

# 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/torsion.py
import os, sys
from .helper import cmdline, geometry


                # Now record N, C, and CA entries.  Take only a unique one from
                # each residue to deal with multiple conformations etc.
                if line[13:16] not in resid_contents:
                    resid_contents[line[13:16]] = line
                else:
                    err = "Warning: %s has repeated atoms!\n" % current_residue
                    sys.stderr.write(err)

    # Record the last residue
    try:
        N.append([float(resid_contents["N  "][30+8*i:38+8*i])
                  for i in range(3)])
        CO.append([float(resid_contents["C  "][30+8*i:38+8*i])
                   for i in range(3)])
        CA.append([float(resid_contents["CA "][30+8*i:38+8*i])
                   for i in range(3)])
        residue_list.append(current_residue)

    except KeyError:
        err = "Residue %s has missing atoms: skipping.\n" % current_residue
        sys.stderr.write(err)


    # Calculate phi and psi for each residue.  If the calculation fails, write
    # that to standard error and move on.
    labels = []
    dihedrals = []
    for i in range(1,len(residue_list)-1):
        try:

            dihedrals.append(geometry.calcDihedrals(CO[i-1],N[i],CA[i],CO[i],