use of org.openscience.cdk.isomorphism.matchers.smarts.AnyOrderQueryBond in project ambit-mirror by ideaconsult.
the class SLN2ChemObject method slnBondToQueryBond.
/*
* Converts only the bond type/expression info
* connected atoms info is not handled
*/
public IQueryBond slnBondToQueryBond(SLNBond slnBo) {
currentConversionError = null;
currentConversionWarning = null;
if (slnBo == null) {
currentConversionError = "Bond is null";
return null;
}
if (slnBo.bondType == 0) {
if (slnBo.bondExpression == null)
return new AnyOrderQueryBond(SilentChemObjectBuilder.getInstance());
// TODO handle bond expression
} else {
if (slnBo.bondExpression == null) {
IQueryBond bond = null;
switch(slnBo.bondType) {
case 1:
if (conversionConfig.FlagSLNSingleBondToSingleOrAromaticBond)
bond = new SingleOrAromaticBond(SilentChemObjectBuilder.getInstance());
else if (conversionConfig.FlagSupportSingleBondAromaticityNotSpecified)
bond = new SingleBondAromaticityNotSpecified(SilentChemObjectBuilder.getInstance());
else
bond = new SingleNonAromaticBond(SilentChemObjectBuilder.getInstance());
break;
case 2:
if (conversionConfig.FlagSupportDoubleBondAromaticityNotSpecified)
bond = new DoubleBondAromaticityNotSpecified(SilentChemObjectBuilder.getInstance());
else
bond = new DoubleNonAromaticBond(SilentChemObjectBuilder.getInstance());
break;
case 3:
bond = new OrderQueryBond(IBond.Order.TRIPLE, SilentChemObjectBuilder.getInstance());
break;
}
return bond;
}
// TODO handle bond expression
}
return null;
}
use of org.openscience.cdk.isomorphism.matchers.smarts.AnyOrderQueryBond in project ambit-mirror by ideaconsult.
the class SmartsManager method addBond.
void addBond(IQueryAtomContainer container, IAtom atom0, IAtom atom1, IBond bond) {
IBond newBond = null;
if (bond instanceof AnyOrderQueryBond)
newBond = new AnyOrderQueryBond(bond.getBuilder());
else if (bond instanceof OrderQueryBond) {
newBond = new AnyOrderQueryBond(bond.getBuilder());
newBond.setOrder(bond.getOrder());
} else if (bond instanceof AromaticQueryBond)
newBond = new AromaticQueryBond(bond.getBuilder());
else if (bond instanceof RingQueryBond)
newBond = new RingQueryBond(bond.getBuilder());
else if (bond instanceof SmartsBondExpression) {
newBond = new SmartsBondExpression(bond.getBuilder());
((SmartsBondExpression) newBond).tokens = ((SmartsBondExpression) bond).tokens;
} else {
// by default single bond. Any way this should not be called
newBond = new AnyOrderQueryBond(bond.getBuilder());
newBond.setOrder(IBond.Order.SINGLE);
}
IAtom[] atoms = new IAtom[2];
atoms[0] = atom0;
atoms[1] = atom1;
newBond.setAtoms(atoms);
container.addBond(newBond);
}
use of org.openscience.cdk.isomorphism.matchers.smarts.AnyOrderQueryBond in project cdk by cdk.
the class ParserTest method testAnyOrderBond.
@Test
public void testAnyOrderBond() throws Exception {
QueryAtomContainer container = SMARTSParser.parse("C~C", DefaultChemObjectBuilder.getInstance());
Assert.assertEquals(2, container.getAtomCount());
Assert.assertEquals(1, container.getBondCount());
org.openscience.cdk.interfaces.IBond bond = container.getBond(0);
Assert.assertTrue(bond instanceof AnyOrderQueryBond);
}
use of org.openscience.cdk.isomorphism.matchers.smarts.AnyOrderQueryBond in project ambit-mirror by ideaconsult.
the class SmartsParser method addBond.
void addBond(IQueryAtom atom0, IQueryAtom atom1) {
if (curBond == null) {
switch(curBondType) {
case SmartsConst.BT_ANY:
curBond = new AnyOrderQueryBond(atom0.getBuilder());
break;
case SmartsConst.BT_SINGLE:
if (mSupportSingleBondAromaticityNotSpecified)
curBond = new SingleBondAromaticityNotSpecified(atom0.getBuilder());
else
curBond = new SingleNonAromaticBond(atom0.getBuilder());
break;
case SmartsConst.BT_DOUBLE:
if (mSupportDoubleBondAromaticityNotSpecified)
curBond = new DoubleBondAromaticityNotSpecified(atom0.getBuilder());
else
curBond = new DoubleNonAromaticBond(atom0.getBuilder());
break;
case SmartsConst.BT_TRIPLE:
curBond = new OrderQueryBond(IBond.Order.TRIPLE, atom0.getBuilder());
break;
/*
* case SmartsConst.BT_DOUBLE: curBond = new DoubleStereoBond();
* break;
*/
case SmartsConst.BT_AROMATIC:
curBond = new AromaticQueryBond(atom0.getBuilder());
break;
case SmartsConst.BT_RING:
curBond = new RingQueryBond(atom0.getBuilder());
break;
case SmartsConst.BT_DOWN:
case SmartsConst.BT_UP:
case SmartsConst.BT_DOWNUNSPEC:
case SmartsConst.BT_UPUNSPEC:
// Directional bond is treated as a single bond.
// Additionally this bond is stored in contaner directionaBonds
// for further processing
curBond = new OrderQueryBond(IBond.Order.SINGLE, atom0.getBuilder());
directionalBonds.add(curBond);
directions.add(new Integer(curBondType));
break;
case SmartsConst.BT_UNDEFINED:
curBond = new SingleOrAromaticBond(atom0.getBuilder());
break;
}
}
IAtom[] atoms = new IAtom[2];
atoms[0] = (IAtom) atom0;
atoms[1] = (IAtom) atom1;
curBond.setAtoms(atoms);
container.addBond(curBond);
curFragment.addBond(curBond);
// System.out.println("--> " +
// SmartsHelper.bondToStringExhaustive(container,curBond));
// System.out.println(SmartsHelper.getBondsString(container)+"\n");
}
use of org.openscience.cdk.isomorphism.matchers.smarts.AnyOrderQueryBond in project cdk by cdk.
the class SmartsQueryVisitor method visit.
public Object visit(ASTSimpleBond node, Object data) {
SMARTSBond bond = null;
switch(node.getBondType()) {
case SMARTSParserConstants.S_BOND:
bond = new OrderQueryBond(IBond.Order.SINGLE, builder);
break;
case SMARTSParserConstants.D_BOND:
bond = new OrderQueryBond(IBond.Order.DOUBLE, builder);
doubleBonds.add(bond);
break;
case SMARTSParserConstants.T_BOND:
bond = new OrderQueryBond(IBond.Order.TRIPLE, builder);
break;
case SMARTSParserConstants.DOLLAR:
bond = new OrderQueryBond(IBond.Order.QUADRUPLE, builder);
break;
case SMARTSParserConstants.ANY_BOND:
bond = new AnyOrderQueryBond(builder);
break;
case SMARTSParserConstants.AR_BOND:
bond = new AromaticQueryBond(builder);
break;
case SMARTSParserConstants.R_BOND:
bond = new RingBond(builder);
break;
case SMARTSParserConstants.UP_S_BOND:
bond = new StereoBond(builder, StereoBond.Direction.UP, false);
stereoBonds.add(bond);
break;
case SMARTSParserConstants.DN_S_BOND:
bond = new StereoBond(builder, StereoBond.Direction.DOWN, false);
stereoBonds.add(bond);
break;
case SMARTSParserConstants.UP_OR_UNSPECIFIED_S_BOND:
bond = new StereoBond(builder, StereoBond.Direction.UP, true);
stereoBonds.add(bond);
break;
case SMARTSParserConstants.DN_OR_UNSPECIFIED_S_BOND:
bond = new StereoBond(builder, StereoBond.Direction.DOWN, true);
stereoBonds.add(bond);
break;
default:
logger.error("Un parsed bond: " + node);
break;
}
return bond;
}
Aggregations