📄 smartsqueryvisitortest.java
字号:
package org.openscience.cdk.test.smiles.smarts.parser.visitor;import java.io.StringReader;import junit.framework.Test;import junit.framework.TestSuite;import org.openscience.cdk.DefaultChemObjectBuilder;import org.openscience.cdk.interfaces.IAtomContainer;import org.openscience.cdk.smiles.SmilesParser;import org.openscience.cdk.smiles.smarts.SMARTSQueryTool;import org.openscience.cdk.smiles.smarts.parser.ASTStart;import org.openscience.cdk.smiles.smarts.parser.SMARTSParser;import org.openscience.cdk.smiles.smarts.parser.visitor.SmartsQueryVisitor;import org.openscience.cdk.test.CDKTestCase;/** * JUnit testing routine for SmartsQueryVisitor * * @author Dazhi Jiao * @cdk.created 2007-05-10 * @cdk.module test-smarts * @cdk.keyword SMARTS */public class SmartsQueryVisitorTest extends CDKTestCase { public SmartsQueryVisitorTest() {} public SmartsQueryVisitorTest(String testName) { super(testName); } public static Test suite() { return new TestSuite(SmartsQueryVisitorTest.class); } public void visit(String smarts) throws Exception { SMARTSParser parser = new SMARTSParser(new StringReader(smarts)); ASTStart start = parser.Start(); SmartsQueryVisitor visitor = new SmartsQueryVisitor(); visitor.visit(start, null); } public int match(String smarts, String smiles) throws Exception { SMARTSQueryTool sqt = new SMARTSQueryTool(smarts, true); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); IAtomContainer atomContainer = sp.parseSmiles(smiles); boolean status = sqt.matches(atomContainer); if (status) { int nmatch = sqt.countMatches(); return nmatch; } else { return 0; } } public void testPattern1() throws Exception { visit("[CX4]"); } public void testPattern2() throws Exception { visit("[$([CX2](=C)=C)]"); } public void testPattern3() throws Exception { visit("[$([CX3]=[CX3])]"); } public void testPattern4() throws Exception { visit("[$([CX2]#C)]"); } public void testPattern5() throws Exception { visit("[CX3]=[OX1]"); } public void testPattern6() throws Exception { visit("[$([CX3]=[OX1]),$([CX3+]-[OX1-])]"); } public void testPattern7() throws Exception { visit("[CX3](=[OX1])C"); } public void testPattern8() throws Exception { visit("[OX1]=CN"); } public void testPattern9() throws Exception { visit("[CX3](=[OX1])O"); } public void testPattern10() throws Exception { visit("[CX3](=[OX1])[F,Cl,Br,I]"); } public void testPattern11() throws Exception { visit("[CX3H1](=O)[#6]"); } public void testPattern12() throws Exception { visit("[CX3](=[OX1])[OX2][CX3](=[OX1])"); } public void testPattern13() throws Exception { visit("[NX3][CX3](=[OX1])[#6]"); } public void testPattern14() throws Exception { visit("[NX3][CX3]=[NX3+]"); } public void testPattern15() throws Exception { visit("[NX3,NX4+][CX3](=[OX1])[OX2,OX1-]"); } public void testPattern16() throws Exception { visit("[NX3][CX3](=[OX1])[OX2H0]"); } public void testPattern17() throws Exception { visit("[NX3,NX4+][CX3](=[OX1])[OX2H,OX1-]"); } public void testPattern18() throws Exception { visit("[CX3](=O)[O-]"); } public void testPattern19() throws Exception { visit("[CX3](=[OX1])(O)O"); } public void testPattern20() throws Exception { visit("[CX3](=[OX1])([OX2])[OX2H,OX1H0-1]"); } public void testPattern21() throws Exception { visit("[CX3](=O)[OX2H1]"); } public void testPattern22() throws Exception { visit("[CX3](=O)[OX1H0-,OX2H1]"); } public void testPattern23() throws Exception { visit("[NX3][CX2]#[NX1]"); } public void testPattern24() throws Exception { visit("[#6][CX3](=O)[OX2H0][#6]"); } public void testPattern25() throws Exception { visit("[#6][CX3](=O)[#6]"); } public void testPattern26() throws Exception { visit("[OD2]([#6])[#6]"); } public void testPattern27() throws Exception { visit("[H]"); } public void testPattern28() throws Exception { visit("[!#1]"); } public void testPattern29() throws Exception { visit("[H+]"); } public void testPattern30() throws Exception { visit("[+H]"); } public void testPattern31() throws Exception { visit("[NX3;H2,H1;!$(NC=O)]"); } public void testPattern32() throws Exception { visit("[NX3][CX3]=[CX3]"); } public void testPattern33() throws Exception { visit("[NX3;H2,H1;!$(NC=O)].[NX3;H2,H1;!$(NC=O)]"); } public void testPattern34() throws Exception { visit("[NX3][$(C=C),$(cc)]"); } public void testPattern35() throws Exception { visit("[NX3,NX4+][CX4H]([*])[CX3](=[OX1])[O,N]"); } public void testPattern36() throws Exception { visit("[NX3H2,NH3X4+][CX4H]([*])[CX3](=[OX1])[NX3,NX4+][CX4H]([*])[CX3](=[OX1])[OX2H,OX1-]"); } public void testPattern37() throws Exception { visit("[$([NX3H2,NX4H3+]),$([NX3H](C)(C))][CX4H]([*])[CX3](=[OX1])[OX2H,OX1-,N]"); } public void testPattern38() throws Exception { visit("[CH3X4]"); } public void testPattern39() throws Exception { visit("[CH2X4][CH2X4][CH2X4][NHX3][CH0X3](=[NH2X3+,NHX2+0])[NH2X3]"); } public void testPattern40() throws Exception { visit("[CH2X4][CX3](=[OX1])[NX3H2]"); } public void testPattern41() throws Exception { visit("[CH2X4][CX3](=[OX1])[OH0-,OH]"); } public void testPattern42() throws Exception { visit("[CH2X4][SX2H,SX1H0-]"); } public void testPattern43() throws Exception { visit("[CH2X4][CH2X4][CX3](=[OX1])[OH0-,OH]"); } public void testPattern44() throws Exception { visit("[$([$([NX3H2,NX4H3+]),$([NX3H](C)(C))][CX4H2][CX3](=[OX1])[OX2H,OX1-,N])]"); } public void testPattern45() throws Exception { visit("[CH2X4][#6X3]1:[$([#7X3H+,#7X2H0+0]:[#6X3H]:[#7X3H]),$([#7X3H])]:[#6X3H]:[$([#7X3H+,#7X2H0+0]:[#6X3H]:[#7X3H]),$([#7X3H])]:[#6X3H]1"); } public void testPattern47() throws Exception { visit("[CHX4]([CH3X4])[CH2X4][CH3X4]"); } public void testPattern48() throws Exception { visit("[CH2X4][CHX4]([CH3X4])[CH3X4]"); } public void testPattern49() throws Exception { visit("[CH2X4][CH2X4][CH2X4][CH2X4][NX4+,NX3+0]"); } public void testPattern50() throws Exception { visit("[CH2X4][CH2X4][SX2][CH3X4]"); } public void testPattern51() throws Exception { visit("[CH2X4][cX3]1[cX3H][cX3H][cX3H][cX3H][cX3H]1"); } public void testPattern52() throws Exception { visit("[$([NX3H,NX4H2+]),$([NX3](C)(C)(C))]1[CX4H]([CH2][CH2][CH2]1)[CX3](=[OX1])[OX2H,OX1-,N]"); } public void testPattern53() throws Exception { visit("[CH2X4][OX2H]"); } public void testPattern54() throws Exception { visit("[NX3][CX3]=[SX1]"); } public void testPattern55() throws Exception { visit("[CHX4]([CH3X4])[OX2H]"); } public void testPattern56() throws Exception { visit("[CH2X4][cX3]1[cX3H][nX3H][cX3]2[cX3H][cX3H][cX3H][cX3H][cX3]12"); } public void testPattern57() throws Exception { visit("[CH2X4][cX3]1[cX3H][cX3H][cX3]([OHX2,OH0X1-])[cX3H][cX3H]1"); } public void testPattern58() throws Exception { visit("[CHX4]([CH3X4])[CH3X4]"); } public void testPattern59() throws Exception { visit("[CH3X4]"); } public void testPattern60() throws Exception { visit("[CH2X4][CH2X4][CH2X4][NHX3][CH0X3](=[NH2X3+,NHX2+0])[NH2X3]"); } public void testPattern61() throws Exception { visit("[CH2X4][CX3](=[OX1])[NX3H2]"); } public void testPattern62() throws Exception { visit("[CH2X4][CX3](=[OX1])[OH0-,OH]"); } public void testPattern63() throws Exception { visit("[CH2X4][SX2H,SX1H0-]"); } public void testPattern64() throws Exception { visit("[CH2X4][CH2X4][CX3](=[OX1])[OH0-,OH]"); } public void testPattern65() throws Exception { visit("[CH2X4][#6X3]1:[$([#7X3H+,#7X2H0+0]:[#6X3H]:[#7X3H]),$([#7X3H])]:[#6X3H]:[$([#7X3H+,#7X2H0+0]:[#6X3H]:[#7X3H]),$([#7X3H])]:[#6X3H]1"); } public void testPattern67() throws Exception { visit("[CHX4]([CH3X4])[CH2X4][CH3X4]"); } public void testPattern68() throws Exception { visit("[CH2X4][CHX4]([CH3X4])[CH3X4]"); } public void testPattern69() throws Exception { visit("[CH2X4][CH2X4][CH2X4][CH2X4][NX4+,NX3+0]"); } public void testPattern70() throws Exception { visit("[CH2X4][CH2X4][SX2][CH3X4]"); } public void testPattern71() throws Exception { visit("[CH2X4][cX3]1[cX3H][cX3H][cX3H][cX3H][cX3H]1"); } public void testPattern72() throws Exception { visit("[CH2X4][OX2H]"); } public void testPattern73() throws Exception { visit("[CHX4]([CH3X4])[OX2H]"); } public void testPattern74() throws Exception { visit("[CH2X4][cX3]1[cX3H][nX3H][cX3]2[cX3H][cX3H][cX3H][cX3H][cX3]12"); } public void testPattern75() throws Exception { visit("[CH2X4][cX3]1[cX3H][cX3H][cX3]([OHX2,OH0X1-])[cX3H][cX3H]1"); } public void testPattern76() throws Exception { visit("[CHX4]([CH3X4])[CH3X4]"); } public void testPattern77() throws Exception { visit("[$(*-[NX2-]-[NX2+]#[NX1]),$(*-[NX2]=[NX2+]=[NX1-])]"); } public void testPattern78() throws Exception { visit("[$([NX1-]=[NX2+]=[NX1-]),$([NX1]#[NX2+]-[NX1-2])]"); } public void testPattern79() throws Exception { visit("[#7]"); } public void testPattern80() throws Exception { visit("[NX2]=N"); } public void testPattern81() throws Exception { visit("[NX2]=[NX2]"); } public void testPattern82() throws Exception { visit("[$([NX2]=[NX3+]([O-])[#6]),$([NX2]=[NX3+0](=[O])[#6])]"); } public void testPattern83() throws Exception { visit("[$([#6]=[N+]=[N-]),$([#6-]-[N+]#[N])]"); } public void testPattern84() throws Exception { visit("[$([nr5]:[nr5,or5,sr5]),$([nr5]:[cr5]:[nr5,or5,sr5])]"); } public void testPattern85() throws Exception { visit("[NX3][NX3]"); } public void testPattern86() throws Exception { visit("[NX3][NX2]=[*]"); } public void testPattern87() throws Exception { visit("[CX3;$([C]([#6])[#6]),$([CH][#6])]=[NX2][#6]"); } public void testPattern88() throws Exception { visit("[$([CX3]([#6])[#6]),$([CX3H][#6])]=[$([NX2][#6]),$([NX2H])]"); } public void testPattern89() throws Exception { visit("[NX3+]=[CX3]"); } public void testPattern90() throws Exception { visit("[CX3](=[OX1])[NX3H][CX3](=[OX1])"); } public void testPattern91() throws Exception { visit("[CX3](=[OX1])[NX3H0]([#6])[CX3](=[OX1])"); } public void testPattern92() throws Exception { visit("[CX3](=[OX1])[NX3H0]([NX3H0]([CX3](=[OX1]))[CX3](=[OX1]))[CX3](=[OX1])"); } public void testPattern93() throws Exception { visit("[$([NX3](=[OX1])(=[OX1])O),$([NX3+]([OX1-])(=[OX1])O)]"); } public void testPattern94() throws Exception { visit("[$([OX1]=[NX3](=[OX1])[OX1-]),$([OX1]=[NX3+]([OX1-])[OX1-])]"); } public void testPattern95() throws Exception { visit("[NX1]#[CX2]"); } public void testPattern96() throws Exception { visit("[CX1-]#[NX2+]"); } public void testPattern97() throws Exception { visit("[$([NX3](=O)=O),$([NX3+](=O)[O-])][!#8]"); } public void testPattern98() throws Exception { visit("[$([NX3](=O)=O),$([NX3+](=O)[O-])][!#8].[$([NX3](=O)=O),$([NX3+](=O)[O-])][!#8]"); } public void testPattern99() throws Exception { visit("[NX2]=[OX1]"); } public void testPattern101() throws Exception { visit("[$([#7+][OX1-]),$([#7v5]=[OX1]);!$([#7](~[O])~[O]);!$([#7]=[#7])]"); } public void testPattern102() throws Exception { visit("[OX2H]"); } public void testPattern103() throws Exception { visit("[#6][OX2H]"); } public void testPattern104() throws Exception {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -