1 /* Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project 2 * 3 * This library is free software; you can redistribute it and/or 4 * modify it under the terms of the GNU Lesser General Public 5 * License as published by the Free Software Foundation; either 6 * version 2.1 of the License, or (at your option) any later version. 7 * 8 * This library is distributed in the hope that it will be useful, 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * Lesser General Public License for more details. 12 * 13 * You should have received a copy of the GNU Lesser General Public 14 * License along with this library; if not, write to the Free Software 15 * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 16 * (or see http://www.gnu.org/copyleft/lesser.html) 17 */ 18 package org.openscience.cdk.isomorphism.matchers.smarts; 19 20 import org.openscience.cdk.interfaces.IAtom; 21 import org.openscience.cdk.interfaces.IBond; 22 import org.openscience.cdk.interfaces.IChemObjectBuilder; 23 24 /** 25 * This query bond indicates a particular geometric stereo configuration. 26 * 27 * @cdk.module smarts 28 * @cdk.githash 29 * @cdk.keyword SMARTS 30 */ 31 @Deprecated 32 public class StereoBond extends SMARTSBond { 33 34 private final boolean unspecified; 35 private final Direction direction; 36 37 public enum Direction { 38 UP, DOWN 39 } 40 StereoBond(IChemObjectBuilder builder, Direction direction, boolean unspecified)41 public StereoBond(IChemObjectBuilder builder, Direction direction, boolean unspecified) { 42 super(builder); 43 this.unspecified = unspecified; 44 this.direction = direction; 45 } 46 47 @Override matches(IBond bond)48 public boolean matches(IBond bond) { 49 return Order.SINGLE.equals(bond.getOrder()); 50 } 51 unspecified()52 public boolean unspecified() { 53 return unspecified; 54 } 55 direction(IAtom atom)56 public Direction direction(IAtom atom) { 57 if (getBegin().equals(atom)) 58 return direction; 59 else if (getEnd().equals(atom)) 60 return inv(direction); 61 throw new IllegalArgumentException("atom is not a memeber of this bond"); 62 } 63 inv(Direction direction)64 private Direction inv(Direction direction) { 65 return direction == Direction.UP ? Direction.DOWN : Direction.UP; 66 } 67 } 68