use of org.openscience.cdk.isomorphism.matchers.smarts.OrderQueryBond 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.OrderQueryBond 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.OrderQueryBond in project ambit-mirror by ideaconsult.
the class SmartsToChemObject method toBond.
public IBond toBond(IBond b) {
if (b instanceof SmartsBondExpression)
return (smartsExpressionToBond((SmartsBondExpression) b));
if (b instanceof SingleOrAromaticBond) {
IBond bond = MoleculeTools.newBond(SilentChemObjectBuilder.getInstance());
bond.setOrder(IBond.Order.SINGLE);
mFlagConfirmAromaticBond = true;
return (bond);
}
if (// This case returns a bond with
b instanceof AromaticQueryBond) // order null!! Must be handled carefully!
{
IBond bond = MoleculeTools.newBond(SilentChemObjectBuilder.getInstance());
bond.setOrder(b.getOrder());
bond.setFlag(CDKConstants.ISAROMATIC, true);
return (bond);
}
if (b instanceof OrderQueryBond) {
IBond bond = MoleculeTools.newBond(SilentChemObjectBuilder.getInstance());
bond.setOrder(b.getOrder());
return (bond);
}
if (b instanceof SingleNonAromaticBond) {
IBond bond = MoleculeTools.newBond(SilentChemObjectBuilder.getInstance());
bond.setOrder(IBond.Order.SINGLE);
return (bond);
}
if (b instanceof SingleBondAromaticityNotSpecified) {
IBond bond = MoleculeTools.newBond(SilentChemObjectBuilder.getInstance());
bond.setOrder(IBond.Order.SINGLE);
return (bond);
}
if (b instanceof DoubleNonAromaticBond) {
IBond bond = MoleculeTools.newBond(SilentChemObjectBuilder.getInstance());
bond.setOrder(IBond.Order.DOUBLE);
return (bond);
}
if (b instanceof DoubleBondAromaticityNotSpecified) {
IBond bond = MoleculeTools.newBond(SilentChemObjectBuilder.getInstance());
bond.setOrder(IBond.Order.DOUBLE);
return (bond);
}
// RingQueryBond
return (null);
}
use of org.openscience.cdk.isomorphism.matchers.smarts.OrderQueryBond in project cdk by cdk.
the class ParserTest method testDoubleBond.
@Test
public void testDoubleBond() 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 OrderQueryBond);
OrderQueryBond qBond = (OrderQueryBond) bond;
Assert.assertEquals(IBond.Order.DOUBLE, qBond.getOrder());
}
use of org.openscience.cdk.isomorphism.matchers.smarts.OrderQueryBond 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");
}
Aggregations