1 /* Copyright (C) 2002-2006 The Chemistry Development Kit (CDK) project 2 * 3 * Contact: cdk-devel@lists.sourceforge.net 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU Lesser General Public License 7 * as published by the Free Software Foundation; either version 2.1 8 * of the License, or (at your option) any later version. 9 * All I ask is that proper credit is given for my work, which includes 10 * - but is not limited to - adding the above copyright notice to the beginning 11 * of your source code files, and to any copyright notice that you may distribute 12 * with programs based on this work. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU Lesser General Public License for more details. 18 * 19 * You should have received a copy of the GNU Lesser General Public License 20 * along with this program; if not, write to the Free Software 21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 22 * 23 */ 24 25 package org.openscience.cdk.isomorphism.matchers.smarts; 26 27 import org.openscience.cdk.interfaces.IAtom; 28 import org.openscience.cdk.interfaces.IChemObjectBuilder; 29 30 /** 31 * Match an atom in a specific size ring. The ring size is specified by {@code 32 * r<NUMBER>} in a SMARTS pattern. This term is non-portable, depending on the 33 * set of rings chosen and which ring sizes are used. The default implementation 34 * (Daylight) only stores the smallest ring each atom belongs to whilst other 35 * implementations may store multiple values. A more portable term is the 36 * ring connectivity which is specified as {@code x<NUMBER>}. 37 * 38 * @cdk.module smarts 39 * @cdk.keyword SMARTS 40 * @cdk.githash 41 */ 42 @Deprecated 43 public final class SmallestRingAtom extends SMARTSAtom { 44 45 /** Ring size to check. */ 46 private int ringSize; 47 48 /** 49 * Creates a matcher for specified ring size. 50 * 51 * @param ringSize size of the ring to check. 52 */ SmallestRingAtom(int ringSize, IChemObjectBuilder builder)53 public SmallestRingAtom(int ringSize, IChemObjectBuilder builder) { 54 super(builder); 55 this.ringSize = ringSize; 56 } 57 58 /**{@inheritDoc} */ 59 @Override matches(IAtom atom)60 public boolean matches(IAtom atom) { 61 return ringSize < 0 ? invariants(atom).ringConnectivity() > 0 62 : invariants(atom).ringSize().contains(ringSize); 63 } 64 } 65