~ubuntu-branches/ubuntu/maverick/cdk/maverick

« back to all changes in this revision

Viewing changes to src/org/openscience/cdk/isomorphism/matchers/smarts/RingMembershipAtom.java

  • Committer: Bazaar Package Importer
  • Author(s): Paul Cager
  • Date: 2008-04-09 21:17:53 UTC
  • Revision ID: james.westby@ubuntu.com-20080409211753-46lmjw5z8mx5pd8d
Tags: upstream-1.0.2
ImportĀ upstreamĀ versionĀ 1.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Revision: $ $Author: $ $Date: $ 
 
2
 *
 
3
 * Copyright (C) 2004-2007  The Chemistry Development Kit (CDK) project
 
4
 *
 
5
 * This library is free software; you can redistribute it and/or
 
6
 * modify it under the terms of the GNU Lesser General Public
 
7
 * License as published by the Free Software Foundation; either
 
8
 * version 2.1 of the License, or (at your option) any later version.
 
9
 *
 
10
 * This library is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 * Lesser General Public License for more details.
 
14
 *
 
15
 * You should have received a copy of the GNU Lesser General Public
 
16
 * License along with this library; if not, write to the Free Software
 
17
 * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 
18
 * (or see http://www.gnu.org/copyleft/lesser.html)
 
19
 */
 
20
package org.openscience.cdk.isomorphism.matchers.smarts;
 
21
 
 
22
import org.openscience.cdk.CDKConstants;
 
23
import org.openscience.cdk.interfaces.IAtom;
 
24
import org.openscience.cdk.interfaces.IRingSet;
 
25
 
 
26
/**
 
27
 * This query atom matches any atom with a certain number of SSSR. 
 
28
 *
 
29
 * @author Dazhi Jiao
 
30
 * @cdk.created 2007-04-24
 
31
 * @cdk.module smarts
 
32
 * @cdk.keyword SMARTS AST
 
33
 */
 
34
public class RingMembershipAtom extends SMARTSAtom {
 
35
        private static final long serialVersionUID = -7963168231557641862L;
 
36
        /**
 
37
         * Number of SSSR
 
38
         */
 
39
        private int numSSSR;
 
40
 
 
41
        public RingMembershipAtom(int num) {
 
42
                this.numSSSR = num;
 
43
        }
 
44
 
 
45
        public boolean matches(IAtom atom) {
 
46
                if (atom.getFlag(CDKConstants.ISINRING)) {
 
47
                        IRingSet ringSet = (IRingSet)atom.getProperty(CDKConstants.SMALLEST_RINGS);
 
48
                        return ringSet.getAtomContainerCount() == numSSSR;
 
49
                }
 
50
                return false;
 
51
        }
 
52
}