Search in sources :

Example 1 with EdgeToBondMap

use of org.openscience.cdk.graph.GraphUtil.EdgeToBondMap in project cdk by cdk.

the class Ullmann method matchAll.

@Override
public Mappings matchAll(IAtomContainer target) {
    EdgeToBondMap bonds2 = EdgeToBondMap.withSpaceFor(target);
    int[][] g2 = GraphUtil.toAdjList(target, bonds2);
    Iterable<int[]> iterable = new UllmannIterable(query, target, g1, g2, bonds1, bonds2, atomMatcher, bondMatcher);
    Mappings mappings = new Mappings(query, target, iterable);
    return filter(mappings, query, target);
}
Also used : EdgeToBondMap(org.openscience.cdk.graph.GraphUtil.EdgeToBondMap)

Example 2 with EdgeToBondMap

use of org.openscience.cdk.graph.GraphUtil.EdgeToBondMap in project cdk by cdk.

the class VentoFoggia method matchAll.

/**
 *{@inheritDoc}
 */
@Override
public Mappings matchAll(final IAtomContainer target) {
    final EdgeToBondMap bonds2;
    final int[][] g2;
    AdjListCache cached = target.getProperty(AdjListCache.class.getName());
    if (cached == null || !cached.validate(target)) {
        cached = new AdjListCache(target);
        target.setProperty(AdjListCache.class.getName(), cached);
    }
    bonds2 = cached.bmap;
    g2 = cached.g;
    Iterable<int[]> iterable = new VFIterable(query, target, g1, g2, bonds1, bonds2, atomMatcher, bondMatcher, subgraph);
    Mappings mappings = new Mappings(query, target, iterable);
    return filter(mappings, query, target);
}
Also used : EdgeToBondMap(org.openscience.cdk.graph.GraphUtil.EdgeToBondMap)

Example 3 with EdgeToBondMap

use of org.openscience.cdk.graph.GraphUtil.EdgeToBondMap in project cdk by cdk.

the class StereoElementFactory method using3DCoordinates.

/**
 * Create a stereo element factory for creating stereo elements using 3D
 * coordinates and depiction labels (up/down, wedge/hatch).
 *
 * @param container the structure to create the factory for
 * @return the factory instance
 */
public static StereoElementFactory using3DCoordinates(IAtomContainer container) {
    EdgeToBondMap bondMap = EdgeToBondMap.withSpaceFor(container);
    int[][] graph = GraphUtil.toAdjList(container, bondMap);
    return new StereoElementFactory3D(container, graph, bondMap).checkSymmetry(true);
}
Also used : EdgeToBondMap(org.openscience.cdk.graph.GraphUtil.EdgeToBondMap)

Example 4 with EdgeToBondMap

use of org.openscience.cdk.graph.GraphUtil.EdgeToBondMap in project cdk by cdk.

the class AllRingsFinder method findAllRingsInIsolatedRingSystem.

/**
 * Compute all rings up to an including the {@literal maxRingSize}. No
 * pre-processing is done on the container.
 *
 * @param atomContainer the molecule to be searched for rings
 * @param maxRingSize   Maximum ring size to consider. Provides a possible
 *                      breakout from recursion for complex compounds.
 * @return a RingSet containing the rings in molecule
 * @throws CDKException An exception thrown if the threshold was exceeded
 */
public IRingSet findAllRingsInIsolatedRingSystem(IAtomContainer atomContainer, int maxRingSize) throws CDKException {
    final EdgeToBondMap edges = EdgeToBondMap.withSpaceFor(atomContainer);
    final int[][] graph = GraphUtil.toAdjList(atomContainer, edges);
    AllCycles ac = new AllCycles(graph, maxRingSize, threshold.value);
    if (!ac.completed())
        throw new CDKException("Threshold exceeded for AllRingsFinder");
    IRingSet ringSet = atomContainer.getBuilder().newInstance(IRingSet.class);
    for (int[] path : ac.paths()) {
        ringSet.addAtomContainer(toRing(atomContainer, edges, path));
    }
    return ringSet;
}
Also used : AllCycles(org.openscience.cdk.graph.AllCycles) CDKException(org.openscience.cdk.exception.CDKException) IRingSet(org.openscience.cdk.interfaces.IRingSet) EdgeToBondMap(org.openscience.cdk.graph.GraphUtil.EdgeToBondMap)

Example 5 with EdgeToBondMap

use of org.openscience.cdk.graph.GraphUtil.EdgeToBondMap in project cdk by cdk.

the class FischerRecognitionTest method recogniseRightHandedGlyceraldehydeWithImplicitHydrogen.

/**
 * @cdk.inchi InChI=1/C3H6O3/c4-1-3(6)2-5/h1,3,5-6H,2H2/t3-/s2
 */
@Test
public void recogniseRightHandedGlyceraldehydeWithImplicitHydrogen() throws Exception {
    IAtomContainer m = new AtomContainer(8, 7, 0, 0);
    m.addAtom(atom("C", 0, 0.80d, 1.24d));
    m.addAtom(atom("C", 1, 0.80d, 0.42d));
    m.addAtom(atom("O", 1, 0.09d, 1.66d));
    m.addAtom(atom("O", 0, 1.52d, 1.66d));
    m.addAtom(atom("O", 1, 1.63d, 0.42d));
    m.addAtom(atom("C", 2, 0.80d, -0.41d));
    m.addAtom(atom("O", 1, 1.52d, -0.82d));
    m.addBond(0, 1, IBond.Order.SINGLE);
    m.addBond(0, 2, IBond.Order.SINGLE);
    m.addBond(0, 3, IBond.Order.DOUBLE, IBond.Stereo.E_Z_BY_COORDINATES);
    m.addBond(1, 4, IBond.Order.SINGLE);
    m.addBond(1, 5, IBond.Order.SINGLE);
    m.addBond(5, 6, IBond.Order.SINGLE);
    EdgeToBondMap bondMap = EdgeToBondMap.withSpaceFor(m);
    int[][] graph = GraphUtil.toAdjList(m, bondMap);
    FischerRecognition recogniser = new FischerRecognition(m, graph, bondMap, Stereocenters.of(m));
    List<IStereoElement> elements = recogniser.recognise(Collections.singleton(Projection.Fischer));
    org.hamcrest.MatcherAssert.assertThat(elements.size(), is(1));
    assertTetrahedralCenter(elements.get(0), m.getAtom(1), ANTI_CLOCKWISE, m.getAtom(0), m.getAtom(4), m.getAtom(5), m.getAtom(1));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.silent.AtomContainer) EdgeToBondMap(org.openscience.cdk.graph.GraphUtil.EdgeToBondMap) IStereoElement(org.openscience.cdk.interfaces.IStereoElement) Test(org.junit.Test)

Aggregations

EdgeToBondMap (org.openscience.cdk.graph.GraphUtil.EdgeToBondMap)28 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)16 Test (org.junit.Test)15 AtomContainer (org.openscience.cdk.silent.AtomContainer)15 IStereoElement (org.openscience.cdk.interfaces.IStereoElement)12 CDKException (org.openscience.cdk.exception.CDKException)3 IBond (org.openscience.cdk.interfaces.IBond)3 AllCycles (org.openscience.cdk.graph.AllCycles)2 IAtom (org.openscience.cdk.interfaces.IAtom)2 IRingSet (org.openscience.cdk.interfaces.IRingSet)2 ArrayList (java.util.ArrayList)1 BitSet (java.util.BitSet)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 LinkedHashMap (java.util.LinkedHashMap)1 Point2d (javax.vecmath.Point2d)1 Matching (org.openscience.cdk.graph.Matching)1 IRing (org.openscience.cdk.interfaces.IRing)1 RingSearch (org.openscience.cdk.ringsearch.RingSearch)1