Search in sources :

Example 1 with SmartsPatternAmbit

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);
    }
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) SmartsPatternAmbit(ambit2.smarts.query.SmartsPatternAmbit) AtomConfigurator(ambit2.core.processors.structure.AtomConfigurator) IQueryAtomContainer(org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer) AmbitException(net.idea.modbcum.i.exceptions.AmbitException) AmbitException(net.idea.modbcum.i.exceptions.AmbitException)

Example 2 with SmartsPatternAmbit

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;
}
Also used : SmartsPatternAmbit(ambit2.smarts.query.SmartsPatternAmbit)

Example 3 with SmartsPatternAmbit

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));
    }
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) SmartsPatternAmbit(ambit2.smarts.query.SmartsPatternAmbit) Test(org.junit.Test)

Example 4 with SmartsPatternAmbit

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);
}
Also used : SmartsPatternAmbit(ambit2.smarts.query.SmartsPatternAmbit) ArrayList(java.util.ArrayList) AmbitException(net.idea.modbcum.i.exceptions.AmbitException) CDKException(org.openscience.cdk.exception.CDKException) PKANode(ambit2.descriptors.PKANode) Test(org.junit.Test)

Aggregations

SmartsPatternAmbit (ambit2.smarts.query.SmartsPatternAmbit)4 AmbitException (net.idea.modbcum.i.exceptions.AmbitException)2 Test (org.junit.Test)2 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)2 AtomConfigurator (ambit2.core.processors.structure.AtomConfigurator)1 PKANode (ambit2.descriptors.PKANode)1 ArrayList (java.util.ArrayList)1 CDKException (org.openscience.cdk.exception.CDKException)1 IQueryAtomContainer (org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer)1