~ubuntu-branches/ubuntu/trusty/cdk/trusty-proposed

« back to all changes in this revision

Viewing changes to src/org/openscience/cdk/isomorphism/matchers/smarts/AtomicNumberAtom.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
/*
 
2
 *  $RCSfile$
 
3
 *  $Author: $
 
4
 *  $Date: $
 
5
 *  $Revision: $
 
6
 *
 
7
 *  Copyright (C) 2002-2006  The Chemistry Development Kit (CDK) project
 
8
 *
 
9
 *  Contact: cdk-devel@lists.sourceforge.net
 
10
 *
 
11
 *  This program is free software; you can redistribute it and/or
 
12
 *  modify it under the terms of the GNU Lesser General Public License
 
13
 *  as published by the Free Software Foundation; either version 2.1
 
14
 *  of the License, or (at your option) any later version.
 
15
 *  All I ask is that proper credit is given for my work, which includes
 
16
 *  - but is not limited to - adding the above copyright notice to the beginning
 
17
 *  of your source code files, and to any copyright notice that you may distribute
 
18
 *  with programs based on this work.
 
19
 *
 
20
 *  This program is distributed in the hope that it will be useful,
 
21
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
22
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
23
 *  GNU Lesser General Public License for more details.
 
24
 *
 
25
 *  You should have received a copy of the GNU Lesser General Public License
 
26
 *  along with this program; if not, write to the Free Software
 
27
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 
28
 *
 
29
 */
 
30
package org.openscience.cdk.isomorphism.matchers.smarts;
 
31
 
 
32
import org.openscience.cdk.interfaces.IAtom;
 
33
 
 
34
/**
 
35
 * It matches an atom using the atomic number
 
36
 *
 
37
 * @author Dazhi Jiao
 
38
 * @cdk.created 2007-05-10
 
39
 * @cdk.module smarts
 
40
 * @cdk.keyword SMARTS AST
 
41
 */
 
42
public class AtomicNumberAtom extends SMARTSAtom {
 
43
        private static final long serialVersionUID = 4811205092161793129L;
 
44
        private int atomicNumber;
 
45
        
 
46
        public AtomicNumberAtom(int atomicNumber) {
 
47
                this.atomicNumber = atomicNumber;
 
48
        }
 
49
        
 
50
    public boolean matches(IAtom atom) {
 
51
        // TODO: this is just a hack for a few
 
52
        if (atom.getAtomicNumber() != 0) {
 
53
            return (atom.getAtomicNumber() == atomicNumber);
 
54
        } 
 
55
        if (atom.getSymbol().equals("C")) {
 
56
                return atomicNumber == 6;
 
57
        } else if (atom.getSymbol().equals("O")) {
 
58
                return atomicNumber == 8;
 
59
        } else if (atom.getSymbol().equals("N")) {
 
60
                return atomicNumber == 7;
 
61
        }
 
62
        return false;
 
63
    }
 
64
}