src.hydrogens (22 April 2009) | index /Users/d3y382/workspaces/apbs-pdb2pqr/pdb2pqr/src/hydrogens.py

`Hydrogen optimization for PDB2PQR
This is an module for hydrogen optimization routines.
----------------------------
PDB2PQR -- An automated pipeline for the setup, execution, and analysis of
Poisson-Boltzmann electrostatics calculations
Copyright (c) 2002-2011, Jens Erik Nielsen, University College Dublin;
Nathan A. Baker, Battelle Memorial Institute, Developed at the Pacific
Northwest National Laboratory, operated by Battelle Memorial Institute,
Pacific Northwest Division for the U.S. Department Energy.;
Paul Czodrowski & Gerhard Klebe, University of Marburg.
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
* Neither the names of University College Dublin, Battelle Memorial Institute,
Pacific Northwest National Laboratory, US Department of Energy, or University
of Marburg nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
OF THE POSSIBILITY OF SUCH DAMAGE.
----------------------------`

Modules

``

copy getopt math | os re xml.sax | string sys src.topology |

Classes

``

HydrogenConformation
HydrogenDefinition
OptimizationHolder
Optimize
  Alcoholic
  Carboxylic
  Flip
  Generic
  Water
PotentialBond
hydrogenAmbiguity
hydrogenRoutines
xml.sax.handler.ContentHandler
  HydrogenHandler

class Alcoholic(Optimize)
`` | `The class for alcoholic residues`

Methods defined here:

__init__(self, residue, optinstance, routines)
  `Initialize the alcoholic class by removing
  the alcoholic hydrogen if it exists.`

complete(self)
  `Complete an alcoholic optimization. Call finalize(), and then
  remove all extra LP atoms.`

finalize(self)
  `Finalize an alcoholic residue. Try to minimize
  conflict with nearby atoms by building away
  from them. Called when LPs are still present
  so as to account for their bonds.`

tryAcceptor(self, acc, donor)
  `The main driver for adding an LP to an optimizeable
  residue.`

tryBoth(self, donor, acc, accobj)
  `Called when both the donor and acceptor are optimizeable;
  If one is fixed, we only need to try one side. Otherwise
  first try to satisfy the donor - if that's succesful,
  try to satisfy the acceptor. An undo may be necessary
  if the donor is satisfied and the acceptor isn't.`

tryDonor(self, donor, acc)
  `The main driver for adding a hydrogen to an
  optimizeable residue.`

Methods inherited from Optimize:

__str__(self)
  `String output for debugging`

debug(self, txt)
  `Easy way to turn on/off debugging`

getPositionWithThreeBonds(self, atom)
  `If there's three bonds in a tetrahedral geometry,
  there's only one available position. Find that
  position.`

getPositionsWithTwoBonds(self, atom)
  `Given a tetrahedral geometry with two
  existing bonds, return the two potential
  sets of coordinates that are possible for
  a new bond.`

isHbond(self, donor, acc)
  `Determine whether this donor acceptor pair is a
  hydrogen bond`

makeAtomWithNoBonds(self, atom, closeatom, addname)
  `Called for water oxygen atoms with no current bonds.
  Uses the closeatom to place the new atom directly
  colinear with the atom and the closeatom.
  Parameters
  atom: The oxygen atom of the water
  closeatom: The nearby atom (donor/acceptor)
  addname: The name of the atom to add`

makeAtomWithOneBondH(self, atom, addname)
  `Add a hydrogen to an alcoholic donor with one
  existing bond.`

makeAtomWithOneBondLP(self, atom, addname)
  `Add a lone pair to an alcoholic donor with one
  existing bond.`

makeWaterWithOneBond(self, atom, addname)
  `Add an atom to a water residue that already has
  one bond. Uses the water reference structure to
  align the new atom.`

tryPositionsWithThreeBondsH(self, donor, acc, newname, loc)
  `Try making a hydrogen bond with the lone available
  position.`

tryPositionsWithThreeBondsLP(self, acc, donor, newname, loc)
  `Try making a hydrogen bond using the lone
  available hydrogen position.`

tryPositionsWithTwoBondsH(self, donor, acc, newname, loc1, loc2)
  `Try adding a new hydrogen two the two potential
  locations. If both form hydrogen bonds, place at
  whatever returns the best bond as determined by
  getPairEnergy.`

tryPositionsWithTwoBondsLP(self, acc, donor, newname, loc1, loc2)
  `Try placing an LP on a tetrahedral geometry with
  two existing bonds. If this isn't a hydrogen bond
  it can return - otherwise ensure that the H(D)-A-LP
  angle is minimized.`

trySingleAlcoholicH(self, donor, acc, newatom)
  `After a new bond has been added using
  makeAtomWithOneBond*, try to find the best orientation
  by rotating to form a hydrogen bond. If a bond
  cannot be formed, remove the newatom (thereby
  returning to a single bond).`

trySingleAlcoholicLP(self, acc, donor, newatom)
  `After a new bond has been added using
  makeAtomWithOneBond*, ensure that a
  hydrogen bond has been made. If so, try to
  minimze the H(D)-A-LP angle. If that cannot
  be minimized, ignore the bond and remove the
  atom.`

Static methods inherited from Optimize:

getHbondangle(atom1, atom2, atom3)
  `Get the angle between three atoms
  Parameters
  atom1: The first atom (atom)
  atom2: The second (vertex) atom (atom)
  atom3: The third atom (atom)
  Returns
  angle: The angle between the atoms (float)`

getPairEnergy(donor, acceptor)
  `Get the energy between two atoms
  Parameters
  donor: The first atom in the pair (Atom)
  acceptor: The second atom in the pair (Atom)
  Returns
  energy: The energy of the pair (float)`

class Carboxylic(Optimize)
`` | `The class for carboxylic residues`

Methods defined here:

__init__(self, residue, optinstance, routines)
  `Initialize a case where the lone hydrogen atom
  can have four different orientations. Works similar
  to initializeFlip by preadding the necessary atoms.
  This also takes into account that the carboxyl group
  has different bond lengths for the two C-O bonds -
  this is probably due to one bond being assigned
  as a C=O. As a result hydrogens are only added to
  the C-O (longer) bond.
  Parameters
  residue: The residue to flip (residue)
  dihedral: The angle to flip about
  hname: The name of one of the hydrogens to add
  Returns
  optlist: A list of optimizeable donors and
  acceptors in the residue (list)`

complete(self)
  `If not already fixed, finalize`

finalize(self)
  `Finalize a protontated residue. Try to minimize
  conflict with nearby atoms.`

fix(self, donor, acc)
  `Fix the carboxylic residue.`

isCarboxylicHbond(self, donor, acc)
  `Determine whether this donor acceptor pair is a
  hydrogen bond`

rename(self, hydatom)
  `Rename the optimized atoms appropriately. This is done
  since the forcefields tend to require that the hydrogen is
  linked to a specific oxygen, and this atom may have different
  parameter values.
  Parameters
  hydatom: The hydrogen atom that was added. (atom)`

tryAcceptor(self, acc, donor)
  `The main driver for adding an LP to an optimizeable
  residue.`

tryBoth(self, donor, acc, accobj)
  `Called when both the donor and acceptor are optimizeable;
  If one is fixed, we only need to try one side. Otherwise
  first try to satisfy the donor - if that's succesful,
  try to satisfy the acceptor. An undo may be necessary
  if the donor is satisfied and the acceptor isn't.`

tryDonor(self, donor, acc)
  `The main driver for adding a hydrogen to an
  optimizeable residue.`

Methods inherited from Optimize:

__str__(self)
  `String output for debugging`

debug(self, txt)
  `Easy way to turn on/off debugging`

getPositionWithThreeBonds(self, atom)
  `If there's three bonds in a tetrahedral geometry,
  there's only one available position. Find that
  position.`

getPositionsWithTwoBonds(self, atom)
  `Given a tetrahedral geometry with two
  existing bonds, return the two potential
  sets of coordinates that are possible for
  a new bond.`

isHbond(self, donor, acc)
  `Determine whether this donor acceptor pair is a
  hydrogen bond`

makeAtomWithNoBonds(self, atom, closeatom, addname)
  `Called for water oxygen atoms with no current bonds.
  Uses the closeatom to place the new atom directly
  colinear with the atom and the closeatom.
  Parameters
  atom: The oxygen atom of the water
  closeatom: The nearby atom (donor/acceptor)
  addname: The name of the atom to add`

makeAtomWithOneBondH(self, atom, addname)
  `Add a hydrogen to an alcoholic donor with one
  existing bond.`

makeAtomWithOneBondLP(self, atom, addname)
  `Add a lone pair to an alcoholic donor with one
  existing bond.`

makeWaterWithOneBond(self, atom, addname)
  `Add an atom to a water residue that already has
  one bond. Uses the water reference structure to
  align the new atom.`

tryPositionsWithThreeBondsH(self, donor, acc, newname, loc)
  `Try making a hydrogen bond with the lone available
  position.`

tryPositionsWithThreeBondsLP(self, acc, donor, newname, loc)
  `Try making a hydrogen bond using the lone
  available hydrogen position.`

tryPositionsWithTwoBondsH(self, donor, acc, newname, loc1, loc2)
  `Try adding a new hydrogen two the two potential
  locations. If both form hydrogen bonds, place at
  whatever returns the best bond as determined by
  getPairEnergy.`

tryPositionsWithTwoBondsLP(self, acc, donor, newname, loc1, loc2)
  `Try placing an LP on a tetrahedral geometry with
  two existing bonds. If this isn't a hydrogen bond
  it can return - otherwise ensure that the H(D)-A-LP
  angle is minimized.`

trySingleAlcoholicH(self, donor, acc, newatom)
  `After a new bond has been added using
  makeAtomWithOneBond*, try to find the best orientation
  by rotating to form a hydrogen bond. If a bond
  cannot be formed, remove the newatom (thereby
  returning to a single bond).`

trySingleAlcoholicLP(self, acc, donor, newatom)
  `After a new bond has been added using
  makeAtomWithOneBond*, ensure that a
  hydrogen bond has been made. If so, try to
  minimze the H(D)-A-LP angle. If that cannot
  be minimized, ignore the bond and remove the
  atom.`

Static methods inherited from Optimize:

getHbondangle(atom1, atom2, atom3)
  `Get the angle between three atoms
  Parameters
  atom1: The first atom (atom)
  atom2: The second (vertex) atom (atom)
  atom3: The third atom (atom)
  Returns
  angle: The angle between the atoms (float)`

getPairEnergy(donor, acceptor)
  `Get the energy between two atoms
  Parameters
  donor: The first atom in the pair (Atom)
  acceptor: The second atom in the pair (Atom)
  Returns
  energy: The energy of the pair (float)`

class Flip(Optimize)
`` | `The holder for optimization of flippable residues.`

Methods defined here:

__init__(self, residue, optinstance, routines)
  `Initialize a potential flip. Rather than flipping
  the given residue back and forth, take each atom
  that would be flipped and pre-flip it, making a
  new *FLIP atom in its place.
  Parameters
  residue: The residue to flip (residue)
  optinstance: The optimization instance containing
  information about what to optimize`

complete(self)
  `Complete the flippable residue optimization. Call the finalize
  function, and then rename all FLIP atoms back to their standard
  names.`

finalize(self)
  `Finalizes a flippable back to its original state -
  since the original atoms are now *FLIP, it deletes
  the * atoms and renames the *FLIP atoms back to *.`

fixFlip(self, bondatom)
  `Called if a hydrogen bond has been found using
  the bondatom. If bondatom is *FLIP, remove all *
  atoms, otherwise remove all *FLIP atoms.`

tryAcceptor(self, acc, donor)
  `The main driver for adding an LP to an optimizeable
  residue.`

tryBoth(self, donor, acc, accobj)
  `Called when both the donor and acceptor are optimizeable;
  If one is fixed, we only need to try one side. Otherwise
  first try to satisfy the donor - if that's succesful,
  try to satisfy the acceptor. An undo may be necessary
  if the donor is satisfied and the acceptor isn't.`

tryDonor(self, donor, acc)
  `The main driver for adding a hydrogen to an
  optimizeable residue.`

Methods inherited from Optimize:

__str__(self)
  `String output for debugging`

debug(self, txt)
  `Easy way to turn on/off debugging`

getPositionWithThreeBonds(self, atom)
  `If there's three bonds in a tetrahedral geometry,
  there's only one available position. Find that
  position.`

getPositionsWithTwoBonds(self, atom)
  `Given a tetrahedral geometry with two
  existing bonds, return the two potential
  sets of coordinates that are possible for
  a new bond.`

isHbond(self, donor, acc)
  `Determine whether this donor acceptor pair is a
  hydrogen bond`

makeAtomWithNoBonds(self, atom, closeatom, addname)
  `Called for water oxygen atoms with no current bonds.
  Uses the closeatom to place the new atom directly
  colinear with the atom and the closeatom.
  Parameters
  atom: The oxygen atom of the water
  closeatom: The nearby atom (donor/acceptor)
  addname: The name of the atom to add`

makeAtomWithOneBondH(self, atom, addname)
  `Add a hydrogen to an alcoholic donor with one
  existing bond.`

makeAtomWithOneBondLP(self, atom, addname)
  `Add a lone pair to an alcoholic donor with one
  existing bond.`

makeWaterWithOneBond(self, atom, addname)
  `Add an atom to a water residue that already has
  one bond. Uses the water reference structure to
  align the new atom.`

tryPositionsWithThreeBondsH(self, donor, acc, newname, loc)
  `Try making a hydrogen bond with the lone available
  position.`

tryPositionsWithThreeBondsLP(self, acc, donor, newname, loc)
  `Try making a hydrogen bond using the lone
  available hydrogen position.`

tryPositionsWithTwoBondsH(self, donor, acc, newname, loc1, loc2)
  `Try adding a new hydrogen two the two potential
  locations. If both form hydrogen bonds, place at
  whatever returns the best bond as determined by
  getPairEnergy.`

tryPositionsWithTwoBondsLP(self, acc, donor, newname, loc1, loc2)
  `Try placing an LP on a tetrahedral geometry with
  two existing bonds. If this isn't a hydrogen bond
  it can return - otherwise ensure that the H(D)-A-LP
  angle is minimized.`

trySingleAlcoholicH(self, donor, acc, newatom)
  `After a new bond has been added using
  makeAtomWithOneBond*, try to find the best orientation
  by rotating to form a hydrogen bond. If a bond
  cannot be formed, remove the newatom (thereby
  returning to a single bond).`

trySingleAlcoholicLP(self, acc, donor, newatom)
  `After a new bond has been added using
  makeAtomWithOneBond*, ensure that a
  hydrogen bond has been made. If so, try to
  minimze the H(D)-A-LP angle. If that cannot
  be minimized, ignore the bond and remove the
  atom.`

Static methods inherited from Optimize:

getHbondangle(atom1, atom2, atom3)
  `Get the angle between three atoms
  Parameters
  atom1: The first atom (atom)
  atom2: The second (vertex) atom (atom)
  atom3: The third atom (atom)
  Returns
  angle: The angle between the atoms (float)`

getPairEnergy(donor, acceptor)
  `Get the energy between two atoms
  Parameters
  donor: The first atom in the pair (Atom)
  acceptor: The second atom in the pair (Atom)
  Returns
  energy: The energy of the pair (float)`

class Generic(Optimize)
`` | `Generic optimization class`

Methods defined here:

__init__(self, residue, optinstance, routines)
  `Initialize the generic optimization class`

complete(self)
  `If not already fixed, finalize`

finalize(self)

Methods inherited from Optimize:

__str__(self)
  `String output for debugging`

debug(self, txt)
  `Easy way to turn on/off debugging`

getPositionWithThreeBonds(self, atom)
  `If there's three bonds in a tetrahedral geometry,
  there's only one available position. Find that
  position.`

getPositionsWithTwoBonds(self, atom)
  `Given a tetrahedral geometry with two
  existing bonds, return the two potential
  sets of coordinates that are possible for
  a new bond.`

isHbond(self, donor, acc)
  `Determine whether this donor acceptor pair is a
  hydrogen bond`

makeAtomWithNoBonds(self, atom, closeatom, addname)
  `Called for water oxygen atoms with no current bonds.
  Uses the closeatom to place the new atom directly
  colinear with the atom and the closeatom.
  Parameters
  atom: The oxygen atom of the water
  closeatom: The nearby atom (donor/acceptor)
  addname: The name of the atom to add`

makeAtomWithOneBondH(self, atom, addname)
  `Add a hydrogen to an alcoholic donor with one
  existing bond.`

makeAtomWithOneBondLP(self, atom, addname)
  `Add a lone pair to an alcoholic donor with one
  existing bond.`

makeWaterWithOneBond(self, atom, addname)
  `Add an atom to a water residue that already has
  one bond. Uses the water reference structure to
  align the new atom.`

tryPositionsWithThreeBondsH(self, donor, acc, newname, loc)
  `Try making a hydrogen bond with the lone available
  position.`

tryPositionsWithThreeBondsLP(self, acc, donor, newname, loc)
  `Try making a hydrogen bond using the lone
  available hydrogen position.`

tryPositionsWithTwoBondsH(self, donor, acc, newname, loc1, loc2)
  `Try adding a new hydrogen two the two potential
  locations. If both form hydrogen bonds, place at
  whatever returns the best bond as determined by
  getPairEnergy.`

tryPositionsWithTwoBondsLP(self, acc, donor, newname, loc1, loc2)
  `Try placing an LP on a tetrahedral geometry with
  two existing bonds. If this isn't a hydrogen bond
  it can return - otherwise ensure that the H(D)-A-LP
  angle is minimized.`

trySingleAlcoholicH(self, donor, acc, newatom)
  `After a new bond has been added using
  makeAtomWithOneBond*, try to find the best orientation
  by rotating to form a hydrogen bond. If a bond
  cannot be formed, remove the newatom (thereby
  returning to a single bond).`

trySingleAlcoholicLP(self, acc, donor, newatom)
  `After a new bond has been added using
  makeAtomWithOneBond*, ensure that a
  hydrogen bond has been made. If so, try to
  minimze the H(D)-A-LP angle. If that cannot
  be minimized, ignore the bond and remove the
  atom.`

Static methods inherited from Optimize:

getHbondangle(atom1, atom2, atom3)
  `Get the angle between three atoms
  Parameters
  atom1: The first atom (atom)
  atom2: The second (vertex) atom (atom)
  atom3: The third atom (atom)
  Returns
  angle: The angle between the atoms (float)`

getPairEnergy(donor, acceptor)
  `Get the energy between two atoms
  Parameters
  donor: The first atom in the pair (Atom)
  acceptor: The second atom in the pair (Atom)
  Returns
  energy: The energy of the pair (float)`

class HydrogenConformation
`` | `HydrogenConformation class The HydrogenConformation class contains data about possible hydrogen conformations as specified in the hydrogen data file.`

Methods defined here:

__init__(self, hname, boundatom, bondlength)
  `Initialize the object
  Parameters
  hname : The hydrogen name (string)
  boundatom : The atom the hydrogen is bound to (string)
  bondlength : The bond length (float)`

__str__(self)
  `Used for debugging purposes
  Returns
  output: Information about this conformation (string)`

addAtom(self, atom)
  `Add an atom to the list of atoms
  Parameters
  atom: The atom to be added (DefinitionAtom)`

class HydrogenDefinition
`` | `HydrogenDefinition class The HydrogenDefinition class provides information on possible ambiguities in amino acid hydrogens. It is essentially the hydrogen definition file in object form.`

Methods defined here:

__init__(self, name, opttype, optangle, map)
  `Initialize the object with information from the definition file
  Parameters:
  name: The name of the grouping (string)
  opttype: The optimization type of the grouping (string)
  optangle: The optimization angle of the grouping (string)
  map: The map of Hydrogens.
  See HYDROGENS.XML for more information`

__str__(self)
  `Used for debugging purposes
  Returns
  output: The information about this definition (string)`

addConf(self, conf)
  `Add a HydrogenConformation to the list of conformations
  Parameters
  conf: The conformation to be added (HydrogenConformation)`

class HydrogenHandler(xml.sax.handler.ContentHandler)
`` | `Extends the SAX XML Parser to parse the Hydrogens.xml class`

Methods defined here:

__init__(self)
  `Initalize the class.`

characters(self, text)
  `Set a given attribute of the object to the text`

endElement(self, name)
  `Complete whatever object is currently passed in
  by the name parameter`

startElement(self, name, attributes)
  `Create optimization holder objects or atoms`

Methods inherited from xml.sax.handler.ContentHandler:

endDocument(self)
  `Receive notification of the end of a document.
  The SAX parser will invoke this method only once, and it will
  be the last method invoked during the parse. The parser shall
  not invoke this method until it has either abandoned parsing
  (because of an unrecoverable error) or reached the end of
  input.`

endElementNS(self, name, qname)
  `Signals the end of an element in namespace mode.
  The name parameter contains the name of the element type, just
  as with the startElementNS event.`

endPrefixMapping(self, prefix)
  `End the scope of a prefix-URI mapping.
  See startPrefixMapping for details. This event will always
  occur after the corresponding endElement event, but the order
  of endPrefixMapping events is not otherwise guaranteed.`

ignorableWhitespace(self, whitespace)
  `Receive notification of ignorable whitespace in element content.
  Validating Parsers must use this method to report each chunk
  of ignorable whitespace (see the W3C XML 1.0 recommendation,
  section 2.10): non-validating parsers may also use this method
  if they are capable of parsing and using content models.
  SAX parsers may return all contiguous whitespace in a single
  chunk, or they may split it into several chunks; however, all
  of the characters in any single event must come from the same
  external entity, so that the Locator provides useful
  information.`

processingInstruction(self, target, data)
  `Receive notification of a processing instruction.
  The Parser will invoke this method once for each processing
  instruction found: note that processing instructions may occur
  before or after the main document element.
  A SAX parser should never report an XML declaration (XML 1.0,
  section 2.8) or a text declaration (XML 1.0, section 4.3.1)
  using this method.`

setDocumentLocator(self, locator)
  `Called by the parser to give the application a locator for
  locating the origin of document events.
  SAX parsers are strongly encouraged (though not absolutely
  required) to supply a locator: if it does so, it must supply
  the locator to the application by invoking this method before
  invoking any of the other methods in the DocumentHandler
  interface.
  The locator allows the application to determine the end
  position of any document-related event, even if the parser is
  not reporting an error. Typically, the application will use
  this information for reporting its own errors (such as
  character content that does not match an application's
  business rules). The information returned by the locator is
  probably not sufficient for use with a search engine.
  Note that the locator will return correct information only
  during the invocation of the events in this interface. The
  application should not attempt to use it at any other time.`

skippedEntity(self, name)
  `Receive notification of a skipped entity.
  The Parser will invoke this method once for each entity
  skipped. Non-validating processors may skip entities if they
  have not seen the declarations (because, for example, the
  entity was declared in an external DTD subset). All processors
  may skip external entities, depending on the values of the
  http://xml.org/sax/features/external-general-entities and the
  http://xml.org/sax/features/external-parameter-entities
  properties.`

startDocument(self)
  `Receive notification of the beginning of a document.
  The SAX parser will invoke this method only once, before any
  other methods in this interface or in DTDHandler (except for
  setDocumentLocator).`

startElementNS(self, name, qname, attrs)
  `Signals the start of an element in namespace mode.
  The name parameter contains the name of the element type as a
  (uri, localname) tuple, the qname parameter the raw XML 1.0
  name used in the source document, and the attrs parameter
  holds an instance of the Attributes class containing the
  attributes of the element.
  The uri part of the name tuple is None for elements which have
  no namespace.`

startPrefixMapping(self, prefix, uri)
  `Begin the scope of a prefix-URI Namespace mapping.
  The information from this event is not necessary for normal
  Namespace processing: the SAX XML reader will automatically
  replace prefixes for element and attribute names when the
  http://xml.org/sax/features/namespaces feature is true (the
  default).
  There are cases, however, when applications need to use
  prefixes in character data or in attribute values, where they
  cannot safely be expanded automatically; the
  start/endPrefixMapping event supplies the information to the
  application to expand prefixes in those contexts itself, if
  necessary.
  Note that start/endPrefixMapping events are not guaranteed to
  be properly nested relative to each-other: all
  startPrefixMapping events will occur before the corresponding
  startElement event, and all endPrefixMapping events will occur
  after the corresponding endElement event, but their order is
  not guaranteed.`

class OptimizationHolder
`` | `A holder class for the XML parser.`

Methods defined here:

__init__(self)
  `Initialize the class.`

__str__(self)
  `A basic string representation for debugging`

class Optimize
`` | `The holder class for the hydrogen optimization routines. Individual optimization types inherit off of this class. Any functions used by multiple types appear here.`

Methods defined here:

__init__(self)
  `Initialize the class`

__str__(self)
  `String output for debugging`

debug(self, txt)
  `Easy way to turn on/off debugging`

getPositionWithThreeBonds(self, atom)
  `If there's three bonds in a tetrahedral geometry,
  there's only one available position. Find that
  position.`

getPositionsWithTwoBonds(self, atom)
  `Given a tetrahedral geometry with two
  existing bonds, return the two potential
  sets of coordinates that are possible for
  a new bond.`

isHbond(self, donor, acc)
  `Determine whether this donor acceptor pair is a
  hydrogen bond`

makeAtomWithNoBonds(self, atom, closeatom, addname)
  `Called for water oxygen atoms with no current bonds.
  Uses the closeatom to place the new atom directly
  colinear with the atom and the closeatom.
  Parameters
  atom: The oxygen atom of the water
  closeatom: The nearby atom (donor/acceptor)
  addname: The name of the atom to add`

makeAtomWithOneBondH(self, atom, addname)
  `Add a hydrogen to an alcoholic donor with one
  existing bond.`

makeAtomWithOneBondLP(self, atom, addname)
  `Add a lone pair to an alcoholic donor with one
  existing bond.`

makeWaterWithOneBond(self, atom, addname)
  `Add an atom to a water residue that already has
  one bond. Uses the water reference structure to
  align the new atom.`

tryPositionsWithThreeBondsH(self, donor, acc, newname, loc)
  `Try making a hydrogen bond with the lone available
  position.`

tryPositionsWithThreeBondsLP(self, acc, donor, newname, loc)
  `Try making a hydrogen bond using the lone
  available hydrogen position.`

tryPositionsWithTwoBondsH(self, donor, acc, newname, loc1, loc2)
  `Try adding a new hydrogen two the two potential
  locations. If both form hydrogen bonds, place at
  whatever returns the best bond as determined by
  getPairEnergy.`

tryPositionsWithTwoBondsLP(self, acc, donor, newname, loc1, loc2)
  `Try placing an LP on a tetrahedral geometry with
  two existing bonds. If this isn't a hydrogen bond
  it can return - otherwise ensure that the H(D)-A-LP
  angle is minimized.`

trySingleAlcoholicH(self, donor, acc, newatom)
  `After a new bond has been added using
  makeAtomWithOneBond*, try to find the best orientation
  by rotating to form a hydrogen bond. If a bond
  cannot be formed, remove the newatom (thereby
  returning to a single bond).`

trySingleAlcoholicLP(self, acc, donor, newatom)
  `After a new bond has been added using
  makeAtomWithOneBond*, ensure that a
  hydrogen bond has been made. If so, try to
  minimze the H(D)-A-LP angle. If that cannot
  be minimized, ignore the bond and remove the
  atom.`

Static methods defined here:

getHbondangle(atom1, atom2, atom3)
  `Get the angle between three atoms
  Parameters
  atom1: The first atom (atom)
  atom2: The second (vertex) atom (atom)
  atom3: The third atom (atom)
  Returns
  angle: The angle between the atoms (float)`

getPairEnergy(donor, acceptor)
  `Get the energy between two atoms
  Parameters
  donor: The first atom in the pair (Atom)
  acceptor: The second atom in the pair (Atom)
  Returns
  energy: The energy of the pair (float)`

class PotentialBond
`` | `A small class containing the hbond structure`

Methods defined here:

__init__(self, atom1, atom2, dist)
  `Initialize the class
  Parameters
  atom1: The first atom in the potential bond (Atom)
  atom2: The second atom in the potential bond (Atom)
  dist: The distance between the two atoms (float)`

__str__(self)
  `String for debugging`

class Water(Optimize)
`` | `The class for water residues`

Methods defined here:

__init__(self, residue, optinstance, routines)
  `Initialize the water optimization class`

complete(self)
  `Complete the water optimization class`

finalize(self)
  `Finalize a water residue. Try to minimize
  conflict with nearby atoms by building away
  from them. Called when LPs are still present
  so as to account for their bonds.`

tryAcceptor(self, acc, donor)
  `The main driver for adding an LP to an optimizeable
  residue.`

tryBoth(self, donor, acc, accobj)
  `Called when both the donor and acceptor are optimizeable;
  If one is fixed, we only need to try one side. Otherwise
  first try to satisfy the donor - if that's succesful,
  try to satisfy the acceptor. An undo may be necessary
  if the donor is satisfied and the acceptor isn't.`

tryDonor(self, donor, acc)
  `The main driver for adding a hydrogen to an
  optimizeable residue.`

Methods inherited from Optimize:

__str__(self)
  `String output for debugging`

debug(self, txt)
  `Easy way to turn on/off debugging`

getPositionWithThreeBonds(self, atom)
  `If there's three bonds in a tetrahedral geometry,
  there's only one available position. Find that
  position.`

getPositionsWithTwoBonds(self, atom)
  `Given a tetrahedral geometry with two
  existing bonds, return the two potential
  sets of coordinates that are possible for
  a new bond.`

isHbond(self, donor, acc)
  `Determine whether this donor acceptor pair is a
  hydrogen bond`

makeAtomWithNoBonds(self, atom, closeatom, addname)
  `Called for water oxygen atoms with no current bonds.
  Uses the closeatom to place the new atom directly
  colinear with the atom and the closeatom.
  Parameters
  atom: The oxygen atom of the water
  closeatom: The nearby atom (donor/acceptor)
  addname: The name of the atom to add`

makeAtomWithOneBondH(self, atom, addname)
  `Add a hydrogen to an alcoholic donor with one
  existing bond.`

makeAtomWithOneBondLP(self, atom, addname)
  `Add a lone pair to an alcoholic donor with one
  existing bond.`

makeWaterWithOneBond(self, atom, addname)
  `Add an atom to a water residue that already has
  one bond. Uses the water reference structure to
  align the new atom.`

tryPositionsWithThreeBondsH(self, donor, acc, newname, loc)
  `Try making a hydrogen bond with the lone available
  position.`

tryPositionsWithThreeBondsLP(self, acc, donor, newname, loc)
  `Try making a hydrogen bond using the lone
  available hydrogen position.`

tryPositionsWithTwoBondsH(self, donor, acc, newname, loc1, loc2)
  `Try adding a new hydrogen two the two potential
  locations. If both form hydrogen bonds, place at
  whatever returns the best bond as determined by
  getPairEnergy.`

tryPositionsWithTwoBondsLP(self, acc, donor, newname, loc1, loc2)
  `Try placing an LP on a tetrahedral geometry with
  two existing bonds. If this isn't a hydrogen bond
  it can return - otherwise ensure that the H(D)-A-LP
  angle is minimized.`

trySingleAlcoholicH(self, donor, acc, newatom)
  `After a new bond has been added using
  makeAtomWithOneBond*, try to find the best orientation
  by rotating to form a hydrogen bond. If a bond
  cannot be formed, remove the newatom (thereby
  returning to a single bond).`

trySingleAlcoholicLP(self, acc, donor, newatom)
  `After a new bond has been added using
  makeAtomWithOneBond*, ensure that a
  hydrogen bond has been made. If so, try to
  minimze the H(D)-A-LP angle. If that cannot
  be minimized, ignore the bond and remove the
  atom.`

Static methods inherited from Optimize:

getHbondangle(atom1, atom2, atom3)
  `Get the angle between three atoms
  Parameters
  atom1: The first atom (atom)
  atom2: The second (vertex) atom (atom)
  atom3: The third atom (atom)
  Returns
  angle: The angle between the atoms (float)`

getPairEnergy(donor, acceptor)
  `Get the energy between two atoms
  Parameters
  donor: The first atom in the pair (Atom)
  acceptor: The second atom in the pair (Atom)
  Returns
  energy: The energy of the pair (float)`

class hydrogenAmbiguity
`` | `A class containing information about the ambiguity`

Methods defined here:

__init__(self, residue, hdef, routines)
  `Initialize the class - if the residue has a rotateable hydrogen,
  remove it. If it can be flipped, pre-flip the residue by creating
  all additional atoms.
  Parameters
  residue: The residue in question (residue)
  hdef: The hydrogen definition matching the residue
  routines: Pointer to the general routines object`

__str__(self)
  `Print the ambiguity for debugging purposes`

class hydrogenRoutines
`` | `The main routines for hydrogen optimization. This could potentially be extended from the routines object...`

Methods defined here:

__init__(self, routines)
  `Parse the XML hydrogenFile and store the data in a map`

cleanup(self)
  `If there are any extra carboxlyic *1 atoms, delete them.
  This may occur when no optimization is chosen`

debug(self, text)
  `Print text to stdout for debugging purposes.
  Parameters
  text: The text to output (string)`

initializeFullOptimization(self)
  `Initialize the full optimization. Detects all
  optimizeable donors and acceptors and sets the internal
  optlist.`

initializeWaterOptimization(self)
  `Initialize optimization for waters only. Detects all
  optimizeable donors and acceptors and sets the internal
  optlist.`

isOptimizeable(self, residue)
  `Check to see if the given residue is optimizeable
  There are three ways to identify a residue:
  1. By name (i.e. HIS)
  2. By reference name - a PDB file HSP has
  a HIS reference name
  3. By patch - applied by PropKa, terminal selection
  Parameters
  residue: The residue in question (Residue)
  Returns
  optinstance: None if not optimizeable, otherwise
  the OptimizationHolder instance that
  corresponds to the residue.`

optimizeHydrogens(self)
  `The main driver for the optimization. Should be
  called only after the optlist has been initialized.`

pKa_switchstate(self, amb, stateID)
  `Switch a residue to a new state by first removing all
  hydrogens. this routine is used in pKa calculations only!
  Parameters
  amb : The amibiguity to switch (tuple)
  stateID : The state id to switch to (list)`

parseHydrogen(self, res)
  `Parse a list of lines in order to make a hydrogen
  definition
  Parameters
  lines: The lines to parse (list)
  Returns
  mydef: The hydrogen definition object (HydrogenDefinition)
  This is the current definition: Name Ttyp A R # Stdconf HT Chi OPTm`

readHydrogenDefinition(self)
  `Read the Hydrogen Definition file
  Returns
  hydrodef: The hydrogen definition ()`

setOptimizeableHydrogens(self)
  `Set any hydrogen listed in HYDROGENS.xml that
  is optimizeable. Used BEFORE hydrogen optimization
  to label atoms so that they won't be debumped - i.e.
  if SER HG is too close to another atom, don't debump
  but wait for optimization. This function should not
  be used if full optimization is not taking place.`

switchstate(self, states, amb, stateID)
  `Switch a residue to a new state by first removing all
  hydrogens.
  Parameters
  states: The list of states (list)
  amb : The amibiguity to switch (tuple)
  stateID : The state id to switch to (int)`

Data

``

AAPATH = 'dat/AA.xml'
AAS = ['ALA', 'ARG', 'ASH', 'ASN', 'ASP', 'CYS', 'CYM', 'GLN', 'GLU', 'GLH', 'GLY', 'HIS', 'HID', 'HIE', 'HIP', 'HSD', 'HSE', 'HSP', 'ILE', 'LEU', ...]
ANGLE_CUTOFF = 20.0
BACKBONE = ['N', 'CA', 'C', 'O', 'O2', 'HA', 'HN', 'H', 'tN']
BONDED_SS_LIMIT = 2.5
BUMP_DIST = 2.0
BUMP_HDIST = 1.5
BUMP_HEAVY_SIZE = 1.0
BUMP_HYDROGEN_SIZE = 0.5
CELL_SIZE = 2
DIHEDRAL = 57.2958
DIST_CUTOFF = 3.3
HDEBUG = 0
HYDPATH = 'dat/HYDROGENS.xml'
INSTALLDIR = '/Users/d3y382/pdb2pqr/'
NAPATH = 'dat/NA.xml'
NAS = ['A', 'A5', 'A3', 'C', 'C5', 'C3', 'G', 'G5', 'G3', 'T', 'T5', 'T3', 'U', 'U5', 'U3', 'RA', 'RG', 'RC', 'RU', 'DA', ...]
PATCHPATH = 'dat/PATCHES.xml'
PEPTIDE_DIST = 1.7
REPAIR_LIMIT = 10
SMALL = 1e-07
TMPDIR = 'tmp/'
TOPOLOGYPATH = 'dat/TOPOLOGY.xml'
__author__ = 'Todd Dolinsky, Jens Erik Nielsen, Yong Huang'
__date__ = '22 April 2009'
lineParsers = {'ANISOU': <class 'src.pdb.ANISOU'>, 'ATOM': <class 'src.pdb.ATOM'>, 'AUTHOR': <class 'src.pdb.AUTHOR'>, 'CAVEAT': <class 'src.pdb.CAVEAT'>, 'CISPEP': <class 'src.pdb.CISPEP'>, 'COMPND': <class 'src.pdb.COMPND'>, 'CONECT': <class 'src.pdb.CONECT'>, 'CRYST1': <class 'src.pdb.CRYST1'>, 'DBREF': <class 'src.pdb.DBREF'>, 'END': <class 'src.pdb.END'>, ...}

Author
`` |  | Todd Dolinsky, Jens Erik Nielsen, Yong Huang