Logo Search packages:      
Sourcecode: cdk version File versions  Download package

IAtomContainer org::openscience::cdk::layout::AtomPlacer::getLongestUnplacedChain ( IMolecule  molecule,
IAtom  startAtom 
) throws CDKException [inline]

Search a molecule for the longest unplaced, aliphatic chain in it. If an aliphatic chain encounters an unplaced ring atom, the ring atom is also appended to allow for it to be laid out. This gives us a vector for attaching the unplaced ring later.

moleculeThe molecule to be search for the longest unplaced chain
startAtomA start atom from which the chain search starts
An AtomContainer holding the longest unplaced chain.
org.openscience.cdk.exception.CDKExceptionDescription of the Exception

Definition at line 603 of file AtomPlacer.java.

References org::openscience::cdk::interfaces::IAtomContainer::addAtom(), breadthFirstSearch(), org::openscience::cdk::tools::LoggingTool::debug(), org::openscience::cdk::interfaces::IAtomContainer::getAtom(), org::openscience::cdk::interfaces::IAtomContainer::getAtomCount(), org::openscience::cdk::interfaces::IChemObject::getBuilder(), getDegreeSum(), molecule, org::openscience::cdk::interfaces::IChemObjectBuilder::newAtomContainer(), org::openscience::cdk::interfaces::IChemObject::setFlag(), and org::openscience::cdk::CDKConstants::VISITED.

Referenced by getInitialLongestChain(), and org::openscience::cdk::layout::StructureDiagramGenerator::handleAliphatics().

        logger.debug("Start of getLongestUnplacedChain.");
        //ConnectivityChecker cc = new ConnectivityChecker();
        int longest = 0;
        int longestPathLength = 0;
        int maxDegreeSum = 0;
        int degreeSum = 0;
        IAtomContainer[] pathes = new IAtomContainer[molecule.getAtomCount()];
        for (int f = 0; f < molecule.getAtomCount(); f++)
            molecule.getAtom(f).setFlag(CDKConstants.VISITED, false);
            pathes[f] = molecule.getBuilder().newAtomContainer();

        Vector startSphere = new Vector();
        breadthFirstSearch(molecule, startSphere, pathes);
        for (int f = 0; f < molecule.getAtomCount(); f++)
            if (pathes[f].getAtomCount() >= longestPathLength)
                  degreeSum = getDegreeSum(pathes[f], molecule);
                  if (degreeSum > maxDegreeSum) 
                        maxDegreeSum = degreeSum;
                        longest = f;
                        longestPathLength = pathes[f].getAtomCount();
        logger.debug("End of getLongestUnplacedChain.");
        return pathes[longest];

Here is the call graph for this function:

Here is the caller graph for this function:

Generated by  Doxygen 1.6.0   Back to index