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);
}
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);
}
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);
}
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;
}
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));
}
Aggregations