From: <mar...@us...> - 2006-12-19 12:51:43
|
Revision: 7502 http://svn.sourceforge.net/cdk/?rev=7502&view=rev Author: mario_baseda Date: 2006-12-19 04:45:19 -0800 (Tue, 19 Dec 2006) Log Message: ----------- Modified Paths: -------------- trunk/cdk-taverna/.classpath trunk/cdk-taverna/build.xml trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/qsar/descriptors/atomic/RDFProton.java trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/CDKTavernaTests.java trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/TavernaTestData.java trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/qsar/descriptors/atomic/InductiveAtomicHardnessTest.java trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/qsar/descriptors/atomic/InductiveAtomicSoftnessTest.java trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/qsar/descriptors/atomic/RDFProtonTest.java trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/qsar/descriptors/bond/ResonancePositiveChargeTest.java trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/qsar/descriptors/molecular/IPMolecularTest.java trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/qsar/descriptors/molecular/LengthOverBreadthTest.java trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/qsar/descriptors/molecular/PetitjeanShapeIndexTest.java Added Paths: ----------- trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/CreateJPGWith2DStructures.java trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/CreatePDFWith2DStructures.java trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/CreatePNGWith2DStructures.java trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/CreateSVGWith2DStructures.java trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/Draw2DStructure.java trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/io/JPGCreationTest.java trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/io/PNGCreationTest.java trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/io/PdfCreationTest.java trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/io/SVGCreationTest.java Modified: trunk/cdk-taverna/.classpath =================================================================== --- trunk/cdk-taverna/.classpath 2006-12-19 12:45:08 UTC (rev 7501) +++ trunk/cdk-taverna/.classpath 2006-12-19 12:45:19 UTC (rev 7502) @@ -11,6 +11,6 @@ <classpathentry kind="lib" path="develjar/itext-1.4.6.jar"/> <classpathentry kind="lib" path="develjar/commons-io-1.2/commons-io-1.2/commons-io-1.2.jar"/> <classpathentry kind="lib" path="develjar/commons-io-1.2/commons-io-1.2/commons-io-1.2-src-ide.zip"/> - <classpathentry kind="lib" path="develjar/cdk-svn-20061207.jar" sourcepath="/cdk"/> + <classpathentry kind="lib" path="develjar/cdk-svn-20061215.jar" sourcepath="/cdk"/> <classpathentry kind="output" path="bin"/> </classpath> Modified: trunk/cdk-taverna/build.xml =================================================================== --- trunk/cdk-taverna/build.xml 2006-12-19 12:45:08 UTC (rev 7501) +++ trunk/cdk-taverna/build.xml 2006-12-19 12:45:19 UTC (rev 7502) @@ -35,7 +35,7 @@ </target> <target id="unjar.cdk" name="unjar.cdk"> - <unjar dest="${classes.dir}" src="${lib.dir}/cdk-svn-20061207.jar"> + <unjar dest="${classes.dir}" src="${lib.dir}/cdk-svn-20061215.jar"> <patternset> <include name="**/*"/> <exclude name="org/openscience/cdk/applications/jchempaint/**/*"/> Added: trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/CreateJPGWith2DStructures.java =================================================================== --- trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/CreateJPGWith2DStructures.java (rev 0) +++ trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/CreateJPGWith2DStructures.java 2006-12-19 12:45:19 UTC (rev 7502) @@ -0,0 +1,101 @@ +/* + * $Author$ + * $Date$ + * $Revision$ + * + * Copyright (C) 2006 by Mario Baseda <mar...@us...> + * + * 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 org.openscience.cdk.applications.taverna.io; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.embl.ebi.escience.baclava.DataThing; +import org.openscience.cdk.applications.taverna.CMLChemFile; +import org.openscience.cdk.applications.taverna.LocalWorkerCDK; +import org.openscience.cdk.interfaces.IAtomContainer; +import org.openscience.cdk.tools.manipulator.ChemFileManipulator; + +import org.openscience.cdk.applications.taverna.basicutilities.FileNameGenerator; +import uk.ac.soton.itinnovation.taverna.enactor.entities.TaskExecutionException; + +public class CreateJPGWith2DStructures implements LocalWorkerCDK { + + private String[] inputNames = new String[] { "inputStructures" }; + private String[] outputNames = new String[] { "Comment" }; + + // Region: input and outpout definition + + public String[] inputNames() { + return inputNames; + } + public String[] inputTypes() { + return new String[] {LocalWorkerCDK.CMLChemFileList}; + } + + public String[] outputNames() { + return outputNames; + } + public String[] outputTypes() { + return new String[] {LocalWorkerCDK.STRING_ARRAY}; + } + + // End of region + + // Region: local worker execution + + public Map execute(Map inputs) throws TaskExecutionException { + FileNameGenerator fileNameGenerator = new FileNameGenerator(); + boolean tab = false; + String ofor = "jpeg"; + List inputList = null; + List comment = new ArrayList(); + if (inputs.get(inputNames[0]) != null) { + inputList = (List) ((DataThing) (inputs.get(inputNames[0]))).getDataObject(); + } else { + return null; + } + try { + for (Iterator iter = inputList.iterator(); iter.hasNext();) { + CMLChemFile file = (CMLChemFile) iter.next(); + String fileName = fileNameGenerator.generateFileNameAndPathFromList((List<String>) file.getProperty(fileNameGenerator.FILENAME), ""); + List moleculeList = ChemFileManipulator.getAllAtomContainers(file); + try { + Draw2DStructure.draw(moleculeList, tab, ofor, fileName); + comment.add("done"); + } catch (Exception e){ + comment.add("Error"); + } + } + } catch (Exception exception) { + throw new TaskExecutionException(exception); + } + Map outputs = new HashMap(); + outputs.put(outputNames[0], new DataThing(comment)); + return outputs; + } +} + // End of Region + Added: trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/CreatePDFWith2DStructures.java =================================================================== --- trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/CreatePDFWith2DStructures.java (rev 0) +++ trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/CreatePDFWith2DStructures.java 2006-12-19 12:45:19 UTC (rev 7502) @@ -0,0 +1,100 @@ +/* + * $Author$ + * $Date$ + * $Revision$ + * + * Copyright (C) 2006 by Mario Baseda <mar...@us...> + * + * 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 org.openscience.cdk.applications.taverna.io; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.embl.ebi.escience.baclava.DataThing; +import org.openscience.cdk.applications.taverna.CMLChemFile; +import org.openscience.cdk.applications.taverna.LocalWorkerCDK; +import org.openscience.cdk.interfaces.IAtomContainer; +import org.openscience.cdk.tools.manipulator.ChemFileManipulator; + +import org.openscience.cdk.applications.taverna.basicutilities.FileNameGenerator; +import uk.ac.soton.itinnovation.taverna.enactor.entities.TaskExecutionException; + +public class CreatePDFWith2DStructures implements LocalWorkerCDK { + + private String[] inputNames = new String[] { "inputStructures" }; + private String[] outputNames = new String[] { "Comment" }; + + // Region: input and outpout definition + + public String[] inputNames() { + return inputNames; + } + public String[] inputTypes() { + return new String[] {LocalWorkerCDK.CMLChemFileList}; + } + + public String[] outputNames() { + return outputNames; + } + public String[] outputTypes() { + return new String[] {LocalWorkerCDK.STRING_ARRAY}; + } + + // End of region + + // Region: local worker execution + + public Map execute(Map inputs) throws TaskExecutionException { + FileNameGenerator fileNameGenerator = new FileNameGenerator(); + boolean tab = true; + String ofor = "pdf"; + List inputList = null; + List comment = new ArrayList(); + if (inputs.get(inputNames[0]) != null) { + inputList = (List) ((DataThing) (inputs.get(inputNames[0]))).getDataObject(); + } else { + return null; + } + try { + for (Iterator iter = inputList.iterator(); iter.hasNext();) { + CMLChemFile file = (CMLChemFile) iter.next(); + String fileName = fileNameGenerator.generateFileNameAndPathFromList((List<String>) file.getProperty(fileNameGenerator.FILENAME), ""); + List moleculeList = ChemFileManipulator.getAllAtomContainers(file); + try { + Draw2DStructure.draw(moleculeList, tab, ofor, fileName); + comment.add("done"); + } catch (Exception e){ + comment.add("Error"); + } + } + } catch (Exception exception) { + throw new TaskExecutionException(exception); + } + Map outputs = new HashMap(); + outputs.put(outputNames[0], new DataThing(comment)); + return outputs; + } +} + // End of Region Added: trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/CreatePNGWith2DStructures.java =================================================================== --- trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/CreatePNGWith2DStructures.java (rev 0) +++ trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/CreatePNGWith2DStructures.java 2006-12-19 12:45:19 UTC (rev 7502) @@ -0,0 +1,101 @@ +/* + * $Author$ + * $Date$ + * $Revision$ + * + * Copyright (C) 2006 by Mario Baseda <mar...@us...> + * + * 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 org.openscience.cdk.applications.taverna.io; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.embl.ebi.escience.baclava.DataThing; +import org.openscience.cdk.applications.taverna.CMLChemFile; +import org.openscience.cdk.applications.taverna.LocalWorkerCDK; +import org.openscience.cdk.interfaces.IAtomContainer; +import org.openscience.cdk.tools.manipulator.ChemFileManipulator; + +import org.openscience.cdk.applications.taverna.basicutilities.FileNameGenerator; +import uk.ac.soton.itinnovation.taverna.enactor.entities.TaskExecutionException; + +public class CreatePNGWith2DStructures implements LocalWorkerCDK { + + private String[] inputNames = new String[] { "inputStructures" }; + private String[] outputNames = new String[] { "Comment" }; + + // Region: input and outpout definition + + public String[] inputNames() { + return inputNames; + } + public String[] inputTypes() { + return new String[] {LocalWorkerCDK.CMLChemFileList}; + } + + public String[] outputNames() { + return outputNames; + } + public String[] outputTypes() { + return new String[] {LocalWorkerCDK.STRING_ARRAY}; + } + + // End of region + + // Region: local worker execution + + public Map execute(Map inputs) throws TaskExecutionException { + FileNameGenerator fileNameGenerator = new FileNameGenerator(); + boolean tab = false; + String ofor = "PNG"; + List inputList = null; + List comment = new ArrayList(); + if (inputs.get(inputNames[0]) != null) { + inputList = (List) ((DataThing) (inputs.get(inputNames[0]))).getDataObject(); + } else { + return null; + } + try { + for (Iterator iter = inputList.iterator(); iter.hasNext();) { + CMLChemFile file = (CMLChemFile) iter.next(); + String fileName = fileNameGenerator.generateFileNameAndPathFromList((List<String>) file.getProperty(fileNameGenerator.FILENAME), ""); + List moleculeList = ChemFileManipulator.getAllAtomContainers(file); + try { + Draw2DStructure.draw(moleculeList, tab, ofor, fileName); + comment.add("done"); + } catch (Exception e){ + comment.add("Error"); + } + } + } catch (Exception exception) { + throw new TaskExecutionException(exception); + } + Map outputs = new HashMap(); + outputs.put(outputNames[0], new DataThing(comment)); + return outputs; + } +} + // End of Region + Added: trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/CreateSVGWith2DStructures.java =================================================================== --- trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/CreateSVGWith2DStructures.java (rev 0) +++ trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/CreateSVGWith2DStructures.java 2006-12-19 12:45:19 UTC (rev 7502) @@ -0,0 +1,101 @@ +/* + * $Author$ + * $Date$ + * $Revision$ + * + * Copyright (C) 2006 by Mario Baseda <mar...@us...> + * + * 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 org.openscience.cdk.applications.taverna.io; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.List; +import java.util.Map; + +import org.embl.ebi.escience.baclava.DataThing; +import org.openscience.cdk.applications.taverna.CMLChemFile; +import org.openscience.cdk.applications.taverna.LocalWorkerCDK; +import org.openscience.cdk.interfaces.IAtomContainer; +import org.openscience.cdk.tools.manipulator.ChemFileManipulator; + +import org.openscience.cdk.applications.taverna.basicutilities.FileNameGenerator; +import uk.ac.soton.itinnovation.taverna.enactor.entities.TaskExecutionException; + +public class CreateSVGWith2DStructures implements LocalWorkerCDK { + + private String[] inputNames = new String[] { "inputStructures" }; + private String[] outputNames = new String[] { "Comment" }; + + // Region: input and outpout definition + + public String[] inputNames() { + return inputNames; + } + public String[] inputTypes() { + return new String[] {LocalWorkerCDK.CMLChemFileList}; + } + + public String[] outputNames() { + return outputNames; + } + public String[] outputTypes() { + return new String[] {LocalWorkerCDK.STRING_ARRAY}; + } + + // End of region + + // Region: local worker execution + + public Map execute(Map inputs) throws TaskExecutionException { + FileNameGenerator fileNameGenerator = new FileNameGenerator(); + boolean tab = false; + String ofor = "svg"; + List inputList = null; + List comment = new ArrayList(); + if (inputs.get(inputNames[0]) != null) { + inputList = (List) ((DataThing) (inputs.get(inputNames[0]))).getDataObject(); + } else { + return null; + } + try { + for (Iterator iter = inputList.iterator(); iter.hasNext();) { + CMLChemFile file = (CMLChemFile) iter.next(); + String fileName = fileNameGenerator.generateFileNameAndPathFromList((List<String>) file.getProperty(fileNameGenerator.FILENAME), ""); + List moleculeList = ChemFileManipulator.getAllAtomContainers(file); + try { + Draw2DStructure.draw(moleculeList, tab, ofor, fileName); + comment.add("done"); + } catch (Exception e){ + comment.add("Error"); + } + } + } catch (Exception exception) { + throw new TaskExecutionException(exception); + } + Map outputs = new HashMap(); + outputs.put(outputNames[0], new DataThing(comment)); + return outputs; + } +} + // End of Region + Added: trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/Draw2DStructure.java =================================================================== --- trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/Draw2DStructure.java (rev 0) +++ trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/io/Draw2DStructure.java 2006-12-19 12:45:19 UTC (rev 7502) @@ -0,0 +1,450 @@ +/* + * Rajarshi Guha <raj...@pr...> + * 3/4/05 + * + * 01/19/06 - Thanks to Noel O'Boyle for supplying a patch to update the code + * 01/19/06 - Updated to produce PDF output if specified + * 01/20/06 - Applied patch from Egon Willighagen to produce a PDF table of structures + * 01/22/06 - Updated to allow multiple columns in tabular output + * 01/22/06 - Applied patch from Egon Willighagen to output properties if present in the SDF file + * 01/24/06 - Updated to improve the formatting of numbers when the properties are + * included in tabular PDF output + * 02/09/06 - Updated to be in sync with the latest CDK CVS + * 03/20/06 - Updated to be in sync with the latest CDK CVS + * 04/28/06 - Added code to perform explicity aromaticity detection and synced with latest CDK + * 05/10/06 - Caught an exception, synced with latest CDK + * 05/18/06 - Updated to show H's for heteroatoms - not configurable from the CLI + * + * 12/19/06 - Modified by Mario Baseda for the use within the CDK-Taverna project + * ---------------------------------------------------------------------------------------- + * 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 org.openscience.cdk.applications.taverna.io; + +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.text.DecimalFormat; +import java.util.Enumeration; +import java.util.Iterator; +import java.util.List; + +import javax.media.jai.JAI; +import javax.media.jai.RenderedOp; +import javax.swing.JFrame; +import javax.swing.JPanel; + +import org.openscience.cdk.CDKConstants; +import org.openscience.cdk.aromaticity.HueckelAromaticityDetector; +import org.openscience.cdk.exception.CDKException; +import org.openscience.cdk.geometry.GeometryTools; +import org.openscience.cdk.interfaces.IAtomContainer; +import org.openscience.cdk.interfaces.IMolecule; +import org.openscience.cdk.io.SVGWriter; +import org.openscience.cdk.layout.StructureDiagramGenerator; +import org.openscience.cdk.math.RandomNumbersTool; +import org.openscience.cdk.renderer.Renderer2D; +import org.openscience.cdk.renderer.Renderer2DModel; +import org.openscience.cdk.tools.manipulator.AtomContainerManipulator; + +import com.lowagie.text.Chunk; +import com.lowagie.text.Document; +import com.lowagie.text.DocumentException; +import com.lowagie.text.FontFactory; +import com.lowagie.text.Phrase; +import com.lowagie.text.Rectangle; +import com.lowagie.text.pdf.PdfContentByte; +import com.lowagie.text.pdf.PdfPCell; +import com.lowagie.text.pdf.PdfPTable; +import com.lowagie.text.pdf.PdfWriter; + +// Region: Draw 2D Structure + +public class Draw2DStructure { + private static boolean withH = false; + private static int width = 300; + private static int height = 300; + private static double scale = 0.9; + private static String oformat; + private static String outputDirectory = "./"; + private static boolean tabular; + private static int ncol = 2; + private static boolean props = false; + private static boolean doColor = false; + + // Region: draw + public static void draw(List m, boolean tab, String ofor, String output) { + tabular = tab; + displayStructure ds = null; + outputDirectory = output; + if (tabular) oformat = "PDF"; + if (tabular) { + ds = new displayStructureAsPDFTable(withH, width, height, scale, ncol, props, doColor, outputDirectory); + } + try { + int cnt = 1; + for (Iterator iterator = m.iterator(); iterator.hasNext();) { + if (!tabular) { + oformat = ofor; + ds = new displayStructure(withH, width, height, scale, doColor, oformat, outputDirectory); + } + assert ds != null; + ds.drawStructure((IAtomContainer) iterator.next(), cnt); + cnt += 1; + } + if (ds != null) ds.close(); + } catch (FileNotFoundException fnf) { + System.out.println(fnf.toString()); + } catch (Exception fnf) { + System.out.println(fnf.toString()); + fnf.printStackTrace(); + } + } + // End of Region +} + +// End of Region + +// Region: display Structure as PDF Table + +class displayStructureAsPDFTable extends displayStructure { + private PdfPTable table; + private Document document; + int ncol = 1; + boolean props = false; + boolean doColor = false; + DecimalFormat decimalFormat; + + public displayStructureAsPDFTable(boolean withH, int width, int height, double scale, int ncol, boolean props, boolean doColor, String odir) { + this.withH = withH; + this.width = width; + this.height = height; + this.scale = scale; + this.odir = odir; + this.props = props; + this.ncol = ncol; + this.doColor = doColor; + + suffix = ".pdf"; + oformat = "PDF"; + + decimalFormat = new DecimalFormat("0.000E00"); + this.frame = new JFrame(); + + try { + String uniquifyFileName = "_" + System.currentTimeMillis() + "_" + + RandomNumbersTool.randomInt(0, 100000); + File file = new File(odir + uniquifyFileName + this.suffix); + document = new Document(); + PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file)); + + float[] widths = new float[ncol]; + for (int i = 0; i < ncol; i += 2) { + if (props) { + widths[i] = 3f; + widths[i + 1] = 2f; + } else { + widths[i] = 1.5f; + widths[i + 1] = 3f; + } + } + table = new PdfPTable(widths); + document.open(); + } catch (Exception exc) { + exc.printStackTrace(); + } + } + + private void addTitle(IAtomContainer mol, Phrase phrase) { + if (mol.getProperty(CDKConstants.TITLE) == null || + mol.getProperty(CDKConstants.TITLE).toString().trim().length() == 0) return; + phrase.add(new Chunk( + CDKConstants.TITLE + ": ", + FontFactory.getFont(FontFactory.HELVETICA_BOLD) + )); + phrase.add(new Chunk( + mol.getProperty(CDKConstants.TITLE) + "\n", + FontFactory.getFont(FontFactory.HELVETICA) + )); + } + + + private void addProperty(Object propertyLabel, IAtomContainer mol, Phrase phrase) { + if (mol.getProperty(propertyLabel) == null || + mol.getProperty(propertyLabel).toString().trim().length() == 0) return; + + phrase.add(new Chunk( + propertyLabel + ": ", + FontFactory.getFont(FontFactory.HELVETICA_BOLD) + )); + String value; + try { + double tmp = Double.parseDouble(mol.getProperty(propertyLabel).toString()); + value = decimalFormat.format(tmp); + } catch (NumberFormatException nfe) { + value = mol.getProperty(propertyLabel).toString(); + } + phrase.add(new Chunk( + value + "\n", + FontFactory.getFont(FontFactory.HELVETICA) + )); + } + + public void drawStructure(IAtomContainer mol, int cnt) { + if (!this.withH) { + mol = AtomContainerManipulator.removeHydrogens(mol); + } + + // do aromaticity detection + try { + HueckelAromaticityDetector.detectAromaticity(mol); + } catch (CDKException cdke) { + cdke.printStackTrace(); + } + r2dm = new Renderer2DModel(); + renderer = new Renderer2D(r2dm); + Dimension screenSize = new Dimension(this.width, this.height); + setPreferredSize(screenSize); + r2dm.setBackgroundDimension(screenSize); // make sure it is synched with the JPanel size + setBackground(r2dm.getBackColor()); + + + try { + StructureDiagramGenerator sdg = new StructureDiagramGenerator(); + sdg.setMolecule((IMolecule) mol); + sdg.generateCoordinates(); + this.mol = sdg.getMolecule(); + r2dm.setDrawNumbers(false); + r2dm.setUseAntiAliasing(true); + r2dm.setColorAtomsByType(doColor); + r2dm.setShowImplicitHydrogens(true); + r2dm.setShowAromaticity(true); + r2dm.setShowReactionBoxes(false); + r2dm.setKekuleStructure(false); + GeometryTools.translateAllPositive(this.mol, r2dm.getRenderingCoordinates()); + GeometryTools.scaleMolecule(this.mol, getPreferredSize(), this.scale, r2dm.getRenderingCoordinates()); + GeometryTools.center(this.mol, getPreferredSize(), r2dm.getRenderingCoordinates()); + } + catch (Exception exc) { + exc.printStackTrace(); + } + this.frame.getContentPane().add(this); + this.frame.pack(); + Rectangle pageSize = new Rectangle(this.getSize().width, this.getSize().height); + try { + StringBuffer comment = new StringBuffer(); + PdfPCell cell = new PdfPCell(); + Phrase phrase = new Phrase(); + addTitle(mol, phrase); + if (props) { + Enumeration props = mol.getProperties().keys(); + while (props.hasMoreElements()) { + Object key = props.nextElement(); + if (key.equals("AllRings")) continue; + if (key.equals("SmallestRings")) continue; + if (key.equals(CDKConstants.TITLE)) continue; + addProperty(key, mol, phrase); + } + } + cell.addElement(phrase); + table.addCell(cell); + Image awtImage = createImage(this.getSize().width, this.getSize().height); + Graphics snapGraphics = awtImage.getGraphics(); + paint(snapGraphics); + com.lowagie.text.Image pdfImage = com.lowagie.text.Image.getInstance(awtImage, null); + pdfImage.setAbsolutePosition(0, 0); + table.addCell(pdfImage); + + } catch (DocumentException de) { + System.err.println(de.getMessage()); + } catch (IOException ioe) { + System.err.println(ioe.getMessage()); + } + } + + public void paint(Graphics g) { + super.paint(g); + renderer.paintMolecule(this.mol, (Graphics2D) g, false, true); + } + + public void close() throws Exception { + document.add(table); + document.close(); + } + +} + +// End of region + +// Region: display Structure + +class displayStructure extends JPanel { + protected boolean withH = false; + protected int width = 300; + protected int height = 300; + protected double scale = .9; + protected boolean doColor = false; + protected String oformat = "PNG"; + protected String odir = "./"; + protected String suffix = ".png"; + protected JFrame frame = null; + + IAtomContainer mol; + + Renderer2DModel r2dm; + Renderer2D renderer; + + public displayStructure() { + } + + public displayStructure(boolean withH, int width, int height, double scale, boolean doColor, String oformat, String odir) { + this.withH = withH; + this.width = width; + this.height = height; + this.scale = scale; + this.oformat = oformat; + this.odir = odir; + this.doColor = doColor; + if (oformat.equalsIgnoreCase("png")) { + suffix = ".png"; + oformat = "PNG"; + } else if (oformat.equalsIgnoreCase("jpeg")) { + suffix = ".jpg"; + oformat = "JPEG"; + } else if (oformat.equalsIgnoreCase("pdf")) { + suffix = ".pdf"; + oformat = "PDF"; + } else if (oformat.equalsIgnoreCase("svg")) { + suffix = ".svg"; + oformat = "SVG"; + } + + this.frame = new JFrame(); + } + + public void drawStructure(IAtomContainer mol, int cnt) { + if (!this.withH) { + mol = AtomContainerManipulator.removeHydrogens(mol); + } + + // do aromaticity detection + try { + HueckelAromaticityDetector.detectAromaticity(mol); + } catch (CDKException cdke) { + cdke.printStackTrace(); + } + + r2dm = new Renderer2DModel(); + renderer = new Renderer2D(r2dm); + Dimension screenSize = new Dimension(this.width, this.height); + setPreferredSize(screenSize); + r2dm.setBackgroundDimension(screenSize); // make sure it is synched with the JPanel size + setBackground(r2dm.getBackColor()); + + try { + StructureDiagramGenerator sdg = new StructureDiagramGenerator(); + sdg.setMolecule((IMolecule) mol); + sdg.generateCoordinates(); + this.mol = sdg.getMolecule(); + r2dm.setDrawNumbers(false); + r2dm.setUseAntiAliasing(true); + r2dm.setColorAtomsByType(doColor); + r2dm.setShowImplicitHydrogens(true); + r2dm.setShowAromaticity(true); + r2dm.setShowReactionBoxes(false); + r2dm.setKekuleStructure(false); + GeometryTools.translateAllPositive(this.mol, r2dm.getRenderingCoordinates()); + GeometryTools.scaleMolecule(this.mol, getPreferredSize(), this.scale, r2dm.getRenderingCoordinates()); + GeometryTools.center(this.mol, getPreferredSize(), r2dm.getRenderingCoordinates()); + } catch (Exception exc) { + exc.printStackTrace(); + } + this.frame.getContentPane().add(this); + this.frame.pack(); + + String uniquifyFileName = "_" + System.currentTimeMillis() + "_" + + RandomNumbersTool.randomInt(0, 100000); + String name = this.odir + uniquifyFileName + this.suffix; +// if (cnt < 10) filename = this.odir + "/img00" + cnt + "_" + uniquifyFileName + this.suffix; +// else if (cnt < 100) filename = this.odir + "/img0" + cnt + "_" + uniquifyFileName + this.suffix; +// else filename = this.odir + "/img" + cnt + "_" + uniquifyFileName + this.suffix; + if (oformat.equalsIgnoreCase("png") || oformat.equalsIgnoreCase("jpeg")) { + Image img; + try { + img = createImage(this.getSize().width, this.getSize().height); + Graphics2D snapGraphics = (Graphics2D) img.getGraphics(); + this.paint(snapGraphics); + RenderedOp image = JAI.create("AWTImage", img); + JAI.create("filestore", image, name, this.oformat); + } catch (NullPointerException e) { + System.out.println(e.toString()); + } + } else if (oformat.equalsIgnoreCase("pdf")) { + File file = new File(name); + Rectangle pageSize = new Rectangle(this.getSize().width, this.getSize().height); + Document document = new Document(pageSize); + try { + PdfWriter writer = PdfWriter.getInstance(document, new FileOutputStream(file)); + document.open(); + PdfContentByte cb = writer.getDirectContent(); + Image awtImage = createImage(this.getSize().width, this.getSize().height); + Graphics snapGraphics = awtImage.getGraphics(); + paint(snapGraphics); + com.lowagie.text.Image pdfImage = com.lowagie.text.Image.getInstance(awtImage, null); + pdfImage.setAbsolutePosition(0, 0); + cb.addImage(pdfImage); + } catch (DocumentException de) { + System.err.println(de.getMessage()); + } catch (IOException ioe) { + System.err.println(ioe.getMessage()); + } + document.close(); + } else if (oformat.equalsIgnoreCase("svg")) { + try { + SVGWriter cow = new SVGWriter(new FileWriter(name)); + if (cow != null) { + cow.writeAtomContainer(mol); + cow.close(); + } + } catch (IOException ioe) { + ioe.printStackTrace(); + } catch (CDKException cdke) { + cdke.printStackTrace(); + } + } + } + + public void paint(Graphics g) { + super.paint(g); + renderer.paintMolecule(this.mol, (Graphics2D) g, false, true); + } + + public void close() throws Exception { + } +} + +// End of region + + \ No newline at end of file Modified: trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/qsar/descriptors/atomic/RDFProton.java =================================================================== --- trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/qsar/descriptors/atomic/RDFProton.java 2006-12-19 12:45:08 UTC (rev 7501) +++ trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/qsar/descriptors/atomic/RDFProton.java 2006-12-19 12:45:19 UTC (rev 7502) @@ -1,123 +1,123 @@ -/* $RCSfile$ - * $Author: thomaskuhn $ - * $Date: 2006-01-20 08:21:14 +0100 (Fr, 20 Jan 2006) $ - * $Revision: 5602 $ - * - * Copyright (C) 2006 by Thomas Kuhn <tho...@us...> - * - * 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 org.openscience.cdk.applications.taverna.qsar.descriptors.atomic; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -import java.util.Map; - -import org.embl.ebi.escience.baclava.DataThing; -import org.openscience.cdk.applications.taverna.CMLChemFile; -import org.openscience.cdk.applications.taverna.LocalWorkerCDK; -import org.openscience.cdk.applications.taverna.basicutilities.FileNameGenerator; -import org.openscience.cdk.interfaces.IAtomContainer; -import org.openscience.cdk.qsar.DescriptorValue; -import org.openscience.cdk.qsar.descriptors.atomic.RDFProtonDescriptor; -import org.openscience.cdk.tools.manipulator.ChemFileManipulator; - -import uk.ac.soton.itinnovation.taverna.enactor.entities.TaskExecutionException; - -public class RDFProton implements LocalWorkerCDK { - - private static RDFProtonDescriptor descriptor; - private String[] inputNames = new String[] { "inputStructures" }; - private String[] outputNames = new String[] { "calculatedStructures", "NOTCalculatedStructures", - "Comment" }; - - // Region: input and outpout definition - - public String[] inputNames() { - return inputNames; - } - public String[] inputTypes() { - return new String[] {LocalWorkerCDK.CMLChemFileList}; - } - - public String[] outputNames() { - return outputNames; - } - public String[] outputTypes() { - return new String[] {LocalWorkerCDK.CMLChemFileList, LocalWorkerCDK.CMLChemFileList, - LocalWorkerCDK.STRING_ARRAY}; - } - - - // End of region - - // Region: local worker execution - public Map execute(Map inputs) throws TaskExecutionException { - FileNameGenerator fileNameGenerator = new FileNameGenerator(); - List inputList = null; - List calculatedList = new ArrayList(); - List notCalculatedList = new ArrayList(); - List comment = new ArrayList(); - String fileNameCalculated = "RDFProtonDescriptor"; - String fileNameNotCalculated = "Error_RDFProtonDescriptor"; - if (inputs.get(inputNames[0]) != null) { - inputList = (List) ((DataThing) (inputs.get(inputNames[0]))).getDataObject(); - } else { - return null; - } - if (descriptor == null) { - descriptor = new RDFProtonDescriptor(); - } - try { - for (Iterator iter = inputList.iterator(); iter.hasNext();) { - CMLChemFile file = (CMLChemFile) iter.next(); - List moleculeList = ChemFileManipulator.getAllAtomContainers(file); - IAtomContainer molecules; - for (Iterator iterator = moleculeList.iterator(); iterator.hasNext();){ - molecules = (IAtomContainer)iterator.next(); - try { - for (int j = 0; j < molecules.getAtomCount(); j++) { - DescriptorValue value = descriptor - .calculate(molecules.getAtom(j), molecules); - molecules.setProperty(value.getSpecification(), - value); - } - file.setProperty(fileNameGenerator.FILENAME, fileNameGenerator.addFileNameToFileNameList(fileNameCalculated, (List<String>)file.getProperty(FileNameGenerator.FILENAME))); - calculatedList.add(file); - comment.add("Calculation done;"); - } catch (Exception e) { - file.setProperty(fileNameGenerator.FILENAME, fileNameGenerator.addFileNameToFileNameList(fileNameNotCalculated, (List<String>)file.getProperty(FileNameGenerator.FILENAME))); - notCalculatedList.add(file); - comment.add("Error, calculation of the Descriptor for this molecule caused an error!" + e); - } - } - } - } catch (Exception exception) { - throw new TaskExecutionException(exception); - } - Map outputs = new HashMap(); - outputs.put(outputNames[0], new DataThing(calculatedList)); - outputs.put(outputNames[1], new DataThing(notCalculatedList)); - outputs.put(outputNames[2], new DataThing(comment)); - return outputs; - } - // End of region -} +///* $RCSfile$ +// * $Author: thomaskuhn $ +// * $Date: 2006-01-20 08:21:14 +0100 (Fr, 20 Jan 2006) $ +// * $Revision: 5602 $ +// * +// * Copyright (C) 2006 by Thomas Kuhn <tho...@us...> +// * +// * 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 org.openscience.cdk.applications.taverna.qsar.descriptors.atomic; +// +//import java.util.ArrayList; +//import java.util.HashMap; +//import java.util.Iterator; +//import java.util.List; +//import java.util.Map; +// +//import org.embl.ebi.escience.baclava.DataThing; +//import org.openscience.cdk.applications.taverna.CMLChemFile; +//import org.openscience.cdk.applications.taverna.LocalWorkerCDK; +//import org.openscience.cdk.applications.taverna.basicutilities.FileNameGenerator; +//import org.openscience.cdk.interfaces.IAtomContainer; +//import org.openscience.cdk.qsar.DescriptorValue; +//import org.openscience.cdk.qsar.descriptors.atomic.RDFProtonDescriptor; +//import org.openscience.cdk.tools.manipulator.ChemFileManipulator; +// +//import uk.ac.soton.itinnovation.taverna.enactor.entities.TaskExecutionException; +// +//public class RDFProton implements LocalWorkerCDK { +// +// private static RDFProtonDescriptor descriptor; +// private String[] inputNames = new String[] { "inputStructures" }; +// private String[] outputNames = new String[] { "calculatedStructures", "NOTCalculatedStructures", +// "Comment" }; +// +// // Region: input and outpout definition +// +// public String[] inputNames() { +// return inputNames; +// } +// public String[] inputTypes() { +// return new String[] {LocalWorkerCDK.CMLChemFileList}; +// } +// +// public String[] outputNames() { +// return outputNames; +// } +// public String[] outputTypes() { +// return new String[] {LocalWorkerCDK.CMLChemFileList, LocalWorkerCDK.CMLChemFileList, +// LocalWorkerCDK.STRING_ARRAY}; +// } +// +// +// // End of region +// +// // Region: local worker execution +// public Map execute(Map inputs) throws TaskExecutionException { +// FileNameGenerator fileNameGenerator = new FileNameGenerator(); +// List inputList = null; +// List calculatedList = new ArrayList(); +// List notCalculatedList = new ArrayList(); +// List comment = new ArrayList(); +// String fileNameCalculated = "RDFProtonDescriptor"; +// String fileNameNotCalculated = "Error_RDFProtonDescriptor"; +// if (inputs.get(inputNames[0]) != null) { +// inputList = (List) ((DataThing) (inputs.get(inputNames[0]))).getDataObject(); +// } else { +// return null; +// } +// if (descriptor == null) { +// descriptor = new RDFProtonDescriptor(); +// } +// try { +// for (Iterator iter = inputList.iterator(); iter.hasNext();) { +// CMLChemFile file = (CMLChemFile) iter.next(); +// List moleculeList = ChemFileManipulator.getAllAtomContainers(file); +// IAtomContainer molecules; +// for (Iterator iterator = moleculeList.iterator(); iterator.hasNext();){ +// molecules = (IAtomContainer)iterator.next(); +// try { +// for (int j = 0; j < molecules.getAtomCount(); j++) { +// DescriptorValue value = descriptor +// .calculate(molecules.getAtom(j), molecules); +// molecules.setProperty(value.getSpecification(), +// value); +// } +// file.setProperty(fileNameGenerator.FILENAME, fileNameGenerator.addFileNameToFileNameList(fileNameCalculated, (List<String>)file.getProperty(FileNameGenerator.FILENAME))); +// calculatedList.add(file); +// comment.add("Calculation done;"); +// } catch (Exception e) { +// file.setProperty(fileNameGenerator.FILENAME, fileNameGenerator.addFileNameToFileNameList(fileNameNotCalculated, (List<String>)file.getProperty(FileNameGenerator.FILENAME))); +// notCalculatedList.add(file); +// comment.add("Error, calculation of the Descriptor for this molecule caused an error!" + e); +// } +// } +// } +// } catch (Exception exception) { +// throw new TaskExecutionException(exception); +// } +// Map outputs = new HashMap(); +// outputs.put(outputNames[0], new DataThing(calculatedList)); +// outputs.put(outputNames[1], new DataThing(notCalculatedList)); +// outputs.put(outputNames[2], new DataThing(comment)); +// return outputs; +// } +// // End of region +//} Modified: trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/CDKTavernaTests.java =================================================================== --- trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/CDKTavernaTests.java 2006-12-19 12:45:08 UTC (rev 7501) +++ trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/CDKTavernaTests.java 2006-12-19 12:45:19 UTC (rev 7502) @@ -55,7 +55,7 @@ import org.openscience.cdk.applications.taverna.test.qsar.descriptors.atomic.PeriodicTablePositionTest; import org.openscience.cdk.applications.taverna.test.qsar.descriptors.atomic.PiElectronegativityTest; import org.openscience.cdk.applications.taverna.test.qsar.descriptors.atomic.ProtonTotalPartialChargeTest; -import org.openscience.cdk.applications.taverna.test.qsar.descriptors.atomic.RDFProtonTest; +//import org.openscience.cdk.applications.taverna.test.qsar.descriptors.atomic.RDFProtonTest; import org.openscience.cdk.applications.taverna.test.qsar.descriptors.atomic.SigmaElectronegativityTest; import org.openscience.cdk.applications.taverna.test.qsar.descriptors.atomic.VdWRadiusTest; import org.openscience.cdk.applications.taverna.test.qsar.descriptors.atomic.WeightTest; @@ -105,10 +105,10 @@ import org.openscience.cdk.applications.taverna.test.qsar.descriptors.molecular.ZagrebIndexTest; import org.openscience.cdk.applications.taverna.test.smiles.SmilesToolsTest; import org.openscience.cdk.applications.taverna.test.tools.CloningCMLChemFileTest; -//import org.openscience.cdk.applications.taverna.test.io.PdfCreationTest; -//import org.openscience.cdk.applications.taverna.test.io.JPGCreationTest; -//import org.openscience.cdk.applications.taverna.test.io.PNGCreationTest; -//import org.openscience.cdk.applications.taverna.test.io.SVGCreationTest; +import org.openscience.cdk.applications.taverna.test.io.PdfCreationTest; +import org.openscience.cdk.applications.taverna.test.io.JPGCreationTest; +import org.openscience.cdk.applications.taverna.test.io.PNGCreationTest; +import org.openscience.cdk.applications.taverna.test.io.SVGCreationTest; public class CDKTavernaTests { @@ -152,9 +152,9 @@ // Region: Basic utility tests suite.addTest(StringDoubleConverterTest.suite()); -// suite.addTest(PdfCreationTest.suite()); -// suite.addTest(JPGCreationTest.suite()); -// suite.addTest(PNGCreationTest.suite()); + suite.addTest(PdfCreationTest.suite()); + suite.addTest(JPGCreationTest.suite()); + suite.addTest(PNGCreationTest.suite()); //suite.addTest(SVGCreationTest.suite()); //suite.addTest(ReactionEvaluatorTest.suite()); // End of region @@ -182,7 +182,7 @@ suite.addTest(PeriodicTablePositionTest.suite()); //suite.addTest(PiContactDetectionTest.suite()); suite.addTest(ProtonTotalPartialChargeTest.suite()); - suite.addTest(RDFProtonTest.suite()); + // suite.addTest(RDFProtonTest.suite()); suite.addTest(SigmaElectronegativityTest.suite()); suite.addTest(VdWRadiusTest.suite()); suite.addTest(WeightTest.suite()); Modified: trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/TavernaTestData.java =================================================================== --- trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/TavernaTestData.java 2006-12-19 12:45:08 UTC (rev 7501) +++ trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/TavernaTestData.java 2006-12-19 12:45:19 UTC (rev 7502) @@ -109,6 +109,7 @@ private static void createTestData() throws Exception{ String[] smiles = new String[] {"CC", "OCC", "O(C)CCC", "c1ccccc1", "C(=C)=C", "OCC=CCc1ccccc1(C=C)", "O(CC=C)CCN", "CCCCCCCCCCCCCCC", "OCC=CCO", "NCCCCN"}; +// String[] smiles = new String[] {"OCC=CCc1ccccc1(C=C)"}; SmilesParser sp = new SmilesParser(); atomContainer = new IAtomContainer[smiles.length]; cmlChemFile = new CMLChemFile[smiles.length]; Added: trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/io/JPGCreationTest.java =================================================================== --- trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/io/JPGCreationTest.java (rev 0) +++ trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/io/JPGCreationTest.java 2006-12-19 12:45:19 UTC (rev 7502) @@ -0,0 +1,91 @@ +/* $RCSfile$ + * $Author:$ + * $Date:$ + * $Revision:$ + * + * Copyright (C) 2006 by Mario Baseda <mar...@us...> + * + * 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 org.openscience.cdk.applications.taverna.test.io; + +import java.io.FileReader; +import java.io.Reader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Iterator; +import java.util.Map; +import java.io.File; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.embl.ebi.escience.baclava.DataThing; +import org.openscience.cdk.applications.taverna.CMLChemFile; +import org.openscience.cdk.applications.taverna.io.CDKIOReader; +import org.openscience.cdk.applications.taverna.io.Draw2DStructure; +import org.openscience.cdk.applications.taverna.test.CDKTavernaTestCase; +import org.openscience.cdk.applications.taverna.test.CDKTavernaTests; +import org.openscience.cdk.applications.taverna.test.TavernaTestData; +import org.openscience.cdk.applications.taverna.io.CreateJPGWith2DStructures; +import org.openscience.cdk.exception.CDKException; +import org.openscience.cdk.interfaces.IAtomContainer; +import org.openscience.cdk.io.IChemObjectReader; +import org.openscience.cdk.io.MDLReader; +import org.openscience.cdk.tools.manipulator.ChemFileManipulator; + +public class JPGCreationTest extends CDKTavernaTestCase { + private CMLChemFile[] originalData = null; + // inputList which contains a list of the input data for the local workers + private List inputList = null; + // map for the local worker input + private Map inputMap = null; + // map for the local worker result + private Map resultMap = null; +// List which contains the comments of the local worker + private List resultList = null; + public JPGCreationTest(){} + + public static Test suite() { + return new TestSuite(JPGCreationTest.class); + } + + public void test_LocalWorkerJPGCreation()throws CDKException, Exception{ + CreateJPGWith2DStructures test = new CreateJPGWith2DStructures(); + inputList = new ArrayList(); + //originalData = CDKIOReader.readFromSDFile("X:\\test.sdf"); + originalData = TavernaTestData.getCMLChemFile(); + for (int i = 0; i < originalData.length; i++) { + inputList.add(originalData[i]); + } + inputMap = new HashMap(); + inputMap.put(test.inputNames()[0], new DataThing(inputList)); + resultMap = test.execute(inputMap); + resultList = (List)((DataThing)(resultMap.get(test.outputNames()[0]))).getDataObject(); + boolean hasAnError = false; + for (Iterator iter = resultList.iterator(); iter.hasNext();){ + if ((String) iter.next() == "Error"){ + hasAnError = true; + } + } + assertEquals(false, hasAnError); + } +} Added: trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/io/PNGCreationTest.java =================================================================== --- trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/io/PNGCreationTest.java (rev 0) +++ trunk/cdk-taverna/src/org/openscience/cdk/applications/taverna/test/io/PNGCreationTest.java 2006-12-19 12:45:19 UTC (rev 7502) @@ -0,0 +1,93 @@ +/* $RCSfile$ + * $Author:$ + * $Date:$ + * $Revision:$ + * + * Copyright (C) 2006 by Mario Baseda <mar...@us...> + * + * 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 org.openscience.cdk.applications.taverna.test.io; + +import java.io.FileReader; +import java.io.Reader; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Iterator; +import java.util.Map; +import java.io.File; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.embl.ebi.escience.baclava.DataThing; +import org.openscience.cdk.applications.taverna.CMLChemFile; +import org.openscience.cdk.applications.taverna.io.CDKIOReader; +import org.openscience.cdk.applications.taverna.io.Draw2DStructure; +import org.openscience.cdk.applications.taverna.test.CDKTavernaTestCase; +import org.openscience.cdk.applications.taverna.test.CDKTavernaTests; +import org.openscience.cdk.applications.taverna.test.TavernaTestData; +import org.openscience.cdk.applications.taverna.io.CreatePNGWith2DStructures; +import org.openscience.cdk.exception.CDKException; +import org.openscience.cdk.interfaces.IAtomContainer; +import org.openscience.cdk.io.IChemObjectReader; +import org.openscience.cdk.io.MDLReader; +import org.openscience.cdk.tools.manipulator.ChemFileManipulator; + +public class PNGCreationTest extends CDKTavernaTestCase { + private CMLChemFile[] originalData = null; + // inputList which contains a list of the input data for the local workers + private List inputList = null; + // map for the local worker input + private Map inputMap = null; + // map for the local worker result + private Map resultMap = null; +// List which contains the comments of the local worker + private List resultList = null; + public PNGCreationTest(){} + + public static Test suite() { + return new TestSuite(PNGCreationTest.class); + } + + public void test_LocalWorkerPNGCreation()throws CDKException, Exception{ + CreatePNGWith2DStructures test = new CreatePNGWith2DStructures(); + inputList = new ArrayList(); + //originalData = CDKIOReader.readFromSDFile("X:\\test.sdf"); + originalData = TavernaTestData.getCMLChemFile(); + for (int i = 0; i < originalData.length; i++) { + inputList.add(originalData[i]); + } + inputMap = new HashMap(); + inputMap.put(test.inputNames()[0], new DataThing(inputList)); + resultMap = test.execute(inputMap); + resultList = (List)((DataThing)(resultMap.get(test.... [truncated message content] |