use of ambit2.smarts.query.SmartsPatternAmbit in project ambit-mirror by ideaconsult.
the class QuerySMARTS method prepareScreening.
public void prepareScreening() throws AmbitException {
try {
if (((screening.getValue() == null) && isFp1024_screening()) || ((screening.getFieldname() == null)) && isSk1024_screening()) {
// if ((screening.getValue()==null) || (screening.getFieldname()==null)) {
screening.setPageSize(0);
screening.setPage(0);
SmartsPatternAmbit matcher = new SmartsPatternAmbit(builder);
matcher.setUseCDKIsomorphism(false);
value.setQuery(matcher);
IQueryAtomContainer container = matcher.getQuery();
IAtomContainer atomContainer = smartsToChemObject.process(container);
try {
AtomConfigurator cfg = new AtomConfigurator();
cfg.process(atomContainer);
} catch (Exception x) {
logger.log(Level.FINE, x.getMessage(), x);
}
try {
CDKHueckelAromaticityDetector.detectAromaticity(atomContainer);
} catch (Exception x) {
logger.log(Level.FINE, x.getMessage(), x);
}
if ((atomContainer == null) || (atomContainer.getAtomCount() == 0)) {
screening.setValue(null);
screening.setFieldname(null);
} else {
try {
screening.setValue(fp1024_screening ? fpGenerator.process(atomContainer) : null);
} catch (Exception x) {
screening.setValue(null);
}
try {
screening.setFieldname(sk1024_screening ? skGenerator.process(atomContainer) : null);
} catch (Exception x) {
screening.setFieldname(null);
}
}
}
} catch (AmbitException x) {
throw x;
// screening.setValue(null);
// screening.setFieldname(null);
}
}
use of ambit2.smarts.query.SmartsPatternAmbit in project ambit-mirror by ideaconsult.
the class PKANode method find.
public boolean find(IAtomContainer ac) throws SMARTSException {
if (getSmarts() != null) {
SmartsPatternAmbit pattern = smartsPattern.get(getSmarts());
if (pattern == null) {
pattern = new SmartsPatternAmbit(SilentChemObjectBuilder.getInstance());
pattern.useMOEvPrimitive(true);
pattern.setUseCDKIsomorphism(false);
pattern.setSmarts(getSmarts());
smartsPattern.put(getSmarts(), pattern);
}
return pattern.hasSMARTSPattern(ac) > 0;
} else
return true;
}
use of ambit2.smarts.query.SmartsPatternAmbit in project ambit-mirror by ideaconsult.
the class FunctionalGroupDescriptorTest method testDefaultGroups1.
@Test
public void testDefaultGroups1() throws Exception {
IAtomContainer m = MoleculeFactory.makeAlkane(10);
m = hadder.process(m);
String[] smarts = new String[] { "[CX4]", "[$([CX2](=C)=C)]" };
int[] results = new int[] { 1, 0 };
for (int i = 0; i < results.length; i++) {
String s = smarts[i];
SmartsPatternAmbit p = new SmartsPatternAmbit(SilentChemObjectBuilder.getInstance());
p.setSmarts(s);
Assert.assertEquals(results[i], p.match(m));
}
}
use of ambit2.smarts.query.SmartsPatternAmbit in project ambit-mirror by ideaconsult.
the class PKASmartsDescriptorTest method test.
@Test
public void test() throws Exception {
Hashtable<Integer, PKANode> tree = pka.getTree();
Enumeration<Integer> k = tree.keys();
SmartsPatternAmbit pattern = new SmartsPatternAmbit(SilentChemObjectBuilder.getInstance());
ArrayList<String> smarts = new ArrayList<String>();
int failedNodes = 0;
int failedSmarts = 0;
int nullSmarts = 0;
int allnodes = 0;
while (k.hasMoreElements()) {
PKANode node = tree.get(k.nextElement());
allnodes++;
try {
if (node.getSmarts() == null) {
nullSmarts++;
} else
pattern.setSmarts(node.getSmarts());
} catch (Exception x) {
failedNodes++;
if (smarts.indexOf(node.getSmarts()) < 0) {
smarts.add(node.getSmarts());
failedSmarts++;
}
}
}
if (smarts.size() > 0) {
/*
System.out.println("Failed nodes "+failedNodes);
System.out.println("Failed smarts "+failedSmarts);
for (int i=0; i < smarts.size();i++)
System.out.println('\''+smarts.get(i)+'\'');
*/
}
// root smarts
Assert.assertEquals(1, nullSmarts);
Assert.assertTrue(failedNodes == 0);
Assert.assertEquals(1527, allnodes);
}
Aggregations