The Octet Molecular Representation Framework v0.8.2

net.sf.octet.model
Class BasicAtomGraph

java.lang.Object
  extended bynet.sf.octet.model.BasicAtomGraph
All Implemented Interfaces:
AtomCollection, AtomGraph, AtomPairCollection

public class BasicAtomGraph
extends java.lang.Object
implements AtomGraph

A default implementation of the AtomGraph interface that is suitable for representing Molecule subgraphs.

Author:
Richard Apodaca

Constructor Summary
BasicAtomGraph()
          Constructs an empty BasicAtomGraph.
BasicAtomGraph(AtomCollection atoms, AtomPairCollection pairs)
          Constructs a BasicAtomGraph from atoms and pairs.
BasicAtomGraph(AtomPairCollection pairs)
          Constructs a BasicAtomGraph from the specified AtomPairCollection.
 
Method Summary
 boolean containsAtom(Atom atom)
          Returns true if the specified Atom is contained in this collection, and false otherwise.
 boolean containsAtomPair(Atom source, Atom target)
          Returns true if an AtomPair connecting source and target is contained in this collection.
 boolean containsAtomPair(AtomPair pair)
          Returns true if an AtomPair matching pair is contained in this collection.
 int countAtomPairs()
          Returns the number of AtomPairs contained in this collection.
 int countAtoms()
          Returns the number of Atoms contained in this atom collection.
 int countNeighbors(Atom atom)
          Returns the number of Atoms connected to atom in the context of this AtomGraph.
 boolean equals(java.lang.Object object)
          Overrides Object.equals().
 Atom getAtom(int index)
          Returns the Atom located at the specified zero-based index.
 int getAtomIndex(Atom atom)
          Returns the zero-based index of the specified Atom.
 AtomPair getAtomPair(Atom source, Atom target)
          Returns an AtomPair containing the specified source and target Atoms.
 AtomPair getAtomPair(int index)
          Returns the AtomPair corresponding to the specified integer index.
 int getAtomPairIndex(AtomPair pair)
          Returns the index of the specified AtomPair.
 int hashCode()
          Overrides Object.hashCode() due to override of Object.equals() .
 AtomPairIterator iterateAtomPairs()
          Returns an iterator over all AtomPairs in this collection.
 AtomIterator iterateAtoms()
          Returns an iterator over all Atoms in this collection.
 AtomIterator iterateNeighbors(Atom atom)
          Returns an iterator over all neighbors of atom in the context of this AtomGraph.
 Atom[] toAtomArray()
          Returns a copy of the Atoms contained in this collection as an array.
 AtomPair[] toAtomPairArray()
          Returns a copy of the atom pairs contained in this collection as an array.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BasicAtomGraph

public BasicAtomGraph()
Constructs an empty BasicAtomGraph.


BasicAtomGraph

public BasicAtomGraph(AtomPairCollection pairs)
Constructs a BasicAtomGraph from the specified AtomPairCollection. Atoms will be induced from pairs.

Parameters:
pairs - the set of AtomPairs
Throws:
java.lang.IllegalArgumentException - if pairs contains duplicate AtomPairs

BasicAtomGraph

public BasicAtomGraph(AtomCollection atoms,
                      AtomPairCollection pairs)
Constructs a BasicAtomGraph from atoms and pairs. Verifies that the Atoms implicit in pairs are all present in atoms. Preserves the indexing of atoms and pairs .

Parameters:
atoms - the Atom collection
pairs - the AtomPair collection
Throws:
java.lang.IllegalArgumentException - if atoms and pairs are not compatible
Method Detail

iterateNeighbors

public AtomIterator iterateNeighbors(Atom atom)
Description copied from interface: AtomGraph
Returns an iterator over all neighbors of atom in the context of this AtomGraph. This iterator may contain only a subset of the Atoms returned by atom.iterateNeighbors(), depending on the nature of this AtomGraph.

Specified by:
iterateNeighbors in interface AtomGraph
Parameters:
atom - the Atom to examine
Returns:
an iterator over all neighbors of atom

countNeighbors

public int countNeighbors(Atom atom)
Description copied from interface: AtomGraph
Returns the number of Atoms connected to atom in the context of this AtomGraph. This value will be less than or equal to the value returned by atom.countNeighbors().

Specified by:
countNeighbors in interface AtomGraph
Parameters:
atom - the Atom to examine
Returns:
the number of neighbors of atom

containsAtom

public boolean containsAtom(Atom atom)
Description copied from interface: AtomCollection
Returns true if the specified Atom is contained in this collection, and false otherwise.

Specified by:
containsAtom in interface AtomCollection
Parameters:
atom - the Atom
Returns:
true if contained, false otherwise

countAtoms

public int countAtoms()
Description copied from interface: AtomCollection
Returns the number of Atoms contained in this atom collection.

Specified by:
countAtoms in interface AtomCollection
Returns:
the number of atoms in this collection

getAtomIndex

public int getAtomIndex(Atom atom)
Description copied from interface: AtomCollection
Returns the zero-based index of the specified Atom.

Specified by:
getAtomIndex in interface AtomCollection
Parameters:
atom - the atom
Returns:
the index of the atom, or -1 if this collection does not contain atom

getAtom

public Atom getAtom(int index)
Description copied from interface: AtomCollection
Returns the Atom located at the specified zero-based index.

Specified by:
getAtom in interface AtomCollection
Parameters:
index - the index
Returns:
the Atom at index, or null if the index is invalid

iterateAtoms

public AtomIterator iterateAtoms()
Description copied from interface: AtomCollection
Returns an iterator over all Atoms in this collection.

Specified by:
iterateAtoms in interface AtomCollection
Returns:
an iterator over all Atoms in this collection

toAtomArray

public Atom[] toAtomArray()
Description copied from interface: AtomCollection
Returns a copy of the Atoms contained in this collection as an array. The resulting array may be modified without changing the state of this collection.

Specified by:
toAtomArray in interface AtomCollection
Returns:
a copy of the Atom array for this collection

containsAtomPair

public boolean containsAtomPair(AtomPair pair)
Description copied from interface: AtomPairCollection
Returns true if an AtomPair matching pair is contained in this collection.

Specified by:
containsAtomPair in interface AtomPairCollection
Parameters:
pair - the AtomPair to search for
Returns:
true if found, false otherwise

containsAtomPair

public boolean containsAtomPair(Atom source,
                                Atom target)
Description copied from interface: AtomPairCollection
Returns true if an AtomPair connecting source and target is contained in this collection.

Specified by:
containsAtomPair in interface AtomPairCollection
Parameters:
source - the source atom
target - the target atom
Returns:
true if the atom pair exists, false otherwise

getAtomPair

public AtomPair getAtomPair(Atom source,
                            Atom target)
Description copied from interface: AtomPairCollection
Returns an AtomPair containing the specified source and target Atoms. If no such pair is found, null is returned.

Specified by:
getAtomPair in interface AtomPairCollection
Parameters:
source - the source atom
target - the target atom
Returns:
the matching AtomPair

countAtomPairs

public int countAtomPairs()
Description copied from interface: AtomPairCollection
Returns the number of AtomPairs contained in this collection.

Specified by:
countAtomPairs in interface AtomPairCollection
Returns:
the number of AtomPairs contained in this collection.

iterateAtomPairs

public AtomPairIterator iterateAtomPairs()
Description copied from interface: AtomPairCollection
Returns an iterator over all AtomPairs in this collection.

Specified by:
iterateAtomPairs in interface AtomPairCollection
Returns:
an iterator over all AtomPairs in this collection

getAtomPairIndex

public int getAtomPairIndex(AtomPair pair)
Description copied from interface: AtomPairCollection
Returns the index of the specified AtomPair.

Specified by:
getAtomPairIndex in interface AtomPairCollection
Parameters:
pair - the AtomPair to search for
Returns:
the index of the AtomPair

getAtomPair

public AtomPair getAtomPair(int index)
Description copied from interface: AtomPairCollection
Returns the AtomPair corresponding to the specified integer index.

Specified by:
getAtomPair in interface AtomPairCollection
Parameters:
index - the index to search for
Returns:
the AtomPair at the specified index

toAtomPairArray

public AtomPair[] toAtomPairArray()
Description copied from interface: AtomPairCollection
Returns a copy of the atom pairs contained in this collection as an array. The resulting array may be modified without changing the state of this collection.

Specified by:
toAtomPairArray in interface AtomPairCollection
Returns:
a copy of the atom pair array for this collection

equals

public boolean equals(java.lang.Object object)
Overrides Object.equals().


hashCode

public int hashCode()
Overrides Object.hashCode() due to override of Object.equals() .


The Octet Molecular Representation Framework v0.8.2