From 1674fc0b03df13976dafffd91f51429a2ed835a5 Mon Sep 17 00:00:00 2001 From: Syed Asad Rahman Date: Wed, 1 Apr 2015 14:40:56 +0100 Subject: [PATCH] File name naming bug fixed --- test/tools/TestMCSS.java | 30 +++--- test/tools/TestMCSSJF.java | 209 +++++++++++++++++++++++++++++++++++++ 2 files changed, 226 insertions(+), 13 deletions(-) create mode 100644 test/tools/TestMCSSJF.java diff --git a/test/tools/TestMCSS.java b/test/tools/TestMCSS.java index dda5c10..e8b0599 100644 --- a/test/tools/TestMCSS.java +++ b/test/tools/TestMCSS.java @@ -3,18 +3,22 @@ * * Contact: cdk-devel@lists.sourceforge.net * - * This program is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General - * Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) - * any later version. All we ask is that proper credit is given for our work, which includes - but is not limited to - - * adding the above copyright notice to the beginning of your source code files, and to any copyright notice that you + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. All we ask is that proper credit is given for our work, + * which includes - but is not limited to - adding the above copyright notice to + * the beginning of your source code files, and to any copyright notice that you * may distribute with programs based on this work. * - * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied - * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more * details. * - * You should have received a copy of the GNU Lesser General Public License along with this program; if not, write to - * the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package tools; @@ -135,7 +139,7 @@ public void case3() { @Test public void case4() { - HashMap map = new HashMap(); + HashMap map = new HashMap<>(); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); // Data @@ -145,7 +149,7 @@ public void case4() { map.put("4", "SSSCCC"); map.put("5", "CSSSCSNNN"); - List jobs = new ArrayList(); + List jobs = new ArrayList<>(); for (String s : map.values()) { try { jobs.add(sp.parseSmiles(s)); @@ -156,7 +160,7 @@ public void case4() { long startTime = Calendar.getInstance().getTimeInMillis(); MCSS mcss = new MCSS(jobs, JobType.SINGLE, 5); for (IAtomContainer ac : mcss.getCalculateMCSS()) { - ////System.out.println("Result MCS " + getMCSSSmiles(ac)); + System.out.println("Result MCS " + getMCSSSmiles(ac)); Assert.assertEquals(1, ac.getAtomCount()); } long endCalcTime = Calendar.getInstance().getTimeInMillis(); @@ -166,14 +170,14 @@ public void case4() { @Test public void case5() { - HashMap map = new HashMap(); + HashMap map = new HashMap<>(); SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); // Data map.put("1", "O=C(OC1OC(CO)C(O)C(O)C1(O))Cc3c[nH]c2ccccc23"); map.put("2", "O=C(OC1C(O)C(O)C(O)C(O)C1(O))Cc3c[nH]c2ccccc23"); - List jobs = new ArrayList(); + List jobs = new ArrayList<>(); for (String s : map.values()) { try { IAtomContainer ac = sp.parseSmiles(s); diff --git a/test/tools/TestMCSSJF.java b/test/tools/TestMCSSJF.java new file mode 100644 index 0000000..b875e66 --- /dev/null +++ b/test/tools/TestMCSSJF.java @@ -0,0 +1,209 @@ +/** + * Copyright (C) 2009-2013 Syed Asad Rahman + * + * Contact: cdk-devel@lists.sourceforge.net + * + * This program is free software; you can redistribute it and/or modify it under + * the terms of the GNU Lesser General Public License as published by the Free + * Software Foundation; either version 2.1 of the License, or (at your option) + * any later version. All we ask is that proper credit is given for our work, + * which includes - but is not limited to - adding the above copyright notice to + * the beginning of your source code files, and to any copyright notice that you + * may distribute with programs based on this work. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more + * details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + */ +package tools; + +import java.util.ArrayList; +import java.util.Calendar; +import java.util.Collection; +import java.util.HashMap; +import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.junit.Assert; +import org.junit.Test; +import org.openscience.cdk.DefaultChemObjectBuilder; +import org.openscience.cdk.exception.CDKException; +import org.openscience.cdk.exception.InvalidSmilesException; +import org.openscience.cdk.interfaces.IAtomContainer; +import org.openscience.cdk.smiles.SmilesGenerator; +import org.openscience.cdk.smiles.SmilesParser; +import org.openscience.smsd.mcss.MCSSJF; + +/** + * + * @author Syed Asad Rahman + * + */ +public class TestMCSSJF { + + @Test + public void case1() { + HashMap map = new HashMap<>(); + SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); + //Data + + map.put("30331701", "Cc1ccc(C2N(C(c3c(Cl)cccc3)=O)c(c4N=C(C2=C5O)CC(c6c(Cl)cccc6)C5)cccc4)cc1"); + map.put("4170207", "CCC(N1C(c2ccc(F)cc2)C(C3=Nc(c14)cccc4)=C(O)CC(c5ccc(C(C)(C)C)cc5)C3)=O"); + map.put("6368123", "CC(N1C(c2ccc(F)cc2)C(C3=Nc(c14)cccc4)=C(O)CC(c5ccc(Cl)cc5)C3)=O"); + map.put("MCS", "O=C(N4c5ccccc5(N=C2C(=C(O)CC(c1ccccc1)C2)C4(c3ccccc3)))C"); + map.put("MMV011436", "CC(c1ccc(C2CC(C3=C(O)C2)=Nc(c4N(C(c5c(Cl)cccc5)=O)C3c6ccc(F)cc6)cccc4)cc1)(C)C"); + map.put("4196500", "CC(c1ccc(C2CC(C3=C(O)C2)=Nc(c4N(C(c5c(Cl)cccc5)=O)C3c6ccc(F)cc6)cccc4)cc1)(C)C"); + + List jobs = new ArrayList<>(); + for (String s : map.values()) { + try { + jobs.add(sp.parseSmiles(s)); + } catch (InvalidSmilesException ex) { + Logger.getLogger(TestMCSSJF.class.getName()).log(Level.SEVERE, null, ex); + } + } + long startTime = Calendar.getInstance().getTimeInMillis(); + MCSSJF mcss = new MCSSJF(jobs, true, true, true); + for (IAtomContainer ac : mcss.getSolutions()) { + ////System.out.println("Result MCS " + getMCSSSmiles(ac)); + Assert.assertEquals(31, ac.getAtomCount()); + } + long endCalcTime = Calendar.getInstance().getTimeInMillis(); + + ////System.out.println("Total time: " + (endCalcTime - startTime) + "ms"); + } + + @Test + public void case2() { + HashMap map = new HashMap<>(); + SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); + // Data + + map.put("1", "CCCCC=NNN"); + map.put("2", "CCCC-NNN"); + map.put("3", "CCCSNNN"); + map.put("4", "CCCC=NNN"); + + List jobs = new ArrayList<>(); + for (String s : map.values()) { + try { + jobs.add(sp.parseSmiles(s)); + } catch (InvalidSmilesException ex) { + Logger.getLogger(TestMCSSJF.class.getName()).log(Level.SEVERE, null, ex); + } + } + long startTime = Calendar.getInstance().getTimeInMillis(); + MCSSJF mcss = new MCSSJF(jobs, true, true, true); + for (IAtomContainer ac : mcss.getSolutions()) { + ////System.out.println("Result MCS " + getMCSSSmiles(ac)); + Assert.assertEquals(3, ac.getAtomCount()); + } + long endCalcTime = Calendar.getInstance().getTimeInMillis(); + + ////System.out.println("Total time: " + (endCalcTime - startTime) + "ms"); + } + + @Test + public void case3() { + HashMap map = new HashMap<>(); + SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); + // Data + + map.put("1", "CCC=NNN"); + map.put("2", "CCC-NNN"); + map.put("3", "CCCSNNN"); + + List jobs = new ArrayList<>(); + for (String s : map.values()) { + try { + jobs.add(sp.parseSmiles(s)); + } catch (InvalidSmilesException ex) { + Logger.getLogger(TestMCSSJF.class.getName()).log(Level.SEVERE, null, ex); + } + } + long startTime = Calendar.getInstance().getTimeInMillis(); + MCSSJF mcss = new MCSSJF(jobs, true, true, false); + for (IAtomContainer ac : mcss.getSolutions()) { + //System.out.println("Result MCS " + getMCSSSmiles(ac)); + Assert.assertEquals(3, ac.getAtomCount()); + } + long endCalcTime = Calendar.getInstance().getTimeInMillis(); + ////System.out.println("Total time: " + (endCalcTime - startTime) + "ms"); + } + + @Test + public void case4() { + HashMap map = new HashMap<>(); + SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); + // Data + + map.put("1", "CCC=NNN"); + map.put("2", "CCC-NNN"); + map.put("3", "CCCSNNN"); + map.put("4", "SSSCCC"); + map.put("5", "CSSSCSNNN"); + + List jobs = new ArrayList<>(); + for (String s : map.values()) { + try { + jobs.add(sp.parseSmiles(s)); + } catch (InvalidSmilesException ex) { + Logger.getLogger(TestMCSSJF.class.getName()).log(Level.SEVERE, null, ex); + } + } + long startTime = Calendar.getInstance().getTimeInMillis(); + MCSSJF mcss = new MCSSJF(jobs, true, true, true); + Collection solutions = mcss.getSolutions(); + System.out.println("Number of Solutions: " + solutions.size()); + for (IAtomContainer ac : solutions) { + try { + System.out.println("Result MCS " + new SmilesGenerator().create(ac)); + } catch (CDKException ex) { + Logger.getLogger(TestMCSSJF.class.getName()).log(Level.SEVERE, null, ex); + } + Assert.assertEquals(1, ac.getAtomCount()); + } + long endCalcTime = Calendar.getInstance().getTimeInMillis(); + + ////System.out.println("Total time: " + (endCalcTime - startTime) + "ms"); + } + + @Test + public void case5() { + HashMap map = new HashMap<>(); + SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); + // Data + + map.put("1", "O=C(OC1OC(CO)C(O)C(O)C1(O))Cc3c[nH]c2ccccc23"); + map.put("2", "O=C(OC1C(O)C(O)C(O)C(O)C1(O))Cc3c[nH]c2ccccc23"); + + List jobs = new ArrayList<>(); + for (String s : map.values()) { + try { + IAtomContainer parseSmiles = sp.parseSmiles(s); + System.out.println(s + ", size:" + parseSmiles.getAtomCount()); + jobs.add(parseSmiles); + } catch (InvalidSmilesException ex) { + Logger.getLogger(TestMCSSJF.class.getName()).log(Level.SEVERE, null, ex); + } + } + long startTime = Calendar.getInstance().getTimeInMillis(); + MCSSJF mcss = new MCSSJF(jobs, true, true, false); + for (IAtomContainer ac : mcss.getSolutions()) { + try { + System.out.println("Result MCS " + new SmilesGenerator().create(ac)); + } catch (CDKException ex) { + Logger.getLogger(TestMCSSJF.class.getName()).log(Level.SEVERE, null, ex); + } + Assert.assertEquals(21, ac.getAtomCount()); + } + long endCalcTime = Calendar.getInstance().getTimeInMillis(); + + ////System.out.println("Total time: " + (endCalcTime - startTime) + "ms"); + } +}