Search in sources :

Example 1 with PKANode

use of ambit2.descriptors.PKANode in project ambit-mirror by ideaconsult.

the class PKASmartsDescriptor method calculate.

public DescriptorValue calculate(IAtomContainer arg0) {
    try {
        ArrayList<String> trace = new ArrayList<String>();
        PKANode node = traverse(arg0, root, trace);
        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new VerboseDescriptorResult<String, DoubleResult>(new DoubleResult(node.getPka()), trace.toString()), title);
    } catch (Exception x) {
        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), null, title, x);
    }
}
Also used : ArrayList(java.util.ArrayList) DoubleResult(org.openscience.cdk.qsar.result.DoubleResult) CDKException(org.openscience.cdk.exception.CDKException) IOException(java.io.IOException) SMARTSException(ambit2.smarts.query.SMARTSException) DescriptorValue(org.openscience.cdk.qsar.DescriptorValue)

Example 2 with PKANode

use of ambit2.descriptors.PKANode 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)

Example 3 with PKANode

use of ambit2.descriptors.PKANode in project ambit-mirror by ideaconsult.

the class PKASmartsDescriptorTest method test462.

@Test
public void test462() throws Exception {
    IAtomContainer mol = SmartsHelper.getMoleculeFromSmiles("O[N+](=O)[O-]");
    HydrogenAdderProcessor ha = new HydrogenAdderProcessor();
    ha.setAddEexplicitHydrogens(true);
    mol = ha.process(mol);
    CDKHueckelAromaticityDetector.detectAromaticity(mol);
    AtomConfigurator cfg = new AtomConfigurator();
    cfg.process(mol);
    PKANode node = new PKANode();
    node.setSmarts("[i][#G6v2]");
    Assert.assertFalse(node.find(mol));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) HydrogenAdderProcessor(ambit2.core.processors.structure.HydrogenAdderProcessor) AtomConfigurator(ambit2.core.processors.structure.AtomConfigurator) PKANode(ambit2.descriptors.PKANode) Test(org.junit.Test)

Example 4 with PKANode

use of ambit2.descriptors.PKANode in project ambit-mirror by ideaconsult.

the class PKASmartsDescriptorTest method testAcidPkaNode.

@Test
public void testAcidPkaNode() throws Exception {
    IAtomContainer mol = SmartsHelper.getMoleculeFromSmiles("O[N+](=O)[O-]");
    HydrogenAdderProcessor ha = new HydrogenAdderProcessor();
    ha.setAddEexplicitHydrogens(true);
    mol = ha.process(mol);
    CDKHueckelAromaticityDetector.detectAromaticity(mol);
    AtomConfigurator cfg = new AtomConfigurator();
    cfg.process(mol);
    PKANode node = new PKANode();
    node.setSmarts("[#G6;H][i]");
    Assert.assertTrue(node.find(mol));
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) HydrogenAdderProcessor(ambit2.core.processors.structure.HydrogenAdderProcessor) AtomConfigurator(ambit2.core.processors.structure.AtomConfigurator) PKANode(ambit2.descriptors.PKANode) Test(org.junit.Test)

Aggregations

PKANode (ambit2.descriptors.PKANode)3 Test (org.junit.Test)3 AtomConfigurator (ambit2.core.processors.structure.AtomConfigurator)2 HydrogenAdderProcessor (ambit2.core.processors.structure.HydrogenAdderProcessor)2 ArrayList (java.util.ArrayList)2 CDKException (org.openscience.cdk.exception.CDKException)2 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)2 SMARTSException (ambit2.smarts.query.SMARTSException)1 SmartsPatternAmbit (ambit2.smarts.query.SmartsPatternAmbit)1 IOException (java.io.IOException)1 AmbitException (net.idea.modbcum.i.exceptions.AmbitException)1 DescriptorValue (org.openscience.cdk.qsar.DescriptorValue)1 DoubleResult (org.openscience.cdk.qsar.result.DoubleResult)1