org.openscience.cdk
Class ConformerContainer

java.lang.Object
  extended by org.openscience.cdk.ConformerContainer
All Implemented Interfaces:
Iterable<IAtomContainer>, Collection<IAtomContainer>, List<IAtomContainer>

@TestClass(value="org.openscience.cdk.ConformerContainer")
public class ConformerContainer
extends Object
implements List<IAtomContainer>

A memory-efficient data structure to store conformers for a single molecule.

Since all the conformers for a given molecule only differ in their 3D coordinates this data structure stores a single IAtomContainer containing the atom and bond details and a List of 3D coordinate sets, each element being the set of 3D coordinates for a given conformer.

The class behaves in many ways as a List object, though a few methods are not implemented. Though it is possible to add conformers by hand, this data structure is probably best used in combination with IteratingMDLConformerReader as

 IteratingMDLConformerReader reader = new IteratingMDLConformerReader(
          new FileReader(new File(filename)),
          DefaultChemObjectBuilder.getInstance());
 while (reader.hasNext()) {
     ConformerContainer cc = (ConformerContainer) reader.next();
     for (IAtomContainer conformer : cc) {
         // do something with each conformer
     }
 }
 

Author:
Rajarshi Guha
See Also:
IteratingMDLConformerReader
Belongs to CDK module:
data
Source code:
cdk-1.4.x

Constructor Summary
ConformerContainer()
           
ConformerContainer(IAtomContainer atomContainer)
          Create a ConformerContainer object from a single molecule object.
ConformerContainer(IAtomContainer[] atomContainers)
          Create a ConformerContainer from an array of molecules.
 
Method Summary
 boolean add(IAtomContainer atomContainer)
          Add a conformer to the end of the list.
 void add(int i, IAtomContainer atomContainer)
           
 boolean addAll(Collection<? extends IAtomContainer> atomContainers)
           
 boolean addAll(int i, Collection<? extends IAtomContainer> iAtomContainers)
           
 void clear()
          Get rid of all the conformers but keeps atom and bond information.
 boolean contains(Object o)
          Checks to see whether the specified conformer is currently stored.
 boolean containsAll(Collection<?> objects)
           
 IAtomContainer get(int i)
          Get the conformer at a specified position.
 String getTitle()
          Get the title of the conformers.
 int indexOf(Object o)
          Returns the lowest index at which the specific IAtomContainer appears in the list or -1 if is not found.
 boolean isEmpty()
          Checks whether any conformers are stored or not.
 Iterator<IAtomContainer> iterator()
          Gets an iterator over the conformers.
 int lastIndexOf(Object o)
          Returns the highest index at which the specific IAtomContainer appears in the list or -1 if is not found.
 ListIterator<IAtomContainer> listIterator()
           
 ListIterator<IAtomContainer> listIterator(int i)
           
 IAtomContainer remove(int i)
          Removes the conformer at the specified position.
 boolean remove(Object o)
          Remove the specified conformer.
 boolean removeAll(Collection<?> objects)
           
 boolean retainAll(Collection<?> objects)
           
 IAtomContainer set(int i, IAtomContainer atomContainer)
           
 int size()
          Get the number of conformers stored.
 List<IAtomContainer> subList(int i, int i1)
           
 Object[] toArray()
          Returns the conformers in the form of an array of IAtomContainers.
<IAtomContainer>
IAtomContainer[]
toArray(IAtomContainer[] ts)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.List
equals, hashCode
 

Constructor Detail

ConformerContainer

public ConformerContainer()

ConformerContainer

public ConformerContainer(IAtomContainer atomContainer)
Create a ConformerContainer object from a single molecule object.

Using this constructor, the resultant conformer container will contain a single conformer. More conformers can be added using the add(org.openscience.cdk.interfaces.IAtomContainer) method.

Note that the constructor will use the title of the input molecule when adding new molecules as conformers. That is, the title of any molecule to be added as a conformer should match the title of the input molecule.

Parameters:
atomContainer - The base molecule (or first conformer).

ConformerContainer

public ConformerContainer(IAtomContainer[] atomContainers)
Create a ConformerContainer from an array of molecules.

This constructor can be used when you have an array of conformers of a given molecule. Note that this constructor will assume that all molecules in the input array will have the same title.

Parameters:
atomContainers - The array of conformers
Method Detail

getTitle

@TestMethod(value="testGetTitle")
public String getTitle()
Get the title of the conformers.

Note that all conformers for a given molecule will have the same title.

Returns:
The title for the conformers

size

@TestMethod(value="testSize")
public int size()
Get the number of conformers stored.

Specified by:
size in interface Collection<IAtomContainer>
Specified by:
size in interface List<IAtomContainer>
Returns:
The number of conformers

isEmpty

@TestMethod(value="testIsEmpty")
public boolean isEmpty()
Checks whether any conformers are stored or not.

Specified by:
isEmpty in interface Collection<IAtomContainer>
Specified by:
isEmpty in interface List<IAtomContainer>
Returns:
true if there is at least one conformer, otherwise false

contains

@TestMethod(value="testContains, testContains_Object")
public boolean contains(Object o)
Checks to see whether the specified conformer is currently stored.

This method first checks whether the title of the supplied molecule matches the stored title. If not, it returns false. If the title matches it then checks all the coordinates to see whether they match. If all coordinates match it returns true else false.

Specified by:
contains in interface Collection<IAtomContainer>
Specified by:
contains in interface List<IAtomContainer>
Parameters:
o - The IAtomContainer to check for
Returns:
true if it is present, false otherwise

iterator

@TestMethod(value="testIterator, testIterator2")
public Iterator<IAtomContainer> iterator()
Gets an iterator over the conformers.

Specified by:
iterator in interface Iterable<IAtomContainer>
Specified by:
iterator in interface Collection<IAtomContainer>
Specified by:
iterator in interface List<IAtomContainer>
Returns:
an iterator over the conformers. Each iteration will return an IAtomContainer object corresponding to the current conformer.

toArray

@TestMethod(value="testToArray")
public Object[] toArray()
Returns the conformers in the form of an array of IAtomContainers.

Beware that if you have a large number of conformers you may run out memory during construction of the array since IAtomContainer's are not light weight objects!

Specified by:
toArray in interface Collection<IAtomContainer>
Specified by:
toArray in interface List<IAtomContainer>
Returns:
The conformers as an array of individual IAtomContainers.

toArray

@TestMethod(value="testToArray_arrayObject")
public <IAtomContainer> IAtomContainer[] toArray(IAtomContainer[] ts)
Specified by:
toArray in interface Collection<IAtomContainer>
Specified by:
toArray in interface List<IAtomContainer>

add

@TestMethod(value="testAdd_IAtomContainer")
public boolean add(IAtomContainer atomContainer)
Add a conformer to the end of the list.

This method allows you to add a IAtomContainer object as another conformer. Before adding it ensures that the title of specific object matches the stored title for these conformers. It will also check that the number of atoms in the specified molecule match the number of atoms in the current set of conformers.

This method will not check for duplicate conformers.

Specified by:
add in interface Collection<IAtomContainer>
Specified by:
add in interface List<IAtomContainer>
Parameters:
atomContainer - The new conformer to add.
Returns:
true

remove

@TestMethod(value="testRemove_Object")
public boolean remove(Object o)
Remove the specified conformer.

Specified by:
remove in interface Collection<IAtomContainer>
Specified by:
remove in interface List<IAtomContainer>
Parameters:
o - The conformer to remove (should be castable to IAtomContainer)
Returns:
true if the specified conformer was present and removed, false if not found

containsAll

@TestMethod(value="testContainsAll_Collection")
public boolean containsAll(Collection<?> objects)
Specified by:
containsAll in interface Collection<IAtomContainer>
Specified by:
containsAll in interface List<IAtomContainer>

addAll

@TestMethod(value="testAddAll_Collection")
public boolean addAll(Collection<? extends IAtomContainer> atomContainers)
Specified by:
addAll in interface Collection<IAtomContainer>
Specified by:
addAll in interface List<IAtomContainer>

addAll

@TestMethod(value="testAddAll_int_Collection")
public boolean addAll(int i,
                                      Collection<? extends IAtomContainer> iAtomContainers)
Specified by:
addAll in interface List<IAtomContainer>

removeAll

@TestMethod(value="testRemoveAll_Collectio")
public boolean removeAll(Collection<?> objects)
Specified by:
removeAll in interface Collection<IAtomContainer>
Specified by:
removeAll in interface List<IAtomContainer>

retainAll

@TestMethod(value="testRetainAll_Collection")
public boolean retainAll(Collection<?> objects)
Specified by:
retainAll in interface Collection<IAtomContainer>
Specified by:
retainAll in interface List<IAtomContainer>

clear

@TestMethod(value="testClear")
public void clear()
Get rid of all the conformers but keeps atom and bond information.

Specified by:
clear in interface Collection<IAtomContainer>
Specified by:
clear in interface List<IAtomContainer>

get

@TestMethod(value="testGet_int, testGet2")
public IAtomContainer get(int i)
Get the conformer at a specified position.

Specified by:
get in interface List<IAtomContainer>
Parameters:
i - The position of the requested conformer
Returns:
The conformer

set

@TestMethod(value="testSet_int_IAtomContainer")
public IAtomContainer set(int i,
                                          IAtomContainer atomContainer)
Specified by:
set in interface List<IAtomContainer>

add

@TestMethod(value="testAdd_int_IAtomContainer")
public void add(int i,
                                IAtomContainer atomContainer)
Specified by:
add in interface List<IAtomContainer>

remove

@TestMethod(value="testRemove_int")
public IAtomContainer remove(int i)
Removes the conformer at the specified position.

Specified by:
remove in interface List<IAtomContainer>
Parameters:
i - The position in the list to remove
Returns:
The conformer that was at the specified position

indexOf

@TestMethod(value="testIndexOf_Object")
public int indexOf(Object o)
Returns the lowest index at which the specific IAtomContainer appears in the list or -1 if is not found.

A given IAtomContainer will occur in the list if the title matches the stored title for the conformers in this container and if the coordinates for each atom in the specified molecule are equal to the coordinates of the corresponding atoms in a conformer.

Specified by:
indexOf in interface List<IAtomContainer>
Parameters:
o - The IAtomContainer whose presence is being tested
Returns:
The index where o was found

lastIndexOf

@TestMethod(value="testLastIndexOf_Object")
public int lastIndexOf(Object o)
Returns the highest index at which the specific IAtomContainer appears in the list or -1 if is not found.

A given IAtomContainer will occur in the list if the title matches the stored title for the conformers in this container and if the coordinates for each atom in the specified molecule are equal to the coordinates of the corresponding atoms in a conformer.

Specified by:
lastIndexOf in interface List<IAtomContainer>
Parameters:
o - The IAtomContainer whose presence is being tested
Returns:
The index where o was found

listIterator

@TestMethod(value="testListIterator")
public ListIterator<IAtomContainer> listIterator()
Specified by:
listIterator in interface List<IAtomContainer>

listIterator

@TestMethod(value="testListIterator_int")
public ListIterator<IAtomContainer> listIterator(int i)
Specified by:
listIterator in interface List<IAtomContainer>

subList

@TestMethod(value="testSubList_int_int")
public List<IAtomContainer> subList(int i,
                                                    int i1)
Specified by:
subList in interface List<IAtomContainer>