use of ambit2.smarts.SmartsAtomExpression in project ambit-mirror by ideaconsult.
the class SLN2ChemObject method slnAtomToQueryAtom.
public IQueryAtom slnAtomToQueryAtom(SLNAtom slnAt) {
currentConversionError = null;
currentConversionWarning = null;
if (slnAt == null) {
currentConversionError = "SNLAtom is null";
return null;
}
if (slnAt.atomType == 0) {
if (slnAt.atomExpression == null || slnAt.atomExpression.tokens.isEmpty()) {
if (slnAt.numHAtom == 0)
return new AnyAtom(SilentChemObjectBuilder.getInstance());
}
// Handle Any atom as an expression
// slnAt.numHAtom > 0 info is added into the expression
SmartsAtomExpression atExpr = slnAtomToSmartsAtomExpression(slnAt);
return atExpr;
}
// slnAt.atomType > 0
if (slnAt.atomType < SLNConst.GlobalDictOffseet) {
if (slnAt.atomType < SLNConst.elSymbols.length) {
if (slnAt.atomExpression == null || slnAt.atomExpression.tokens.isEmpty()) {
if (slnAt.numHAtom == 0) {
AliphaticSymbolQueryAtom atom = new AliphaticSymbolQueryAtom(SilentChemObjectBuilder.getInstance());
String symb = SLNConst.elSymbols[slnAt.atomType];
atom.setSymbol(symb);
atom.setAtomicNumber(PeriodicTable.getAtomicNumber(symb));
return atom;
} else {
// Since there are H atoms they define an expression
// slnAt.numHAtom > 0 info is added into the expression
}
}
// Create an expression
SmartsAtomExpression atExpr = slnAtomToSmartsAtomExpression(slnAt);
return atExpr;
} else {
// TODO
return null;
}
} else {
// TODO
return null;
}
}
use of ambit2.smarts.SmartsAtomExpression in project ambit-mirror by ideaconsult.
the class SLN2ChemObject method queryAtomToSLNAtom.
public SLNAtom queryAtomToSLNAtom(IQueryAtom queryAtom) {
currentConversionError = null;
currentConversionWarning = null;
if (queryAtom == null) {
currentConversionError = "Atom is null";
return null;
}
if (queryAtom instanceof SmartsAtomExpression) {
// TODO
}
boolean FlagKnownAtomType = false;
SLNAtom slnAt = new SLNAtom(builder);
if (queryAtom instanceof AnyAtom) {
slnAt.atomType = 0;
slnAt.atomName = "Any";
FlagKnownAtomType = true;
}
if (FlagKnownAtomType)
return slnAt;
else
return null;
/*
* SLNAtom slnAt = new SLNAtom(builder);
String atomName = atom.getSymbol();
for (int i = 0; i < SLNConst.elSymbols.length; i++)
if (atomName.equals(SLNConst.elSymbols[i]))
{
slnAt.atomType = i;
break;
}
slnAt.atomName = atomName;
if (a instanceof AliphaticSymbolQueryAtom)
return (a.getSymbol());
if (a instanceof AromaticSymbolQueryAtom)
return (a.getSymbol().toLowerCase());
if (a instanceof AliphaticAtom)
return ("A");
if (a instanceof AromaticAtom)
return ("a");
*/
}
use of ambit2.smarts.SmartsAtomExpression in project ambit-mirror by ideaconsult.
the class TestUtilities method testStereoFromSmartsAtomExpression.
int testStereoFromSmartsAtomExpression(String smarts) throws Exception {
System.out.println("Stereo chirality for: " + smarts);
IQueryAtomContainer query = sp.parse(smarts);
String errorMsg = sp.getErrorMessages();
if (!errorMsg.equals("")) {
System.out.println(errorMsg);
return (-1);
}
for (int i = 0; i < query.getAtomCount(); i++) {
IAtom at = query.getAtom(i);
if (at instanceof SmartsAtomExpression) {
SmartsAtomExpression smae = (SmartsAtomExpression) at;
int chir = StereoFromSmartsAtomExpression.getStereo(smae);
System.out.println("atom #" + (i + 1) + " " + smae.toString() + " -->" + chiralityToString(chir));
}
}
return 0;
}
use of ambit2.smarts.SmartsAtomExpression in project ambit-mirror by ideaconsult.
the class TestUtilities method testStereoRemovedTokens.
public void testStereoRemovedTokens(String smarts) {
System.out.println("Smarts " + smarts);
IQueryAtomContainer qac = sp.parse(smarts);
if (!sp.getErrorMessages().equals("")) {
System.out.println("Smarts Parser errors:\n" + sp.getErrorMessages());
return;
}
// System.out.println("Atoms: " + SmartsHelper.getAtomsString(qac));
SmartsAtomExpression expr = (SmartsAtomExpression) qac.getAtom(0);
expr.getStereoRemovedTokens();
System.out.println(expr.toString());
System.out.println(expr.stereoRemovedToString());
}
use of ambit2.smarts.SmartsAtomExpression in project ambit-mirror by ideaconsult.
the class TestUtilities method testHAtomsManager.
int testHAtomsManager(String smarts) throws Exception {
System.out.println("H atoms for: " + smarts);
IQueryAtomContainer query = sp.parse(smarts);
String errorMsg = sp.getErrorMessages();
if (!errorMsg.equals("")) {
System.out.println(errorMsg);
return (-1);
}
for (int i = 0; i < query.getAtomCount(); i++) {
IAtom at = query.getAtom(i);
if (at instanceof SmartsAtomExpression) {
SmartsAtomExpression smae = (SmartsAtomExpression) at;
int ha = HAtomManager.getHAtoms(smae);
System.out.println("atom #" + (i + 1) + " " + smae.toString() + " --> " + ha);
}
}
return 0;
}
Aggregations