cdk-1.2.10/ 40755 0 0 0 11570154753 7376 5ustar 0 0 cdk-1.2.10/doc/ 40755 0 0 0 11570154753 10143 5ustar 0 0 cdk-1.2.10/doc/javadoc/ 40755 0 0 0 11570154753 11552 5ustar 0 0 cdk-1.2.10/doc/refs/ 40755 0 0 0 11570154753 11102 5ustar 0 0 cdk-1.2.10/src/ 40755 0 0 0 11570154753 10165 5ustar 0 0 cdk-1.2.10/src/META-INF/ 40755 0 0 0 11570154753 11325 5ustar 0 0 cdk-1.2.10/src/main/ 40755 0 0 0 11570154753 11111 5ustar 0 0 cdk-1.2.10/src/main/net/ 40755 0 0 0 11570154753 11677 5ustar 0 0 cdk-1.2.10/src/main/net/sf/ 40755 0 0 0 11570154753 12307 5ustar 0 0 cdk-1.2.10/src/main/net/sf/cdk/ 40755 0 0 0 11570154753 13050 5ustar 0 0 cdk-1.2.10/src/main/net/sf/cdk/tools/ 40755 0 0 0 11570154753 14210 5ustar 0 0 cdk-1.2.10/src/main/net/sf/cdk/tools/bibtex/ 40755 0 0 0 11570154753 15465 5ustar 0 0 cdk-1.2.10/src/main/net/sf/cdk/tools/copyright/ 40755 0 0 0 11570154753 16220 5ustar 0 0 cdk-1.2.10/src/main/net/sf/cdk/tools/coverage/ 40755 0 0 0 11570154753 16003 5ustar 0 0 cdk-1.2.10/src/main/net/sf/cdk/tools/doclets/ 40755 0 0 0 11570154753 15645 5ustar 0 0 cdk-1.2.10/src/main/org/ 40755 0 0 0 11570154753 11700 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/ 40755 0 0 0 11570154753 14173 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/ 40755 0 0 0 11570154753 14734 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/annotations/ 40755 0 0 0 11570154753 17271 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/aromaticity/ 40755 0 0 0 11570154753 17261 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/atomtype/ 40755 0 0 0 11570154753 16576 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/atomtype/mapper/ 40755 0 0 0 11570154753 20062 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/charges/ 40755 0 0 0 11570154753 16350 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/config/ 40755 0 0 0 11570154753 16201 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/config/atomtypes/ 40755 0 0 0 11570154753 20226 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/config/data/ 40755 0 0 0 11570154753 17112 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/config/elements/ 40755 0 0 0 11570154753 20015 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/config/fragments/ 40755 0 0 0 11570154753 20167 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/config/isotopes/ 40755 0 0 0 11570154753 20046 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/controller/ 40755 0 0 0 11570154753 17117 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/debug/ 40755 0 0 0 11570154753 16022 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/dict/ 40755 0 0 0 11570154753 15657 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/dict/data/ 40755 0 0 0 11570154753 16570 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/event/ 40755 0 0 0 11570154753 16055 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/exception/ 40755 0 0 0 11570154753 16732 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/fingerprint/ 40755 0 0 0 11570154753 17263 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/formula/ 40755 0 0 0 11570154753 16401 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/formula/rules/ 40755 0 0 0 11570154753 17533 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/geometry/ 40755 0 0 0 11570154753 16567 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/geometry/alignment/ 40755 0 0 0 11570154753 20545 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/geometry/surface/ 40755 0 0 0 11570154753 20217 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/graph/ 40755 0 0 0 11570154753 16035 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/graph/invariant/ 40755 0 0 0 11570154753 20030 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/graph/invariant/exception/ 40755 0 0 0 11570154753 22026 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/graph/matrix/ 40755 0 0 0 11570154753 17341 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/graph/rebond/ 40755 0 0 0 11570154753 17306 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/inchi/ 40755 0 0 0 11570154753 16026 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/index/ 40755 0 0 0 11570154753 16043 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/interfaces/ 40755 0 0 0 11570154753 17057 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/io/ 40755 0 0 0 11570154753 15343 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/io/cml/ 40755 0 0 0 11570154753 16116 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/io/cml/data/ 40755 0 0 0 11570154753 17027 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/io/formats/ 40755 0 0 0 11570154753 17016 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/io/inchi/ 40755 0 0 0 11570154753 16435 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/io/iterator/ 40755 0 0 0 11570154753 17174 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/io/iterator/event/ 40755 0 0 0 11570154753 20315 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/io/listener/ 40755 0 0 0 11570154753 17170 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/io/program/ 40755 0 0 0 11570154753 17012 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/io/pubchemxml/ 40755 0 0 0 11570154753 17507 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/io/random/ 40755 0 0 0 11570154753 16623 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/io/setting/ 40755 0 0 0 11570154753 17020 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/isomorphism/ 40755 0 0 0 11570154753 17305 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/isomorphism/matchers/ 40755 0 0 0 11570154753 21113 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/isomorphism/matchers/smarts/ 40755 0 0 0 11570154753 22424 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/isomorphism/mcss/ 40755 0 0 0 11570154753 20252 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/iupac/ 40755 0 0 0 11570154753 16035 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/iupac/parser/ 40755 0 0 0 11570154753 17331 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/layout/ 40755 0 0 0 11570154753 16251 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/layout/templates/ 40755 0 0 0 11570154753 20247 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/libio/ 40755 0 0 0 11570154753 16032 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/libio/cml/ 40755 0 0 0 11570154753 16605 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/libio/md/ 40755 0 0 0 11570154753 16432 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/math/ 40755 0 0 0 11570154753 15665 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/math/qm/ 40755 0 0 0 11570154753 16302 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/modeling/ 40755 0 0 0 11570154753 16532 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/modeling/builder3d/ 40755 0 0 0 11570154753 20407 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/modeling/builder3d/data/ 40755 0 0 0 11570154753 21320 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/modeling/forcefield/ 40755 0 0 0 11570154753 20634 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/modeling/forcefield/data/ 40755 0 0 0 11570154753 21545 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/nonotify/ 40755 0 0 0 11570154753 16601 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/pharmacophore/ 40755 0 0 0 11570154753 17564 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/protein/ 40755 0 0 0 11570154753 16414 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/protein/data/ 40755 0 0 0 11570154753 17325 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/qsar/ 40755 0 0 0 11570154753 15702 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/qsar/descriptors/ 40755 0 0 0 11570154753 20243 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/qsar/descriptors/atomic/ 40755 0 0 0 11570154753 21517 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/qsar/descriptors/atompair/ 40755 0 0 0 11570154753 22057 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/qsar/descriptors/bond/ 40755 0 0 0 11570154753 21165 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/qsar/descriptors/molecular/ 40755 0 0 0 11570154753 22226 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/qsar/descriptors/protein/ 40755 0 0 0 11570154753 21723 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/qsar/model/ 40755 0 0 0 11570154753 17002 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/qsar/model/R/ 40755 0 0 0 11570154753 17203 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/qsar/model/R2/ 40755 0 0 0 11570154753 17265 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/qsar/model/data/ 40755 0 0 0 11570154753 17713 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/qsar/result/ 40755 0 0 0 11570154753 17220 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/reaction/ 40755 0 0 0 11570154753 16540 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/reaction/mechanism/ 40755 0 0 0 11570154753 20504 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/reaction/type/ 40755 0 0 0 11570154753 17521 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/reaction/type/parameters/ 40755 0 0 0 11570154753 21664 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/renderer/ 40755 0 0 0 11570154753 16542 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/renderer/color/ 40755 0 0 0 11570154753 17660 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/ringsearch/ 40755 0 0 0 11570154753 17061 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/ringsearch/cyclebasis/ 40755 0 0 0 11570154753 21202 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/similarity/ 40755 0 0 0 11570154753 17122 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/smiles/ 40755 0 0 0 11570154753 16230 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/smiles/smarts/ 40755 0 0 0 11570154753 17541 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/smiles/smarts/parser/ 40755 0 0 0 11570154753 21035 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/smiles/smarts/parser/visitor/ 40755 0 0 0 11570154753 22534 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/structgen/ 40755 0 0 0 11570154753 16752 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/structgen/stochastic/ 40755 0 0 0 11570154753 21116 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/structgen/stochastic/operator/ 40755 0 0 0 11570154753 22751 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/templates/ 40755 0 0 0 11570154753 16732 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/templates/saturatedhydrocarbons/ 40755 0 0 0 11570154753 23344 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/tools/ 40755 0 0 0 11570154753 16074 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/tools/diff/ 40755 0 0 0 11570154753 17004 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/tools/diff/tree/ 40755 0 0 0 11570154753 17743 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/tools/features/ 40755 0 0 0 11570154753 17712 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/tools/manipulator/ 40755 0 0 0 11570154753 20427 5ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/validate/ 40755 0 0 0 11570154753 16525 5ustar 0 0 cdk-1.2.10/README100644 0 0 12065 11570154753 10377 0ustar 0 0 CDK - The Chemical Development Kit Copyright 1997-2009 The CDK Development Team License: LGPL v2, see doc/lgpl.license 1. Introduction You are currently reading the README file for the Chemistry Development Project (CDK). This project is hosted under http://cdk.sourceforge.net/ Please refer to these pages for updated information and the latest version of the CDK. The CDK is an open-source library of algorithms for structural chemo- and bioinformatics, implemented in the programming language Java(tm). The library is published under terms of the the GNU Lesser General Public License v2. This has implications on what you can do with sources and binaries of the CDK library. For details, please refer to the file LICENSE, which should have been provided with this distribution. PLEASE NOTE: This is a library of useful data structures and algorithms to manipulate them from the area of structural chemo- and bioinformatics. As such, it is intended for the use by programmers, who wish to save some effort by reusing code. It is not intended for the enduser. If you consider yourself to be more like user, you might not find what you wanted. Please refer to other projects like the JChemPaint project (http://jchempaint.sourceforge.net) or the Jmol project (http://www.jmol.org/) for programs that actually take advantage of the CDK library. 2. Compiling Compiling and jar-ing the software is done with Jakarta's Ant (http://jakarta.apache.org/ant/) 1.7.1 or better and Java 1.5.0 or better: cdk/$ ls build.xml build.xml cdk/$ ant "ant -p" gives a list of possible compilation targets. The default target is 'dist-all', which creates a number of .jar files in the 'dist' directory corresponding to subsets of the CDK functionality. For convenience, one large .jar file containing everything can be created using the target 'dist-large' (using the command "ant dist-large"). This is also created in dist/jar and is typically named something like 'cdk-cvs-20060303.jar'. 2.1 Creating the JavaDoc documentation for the API The JavaDoc documentation for the API describes all of the CDK classes in detail. It functions as the user manual for the CDK, although you should also look at the list of examples and tutorials below. This documentation is created by 'ant' from the Java source code for the CDK as follows: cdk/$ ls javadoc.xml javadoc.xml cdk/$ ant -buildfile javadoc.xml html The documenation is created as a series of .html pages in doc/api. If you use firefox, you can read the documentation using the following command: cdk/$ firefox doc/api/index.html 3. Running tests IMPORTANT: this requires the SVN or Git version of the sources. After you compiled the code, you can do "ant test-all" to run the test suite of non-interactive, automated tests. You might need to copy an appropriate junit.jar into your $ANT_HOME/lib directory or somewhere else in your classpath. Upon "ant dist-all test-dist-all test-all", you should see something like: test: Running org.openscience.cdk.test.CDKTests Tests run: 1065, Failures: 7, Errors: 1, Time elapsed: 27,55 sec As you can see, the vast majority of tests ran successfully, but that there are failures and errors. The $CDK_HOME/reports/results.txt file contains information about the outcome of the tests. Some tests might fail intentionally to mark know issues in CDK. There are also run interactive tests, like the Controller2DTest. In order to try them, you can edit the "run" target in the build.xml file to look like this: Then, a "ant run" should give you a window where you can add bonds to a given structure. Currently, there are more than 2500 test, of which a large part tests the data, datadebug and nonotify classes. 4. Using CDK CDK is a class library intended to be used by other programs. It will not run as a stand-alone program, although it contains some GUI- and command line applications. In order to use the CDK in your program, you need to build the distribution jars by running "ant dist-all". They will end up in $CDK_HOME/dist/jar. Copy all cdk-*.jars as well as all jars from $CDK_HOME/jar to the lib directory of the project for which you intend to have CDK support and use them as you would use any other third party jar. Alternatively, run "ant dist-large" to create a jar cdk-svn-YYYYMMDD.jar in $CDK_HOME/dist/jar. This large jar contains all the CDK code and all third party libraries that code depends on. 5. Examples and tutorials To get started using the CDK, you may be interested in the following websites which contain examples and tutorials: * http://www.chemistry-development-kit.org * http://blue.chem.psu.edu/~rajarshi/code/java * http://www.redbrick.dcu.ie/~noel/CDKJython.html Further examples can also be found in issues of the CDK News: * http://cdknews.org/ cdk-1.2.10/build.props100644 0 0 46 11570154753 11617 0ustar 0 0 # configuration file # version=1.2.10 cdk-1.2.10/build.xml100644 0 0 173627 11570154753 11374 0ustar 0 0 Not skipping doclet run... package org.openscience.cdk.smiles.smarts.parser; /** * * @cdk.module smarts */
Checking copyright info...
cdk-1.2.10/changelog.20060714.txt100644 0 0 15402 11570154753 13107 0ustar 0 0 ===== ChangeLog 20060714 Release ===== Release 20060714 matches the source code from SVN revision 6678. General changes: * new build system that compiles modules one by one to have clear dependencies * more use of @cdk.keyword for the topic index * data files moved from cdk/data to cdk/src/data * updated the FSF address * code clean ups and JavaDoc improvement * many bug fixes and new JUnit tests * removed printf.jar which had a suspicious licence * upgraded log4j version to 1.2.13 * upgraded jgrapht version to 0.6.0 * dependency on gnujaxp has been removed Below is an overview of major changes sorted per module. ==== interfaces ==== * the interfaces are now located in org.openscience.cdk.interfaces * many methods now make use of interfaces instead of implementations: generally a replace if ChemObject by IChemObject * the data classes return interfaces now * the interface cdk.ChemObjectListener is now known as cdk.IChemObjectListener * added an IChemObjectBuilder interface with implementations * IRingSet now extends ISetOfAtomContainers * IChemObject.clone() now declares a 'throws CloneNotSupported' (as is normal in Java) * the API now use the List interface instead of the Vector implementation ==== data (+ data-debug + nonotify) ==== * Added a DefaultChemObjectBuilder for the data classes * Added new set of data classes that debug calls to the classes (data-debug module) * Added new set of data classes that do not trigger ChangedNotification calls (nonotify module) * Added missing serialVersionUID fields to data classes * Mapping now properly implements clone() ==== core ==== * now only depends on interfaces, no longer on the data class implementations * added a constructor CDKException(String message, Throwable cause) * added a number of missing atom types from our lists ==== standard ==== * added DeAromatizationTool which can convert 'aromatic' systems to Kekule systems * removed the deprecated RTools * added a method to calculate double bond equivalents (DBEs) * added some methods to get all paths between 2 atoms and all paths starting from an atom of a given length * added a method to get the actual shortest path between two atoms * added a general IImplementationSpecification which DescriptorSpecification and ReactionSpecification now extend * added getAtomCount() and getBondCount() to manipulators * deprecated the manipulators' getAllInOneAtomContainer() convenience method as they pose a serious performance hit * added a method in GeometryTools to rotate the coordinates of an atom in 3d around a line segment by a specified angle * added an EState atom type matcher ==== render ==== * added option to turn of rendering of reaction boxes * added option to draw CDKConstants.TITLE * added rendering of curly arrows * extended highlighting posibilities: there are now three types of selection: - highlightAtom/Bond with highligh color, for hovering over - selectedPart/selectedPartColor for internally selected part - externalSelectdPart/externalHighlightColor for external selections * added 'compact' mode in which atoms are drawn like squares (like on PubChem) * the renderer now uses cached screen coordinates instead of modifying the atomic coordinates all the time * removed the unmaintained Java3D based 3D renderer ==== io ==== * removed ChemObjectWriter.highestSupportedChemObject() * no longer depends on a specific interfaces implementation * the MDLWriter can now write IChemFile * added a basic Mol2 writer * the MDLReader is now more flexible with corrupt output from other programs * ChemObjectIO.accepts(Object) is deprecated in favor of .accepts(Class) * many chemical file formats were added defined in OpenBabel * the MDLRXNReader now reads atom-atom mappings * IChemFormat now extends IResourceFormat * added the new methods IResourceFormat.getMIMEType(), getFileExtensions() and isXMLBased() * added IChemFormat.getSupportedDataFeatures() * added ReaderFactory.createReader(IChemFormat) and WriterFactory.createWriter(IChemFormat) ==== valencycheck ==== ==== extra ==== * Stereo center detection was refactored out of the SmilesGenerator into BondTools * getAllChemObjects() were added to cdk.tools.manipulators classes * namespace declarations in dictionaries and atom type lists were fixed * added a GridGenerator * added the Tanimoto similarity measure * dictionaries can now be in OWL too, in addition to STMML (part of CML) * the StructureDiagramGenerator no longer deletes E/Z stereochemistry * the AbstractController now allows merging of Atoms * added tool to determine the number of lone pair electrons for an atomtype ==== pdb ==== * REMARK and COMPND are now read from PDB files * mutliple MODEL in PDB files are now read into a ChemSequence * PDBAtom was moved into the cdk.protein.data package * added method PDBStrand.getMonomerNamesInSequentialOrder() * the PDBReader performance was improved by some 30% ==== qsar ==== * descriptors are moved to cdk.qsar.descriptors.molecular and descriptor.atomic * added the Petitjean shape indices descriptor * added Randic's weighted path descriptor * added descriptors for the number of atoms in the longest aliphatic chain, longest chain and largest pi system * added new interfaces IAtomicDescriptor, IBondDescriptor and IMolecularDescriptor * added a few bond descriptors * added Weka to build linear regression models * R-CDK bridge now uses rJava/JRI instead of previous library ==== forcefield ==== * added a line search algorithm for the Wolfe conditions and a cubic interpolation * added MMFF94EnergyFunction.MMFF94EnergyFunction(IAtomContainer) to calculate for force field energy ==== libio_cml (+ qsar_cml + pdb_cml) ==== * Uses Jumbo 5.2 now, with a XOM 1.1 based CMLDOM ==== libio_biojava ==== * added tool to convert a BioJava SymbolList to a CDK IBioPolymer * added customizing of Bond in the ICMLCustomizer API ==== charges ==== * implemented Garsteiger pi charges ==== reaction ==== * added cdk.reaction.IReactionProcess for describing reaction processes * added a set of reaction types found in mass spectroscopy * added a method in ReactionManipulator that returns the mapped ChemObject for a given ChemObject * added a StructureResonanceGenerator that uses known reaction types from cdk.reaction.type ==== smiles ==== * added four missing one char symbol elements in parser: K, U, V and Y * added a DeduceBondSystemTool that is supposed to resolve double bond placement in delocalized systems ==== builder3d ==== ==== experimental ==== * added a ProteinPocket finder algorithm * added a SubstructureFingerprinter (which still lacks a good optimized list of descriptive substructures. Anyone?) * added generator for Murcko fragments cdk-1.2.10/changelog.xml100644 0 0 22537 11570154753 12175 0ustar 0 0 Added a cdk.tools.ProteinBuilderTool to build protein structures Added a AminoAcid class that extends Monomer Added MM2AtomTypeMatcher to cdk BondTools contains a method if a double bond configuration is cis or trans For the embedded component, the menu can be exported and integrated into mparent application Embedded component has own context menu with file related functions Drawing area has a defined size, currently only A4 Menu/Tool/Statusbar can be hidden and by hiding all the editor looks like an viewer When double clicking on embedded drawing panel, new editor/viewer frame pops up with model of exisiting frame Applets for editor and viewer exist Splitting of JCP in editor and viewer as separate applications Added MMFF94AtomTypeMatcher to cdk Deprecated RTools which should be removed in the first release after the next; it's outdated, contains a few bugs, and redundant. Use UniversalIsomorphismTester instead. Fixed copying and matching of aromatic bonds. Fixed broken Junit test when coffein.pdb is read. Corrected way of setting element symbol in PDBAtom. Added an option for flipping a selected molecule horizontally or vertically. Insert from SMILES in JChemPaint now really inserts, instead of adding a new model. Added copy/paste functionality to JChemPaint. Added classes for permuting the order of atoms in an AtomContainer (graph.AtomContainerAtomPermutor) AtomPlacer now draws 180 deg geometry when encountering triple bonds JChemPaint sources reintegrated to applications.jchempaint package Added new method MFAnalyser.getHTMLMolecularFormulaWithCharge() Added new methods SetOfAtomContainers.removeAtomContainer() Added a CDKRXNWriter. Atom type list for PDB atom codes Implemented an iterating (event based) CML reader ReaderFactory now uses the new CDK set io-formats instead of hardcoding the recognized formats The PluginManager now adds the plugin menu to the plugin window Jmol API and IO from CVS HEAD on 10.05 Added AminoAcid templates The libio.cml.Convertor now also accepts AtomContainer Added customization of atom color for Renderer[2D|3D]Model Added the new method CDKPluginInterface.getPluginLicense() Added the new method CDKEditBus.runScript() CML2 from Jumbo 4.6 was uploaded (for Java 1.4 and 1.5) Added rendering of radicals (SingleElectron) Added reading of 'M RAD' from MDL molfiles Added writing and reading of radicals in CML2 Added getRelevantAtomContainer(ChemObject, Bond) to cdk.tools.manipulators Implemented reading of data items from MDL SD files Added cdk.index.CASNumber.calculateCheckBit() Added the new class PDBAtom with field for PDB specific information Added a CML Customizer interface which reduces the CDK module dependency of the libio-cml module Added two new module for outputting data for specific CDK modules: pdb-cml for outputing PDBAtom information, and qsar-cml for outputing QSAR-descriptor information Removed exponential growth of the ChemSequence length. Fixed output of mass number information in MDL files. Fixed problem with UniversalIsomorphism. Under certain conditions extra subgraphs were found, breaking symmetry. Fixed KabschAlignment so that the rotation matrixi, U, is returned properly Fixed junit-test and run-test: missing cdk-data.jar Don't consume Exceptions while writing MDL Removed entry for 'D' in the isotope list; '2H' is still present Fail more informative on (corrupt) MDL files that lack the property block Fixed API detection in CDKPluginManager when distributing change events Fixed returning of SingleElectron's with AtomContainer .getConnectedElectronContainers(Atom) Fixed retaining LonePair's and SingleElectron's when using ConnectivityChecker.partitionIntoMolecules() Fixed showing ElectronContainers in the cdk.apps.swing.ChemObectTree The IteratingMDLReader can now also read MDL molfiles with only one molecule Fixed output of CML2 for reactions with IDs CDK IO is now fully supports InputStream Fixed error in isotope list Fixed reading of Z from CrystClust files AtomPlacer now draws linear geometries for C#C and C=C=C Fixed reading of explicit single bonds in SMILES Fixed false handling of terminal branched groups in Fingerprinter No overlapping atoms in layout Fixed misuse of ready() in MDLReader which cause problems when reading over the internet Moved IsotopeFactory from cdk-standard to the cdk-core module Descriptor.calculate() now returns a DescriptorValue instead of DescriptorResult Removed LoggingTool(boolean) and LoggingTool(Object, boolean) because configuration should be done at application level Renamed ValencyCheckerInterface.calculateMissingHydrogen() to .calculateNumberOfImplicitHydrogens() PDB fields are now read into the new PDBAtom fields instead of the previously used ChemObject properties defined in CDKConstants The cdk.layout.TemplateHandler now uses CML2 files reaction.ReactionBalancer: removed init method, constructor no longer takes a Reaction object, the isBalanced and balance method do so now. Refactored Strand out of Polymer into BioPolymer. cdk-1.2.10/changelog.xsd100644 0 0 7162 11570154753 12150 0ustar 0 0 cdk-1.2.10/doc/lgpl.license100644 0 0 57476 11570154753 12605 0ustar 0 0 GNU LESSER GENERAL PUBLIC LICENSE Version 2.1, February 1999 Copyright (C) 1991, 1999 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. [This is the first released version of the Lesser GPL. It also counts as the successor of the GNU Library Public License, version 2, hence the version number 2.1.] Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public Licenses are intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This license, the Lesser General Public License, applies to some specially designated software packages--typically libraries--of the Free Software Foundation and other authors who decide to use it. You can use it too, but we suggest you first think carefully about whether this license or the ordinary General Public License is the better strategy to use in any particular case, based on the explanations below. When we speak of free software, we are referring to freedom of use, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish); that you receive source code or can get it if you want it; that you can change the software and use pieces of it in new free programs; and that you are informed that you can do these things. To protect your rights, we need to make restrictions that forbid distributors to deny you these rights or to ask you to surrender these rights. These restrictions translate to certain responsibilities for you if you distribute copies of the library or if you modify it. For example, if you distribute copies of the library, whether gratis or for a fee, you must give the recipients all the rights that we gave you. You must make sure that they, too, receive or can get the source code. If you link other code with the library, you must provide complete object files to the recipients, so that they can relink them with the library after making changes to the library and recompiling it. And you must show them these terms so they know their rights. We protect your rights with a two-step method: (1) we copyright the library, and (2) we offer you this license, which gives you legal permission to copy, distribute and/or modify the library. To protect each distributor, we want to make it very clear that there is no warranty for the free library. Also, if the library is modified by someone else and passed on, the recipients should know that what they have is not the original version, so that the original author's reputation will not be affected by problems that might be introduced by others. Finally, software patents pose a constant threat to the existence of any free program. We wish to make sure that a company cannot effectively restrict the users of a free program by obtaining a restrictive license from a patent holder. Therefore, we insist that any patent license obtained for a version of the library must be consistent with the full freedom of use specified in this license. Most GNU software, including some libraries, is covered by the ordinary GNU General Public License. This license, the GNU Lesser General Public License, applies to certain designated libraries, and is quite different from the ordinary General Public License. We use this license for certain libraries in order to permit linking those libraries into non-free programs. When a program is linked with a library, whether statically or using a shared library, the combination of the two is legally speaking a combined work, a derivative of the original library. The ordinary General Public License therefore permits such linking only if the entire combination fits its criteria of freedom. The Lesser General Public License permits more lax criteria for linking other code with the library. We call this license the "Lesser" General Public License because it does Less to protect the user's freedom than the ordinary General Public License. It also provides other free software developers Less of an advantage over competing non-free programs. These disadvantages are the reason we use the ordinary General Public License for many libraries. However, the Lesser license provides advantages in certain special circumstances. For example, on rare occasions, there may be a special need to encourage the widest possible use of a certain library, so that it becomes a de-facto standard. To achieve this, non-free programs must be allowed to use the library. A more frequent case is that a free library does the same job as widely used non-free libraries. In this case, there is little to gain by limiting the free library to free software only, so we use the Lesser General Public License. In other cases, permission to use a particular library in non-free programs enables a greater number of people to use a large body of free software. For example, permission to use the GNU C Library in non-free programs enables many more people to use the whole GNU operating system, as well as its variant, the GNU/Linux operating system. Although the Lesser General Public License is Less protective of the users' freedom, it does ensure that the user of a program that is linked with the Library has the freedom and the wherewithal to run that program using a modified version of the Library. The precise terms and conditions for copying, distribution and modification follow. Pay close attention to the difference between a "work based on the library" and a "work that uses the library". The former contains code derived from the library, whereas the latter must be combined with the library in order to run. GNU LESSER GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any software library or other program which contains a notice placed by the copyright holder or other authorized party saying it may be distributed under the terms of this Lesser General Public License (also called "this License"). Each licensee is addressed as "you". A "library" means a collection of software functions and/or data prepared so as to be conveniently linked with application programs (which use some of those functions and data) to form executables. The "Library", below, refers to any such software library or work which has been distributed under these terms. A "work based on the Library" means either the Library or any derivative work under copyright law: that is to say, a work containing the Library or a portion of it, either verbatim or with modifications and/or translated straightforwardly into another language. (Hereinafter, translation is included without limitation in the term "modification".) "Source code" for a work means the preferred form of the work for making modifications to it. For a library, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the library. Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running a program using the Library is not restricted, and output from such a program is covered only if its contents constitute a work based on the Library (independent of the use of the Library in a tool for writing it). Whether that is true depends on what the Library does and what the program that uses the Library does. 1. You may copy and distribute verbatim copies of the Library's complete source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and distribute a copy of this License along with the Library. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Library or any portion of it, thus forming a work based on the Library, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) The modified work must itself be a software library. b) You must cause the files modified to carry prominent notices stating that you changed the files and the date of any change. c) You must cause the whole of the work to be licensed at no charge to all third parties under the terms of this License. d) If a facility in the modified Library refers to a function or a table of data to be supplied by an application program that uses the facility, other than as an argument passed when the facility is invoked, then you must make a good faith effort to ensure that, in the event an application does not supply such function or table, the facility still operates, and performs whatever part of its purpose remains meaningful. (For example, a function in a library to compute square roots has a purpose that is entirely well-defined independent of the application. Therefore, Subsection 2d requires that any application-supplied function or table used by this function must be optional: if the application does not supply it, the square root function must still compute square roots.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Library, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Library, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Library. In addition, mere aggregation of another work not based on the Library with the Library (or with a work based on the Library) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may opt to apply the terms of the ordinary GNU General Public License instead of this License to a given copy of the Library. To do this, you must alter all the notices that refer to this License, so that they refer to the ordinary GNU General Public License, version 2, instead of to this License. (If a newer version than version 2 of the ordinary GNU General Public License has appeared, then you can specify that version instead if you wish.) Do not make any other change in these notices. Once this change is made in a given copy, it is irreversible for that copy, so the ordinary GNU General Public License applies to all subsequent copies and derivative works made from that copy. This option is useful when you wish to copy part of the code of the Library into a program that is not a library. 4. You may copy and distribute the Library (or a portion or derivative of it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange. If distribution of object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place satisfies the requirement to distribute the source code, even though third parties are not compelled to copy the source along with the object code. 5. A program that contains no derivative of any portion of the Library, but is designed to work with the Library by being compiled or linked with it, is called a "work that uses the Library". Such a work, in isolation, is not a derivative work of the Library, and therefore falls outside the scope of this License. However, linking a "work that uses the Library" with the Library creates an executable that is a derivative of the Library (because it contains portions of the Library), rather than a "work that uses the library". The executable is therefore covered by this License. Section 6 states terms for distribution of such executables. When a "work that uses the Library" uses material from a header file that is part of the Library, the object code for the work may be a derivative work of the Library even though the source code is not. Whether this is true is especially significant if the work can be linked without the Library, or if the work is itself a library. The threshold for this to be true is not precisely defined by law. If such an object file uses only numerical parameters, data structure layouts and accessors, and small macros and small inline functions (ten lines or less in length), then the use of the object file is unrestricted, regardless of whether it is legally a derivative work. (Executables containing this object code plus portions of the Library will still fall under Section 6.) Otherwise, if the work is a derivative of the Library, you may distribute the object code for the work under the terms of Section 6. Any executables containing that work also fall under Section 6, whether or not they are linked directly with the Library itself. 6. As an exception to the Sections above, you may also combine or link a "work that uses the Library" with the Library to produce a work containing portions of the Library, and distribute that work under terms of your choice, provided that the terms permit modification of the work for the customer's own use and reverse engineering for debugging such modifications. You must give prominent notice with each copy of the work that the Library is used in it and that the Library and its use are covered by this License. You must supply a copy of this License. If the work during execution displays copyright notices, you must include the copyright notice for the Library among them, as well as a reference directing the user to the copy of this License. Also, you must do one of these things: a) Accompany the work with the complete corresponding machine-readable source code for the Library including whatever changes were used in the work (which must be distributed under Sections 1 and 2 above); and, if the work is an executable linked with the Library, with the complete machine-readable "work that uses the Library", as object code and/or source code, so that the user can modify the Library and then relink to produce a modified executable containing the modified Library. (It is understood that the user who changes the contents of definitions files in the Library will not necessarily be able to recompile the application to use the modified definitions.) b) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (1) uses at run time a copy of the library already present on the user's computer system, rather than copying library functions into the executable, and (2) will operate properly with a modified version of the library, if the user installs one, as long as the modified version is interface-compatible with the version that the work was made with. c) Accompany the work with a written offer, valid for at least three years, to give the same user the materials specified in Subsection 6a, above, for a charge no more than the cost of performing this distribution. d) If distribution of the work is made by offering access to copy from a designated place, offer equivalent access to copy the above specified materials from the same place. e) Verify that the user has already received a copy of these materials or that you have already sent this user a copy. For an executable, the required form of the "work that uses the Library" must include any data and utility programs needed for reproducing the executable from it. However, as a special exception, the materials to be distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. It may happen that this requirement contradicts the license restrictions of other proprietary libraries that do not normally accompany the operating system. Such a contradiction means you cannot use both them and the Library together in an executable that you distribute. 7. You may place library facilities that are a work based on the Library side-by-side in a single library together with other library facilities not covered by this License, and distribute such a combined library, provided that the separate distribution of the work based on the Library and of the other library facilities is otherwise permitted, and provided that you do these two things: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities. This must be distributed under the terms of the Sections above. b) Give prominent notice with the combined library of the fact that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 8. You may not copy, modify, sublicense, link with, or distribute the Library except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense, link with, or distribute the Library is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 9. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Library or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Library (or any work based on the Library), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Library or works based on it. 10. Each time you redistribute the Library (or any work based on the Library), the recipient automatically receives a license from the original licensor to copy, distribute, link with or modify the Library subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties with this License. 11. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Library at all. For example, if a patent license would not permit royalty-free redistribution of the Library by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Library. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply, and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 12. If the distribution and/or use of the Library is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Library under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 13. The Free Software Foundation may publish revised and/or new versions of the Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Library does not specify a license version number, you may choose any version ever published by the Free Software Foundation. 14. If you wish to incorporate parts of the Library into other free programs whose distribution conditions are incompatible with these, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS cdk-1.2.10/doc/refs/bibtexml.xsd100644 0 0 111172 11570154753 13570 0ustar 0 0 BibteXML bibliography schema Author: Z.W. Hendrikse Version: Adapted from $Revision$ Copyright: GPL An abstract of the work. The authors affiliation. A Table of Contents. Copyright information. Digital Object Identifier number. Key words used for searching or possibly for annotation. The language the document is in. The Library of Congress Call Number, also seen as lib-congress. A location associated with the entry, such as the city in which a conference took place. The Mathematical Reviews number. The price of the document. The physical dimensions of a work. The WWW Universal Resource Locator that points to the item being referenced. This often is used for technical reports to point to the ftp site where the postscript source of the report is located. Category of this bibitem, added by Zeger W. Hendrikse. The bibteXML equivalent of the @article tag. An article from a journal or magazine. Required fields: author, title, journal, year. Optional fields: volume, number, pages, month, note. The bibteXML equivalent of the @book tag. A book with an explicit publisher. Required fields: author or editor, title, publisher, year. Optional fields: volume or number, series, address, edition, month, note. The bibteXML equivalent of the @booklet tag. A work that is printed and bound, but without a named publisher or sponsoring institution. Required fields: title. Optional fields: author, howpublished, address, month, year, note. The bibteXML equivalent of the @conference tag. The same as INPROCEEDINGS, included for Scribe compatibility. The bibteXML equivalent of the @inbook tag. A part of a book, which may be a chapter (or section or publisher or sponsoring institution. Required fields: author or editor, title, chapter and/or pages, publisher, year. Optional fields: fields: volume or number, series, type, address, edition, month, note. The bibteXML equivalent of the @incollection tag. A part of a book having its own title. Required fields: author, title, booktitle, publisher, year. Optional fields: editor, volume or number, series, type, chapter, pages, address, edition, month, note. The bibteXML equivalent of the @inproceedings tag. An article in a conference proceedings. Required fields: author, title, booktitle, year. Optional fields: editor, volume or number, series, pages, address, month, organization, publisher, note. The bibteXML equivalent of the @manual tag. Technical documentation. Required field: title. Optional fields: author, organization, address, edition, month, year, note. The bibteXML equivalent of the @mastersthesis tag. A Master's thesis. Required fields: author, title, school, year. Optional fields: type, address, month, note. The bibteXML equivalent of the @misc tag. Use this type when nothing else fits. Required fields: none. Optional fields: author, title, howpublished, month, year, note. The bibteXML equivalent of the @phdthesis tag. A PhD thesis. Required fields: author, title, school, year. Optional fields: type, address, month, note. The bibteXML equivalent of the @proceedings tag. The proceedings of a conference. Required fields: title, year. Optional fields: editor, volume or number, series, address, month, organization, publisher, note. The bibteXML equivalent of the @techreport tag. A report published by a school or other institution, usually numbered within a series. Required fields: author, title, institution, year. Optional fields: type, number, address, month, note. The bibteXML equivalent of the @unpublished tag. A document having an author and title, but not formally published. Required fields: author, title, note. Optional fields: month, year. Usually the address of the publisher or other type of institution. For major publishing houses, van Leunen recommends omitting the information entirely. For small publishers, on the other hand, you can help the reader by giving the complete address. An annotation. It is not used by the standard bibliography styles, but may be used by others that produce an annotated bibliography. The name(s) of the author(s), in the format described in the LaTeX book. Title of a book, part of which is being cited. See the LaTeX book for how to type titles. For book entries, use the title field instead. A chapter (or section or whatever) number. The database key of the entry being cross referenced. The edition of a book-for example, ``Second''. This should be an ordinal, and should have the first letter capitalized, as shown here; the standard styles convert to lower case when necessary. Name(s) of editor(s), typed as indicated in the LaTeX book. If there is also an author field, then the editor field gives the editor of the book or collection in which the reference appears. How something strange has been published. The first word should be capitalized. The sponsoring institution of a technical report. A journal name. Abbreviations are provided for many journals; see the Local Guide. Used for alphabetizing, cross referencing, and creating a label when the ``author'' information (described in Section [ref: ] is missing. This field should not be confused with the key that appears in the \cite command and at the beginning of the database entry. The month in which the work was published or, for an unpublished work, in which it was written You should use the standard three-letter abbreviation, as described in Appendix B.1.3 of the LaTeX book. As XML Schema supports a special month format, it is decided to allow e.g. 05 (for May) too. Any additional information that can help the reader. The first word should be capitalized. The number of a journal, magazine, technical report, or of a work in a series. An issue of a journal or magazine is usually identified by its volume and number; the organization that issues a technical report usually gives it a number; and sometimes books are given numbers in a named series. The organization that sponsors a conference or that publishes a manual. One or more page numbers or range of numbers, such as 42-111 or 7,41,73-97 or 43+ (the `+" in this last example indicates pages following that don"t form a simple range). To make it easier to maintain Scribe-compatible databases, the standard styles convert a single dash (as in 7-33) to the double dash used in TeX to denote number ranges (as in 7-33). The publisher's name. The name of the school where a thesis was written. The name of a series or set of books. When citing an entire book, the the title field gives its title and an optional series field gives the name of a series or multi-volume set in which the book is published. The work's title, typed as explained in the LaTeX book. The work's title, typed as explained in the LaTeX book. The volume of a journal or multivolume book. The year of publication or, for an unpublished work, the year it was written. Generally it should consist of four numerals, such as 1984. Although the standard styles can handle any year whose last four nonpunctuation characters are numerals, such as `(about 1984)", it is decided here to keep the year limited to four numerals, as such a type is pre-defined in XML Schema. cdk-1.2.10/doc/refs/build.xml100644 0 0 3372 11570154753 13025 0ustar 0 0 cdk-1.2.10/doc/refs/cdknews.bibx100644 0 0 23215 11570154753 13526 0ustar 0 0 Willighagen, E.L. What's 2004 going to bring? CDK News 2004 1 1 3-4 Willighagen, E.L. Submitting articles to CDK News CDK News 2004 1 1 6-7 Willighagen, E.L. Customizing file IO CDK News 2004 1 2 2-4 Steinbeck, C. NMRShiftDB CDK News 2004 1 1 2-3 Kunh, S. Predictor CDK News 2004 1 2 7-8 Hoppe, C. First steps in the implementation of a force field for the CDK package CDK News 2004 1 2 4-5 Helmus, T. Spok - The Spectrum Organisation Kit CDK News 2004 1 2 5-6 Willighagen, E.L. Konqueror web shortcuts to the CDK API CDK News 2004 1 2 8-9 Willighagen, E.L. Communication: ChemNomParse CDK News 2005 2 1 24 Guha, R. Using the CDK as a backend to R CDK News 2005 2 1 2-6 Guha, R. Using R to provide statistical functionality for QSAR modeling in CDK CDK News 2005 2 1 7-13 Willighagen, E.L. and Howard, M. Jmol as 3D viewer for CDK CDK News 2005 2 1 17-20 Willighagen, E.L. The Algorithm and the Implementation CDK News 2005 2 2 46-48 Kuhn, S. Extending www.chemistry-development-kit.org CDK News 2005 2 1 14-16 Bender, A. Representation and use of chemistry in the global eletronic age CDK News 2005 2 1 16-17 O'Boyle, N.M. Accessing the CDK using Python CDK News 2005 2 2 40-42 Apodaca, R. CDKTools: The CDK-Octet Bridge CDK News 2005 2 2 27-34 Murray-Rust, P. The Blue Obelisk CDK News 2005 2 2 43-46 Spjuth, O. and Eklund, M. and Wikberg, E.S. Communication: An Information System for Proteochemometrics CDK News 2005 2 2 54-56 Willighagen, E.L. Development Tools. 1. Unit testing CDK News 2005 2 2 48-51 Nikolova-Jeliazkova, N. Slow fingerprints? CDK News 2005 2 2 34-40 Steinbeck, S. Call for Registration: The CDK 5th Anniversary Workshop CDK News 2005 2 2 54 cdk-1.2.10/doc/refs/cheminf.bibx100644 0 0 121676 11570154753 13533 0ustar 0 0 Bernstein, H.J. Manual RasMol 2.7.2.1 - CPK Colours http://www.openrasmol.org/doc/rasmol.html#cpkcolours Berger, F. and Gritzmann, P. and De Vries, S. Minimum cycle bases for network graphs Algorithmica 2004 1 51-62 Moreau G. and Broto P. The autocorrelation of a topological structure: A new molecular descriptor Nouveau Journal de Chimie 1980 4 359-360 Berger, F. and Gritzmann, P. and De Vries, S. Cyclic Invariants for Molecular Graphs Lehrstuhl f�r Angewandte Geometrie und Diskrete Mathematik, Technische Universit�t M�nchen 2004 http://www-m9.ma.tum.de/dm/cycles/ Bley, K. and Brandt, J. and Dengler, A. and Frank, R. and Ugi, I. Constitutional Formulae generated from Connectivity Information: the Program MDRAW Journal of Chemical Research 1991 2601-2689 Bremser, W. HOSE - A Novel Substructure Code Analytica Chimica Acta 1978 103 355-365 Bremser, W. Expectation Ranges of 13-C NMR Chemical Shifts Magnetic Resonance in Chemistry 1985 23 4 271-275 Burden, F.R. Molecular identification number for substructure searches J. Chem. Inf. Comput. Sci. 1989 29 3 225-227 Burden, F.R. Chemically Intuitive Molecular Index Quant. Struct .-Act. Relat. 1997 16 309-314 Cherkasov, A. Inductive Electronegativity Scale. Iterative Calculation of Inductive Partial Charges J. Chem. Inf. Comput. Sci. 2003 43 2039-2047 Dalby, A. and Nourse, J. G. and Hounshell, W. D. and Gushurst, A. K. and Grier, D. L. and Leland, B. A. and Laufer, J. Description of Several Chemical Structure File Formats Used by Computer Programs Developed at Molecular Design Limited Journal of Chemical Information and Computer Sciences 1992 32 3 244-255 An updated online version of this document can be found on http://www.mdli.com/downloads/public/ctfile/ctfile.jsp Ertl, P. and Rohde, B. and Selzer, P. Fast Calculation of Molecular Polar Surface Area as a Sum of Fragment-Based Contributions and Its Application to the Prediction of Drug Transport Properties J. Med. Chem. 2000 43 20 3714-3717 10.1021/jm000942e Faulon, J. L. Stochastic generator of chemical structure .2. Using simulated annealing to search the space of constitutional isomers Journal of Chemical Information and Computer Sciences 1996 36 4 731-740 Figueras, J. Ring Perception Using Breadth-First Search J. Chem. Inf. Comput Sci. 1996 36 986-991 Gasteiger, J. and Hutchings, M.G. Quantitative Models of Gas-Phase Proton Transfer Reactions Involving Alcohols, Ethers, and their Thio analogs. Correlation Analyses Based on Residual Electronegativity and Effective Polarizability J. Amer. Chem. Soc. 1984 106 6489-6495 Gasteiger, J. A Hierarchy of Structure Representations 3 3219-3288 1980 3 Handbook of Chemoinformatics Gasteiger, J. Gasteiger, J. and Marsili, M. Iterative partial equalization of orbital elektronegativity - a rapid access to atomic charges Tetrahedron 1980 36 3219-3288 Saller, H. Quantitative Emperische Modelle fur Elektronische Effekte in Pi-Systemen und fur die Chemische Reaktivitat Tetrahedron 1985 Thecn. Univ. Munchen Tonnelier, C. and Jauffret, Ph. and Hanser, Th. and Jauffret, Ph. and Kaufmann, G. Machine Learning of generic reactions: 3. An efficient algorithm for maximal common substructure determination Tetrahedron Comput. Methodol. 1990 3 6 351-358 Hanser, Th. Apprentissage automatique de m�thodes de synth�se � partir d'exemples Universit� Louis Pasteur 1993 Strasbourg Hanser, Th. and Jauffret, Ph. and Kaufmann, G. A New Algorithm for Exhaustive Ring Perception in a Molecular Graph J. Chem. Inf. Comput. Sci. 1996 36 1146-1152 Helson, Harold E. Structure Diagram Generation 313-398 Wiley-VCH 1999 13 Reviews in Computational Chemistry Lipkowitz, K. B. and Boyd, D. B. New York Stein, S. and Heller, S. IUPAC Chemical Identifier (IChI) Chemistry International 2001 23 3 http://www.iupac.org/publications/ci/2001/may/project_2000-025-1-050.html Hu, C.Y. and Xu, L. Algorithm for computer perception of topological symmetry Analytical Chimica Acta 1994 295 127 Hu, C.Y. and Xu, L. A New Scheme for Assignment of a Canonical Connection Table J.Chem.Inf.Comput.Sci. 1994 34 840 Chang-Yu Hu and Lu Xu On Highly Discriminating Molecular Topological Index J. Chem. Inf. Comput. Sci. 1996 36 82-90 Hu, C.Y. Computer perception of topological symmetry by all-paths algorithm Chemom.Intell.Lab.Syst. 1999 45 318 Kabsch, W. A Solution for the Best Rotation to Relate Two Sets of Vectors Acta Cryst. 1976 A32 922-923 Kabsch, W. Discussion of Solution for Best Rotation to Relate 2 Sets of Vectors Acta Cryst. 1978 A34 827-828 Katritzky, A.R. and Mu, L. and Lobanov, V.S. and Karelson, M. Correlation of Boiling Points With Molecular Structure. 1. A Training Set of 298 Diverse Organics and a Test Set of 9 Simple Inorganics J. Phys. Chem. 1996 100 10400-10407 Kind, Tobias and Fiehn, Oliver 10.1186/1471-2105-8-105 BMC Bioinformatics 2007 Seven Golden Rules for heuristic filtering of molecular formulas obtained by accurate mass spectrometry 8 2007 Kang, Y.K. and Jhon, M.S. Additivity of Atomic Static Polarizabilities and Dispersion Coefficients Theoretica Chimica Acta 1982 61 41-48 Krause, Stefan and Willighagen, Egon and Steinbeck, Christoph JChemPaint - Using the Collaborative Forces of the Internet to Develop a Free Editor for 2D Chemical Structures Molecules 2000 5 93-98 Marston, C.C. J.Chem.Phys. 1989 91 3571 Molchanova Computer Generation of Molecular Structures by the SMOG Program J.Chem.Inf.Comput.Sci. 1996 36 889 Molodtsov, S.G. Computer-Aided Generation of Molecular Graphs Match 1994 30 213 Morgan, H.L. The Generation of a Unique Machine Description for Chemical Structures - A Technique Developed at Chemical Abstracts Service. J.Chem.Doc. 1965 5 107-113 Nilakantan, R. and Nunn, D.S. and Greenblatt, L. and Walker, G. and Haraki, K. and Mobilio, D. A family of ring system-based structural fragments for use in structure-activity studies: database mining and recursive partitioning. Journal of chemical information and modeling 2006 46 3 1069-1077 Csaszar, F. The Open Source Reader Csaszar, F. 2002 Several articles (for example "The Cathedral and the Bazaar", "Homesteading the Noosphere") on the foundations of the open-source idea, that are highly recommended reading, were written by Eric S. Raymond and can be found on http://www.tuxedo.org/. Further, http://www.opensource.org/ is a web site completely dedicated to the open-source idea. http://www.csaszar.org/interesting/The_Open_Source_Reader.pdf Pearlman, R.S. and Smith, K.M. Metric Validation and the Receptor-Relevant Subspace Concept J. Chem. Inf. Comput. Sci. 1999 39 1 28-35 Murray-Rust, P. and Rzepa, H.S. Chemical markup, XML, and the Worldwide Web. 1. Basic principles Journal of Chemical Information and Computer Sciences 1999 39 6 928-942 Chemical markup language (CML) is an application of XML, the extensible markup language, developed for containing chemical information components within documents.Its design supports interoperability with the XML family of tools and protocols.It provides a base functionality for atomic, molecular, and crystallographic information and allows extensibility for other chemical applications.Legacy files can be imported into CML without information loss and can carry any desired chemical ontology.Some applications of CML (Markush structures, chemical searching) will be discussed in later articles.An XML document type declaration (DTD) for CML is included as a Chart. information Murray-Rust, P. and Rzepa, H.S. Chemical Markup, XML, and the World Wide Web. 4. CML Schema Journal of Chemical Information and Computer Sciences 2003 43 3 757-772 10.1021/ci0256541 Murray-Rust, P. and Rzepa, H.S. STMML. A MARKUP LANGUAGE FOR SCIENTIFIC, TECHNICAL AND MEDICAL PUBLISHING http://www.ch.ic.ac.uk/rzepa/codata2/ Murray-Rust, P. and Rzepa, H.S. and Williamson, M.J. and Willighagen, E.L. Chemical Markup, XML, and the World Wide Web. 5. Applications of Chemical Metadata in RSS Aggregators J. Chem. Inf. Comput. Sci. 2004 44 2 462-469 10.1021/ci034244p SMILES Tutorial http://www.daylight.com/dayhtml/smiles/smiles-intro.html SSMILES Tutorial http://www.daylight.com/dayhtml/smiles/ssmiles.html Von Scholley, A. J. Chem. Inf. Comput. Sci. 1984 24 235-241 Steinbeck, C. SENECA: A platform-independent, distributed, and parallel system for computer-assisted structure elucidation in organic chemistry Journal of Chemical Information and Computer Sciences 2001 41 6 1500-1507 The program package SENECA for Computer-Assisted Structure Elucidation (CASE) of organic molecules is described.SENECA is written completely in the programming language Java and divided into a server, a client, and a gatekeeper part.While the client allows for input of spectroscopic information, the server part performs the actual structure elucidation by stochastically walking through constitution space while optimizing the molecule toward agreement with given spectral properties.The convergence is guided by simulated annealing.The gatekeeper administers a list of server processes, which can be retrieved by the client.The package is completely platform-independent and its server part can be distributed over the Internet or an intranet using a heterogeneous network of almost any number and type of computers, thus allowing for parallel CASE computations on ordinary networks, present in almost any institution.[References: 23] 10.1021/ci000407n Chemical-structure,Natural-products,Spectroscopy,Molecules,Search., Chemistry in Current Contents(R)/Physical, Chemical and Earth,Sciences. Steinbeck, C. and Kuhn, S. and Krause, S. NMRShiftDB - Constructing a Chemical Information System with Open Source Components Journal of Chemical Information and Computer Sciences 2002 43 6 10.1021/ci0341363 Steinbeck, C. and Han, Y. and Kuhn, S, and Horlacher, O. and Luttmann, E. and Willighagen, E. The Chemistry Development Kit (CDK): An Open-Source Java Library for Chemo- and Bioinformatics Journal of Chemical Information and Computer Sciences 2003 43 493-500 10.1021/ci025584y http://www.cdk.org/ Todeschini, R. and Gramatica, P. New 3D Molecular Descriptors: The WHIM theory and QAR Applications Persepectives in Drug Discovery and Design 1998 355-380 Trinijastic, N. Chemical Graph Theory CRC Press 1992 0-8493-4256-2 Wang, R., Gao, Y., and Lai, L. Calculating partition coefficient by atom-additive method Perspectives in Drug Discovery and Design 2000 19 47-66 Wang, R., Fu, Y., and Lai, L. A New Atom-Additive Method for Calculating Partition Coefficients Journal of Chemical Information and Computer Sciences 1997 37 615-621 Weininger, David SMILES, a Chemical Language and Information System. 1. Introduction to Methodology and Encoding Rules Journal of Chemical Information and Computer Sciences 1988 28 1 31-36 Weininger, David and Weininger, Arthur and Weininger, Joseph L. SMILES 2. Algorithm for Generation of Unique SMILES Notation Journal of Chemical Information and Computer Sciences 1989 29 2 97-101 Sharma, V. and Goswami, R. and Madan, A.K. Eccentric Connectivity Index: A Novel Highly Discriminating Topological Descriptor for Structure-Property and Structure-Activity Studies Journal of Chemical Information and Computer Sciences 1997 37 273-282 Wessel, M.D. and Jurs, P.C. and Tolan, J.W. and Muskal, S.M. Prediction of Human Intestinal Absorption of Drug Compounds From Molecular Structure Journal of Chemical Information and Computer Sciences 1998 38 726-735 Stanton, D.T. and Jurs, P.C. Development and Use of Charged Partial Surface Area Structural Descriptors in Computer Assissted Quantitative Structure Property Relationship Studies Analytical Chemistry 1990 62 2323-2329 Hendlich, M. and Rippmann, F. and Bernickel, G. LIGSITE: Automatic and efficient detection of potential small molecule-binding sites in proteins Journal of Molecular Graphics and Modelling 1997 15 359-363 Eisenhaber, F. and Lijnzaad, P. and Argos, P. and Sander, C. and Scharf, M. The Double Cubic Lattice Method: Efficient Approaches to Numerical Integration of Surface Area and Volume and to Dot Surface Contourin gof Molecular Assemblies Journal of Computational Chemistry 1995 16 273-284 Willighagen, E.L. Processing CML Conventions in Java Internet Journal of Chemistry 2001 4 This article describes the first opensource Java implementation of import filters for the Chemical Markup Language (CML). The filters support CML conventions and were tested with two opensource project: Jmol, a 3D molecular viewer, and JChemPaint, a chemical editor. Furthermore, the use of conventions in CML is explained and the reason for using conventions is pointed out. Finally, the implementation is compared with two recently developed techniques for handling CML data. XML, CML, Java World Wide Web Consortium Extensible Markup Language (XML) 1.0 Feb 1998 http://www.w3.org/TR/1998/REC-xml-19980210 Petitjean, M. Applications of the radius-diameter diagram to the classification of topological and geometrical shapes of chemical compounds Journal of Chemical Information and Computer Science 1992 32 331-337 Bath, P.A. and Poirette, A.R. and Willet, P. and Allen, F.H. The Extent of the Relationship between the Graph-Theoretical and the Geometrical Shape Coefficients of Chemical Compounds Journal of Chemical Information and Computer Science 1995 35 714-716 Randic, M. On molecular identification numbers Journal of Chemical Information and Computer Science 1984 24 164-175 Bemis, G.W. and Murcko, M.A. The properties of known drugs. 1. Molecular Frameworks Journal of Medicinal Chemistry 1996 39 2887-2893 Breneman, C.M. and Thompson, T.R. and Rhem, M. and Dung, M. Electron Density Modeling of Large Systems Using the Transferable Atom Equivalent Method Computers and Chemistry 1995 19 161 Breneman, C.M. and Rhem, M. A QSPR Analysis of HPLC Column Capacity Factors for a set of High-Energy Materials Using Electronic Van der Waals Surface Property Descriptors Computed by the Transferable Atom Equivalent Method Journal of Computational Chemistry 1997 18 182-197 Whitehead, C.E. and Sukumar, N. and Breneman, C.M. and Ryan, M.D. Transferable Atom Equivalent Multi-Centered Multipole Expansion Method Journal of Computational Chemistry 2003 24 512-529 Liu, S. and Cao, C. and Li, Z. Approach to Estimation and Prediction for Normal Boiling Point (NBP) of Alkanes Based on a Novel Molecular Distance Edge (MDE) Vector, lambda Journal of Chemical Information and Computer Sciences 1998 38 387-394 Bellester, P.J. and Richards, W.G. Ultrafast shape recognition to search compound databases for similar molecular shapes Journal of Computational Chemistry 2007 28 1711-1723 Ghose, A.K. and Crippen, G.M. Atomic physicochemical parameters for three-dimensional structure-directed quantitative structure-activity relationships. I. Partition coefficients as a measure of hydrophobicity Journal of Computational Chemistry 1986 7 565-577 Ghose, A.K. and Crippen, G.M. Atomic physicochemical parameters for three-dimensional-structure-directed quantitative structure-activity relationships. 2. Modeling dispersive and hydrophobic interactions Journal of Chemical Information and Computer Science 1987 27 21-35 Saller, H. 1985 TU München München Hall, L.H. and Kier, L.B. Electrotopological State Indices for Atom Types: A Novel Combination of Electronic, Topological, and Valence State Information Journal of Chemical Information and Computer Science 1995 35 1039-1045 Butina, D. Performance of Kier-Hall E-state Descriptors in Quantitative Structure Activity Relationship (QSAR) Studies of Multifunctional Molecules Molecules 2004 9 1004-1009 Labute, P. A Widely Applicable Set of Descriptors Journal of Molecular Graphics and Modeling 2000 18 464-477 cdk-1.2.10/javadoc.xml100644 0 0 13243 11570154753 11647 0ustar 0 0 cdk-1.2.10/src/META-INF/applet-core.files100644 0 0 31745 11570154753 14713 0ustar 0 0 javax/vecmath/Point2d.class javax/vecmath/Point2f.class javax/vecmath/Point3d.class javax/vecmath/Point3f.class javax/vecmath/Point4d.class javax/vecmath/Tuple2d.class javax/vecmath/Tuple2f.class javax/vecmath/Tuple3d.class javax/vecmath/Tuple3f.class javax/vecmath/Tuple4d.class javax/vecmath/Vector2d.class javax/vecmath/Vector2f.class javax/vecmath/Vector3d.class org/_3pq/jgrapht/alg/ConnectivityInspector.class org/_3pq/jgrapht/alg/ConnectivityInspector$MyTraversalListener.class org/_3pq/jgrapht/DirectedGraph.class org/_3pq/jgrapht/Edge.class org/_3pq/jgrapht/edge/DefaultEdge.class org/_3pq/jgrapht/edge/DirectedEdge.class org/_3pq/jgrapht/edge/EdgeFactories$AbstractEdgeFactory.class org/_3pq/jgrapht/edge/EdgeFactories$DirectedEdgeFactory.class org/_3pq/jgrapht/edge/EdgeFactories$UndirectedEdgeFactory.class org/_3pq/jgrapht/EdgeFactory.class org/_3pq/jgrapht/edge/UndirectedEdge.class org/_3pq/jgrapht/event/ConnectedComponentTraversalEvent.class org/_3pq/jgrapht/event/EdgeTraversalEvent.class org/_3pq/jgrapht/event/GraphListener.class org/_3pq/jgrapht/event/TraversalListenerAdapter.class org/_3pq/jgrapht/event/TraversalListener.class org/_3pq/jgrapht/event/VertexSetListener.class org/_3pq/jgrapht/event/VertexTraversalEvent.class org/_3pq/jgrapht/graph/AbstractBaseGraph$ArrayListFactory.class org/_3pq/jgrapht/graph/AbstractBaseGraph.class org/_3pq/jgrapht/graph/AbstractBaseGraph$DirectedEdgeContainer.class org/_3pq/jgrapht/graph/AbstractBaseGraph$DirectedSpecifics.class org/_3pq/jgrapht/graph/AbstractBaseGraph$Specifics.class org/_3pq/jgrapht/graph/AbstractBaseGraph$UndirectedEdgeContainer.class org/_3pq/jgrapht/graph/AbstractBaseGraph$UndirectedSpecifics.class org/_3pq/jgrapht/graph/AbstractGraph.class org/_3pq/jgrapht/Graph.class org/_3pq/jgrapht/graph/EdgeListFactory.class org/_3pq/jgrapht/graph/SimpleDirectedGraph.class org/_3pq/jgrapht/graph/SimpleGraph.class org/_3pq/jgrapht/graph/Subgraph.class org/_3pq/jgrapht/graph/UndirectedSubgraph.class org/_3pq/jgrapht/ListenableGraph.class org/_3pq/jgrapht/traverse/AbstractGraphIterator.class org/_3pq/jgrapht/traverse/BreadthFirstIterator.class org/_3pq/jgrapht/traverse/CrossComponentIterator.class org/_3pq/jgrapht/traverse/CrossComponentIterator$DirectedSpecifics.class org/_3pq/jgrapht/traverse/CrossComponentIterator$FlyweightEdgeEvent.class org/_3pq/jgrapht/traverse/CrossComponentIterator$FlyweightVertexEvent.class org/_3pq/jgrapht/traverse/CrossComponentIterator$Specifics.class org/_3pq/jgrapht/traverse/CrossComponentIterator$UndirectedSpecifics.class org/_3pq/jgrapht/traverse/GraphIterator.class org/_3pq/jgrapht/UndirectedGraph.class org/openscience/cdk/applications/jchempaint/applet/JChemPaintAbstractApplet$1.class org/openscience/cdk/applications/jchempaint/applet/JChemPaintAbstractApplet.class org/openscience/cdk/applications/jchempaint/applet/JChemPaintViewerOnlyApplet.class org/openscience/cdk/applications/jchempaint/DrawingPanel.class org/openscience/cdk/applications/jchempaint/JChemPaintModel.class org/openscience/cdk/applications/jchempaint/JChemPaintPanel.class org/openscience/cdk/applications/jchempaint/JChemPaintViewerOnlyPanel.class org/openscience/cdk/applications/jchempaint/JCPLocalizationHandler.class org/openscience/cdk/applications/jchempaint/JCPPropertyHandler.class org/openscience/cdk/applications/plugin/ICDKEditBus.class org/openscience/cdk/applications/swing/JExternalFrame.class org/openscience/cdk/applications/undoredo/AddAtomsAndBondsEdit.class org/openscience/cdk/applications/undoredo/UndoAdapter.class org/openscience/cdk/Atom.class org/openscience/cdk/AtomContainer$AtomIterator.class org/openscience/cdk/AtomContainer.class org/openscience/cdk/AtomContainerSet$AtomContainerIterator.class org/openscience/cdk/AtomContainerSet.class org/openscience/cdk/AtomType.class org/openscience/cdk/Bond$AtomsIterator.class org/openscience/cdk/Bond.class org/openscience/cdk/ChemModel.class org/openscience/cdk/ChemObject.class org/openscience/cdk/config/AtomTypeFactory.class org/openscience/cdk/config/atomtypes/AtomTypeHandler.class org/openscience/cdk/config/atomtypes/AtomTypeReader.class org/openscience/cdk/config/CDKBasedAtomTypeConfigurator.class org/openscience/cdk/config/IAtomTypeConfigurator.class org/openscience/cdk/config/IsotopeFactory.class org/openscience/cdk/config/isotopes/IsotopeHandler.class org/openscience/cdk/config/isotopes/IsotopeReader.class org/openscience/cdk/controller/AbstractController2D.class org/openscience/cdk/controller/Controller2D.class org/openscience/cdk/controller/Controller2DModel.class org/openscience/cdk/controller/SimpleController2D.class org/openscience/cdk/DefaultChemObjectBuilder.class org/openscience/cdk/ElectronContainer.class org/openscience/cdk/Element.class org/openscience/cdk/event/ChemObjectChangeEvent.class org/openscience/cdk/event/ICDKChangeListener.class org/openscience/cdk/exception/CDKException.class org/openscience/cdk/exception/NoSuchAtomTypeException.class org/openscience/cdk/geometry/GeometryTools.class org/openscience/cdk/graph/BFSShortestPath.class org/openscience/cdk/graph/BFSShortestPath$MyBreadthFirstIterator.class org/openscience/cdk/graph/BiconnectivityInspector.class org/openscience/cdk/graph/ConnectivityChecker.class org/openscience/cdk/graph/MoleculeGraphs.class org/openscience/cdk/graph/PathTools.class org/openscience/cdk/interfaces/IAminoAcid.class org/openscience/cdk/interfaces/IAtom.class org/openscience/cdk/interfaces/IAtomContainer.class org/openscience/cdk/interfaces/IAtomContainerSet.class org/openscience/cdk/interfaces/IAtomParity.class org/openscience/cdk/interfaces/IAtomType.class org/openscience/cdk/interfaces/IBioPolymer.class org/openscience/cdk/interfaces/IBond.class org/openscience/cdk/interfaces/IChemFile.class org/openscience/cdk/interfaces/IChemModel.class org/openscience/cdk/interfaces/IChemObjectBuilder.class org/openscience/cdk/interfaces/IChemObjectChangeEvent.class org/openscience/cdk/interfaces/IChemObject.class org/openscience/cdk/interfaces/IChemObjectListener.class org/openscience/cdk/interfaces/IChemSequence.class org/openscience/cdk/interfaces/ICrystal.class org/openscience/cdk/interfaces/IElectronContainer.class org/openscience/cdk/interfaces/IElement.class org/openscience/cdk/interfaces/IIsotope.class org/openscience/cdk/interfaces/ILonePair.class org/openscience/cdk/interfaces/IMapping.class org/openscience/cdk/interfaces/IMolecule.class org/openscience/cdk/interfaces/IMoleculeSet.class org/openscience/cdk/interfaces/IMonomer.class org/openscience/cdk/interfaces/IPDBAtom.class org/openscience/cdk/interfaces/IPDBMonomer.class org/openscience/cdk/interfaces/IPDBPolymer.class org/openscience/cdk/interfaces/IPDBStructure.class org/openscience/cdk/interfaces/IPolymer.class org/openscience/cdk/interfaces/IPseudoAtom.class org/openscience/cdk/interfaces/IReaction.class org/openscience/cdk/interfaces/IReactionSet.class org/openscience/cdk/interfaces/IRing.class org/openscience/cdk/interfaces/IRingSet.class org/openscience/cdk/interfaces/ISingleElectron.class org/openscience/cdk/interfaces/IStrand.class org/openscience/cdk/io/DefaultChemObjectReader.class org/openscience/cdk/io/formats/ABINITFormat.class org/openscience/cdk/io/formats/Aces2Format.class org/openscience/cdk/io/formats/ADFFormat.class org/openscience/cdk/io/formats/AlchemyFormat.class org/openscience/cdk/io/formats/BGFFormat.class org/openscience/cdk/io/formats/BSFormat.class org/openscience/cdk/io/formats/CacaoCartesianFormat.class org/openscience/cdk/io/formats/CacaoInternalFormat.class org/openscience/cdk/io/formats/CACheFormat.class org/openscience/cdk/io/formats/CDKSourceCodeFormat.class org/openscience/cdk/io/formats/Chem3D_Cartesian_1Format.class org/openscience/cdk/io/formats/Chem3D_Cartesian_2Format.class org/openscience/cdk/io/formats/ChemDrawFormat.class org/openscience/cdk/io/formats/ChemtoolFormat.class org/openscience/cdk/io/formats/CIFFormat.class org/openscience/cdk/io/formats/CMLFormat.class org/openscience/cdk/io/formats/CMLRSSFormat.class org/openscience/cdk/io/formats/CRK2DFormat.class org/openscience/cdk/io/formats/CRK3DFormat.class org/openscience/cdk/io/formats/CrystClustFormat.class org/openscience/cdk/io/formats/CTXFormat.class org/openscience/cdk/io/formats/DaltonFormat.class org/openscience/cdk/io/formats/DMol3Format.class org/openscience/cdk/io/formats/DOCK5Format.class org/openscience/cdk/io/formats/FenskeHall_ZMatrixFormat.class org/openscience/cdk/io/formats/FingerprintFormat.class org/openscience/cdk/io/formats/GamessFormat.class org/openscience/cdk/io/formats/Gaussian03Format.class org/openscience/cdk/io/formats/Gaussian90Format.class org/openscience/cdk/io/formats/Gaussian92Format.class org/openscience/cdk/io/formats/Gaussian94Format.class org/openscience/cdk/io/formats/Gaussian95Format.class org/openscience/cdk/io/formats/Gaussian98Format.class org/openscience/cdk/io/formats/GaussianInputFormat.class org/openscience/cdk/io/formats/GhemicalMMFormat.class org/openscience/cdk/io/formats/GhemicalSPMFormat.class org/openscience/cdk/io/formats/GROMOS96Format.class org/openscience/cdk/io/formats/HINFormat.class org/openscience/cdk/io/formats/IChemFormat.class org/openscience/cdk/io/formats/IChemFormatMatcher.class org/openscience/cdk/io/formats/INChIFormat.class org/openscience/cdk/io/formats/INChIPlainTextFormat.class org/openscience/cdk/io/formats/IResourceFormat.class org/openscience/cdk/io/formats/JaguarFormat.class org/openscience/cdk/io/formats/JMEFormat.class org/openscience/cdk/io/formats/MACiEFormat.class org/openscience/cdk/io/formats/MacroModelFormat.class org/openscience/cdk/io/formats/MDLFormat.class org/openscience/cdk/io/formats/MDLRXNFormat.class org/openscience/cdk/io/formats/MDLRXNV3000Format.class org/openscience/cdk/io/formats/MDLV3000Format.class org/openscience/cdk/io/formats/MMODFormat.class org/openscience/cdk/io/formats/Mol2Format.class org/openscience/cdk/io/formats/MOPAC2002Format.class org/openscience/cdk/io/formats/MOPAC7Format.class org/openscience/cdk/io/formats/MOPAC93Format.class org/openscience/cdk/io/formats/MOPAC97Format.class org/openscience/cdk/io/formats/MPQCFormat.class org/openscience/cdk/io/formats/NWChemFormat.class org/openscience/cdk/io/formats/PCModelFormat.class org/openscience/cdk/io/formats/PDBFormat.class org/openscience/cdk/io/formats/PDBMLFormat.class org/openscience/cdk/io/formats/PMPFormat.class org/openscience/cdk/io/formats/POVRayFormat.class org/openscience/cdk/io/formats/PQSChemFormat.class org/openscience/cdk/io/formats/PubChemFormat.class org/openscience/cdk/io/formats/QChemFormat.class org/openscience/cdk/io/formats/RawCopyFormat.class org/openscience/cdk/io/formats/SDFFormat.class org/openscience/cdk/io/formats/ShelXFormat.class org/openscience/cdk/io/formats/SMARTSFormat.class org/openscience/cdk/io/formats/SMILESFIXFormat.class org/openscience/cdk/io/formats/SMILESFormat.class org/openscience/cdk/io/formats/SpartanFormat.class org/openscience/cdk/io/formats/SVGFormat.class org/openscience/cdk/io/formats/SybylDescriptorFormat.class org/openscience/cdk/io/formats/TinkerMM2Format.class org/openscience/cdk/io/formats/TinkerXYZFormat.class org/openscience/cdk/io/formats/TurboMoleFormat.class org/openscience/cdk/io/formats/UniChemXYZFormat.class org/openscience/cdk/io/formats/VASPFormat.class org/openscience/cdk/io/formats/ViewmolFormat.class org/openscience/cdk/io/formats/XEDFormat.class org/openscience/cdk/io/formats/XYZFormat.class org/openscience/cdk/io/formats/YasaraFormat.class org/openscience/cdk/io/formats/ZindoFormat.class org/openscience/cdk/io/formats/ZMatrixFormat.class org/openscience/cdk/io/IChemObjectIO.class org/openscience/cdk/io/IChemObjectReader.class org/openscience/cdk/io/listener/IChemObjectIOListener.class org/openscience/cdk/io/MDLReader.class org/openscience/cdk/io/ReaderFactory.class org/openscience/cdk/io/setting/BooleanIOSetting.class org/openscience/cdk/io/setting/IOSetting.class org/openscience/cdk/Isotope.class org/openscience/cdk/Molecule.class org/openscience/cdk/MoleculeSet.class org/openscience/cdk/renderer/AbstractRenderer2D.class org/openscience/cdk/renderer/color/CDK2DAtomColors.class org/openscience/cdk/renderer/color/IAtomColorer.class org/openscience/cdk/renderer/Renderer2D.class org/openscience/cdk/renderer/Renderer2DModel.class org/openscience/cdk/renderer/SimpleRenderer2D.class org/openscience/cdk/Ring.class org/openscience/cdk/ringsearch/cyclebasis/CycleBasis.class org/openscience/cdk/ringsearch/cyclebasis/SimpleCycleBasis$AuxiliaryGraph.class org/openscience/cdk/ringsearch/cyclebasis/SimpleCycleBasis.class org/openscience/cdk/ringsearch/cyclebasis/SimpleCycle.class org/openscience/cdk/ringsearch/SSSRFinder.class org/openscience/cdk/RingSet.class org/openscience/cdk/tools/HydrogenAdder.class org/openscience/cdk/tools/IDeduceBondOrderTool.class org/openscience/cdk/tools/IValencyChecker.class org/openscience/cdk/tools/LoggingTool.class org/openscience/cdk/tools/manipulator/AtomContainerSetManipulator.class org/openscience/cdk/tools/manipulator/ChemModelManipulator.class org/openscience/cdk/tools/manipulator/MoleculeSetManipulator.class org/openscience/cdk/tools/manipulator/RingSetManipulator.class org/openscience/cdk/tools/ValencyChecker.class org/openscience/cdk/validate/ProblemMarker.class cdk-1.2.10/src/META-INF/applet-editor-opts.files100644 0 0 43257 11570154753 16235 0ustar 0 0 data/templates/adamantane.cml data/templates/cubane.cml data/templates/diamantane.cml data/templates/templates.list gnu/xml/aelfred2/JAXPFactory.class gnu/xml/aelfred2/JAXPFactory$JaxpParser.class gnu/xml/aelfred2/SAXDriver.class gnu/xml/aelfred2/XmlParser.class gnu/xml/aelfred2/XmlReader.class gnu/xml/pipeline/EventConsumer.class gnu/xml/pipeline/EventFilter.class gnu/xml/pipeline/NSFilter.class gnu/xml/pipeline/ValidationConsumer.class gnu/xml/pipeline/WellFormednessFilter.class gnu/xml/pipeline/XIncludeFilter.class javax/vecmath/Point2d.class javax/vecmath/Point2f.class javax/vecmath/Point3d.class javax/vecmath/Tuple2d.class javax/vecmath/Tuple2f.class javax/vecmath/Tuple3d.class javax/vecmath/Tuple3f.class javax/vecmath/Vector2d.class javax/vecmath/Vector2f.class javax/vecmath/Vector3d.class javax/vecmath/Vector3f.class META-INF/services/javax.xml.parsers.SAXParserFactory META-INF/services/javax.xml.parsers.SAXParserFactory META-INF/services/javax.xml.parsers.SAXParserFactory META-INF/services/javax.xml.parsers.SAXParserFactory org/_3pq/jgrapht/alg/ConnectivityInspector.class org/_3pq/jgrapht/alg/ConnectivityInspector$MyTraversalListener.class org/_3pq/jgrapht/DirectedGraph.class org/_3pq/jgrapht/Edge.class org/_3pq/jgrapht/edge/DefaultEdge.class org/_3pq/jgrapht/edge/DirectedEdge.class org/_3pq/jgrapht/edge/EdgeFactories$AbstractEdgeFactory.class org/_3pq/jgrapht/edge/EdgeFactories$DirectedEdgeFactory.class org/_3pq/jgrapht/edge/EdgeFactories$UndirectedEdgeFactory.class org/_3pq/jgrapht/EdgeFactory.class org/_3pq/jgrapht/edge/UndirectedEdge.class org/_3pq/jgrapht/event/ConnectedComponentTraversalEvent.class org/_3pq/jgrapht/event/EdgeTraversalEvent.class org/_3pq/jgrapht/event/GraphListener.class org/_3pq/jgrapht/event/TraversalListenerAdapter.class org/_3pq/jgrapht/event/TraversalListener.class org/_3pq/jgrapht/event/VertexSetListener.class org/_3pq/jgrapht/event/VertexTraversalEvent.class org/_3pq/jgrapht/graph/AbstractBaseGraph.class org/_3pq/jgrapht/graph/AbstractBaseGraph$DirectedEdgeContainer.class org/_3pq/jgrapht/graph/AbstractBaseGraph$DirectedSpecifics.class org/_3pq/jgrapht/graph/AbstractBaseGraph$Specifics.class org/_3pq/jgrapht/graph/AbstractBaseGraph$UndirectedEdgeContainer.class org/_3pq/jgrapht/graph/AbstractBaseGraph$UndirectedSpecifics.class org/_3pq/jgrapht/graph/AbstractGraph.class org/_3pq/jgrapht/Graph.class org/_3pq/jgrapht/graph/SimpleDirectedGraph.class org/_3pq/jgrapht/graph/SimpleGraph.class org/_3pq/jgrapht/graph/Subgraph.class org/_3pq/jgrapht/graph/UndirectedSubgraph.class org/_3pq/jgrapht/ListenableGraph.class org/_3pq/jgrapht/traverse/AbstractGraphIterator.class org/_3pq/jgrapht/traverse/BreadthFirstIterator.class org/_3pq/jgrapht/traverse/BreadthFirstIterator$SimpleQueue.class org/_3pq/jgrapht/traverse/CrossComponentIterator.class org/_3pq/jgrapht/traverse/CrossComponentIterator$DirectedSpecifics.class org/_3pq/jgrapht/traverse/CrossComponentIterator$FlyweightEdgeEvent.class org/_3pq/jgrapht/traverse/CrossComponentIterator$FlyweightVertexEvent.class org/_3pq/jgrapht/traverse/CrossComponentIterator$SimpleContainer.class org/_3pq/jgrapht/traverse/CrossComponentIterator$Specifics.class org/_3pq/jgrapht/traverse/CrossComponentIterator$UndirectedSpecifics.class org/_3pq/jgrapht/traverse/GraphIterator.class org/_3pq/jgrapht/UndirectedGraph.class org/openscience/cdk/applications/jchempaint/action/AboutAction.class org/openscience/cdk/applications/jchempaint/action/AddHydrogenAction.class org/openscience/cdk/applications/jchempaint/action/AdjustBondOrdersAction.class org/openscience/cdk/applications/jchempaint/action/ChangeAtomSymbolAction.class org/openscience/cdk/applications/jchempaint/action/ChangeIsotopeAction.class org/openscience/cdk/applications/jchempaint/action/ChemAction.class org/openscience/cdk/applications/jchempaint/action/ChemAction$PTDialogChangeListener.class org/openscience/cdk/applications/jchempaint/action/CleanupAction.class org/openscience/cdk/applications/jchempaint/action/CloseAction.class org/openscience/cdk/applications/jchempaint/action/CreateReactionAction.class org/openscience/cdk/applications/jchempaint/action/CreateSmilesAction.class org/openscience/cdk/applications/jchempaint/action/EditAction.class org/openscience/cdk/applications/jchempaint/action/EditChemObjectPropsAction.class org/openscience/cdk/applications/jchempaint/action/ExitAction.class org/openscience/cdk/applications/jchempaint/action/ExportAction.class org/openscience/cdk/applications/jchempaint/action/ExportCompChemAction.class org/openscience/cdk/applications/jchempaint/action/HelpAction.class org/openscience/cdk/applications/jchempaint/action/InfoAction.class org/openscience/cdk/applications/jchempaint/action/InsertSmilesAction.class org/openscience/cdk/applications/jchempaint/action/JCPAction.class org/openscience/cdk/applications/jchempaint/action/LicenseAction.class org/openscience/cdk/applications/jchempaint/action/MenuBarAction.class org/openscience/cdk/applications/jchempaint/action/ModelPropsAction.class org/openscience/cdk/applications/jchempaint/action/ModifyDisplaySettingsAction.class org/openscience/cdk/applications/jchempaint/action/ModifyGeneralSettingsAction.class org/openscience/cdk/applications/jchempaint/action/NewAction.class org/openscience/cdk/applications/jchempaint/action/OpenAction.class org/openscience/cdk/applications/jchempaint/action/PreferencesAction.class org/openscience/cdk/applications/jchempaint/action/PrintAction.class org/openscience/cdk/applications/jchempaint/action/SaveAction.class org/openscience/cdk/applications/jchempaint/action/SaveAsAction.class org/openscience/cdk/applications/jchempaint/action/StatusBarAction.class org/openscience/cdk/applications/jchempaint/action/ToolBarAction.class org/openscience/cdk/applications/jchempaint/action/ValidateAction.class org/openscience/cdk/applications/jchempaint/action/ZoomAction.class org/openscience/cdk/applications/jchempaint/applet/JChemPaintAbstractApplet.class org/openscience/cdk/applications/jchempaint/applet/JChemPaintEditorApplet.class org/openscience/cdk/applications/jchempaint/dialogs/InfoDialog.class org/openscience/cdk/applications/jchempaint/dialogs/PluginInfoDialog.class org/openscience/cdk/applications/jchempaint/dialogs/PTDialog.class org/openscience/cdk/applications/jchempaint/dnd/JCPTransferHandler.class org/openscience/cdk/applications/jchempaint/DrawingPanel.class org/openscience/cdk/applications/jchempaint/io/JCPFileView.class org/openscience/cdk/applications/jchempaint/JChemPaintEditorPanel.class org/openscience/cdk/applications/jchempaint/JChemPaintMenuBar.class org/openscience/cdk/applications/jchempaint/JChemPaintModel.class org/openscience/cdk/applications/jchempaint/JChemPaintPanel.class org/openscience/cdk/applications/jchempaint/JChemPaintPopupMenu.class org/openscience/cdk/applications/jchempaint/JCPLocalizationHandler.class org/openscience/cdk/applications/jchempaint/JCPPropertyHandler.class org/openscience/cdk/applications/jchempaint/resources/small-bin/benzene.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/benzene.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/bond.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/bond.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/cleanup.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/cleanup.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/down_bond.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/down_bond.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/element.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/element.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/enterelement.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/eraser.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/eraser.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/heptagon.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/heptagon.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/hexagon.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/hexagon.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/lasso.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/lasso.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/min_one.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/min_one.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/move.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/move.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/octagon.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/octagon.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/pentagon.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/pentagon.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/plus_one.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/plus_one.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/redo.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/square.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/square.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/symbol.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/symbol.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/triangle.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/triangle.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/undo.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/up_bond.gif org/openscience/cdk/applications/jchempaint/resources/small-bin/up_bond.gif org/openscience/cdk/applications/jchempaint/resources/text/JChemPaintResources.properties org/openscience/cdk/applications/jchempaint/resources/text/JChemPaintResources.properties org/openscience/cdk/applications/jchempaint/resources/text/JCPBundle_de.properties org/openscience/cdk/applications/jchempaint/resources/text/JCPBundle_es.properties org/openscience/cdk/applications/jchempaint/resources/text/JCPBundle_fr.properties org/openscience/cdk/applications/jchempaint/resources/text/JCPBundle_nl.properties org/openscience/cdk/applications/jchempaint/resources/text/JCPBundle_pl.properties org/openscience/cdk/applications/jchempaint/resources/text/JCPBundle_pt_BR.properties org/openscience/cdk/applications/jchempaint/resources/text/JCPBundle.properties org/openscience/cdk/applications/jchempaint/resources/text/JCPGUI_stable.properties org/openscience/cdk/applications/jchempaint/resources/text/JCPGUI_applet.properties org/openscience/cdk/applications/jchempaint/resources/text/JCPShort_Cuts.properties org/openscience/cdk/applications/jchempaint/StatusBar.class org/openscience/cdk/applications/jchempaint/StringHelper.class org/openscience/cdk/applications/jchempaint/ToolBarMaker$1.class org/openscience/cdk/applications/jchempaint/ToolBarMaker.class org/openscience/cdk/applications/plugin/CDKEditBus.class org/openscience/cdk/applications/swing/editor/AtomEditor.class org/openscience/cdk/applications/swing/editor/ChemObjectEditor.class org/openscience/cdk/applications/swing/editor/PseudoAtomEditor.class org/openscience/cdk/applications/swing/editor/ReactionEditor.class org/openscience/cdk/applications/swing/FieldTablePanel.class org/openscience/cdk/applications/swing/PeriodicTablePanel.class org/openscience/cdk/applications/swing/PeriodicTablePanel$ElementButtonAction.class org/openscience/cdk/applications/swing/PeriodicTablePanel$ElementButton.class org/openscience/cdk/Atom.class org/openscience/cdk/AtomContainer.class org/openscience/cdk/AtomEnumeration.class org/openscience/cdk/AtomType.class org/openscience/cdk/Bond.class org/openscience/cdk/ChemFile.class org/openscience/cdk/ChemModel.class org/openscience/cdk/ChemObject.class org.openscience.cdk.interfaces.ChemObjectListener.class org/openscience/cdk/ChemSequence.class org/openscience/cdk/config/AtomTypeFactory.class org/openscience/cdk/config/data/isotopes.xml org/openscience/cdk/config/IsotopeFactory.class org/openscience/cdk/config/isotopes/IsotopeHandler.class org/openscience/cdk/config/isotopes/IsotopeReader.class org/openscience/cdk/controller/CDKPopupMenu.class org/openscience/cdk/controller/Controller2D.class org/openscience/cdk/controller/Controller2DModel.class org/openscience/cdk/controller/PopupController2D.class org/openscience/cdk/Crystal.class org/openscience/cdk/ElectronContainer.class org/openscience/cdk/Element.class org/openscience/cdk/event/CDKChangeListener.class org/openscience/cdk/event/ChemObjectChangeEvent.class org/openscience/cdk/exception/CDKException.class org/openscience/cdk/exception/NoSuchAtomTypeException.class org/openscience/cdk/geometry/GeometryTools.class org/openscience/cdk/graph/BFSShortestPath.class org/openscience/cdk/graph/BFSShortestPath$MyBreadthFirstIterator.class org/openscience/cdk/graph/BiconnectivityInspector.class org/openscience/cdk/graph/ConnectivityChecker.class org/openscience/cdk/graph/MoleculeGraphs.class org/openscience/cdk/graph/PathTools.class org/openscience/cdk/graph/SpanningTree.class org/openscience/cdk/io/ChemObjectIO.class org/openscience/cdk/io/ChemObjectReader.class org/openscience/cdk/io/ChemObjectWriter.class org/openscience/cdk/io/cml/cdopi/CDOInterface.class org/openscience/cdk/io/cml/ChemFileCDO.class org/openscience/cdk/io/cml/CMLCoreModule.class org/openscience/cdk/io/cml/CMLErrorHandler.class org/openscience/cdk/io/cml/CMLHandler.class org/openscience/cdk/io/cml/CMLResolver.class org/openscience/cdk/io/cml/CMLStack.class org/openscience/cdk/io/cml/ModuleInterface.class org/openscience/cdk/io/CMLReader.class org/openscience/cdk/io/DefaultChemObjectReader.class org/openscience/cdk/io/formats/ChemFormat.class org/openscience/cdk/io/listener/ChemObjectIOListener.class org/openscience/cdk/io/MDLReader.class org/openscience/cdk/isomorphism/matchers/QueryAtom.class org/openscience/cdk/isomorphism/matchers/QueryAtomContainer.class org/openscience/cdk/isomorphism/mcss/RGraph.class org/openscience/cdk/isomorphism/mcss/RMap.class org/openscience/cdk/isomorphism/mcss/RNode.class org/openscience/cdk/isomorphism/UniversalIsomorphismTester.class org/openscience/cdk/Isotope.class org/openscience/cdk/layout/AtomPlacer$1.class org/openscience/cdk/layout/AtomPlacer.class org/openscience/cdk/layout/HydrogenPlacer.class org/openscience/cdk/layout/OverlapResolver.class org/openscience/cdk/layout/RingPlacer.class org/openscience/cdk/layout/StructureDiagramGenerator.class org/openscience/cdk/layout/TemplateHandler.class org/openscience/cdk/LonePair.class org/openscience/cdk/Mapping.class org/openscience/cdk/Molecule.class org/openscience/cdk/PseudoAtom.class org/openscience/cdk/Reaction.class org/openscience/cdk/renderer/color/AtomColorer.class org/openscience/cdk/renderer/color/CDK2DAtomColors.class org/openscience/cdk/renderer/Renderer2D.class org/openscience/cdk/renderer/Renderer2DModel.class org/openscience/cdk/Ring.class org/openscience/cdk/ringsearch/AllRingsFinder.class org/openscience/cdk/ringsearch/cyclebasis/CycleBasis.class org/openscience/cdk/ringsearch/cyclebasis/SimpleCycleBasis$AuxiliaryGraph.class org/openscience/cdk/ringsearch/cyclebasis/SimpleCycleBasis.class org/openscience/cdk/ringsearch/cyclebasis/SimpleCycle.class org/openscience/cdk/ringsearch/RingPartitioner.class org/openscience/cdk/ringsearch/SSSRFinder.class org/openscience/cdk/ringsearch/Path.class org/openscience/cdk/ringsearch/Queue.class org/openscience/cdk/smiles/SmilesGenerator$1.class org/openscience/cdk/smiles/SmilesGenerator$BrokenBond.class org/openscience/cdk/smiles/SmilesGenerator.class org/openscience/cdk/RingSet.class org/openscience/cdk/SetOfAtomContainers.class org/openscience/cdk/SetOfMolecules.class org/openscience/cdk/SingleElectron.class org/openscience/cdk/tools/HydrogenAdder.class org/openscience/cdk/tools/LoggingTool.class org/openscience/cdk/tools/manipulator/ChemFileManipulator.class org/openscience/cdk/tools/manipulator/ChemModelManipulator.class org/openscience/cdk/tools/manipulator/ChemSequenceManipulator.class org/openscience/cdk/tools/manipulator/RingSetManipulator.class org/openscience/cdk/tools/manipulator/SetOfAtomContainersManipulator.class org/openscience/cdk/tools/manipulator/SetOfMoleculesManipulator.class org/openscience/cdk/tools/SaturationChecker.class org/openscience/cdk/tools/ValencyChecker.class org/openscience/cdk/tools/ValencyCheckerInterface.class org/openscience/cdk/tools/DeAromatizationTool.class org/openscience/cdk/tools/ElementComparator.class org/openscience/cdk/validate/ProblemMarker.class org/openscience/cdk/validate/ValidatorInterface.class org/xml/sax/ext/Attributes2.class org/xml/sax/ext/DefaultHandler2.class org/xml/sax/ext/EntityResolver2.class org/openscience/cdk/config/ElementPTFactory.class org/openscience/cdk/config/elements/ElementPTReader.class org/openscience/cdk/config/elements/ElementPTHandler.class org/openscience/cdk/PeriodicTableElement.class org/openscience/cdk/config/elements/ElementPTReader.class org/openscience/cdk/config/elements/ElementPTHandler.class org/openscience/cdk/applications/swing/PeriodicTablePanel$BackAction.class org/openscience/cdk/isomorphism/matchers/QueryBond.class org/openscience/cdk/applications/undoredo/ChangeCoordsEdit.class org/openscience/cdk/applications/undoredo/ChangeAtomSymbolEdit.class org/openscience/cdk/applications/undoredo/CleanUpEdit.class org/openscience/cdk/applications/swing/periodicTable_Mendeleev.jpg org/openscience/cdk/config/CDKBasedAtomTypeConfigurator.class org/openscience/cdk/config/atomtypes/AtomTypeReader.class org/openscience/cdk/config/atomtypes/AtomTypeHandler.class org/openscience/cdk/config/AtomTypeConfigurator.class org/openscience/cdk/config/data/chemicalElements.xml org/openscience/cdk/config/data/structgen_atomtypes.xml cdk-1.2.10/src/META-INF/applet-editor.files100644 0 0 42043 11570154753 15242 0ustar 0 0 javax/vecmath/Point2d.class javax/vecmath/Point2f.class javax/vecmath/Point3d.class javax/vecmath/Point3f.class javax/vecmath/Point4d.class javax/vecmath/Tuple2d.class javax/vecmath/Tuple2f.class javax/vecmath/Tuple3d.class javax/vecmath/Tuple3f.class javax/vecmath/Tuple4d.class javax/vecmath/Vector2d.class javax/vecmath/Vector2f.class javax/vecmath/Vector3d.class org/_3pq/jgrapht/alg/ConnectivityInspector.class org/_3pq/jgrapht/alg/ConnectivityInspector$MyTraversalListener.class org/_3pq/jgrapht/DirectedGraph.class org/_3pq/jgrapht/Edge.class org/_3pq/jgrapht/edge/DefaultEdge.class org/_3pq/jgrapht/edge/DirectedEdge.class org/_3pq/jgrapht/edge/EdgeFactories$AbstractEdgeFactory.class org/_3pq/jgrapht/edge/EdgeFactories$DirectedEdgeFactory.class org/_3pq/jgrapht/edge/EdgeFactories$UndirectedEdgeFactory.class org/_3pq/jgrapht/EdgeFactory.class org/_3pq/jgrapht/edge/UndirectedEdge.class org/_3pq/jgrapht/event/ConnectedComponentTraversalEvent.class org/_3pq/jgrapht/event/EdgeTraversalEvent.class org/_3pq/jgrapht/event/GraphListener.class org/_3pq/jgrapht/event/TraversalListenerAdapter.class org/_3pq/jgrapht/event/TraversalListener.class org/_3pq/jgrapht/event/VertexSetListener.class org/_3pq/jgrapht/event/VertexTraversalEvent.class org/_3pq/jgrapht/graph/AbstractBaseGraph$ArrayListFactory.class org/_3pq/jgrapht/graph/AbstractBaseGraph.class org/_3pq/jgrapht/graph/AbstractBaseGraph$DirectedEdgeContainer.class org/_3pq/jgrapht/graph/AbstractBaseGraph$DirectedSpecifics.class org/_3pq/jgrapht/graph/AbstractBaseGraph$Specifics.class org/_3pq/jgrapht/graph/AbstractBaseGraph$UndirectedEdgeContainer.class org/_3pq/jgrapht/graph/AbstractBaseGraph$UndirectedSpecifics.class org/_3pq/jgrapht/graph/AbstractGraph.class org/_3pq/jgrapht/Graph.class org/_3pq/jgrapht/graph/EdgeListFactory.class org/_3pq/jgrapht/graph/SimpleDirectedGraph.class org/_3pq/jgrapht/graph/SimpleGraph.class org/_3pq/jgrapht/graph/Subgraph.class org/_3pq/jgrapht/graph/UndirectedSubgraph.class org/_3pq/jgrapht/ListenableGraph.class org/_3pq/jgrapht/traverse/AbstractGraphIterator.class org/_3pq/jgrapht/traverse/BreadthFirstIterator.class org/_3pq/jgrapht/traverse/CrossComponentIterator.class org/_3pq/jgrapht/traverse/CrossComponentIterator$DirectedSpecifics.class org/_3pq/jgrapht/traverse/CrossComponentIterator$FlyweightEdgeEvent.class org/_3pq/jgrapht/traverse/CrossComponentIterator$FlyweightVertexEvent.class org/_3pq/jgrapht/traverse/CrossComponentIterator$Specifics.class org/_3pq/jgrapht/traverse/CrossComponentIterator$UndirectedSpecifics.class org/_3pq/jgrapht/traverse/GraphIterator.class org/_3pq/jgrapht/UndirectedGraph.class org/openscience/cdk/applications/jchempaint/action/AboutAction.class org/openscience/cdk/applications/jchempaint/action/AddHydrogenAction.class org/openscience/cdk/applications/jchempaint/action/AdjustBondOrdersAction.class org/openscience/cdk/applications/jchempaint/action/ChangeAtomSymbolAction.class org/openscience/cdk/applications/jchempaint/action/ChangeIsotopeAction.class org/openscience/cdk/applications/jchempaint/action/ChemAction.class org/openscience/cdk/applications/jchempaint/action/CleanupAction.class org/openscience/cdk/applications/jchempaint/action/ConvertToPseudoAtomAction.class org/openscience/cdk/applications/jchempaint/action/CreateReactionAction.class org/openscience/cdk/applications/jchempaint/action/CreateSmilesAction.class org/openscience/cdk/applications/jchempaint/action/EditAction.class org/openscience/cdk/applications/jchempaint/action/EditChemObjectPropsAction.class org/openscience/cdk/applications/jchempaint/action/ElementAction.class org/openscience/cdk/applications/jchempaint/action/FlipAction.class org/openscience/cdk/applications/jchempaint/action/HelpAction.class org/openscience/cdk/applications/jchempaint/action/InsertSmilesAction.class org/openscience/cdk/applications/jchempaint/action/InsertStructureAction.class org/openscience/cdk/applications/jchempaint/action/JCPAction.class org/openscience/cdk/applications/jchempaint/action/LicenseAction.class org/openscience/cdk/applications/jchempaint/action/MenuBarAction.class org/openscience/cdk/applications/jchempaint/action/ModelPropsAction.class org/openscience/cdk/applications/jchempaint/action/ModifyDisplaySettingsAction.class org/openscience/cdk/applications/jchempaint/action/NewAction.class org/openscience/cdk/applications/jchempaint/action/RedoAction.class org/openscience/cdk/applications/jchempaint/action/StatusBarAction.class org/openscience/cdk/applications/jchempaint/action/ToolBarAction.class org/openscience/cdk/applications/jchempaint/action/UndoAction.class org/openscience/cdk/applications/jchempaint/action/ValidateAction.class org/openscience/cdk/applications/jchempaint/action/ZoomAction.class org/openscience/cdk/applications/jchempaint/applet/JChemPaintAbstractApplet$1.class org/openscience/cdk/applications/jchempaint/applet/JChemPaintAbstractApplet.class org/openscience/cdk/applications/jchempaint/applet/JChemPaintEditorApplet.class org/openscience/cdk/applications/jchempaint/dnd/JCPTransferHandler.class org/openscience/cdk/applications/jchempaint/DrawingPanel.class org/openscience/cdk/applications/jchempaint/InsertTextPanel.class org/openscience/cdk/applications/jchempaint/JChemPaintEditorPanel.class org/openscience/cdk/applications/jchempaint/JChemPaintMenuBar.class org/openscience/cdk/applications/jchempaint/JChemPaintModel.class org/openscience/cdk/applications/jchempaint/JChemPaintPanel.class org/openscience/cdk/applications/jchempaint/JChemPaintPopupMenu.class org/openscience/cdk/applications/jchempaint/JChemPaintViewerOnlyPanel.class org/openscience/cdk/applications/jchempaint/JCPLocalizationHandler.class org/openscience/cdk/applications/jchempaint/JCPPropertyHandler.class org/openscience/cdk/applications/jchempaint/StatusBar.class org/openscience/cdk/applications/jchempaint/StringHelper.class org/openscience/cdk/applications/jchempaint/ToolBarMaker$1.class org/openscience/cdk/applications/jchempaint/ToolBarMaker.class org/openscience/cdk/applications/plugin/ICDKEditBus.class org/openscience/cdk/applications/swing/editor/AtomEditor.class org/openscience/cdk/applications/swing/editor/BondEditor.class org/openscience/cdk/applications/swing/editor/ChemObjectEditor.class org/openscience/cdk/applications/swing/editor/PseudoAtomEditor.class org/openscience/cdk/applications/swing/editor/ReactionEditor.class org/openscience/cdk/applications/swing/FieldTablePanel.class org/openscience/cdk/applications/swing/JExternalFrame.class org/openscience/cdk/applications/undoredo/AddAtomsAndBondsEdit.class org/openscience/cdk/applications/undoredo/IUndoRedoHandler.class org/openscience/cdk/applications/undoredo/JCPUndoRedoHandler.class org/openscience/cdk/applications/undoredo/UndoAdapter.class org/openscience/cdk/Atom.class org/openscience/cdk/AtomContainer$AtomIterator.class org/openscience/cdk/AtomContainer.class org/openscience/cdk/AtomContainerSet$AtomContainerIterator.class org/openscience/cdk/AtomContainerSet.class org/openscience/cdk/AtomType.class org/openscience/cdk/Bond$AtomsIterator.class org/openscience/cdk/Bond.class org/openscience/cdk/ChemModel.class org/openscience/cdk/ChemObject.class org/openscience/cdk/config/AtomTypeFactory.class org/openscience/cdk/config/atomtypes/AtomTypeHandler.class org/openscience/cdk/config/atomtypes/AtomTypeReader.class org/openscience/cdk/config/CDKBasedAtomTypeConfigurator.class org/openscience/cdk/config/IAtomTypeConfigurator.class org/openscience/cdk/config/IsotopeFactory.class org/openscience/cdk/config/isotopes/IsotopeHandler.class org/openscience/cdk/config/isotopes/IsotopeReader.class org/openscience/cdk/controller/AbstractController2D.class org/openscience/cdk/controller/CDKPopupMenu.class org/openscience/cdk/controller/Controller2D.class org/openscience/cdk/controller/Controller2DModel.class org/openscience/cdk/controller/PopupController2D.class org/openscience/cdk/controller/SimpleController2D.class org/openscience/cdk/DefaultChemObjectBuilder.class org/openscience/cdk/ElectronContainer.class org/openscience/cdk/Element.class org/openscience/cdk/event/ChemObjectChangeEvent.class org/openscience/cdk/event/ICDKChangeListener.class org/openscience/cdk/exception/CDKException.class org/openscience/cdk/exception/NoSuchAtomTypeException.class org/openscience/cdk/geometry/GeometryTools.class org/openscience/cdk/graph/BFSShortestPath.class org/openscience/cdk/graph/BFSShortestPath$MyBreadthFirstIterator.class org/openscience/cdk/graph/BiconnectivityInspector.class org/openscience/cdk/graph/ConnectivityChecker.class org/openscience/cdk/graph/MoleculeGraphs.class org/openscience/cdk/graph/PathTools.class org/openscience/cdk/interfaces/IAminoAcid.class org/openscience/cdk/interfaces/IAtom.class org/openscience/cdk/interfaces/IAtomContainer.class org/openscience/cdk/interfaces/IAtomContainerSet.class org/openscience/cdk/interfaces/IAtomParity.class org/openscience/cdk/interfaces/IAtomType.class org/openscience/cdk/interfaces/IBioPolymer.class org/openscience/cdk/interfaces/IBond.class org/openscience/cdk/interfaces/IChemFile.class org/openscience/cdk/interfaces/IChemModel.class org/openscience/cdk/interfaces/IChemObjectBuilder.class org/openscience/cdk/interfaces/IChemObjectChangeEvent.class org/openscience/cdk/interfaces/IChemObject.class org/openscience/cdk/interfaces/IChemObjectListener.class org/openscience/cdk/interfaces/IChemSequence.class org/openscience/cdk/interfaces/ICrystal.class org/openscience/cdk/interfaces/IElectronContainer.class org/openscience/cdk/interfaces/IElement.class org/openscience/cdk/interfaces/IIsotope.class org/openscience/cdk/interfaces/ILonePair.class org/openscience/cdk/interfaces/IMapping.class org/openscience/cdk/interfaces/IMolecule.class org/openscience/cdk/interfaces/IMoleculeSet.class org/openscience/cdk/interfaces/IMonomer.class org/openscience/cdk/interfaces/IPDBAtom.class org/openscience/cdk/interfaces/IPDBMonomer.class org/openscience/cdk/interfaces/IPDBPolymer.class org/openscience/cdk/interfaces/IPDBStructure.class org/openscience/cdk/interfaces/IPolymer.class org/openscience/cdk/interfaces/IPseudoAtom.class org/openscience/cdk/interfaces/IReaction.class org/openscience/cdk/interfaces/IReactionSet.class org/openscience/cdk/interfaces/IRing.class org/openscience/cdk/interfaces/IRingSet.class org/openscience/cdk/interfaces/ISingleElectron.class org/openscience/cdk/interfaces/IStrand.class org/openscience/cdk/io/DefaultChemObjectReader.class org/openscience/cdk/io/formats/ABINITFormat.class org/openscience/cdk/io/formats/Aces2Format.class org/openscience/cdk/io/formats/ADFFormat.class org/openscience/cdk/io/formats/AlchemyFormat.class org/openscience/cdk/io/formats/BGFFormat.class org/openscience/cdk/io/formats/BSFormat.class org/openscience/cdk/io/formats/CacaoCartesianFormat.class org/openscience/cdk/io/formats/CacaoInternalFormat.class org/openscience/cdk/io/formats/CACheFormat.class org/openscience/cdk/io/formats/CDKSourceCodeFormat.class org/openscience/cdk/io/formats/Chem3D_Cartesian_1Format.class org/openscience/cdk/io/formats/Chem3D_Cartesian_2Format.class org/openscience/cdk/io/formats/ChemDrawFormat.class org/openscience/cdk/io/formats/ChemtoolFormat.class org/openscience/cdk/io/formats/CIFFormat.class org/openscience/cdk/io/formats/CMLFormat.class org/openscience/cdk/io/formats/CMLRSSFormat.class org/openscience/cdk/io/formats/CRK2DFormat.class org/openscience/cdk/io/formats/CRK3DFormat.class org/openscience/cdk/io/formats/CrystClustFormat.class org/openscience/cdk/io/formats/CTXFormat.class org/openscience/cdk/io/formats/DaltonFormat.class org/openscience/cdk/io/formats/DMol3Format.class org/openscience/cdk/io/formats/DOCK5Format.class org/openscience/cdk/io/formats/FenskeHall_ZMatrixFormat.class org/openscience/cdk/io/formats/FingerprintFormat.class org/openscience/cdk/io/formats/GamessFormat.class org/openscience/cdk/io/formats/Gaussian03Format.class org/openscience/cdk/io/formats/Gaussian90Format.class org/openscience/cdk/io/formats/Gaussian92Format.class org/openscience/cdk/io/formats/Gaussian94Format.class org/openscience/cdk/io/formats/Gaussian95Format.class org/openscience/cdk/io/formats/Gaussian98Format.class org/openscience/cdk/io/formats/GaussianInputFormat.class org/openscience/cdk/io/formats/GhemicalMMFormat.class org/openscience/cdk/io/formats/GhemicalSPMFormat.class org/openscience/cdk/io/formats/GROMOS96Format.class org/openscience/cdk/io/formats/HINFormat.class org/openscience/cdk/io/formats/IChemFormat.class org/openscience/cdk/io/formats/IChemFormatMatcher.class org/openscience/cdk/io/formats/INChIFormat.class org/openscience/cdk/io/formats/INChIPlainTextFormat.class org/openscience/cdk/io/formats/IResourceFormat.class org/openscience/cdk/io/formats/JaguarFormat.class org/openscience/cdk/io/formats/JMEFormat.class org/openscience/cdk/io/formats/MACiEFormat.class org/openscience/cdk/io/formats/MacroModelFormat.class org/openscience/cdk/io/formats/MDLFormat.class org/openscience/cdk/io/formats/MDLRXNFormat.class org/openscience/cdk/io/formats/MDLRXNV3000Format.class org/openscience/cdk/io/formats/MDLV3000Format.class org/openscience/cdk/io/formats/MMODFormat.class org/openscience/cdk/io/formats/Mol2Format.class org/openscience/cdk/io/formats/MOPAC2002Format.class org/openscience/cdk/io/formats/MOPAC7Format.class org/openscience/cdk/io/formats/MOPAC93Format.class org/openscience/cdk/io/formats/MOPAC97Format.class org/openscience/cdk/io/formats/MPQCFormat.class org/openscience/cdk/io/formats/NWChemFormat.class org/openscience/cdk/io/formats/PCModelFormat.class org/openscience/cdk/io/formats/PDBFormat.class org/openscience/cdk/io/formats/PDBMLFormat.class org/openscience/cdk/io/formats/PMPFormat.class org/openscience/cdk/io/formats/POVRayFormat.class org/openscience/cdk/io/formats/PQSChemFormat.class org/openscience/cdk/io/formats/PubChemFormat.class org/openscience/cdk/io/formats/QChemFormat.class org/openscience/cdk/io/formats/RawCopyFormat.class org/openscience/cdk/io/formats/SDFFormat.class org/openscience/cdk/io/formats/ShelXFormat.class org/openscience/cdk/io/formats/SMARTSFormat.class org/openscience/cdk/io/formats/SMILESFIXFormat.class org/openscience/cdk/io/formats/SMILESFormat.class org/openscience/cdk/io/formats/SpartanFormat.class org/openscience/cdk/io/formats/SVGFormat.class org/openscience/cdk/io/formats/SybylDescriptorFormat.class org/openscience/cdk/io/formats/TinkerMM2Format.class org/openscience/cdk/io/formats/TinkerXYZFormat.class org/openscience/cdk/io/formats/TurboMoleFormat.class org/openscience/cdk/io/formats/UniChemXYZFormat.class org/openscience/cdk/io/formats/VASPFormat.class org/openscience/cdk/io/formats/ViewmolFormat.class org/openscience/cdk/io/formats/XEDFormat.class org/openscience/cdk/io/formats/XYZFormat.class org/openscience/cdk/io/formats/YasaraFormat.class org/openscience/cdk/io/formats/ZindoFormat.class org/openscience/cdk/io/formats/ZMatrixFormat.class org/openscience/cdk/io/IChemObjectIO.class org/openscience/cdk/io/IChemObjectReader.class org/openscience/cdk/io/listener/IChemObjectIOListener.class org/openscience/cdk/io/MDLReader.class org/openscience/cdk/io/ReaderFactory.class org/openscience/cdk/io/setting/BooleanIOSetting.class org/openscience/cdk/io/setting/IOSetting.class org/openscience/cdk/Isotope.class org/openscience/cdk/layout/AtomPlacer$1.class org/openscience/cdk/layout/AtomPlacer.class org/openscience/cdk/layout/RingPlacer.class org/openscience/cdk/Mapping.class org/openscience/cdk/Molecule.class org/openscience/cdk/MoleculeSet.class org/openscience/cdk/PseudoAtom.class org/openscience/cdk/Reaction.class org/openscience/cdk/renderer/AbstractRenderer2D.class org/openscience/cdk/renderer/color/CDK2DAtomColors.class org/openscience/cdk/renderer/color/IAtomColorer.class org/openscience/cdk/renderer/Renderer2D.class org/openscience/cdk/renderer/Renderer2DModel.class org/openscience/cdk/renderer/SimpleRenderer2D.class org/openscience/cdk/Ring.class org/openscience/cdk/ringsearch/cyclebasis/CycleBasis.class org/openscience/cdk/ringsearch/cyclebasis/SimpleCycleBasis$AuxiliaryGraph.class org/openscience/cdk/ringsearch/cyclebasis/SimpleCycleBasis.class org/openscience/cdk/ringsearch/cyclebasis/SimpleCycle.class org/openscience/cdk/ringsearch/SSSRFinder.class org/openscience/cdk/RingSet.class org/openscience/cdk/smiles/SmilesGenerator.class org/openscience/cdk/tools/HydrogenAdder.class org/openscience/cdk/tools/IDeduceBondOrderTool.class org/openscience/cdk/tools/IValencyChecker.class org/openscience/cdk/tools/LoggingTool.class org/openscience/cdk/tools/manipulator/AtomContainerManipulator.class org/openscience/cdk/tools/manipulator/AtomContainerSetManipulator.class org/openscience/cdk/tools/manipulator/ChemModelManipulator.class org/openscience/cdk/tools/manipulator/MoleculeSetManipulator.class org/openscience/cdk/tools/manipulator/RingSetManipulator.class org/openscience/cdk/tools/MFAnalyser.class org/openscience/cdk/tools/SaturationChecker.class org/openscience/cdk/tools/ValencyChecker.class org/openscience/cdk/validate/IValidator.class org/openscience/cdk/validate/ProblemMarker.class sun/reflect/GeneratedConstructorAccessor1.class sun/reflect/GeneratedConstructorAccessor2.class sun/reflect/GeneratedMethodAccessor1.class sun/reflect/GeneratedMethodAccessor2.class sun/reflect/GeneratedMethodAccessor3.class sun/reflect/GeneratedMethodAccessor4.class sun/reflect/GeneratedMethodAccessor5.class cdk-1.2.10/src/META-INF/applet-viewer-opts.files100644 0 0 73 11570154753 16155 0ustar 0 0 org/openscience/cdk/applications/swing/JExternalFrame.classcdk-1.2.10/src/META-INF/atomtype.cdkdepends100644 0 0 104 11570154753 15265 0ustar 0 0 cdk-interfaces.jar cdk-annotation.jar cdk-core.jar cdk-standard.jar cdk-1.2.10/src/META-INF/atomtype.datafiles100644 0 0 366 11570154753 15127 0ustar 0 0 org/openscience/cdk/dict/data/atom-type-mappings.owl org/openscience/cdk/dict/data/atom-types.owl org/openscience/cdk/dict/data/cdk-sybyl-mappings.owl org/openscience/cdk/dict/data/elements.owl org/openscience/cdk/dict/data/sybyl-atom-types.owl cdk-1.2.10/src/META-INF/atomtype.libdepends100644 0 0 13 11570154753 15251 0ustar 0 0 log4j*.jar cdk-1.2.10/src/META-INF/builder3d.cdkdepends100644 0 0 322 11570154753 15302 0ustar 0 0 cdk-core.jar cdk-data.jar cdk-nonotify.jar cdk-interfaces.jar cdk-annotation.jar cdk-io.jar cdk-qsar.jar cdk-standard.jar cdk-charges.jar cdk-forcefield.jar cdk-valencycheck.jar cdk-sdg.jar cdk-isomorphism.jar cdk-1.2.10/src/META-INF/builder3d.datafiles100644 0 0 226 11570154753 15135 0ustar 0 0 org/openscience/cdk/modeling/builder3d/data/ringTemplateFingerprints.txt.gz org/openscience/cdk/modeling/builder3d/data/ringTemplateStructures.sdf.gz cdk-1.2.10/src/META-INF/builder3d.libdepends100644 0 0 35 11570154753 15270 0ustar 0 0 jama-1.0.2.jar vecmath*.jar cdk-1.2.10/src/META-INF/builder3dtools.cdkdepends100644 0 0 325 11570154753 16366 0ustar 0 0 cdk-annotation.jar cdk-core.jar cdk-data.jar cdk-nonotify.jar cdk-interfaces.jar cdk-io.jar cdk-qsar.jar cdk-standard.jar cdk-charges.jar cdk-forcefield.jar cdk-valencycheck.jar cdk-smiles.jar cdk-isomorphism.jar cdk-1.2.10/src/META-INF/builder3dtools.libdepends100644 0 0 16 11570154753 16350 0ustar 0 0 vecmath*.jar cdk-1.2.10/src/META-INF/charges.cdkdepends100644 0 0 223 11570154753 15041 0ustar 0 0 cdk-annotation.jar cdk-core.jar cdk-data.jar cdk-interfaces.jar cdk-io.jar cdk-standard.jar cdk-reaction.jar cdk-standard.jar cdk-valencycheck.jar cdk-1.2.10/src/META-INF/charges.libdepends100644 0 0 40 11570154753 15023 0ustar 0 0 vecmath*.jar jgrapht-0.6.0.jar cdk-1.2.10/src/META-INF/control.cdkdepends100644 0 0 177 11570154753 15115 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-render.jar cdk-io.jar cdk-valencycheck.jar cdk-sdg.jar cdk-1.2.10/src/META-INF/control.libdepends100644 0 0 16 11570154753 15072 0ustar 0 0 vecmath*.jar cdk-1.2.10/src/META-INF/core.cdkdepends100644 0 0 46 11570154753 14340 0ustar 0 0 cdk-interfaces.jar cdk-annotation.jar cdk-1.2.10/src/META-INF/core.datafiles100644 0 0 444 11570154753 14212 0ustar 0 0 org/openscience/cdk/config/data/*_atomtypes.txt org/openscience/cdk/config/data/*_atomtypes.xml org/openscience/cdk/config/data/isotopes.xml org/openscience/cdk/config/data/chemicalElements.xml org/openscience/cdk/config/data/log4j.properties org/openscience/cdk/dict/data/cdk-atom-types.owl cdk-1.2.10/src/META-INF/core.libdepends100644 0 0 13 11570154753 14337 0ustar 0 0 log4j*.jar cdk-1.2.10/src/META-INF/data.cdkdepends100644 0 0 63 11570154753 14320 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-1.2.10/src/META-INF/data.libdepends100644 0 0 15 11570154753 14322 0ustar 0 0 vecmath*.jar cdk-1.2.10/src/META-INF/datadebug.cdkdepends100644 0 0 77 11570154753 15334 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-data.jarcdk-1.2.10/src/META-INF/datadebug.libdepends100644 0 0 15 11570154753 15331 0ustar 0 0 vecmath*.jar cdk-1.2.10/src/META-INF/dict.cdkdepends100644 0 0 63 11570154753 14332 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-1.2.10/src/META-INF/dict.libdepends100644 0 0 11 11570154753 14330 0ustar 0 0 xom*.jar cdk-1.2.10/src/META-INF/diff.cdkdepends100644 0 0 63 11570154753 14317 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-1.2.10/src/META-INF/diff.libdepends100644 0 0 15 11570154753 14321 0ustar 0 0 vecmath*.jar cdk-1.2.10/src/META-INF/extra.cdkdepends100644 0 0 257 11570154753 14557 0ustar 0 0 cdk-annotation.jar cdk-data.jar cdk-core.jar cdk-interfaces.jar cdk-io.jar cdk-ioformats.jar cdk-standard.jar cdk-valencycheck.jar cdk-formula.jar cdk-dict.jar cdk-smiles.jar cdk-1.2.10/src/META-INF/extra.datafiles100644 0 0 530 11570154753 14401 0ustar 0 0 org/openscience/cdk/dict/data/*.xml org/openscience/cdk/dict/data/descriptor-algorithms.owl org/openscience/cdk/dict/data/reaction-processes.owl org/openscience/cdk/config/data/radii-vdw.txt org/openscience/cdk/config/data/radii-covalent.txt org/openscience/cdk/config/data/electroneg-pauling.txt org/openscience/cdk/fingerprint/data/maccs.txt cdk-1.2.10/src/META-INF/extra.libdepends100644 0 0 45 11570154753 14537 0ustar 0 0 jama-1.0.2.jar vecmath*.jar xom*.jar cdk-1.2.10/src/META-INF/fingerprint.cdkdepends100644 0 0 227 11570154753 15760 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-io.jar cdk-isomorphism.jar cdk-valencycheck.jar cdk-smarts.jar cdk-formula.jar cdk-1.2.10/src/META-INF/fingerprint.datafiles100644 0 0 53 11570154753 15565 0ustar 0 0 org/openscience/cdk/fingerprint/data/*.txt cdk-1.2.10/src/META-INF/fingerprint.libdepends100644 0 0 15 11570154753 15740 0ustar 0 0 vecmath*.jar cdk-1.2.10/src/META-INF/forcefield.cdkdepends100644 0 0 232 11570154753 15527 0ustar 0 0 cdk-annotation.jar cdk-core.jar cdk-data.jar cdk-interfaces.jar cdk-qsar.jar cdk-qsaratomic.jar cdk-io.jar cdk-standard.jar cdk-charges.jar cdk-extra.jar cdk-1.2.10/src/META-INF/forcefield.datafiles100644 0 0 155 11570154753 15363 0ustar 0 0 org/openscience/cdk/modeling/forcefield/data/*.prm org/openscience/cdk/modeling/forcefield/data/mmffdfsb.par cdk-1.2.10/src/META-INF/forcefield.libdepends100644 0 0 35 11570154753 15515 0ustar 0 0 jama-1.0.2.jar vecmath*.jar cdk-1.2.10/src/META-INF/formula.cdkdepends100644 0 0 104 11570154753 15070 0ustar 0 0 cdk-annotation.jar cdk-core.jar cdk-interfaces.jar cdk-standard.jar cdk-1.2.10/src/META-INF/formula.libdepends100644 0 0 16 11570154753 15057 0ustar 0 0 vecmath*.jar cdk-1.2.10/src/META-INF/inchi.cdkdepends100644 0 0 144 11570154753 14521 0ustar 0 0 cdk-annotation.jar cdk-core.jar cdk-interfaces.jar cdk-io.jar cdk-standard.jar cdk-valencycheck.jar cdk-1.2.10/src/META-INF/inchi.libdepends100644 0 0 71 11570154753 14505 0ustar 0 0 vecmath*.jar xom*.jar jniinchi-0.5.jar cmlxom-2.5-b1.jar cdk-1.2.10/src/META-INF/interfaces.libdepends100644 0 0 15 11570154753 15534 0ustar 0 0 vecmath*.jar cdk-1.2.10/src/META-INF/io.cdkdepends100644 0 0 147 11570154753 14041 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-ioformats.jar cdk-core.jar cdk-standard.jar cdk-atomtype.jar cdk-1.2.10/src/META-INF/io.datafiles100644 0 0 43 11570154753 13644 0ustar 0 0 org/openscience/cdk/io/cml/data/** cdk-1.2.10/src/META-INF/io.libdepends100644 0 0 35 11570154753 14022 0ustar 0 0 vecmath*.jar xpp3-1.1.4c.jar cdk-1.2.10/src/META-INF/ioformats.buildfiles100644 0 0 17 11570154753 15427 0ustar 0 0 io-formats.set cdk-1.2.10/src/META-INF/ioformats.cdkdepends100644 0 0 23 11570154753 15406 0ustar 0 0 cdk-annotation.jar cdk-1.2.10/src/META-INF/ionpot.cdkdepends100644 0 0 254 11570154753 14741 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-libiocml.jar cdk-valencycheck.jar cdk-isomorphism.jar cdk-dict.jar cdk-charges.jar cdk-reaction.jar cdk-1.2.10/src/META-INF/isomorphism.cdkdepends100644 0 0 100 11570154753 15770 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-data.jar cdk-1.2.10/src/META-INF/isomorphism.libdepends100644 0 0 52 11570154753 15763 0ustar 0 0 vecmath*.jar log4j*.jar jgrapht-0.6.0.jar cdk-1.2.10/src/META-INF/libiocml.buildfiles100644 0 0 32 11570154753 15213 0ustar 0 0 libio-cml-customizers.set cdk-1.2.10/src/META-INF/libiocml.cdkdepends100644 0 0 176 11570154753 15226 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-dict.jar cdk-io.jar cdk-ioformats.jar cdk-standard.jar cdk-formula.jar cdk-1.2.10/src/META-INF/libiocml.libdepends100644 0 0 51 11570154753 15203 0ustar 0 0 vecmath*.jar xom*.jar cmlxom-2.5-b1.jar cdk-1.2.10/src/META-INF/libiomd.cdkdepends100644 0 0 155 11570154753 15050 0ustar 0 0 cdk-annotation.jar cdk-core.jar cdk-interfaces.jar cdk-standard.jar cdk-data.jar cdk-libiocml.jar cdk-io.jar cdk-1.2.10/src/META-INF/libiomd.libdepends100644 0 0 33 11570154753 15030 0ustar 0 0 cmlxom-2.5-b1.jar xom*.jar cdk-1.2.10/src/META-INF/nonotify.cdkdepends100644 0 0 77 11570154753 15261 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-data.jarcdk-1.2.10/src/META-INF/nonotify.libdepends100644 0 0 15 11570154753 15256 0ustar 0 0 vecmath*.jar cdk-1.2.10/src/META-INF/pcore.cdkdepends100644 0 0 224 11570154753 14536 0ustar 0 0 cdk-annotation.jar cdk-data.jar cdk-core.jar cdk-interfaces.jar cdk-io.jar cdk-standard.jar cdk-valencycheck.jar cdk-smarts.jar cdk-isomorphism.jar cdk-1.2.10/src/META-INF/pcore.libdepends100644 0 0 26 11570154753 14523 0ustar 0 0 vecmath*.jar xom*.jar cdk-1.2.10/src/META-INF/pdb.cdkdepends100644 0 0 156 11570154753 14177 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-data.jar cdk-ioformats.jar cdk-io.jar cdk-standard.jar cdk-1.2.10/src/META-INF/pdb.datafiles100644 0 0 67 11570154753 14010 0ustar 0 0 org/openscience/cdk/templates/data/list_aminoacids.cml cdk-1.2.10/src/META-INF/pdb.libdepends100644 0 0 16 11570154753 14157 0ustar 0 0 vecmath*.jar cdk-1.2.10/src/META-INF/pdbcml.cdkdepends100644 0 0 156 11570154753 14673 0ustar 0 0 cdk-annotation.jar cdk-core.jar cdk-data.jar cdk-pdb.jar cdk-standard.jar cdk-interfaces.jar cdk-libiocml.jar cdk-1.2.10/src/META-INF/pdbcml.libdepends100644 0 0 33 11570154753 14652 0ustar 0 0 xom*.jar cmlxom-2.5-b1.jar cdk-1.2.10/src/META-INF/qm.cdkdepends100644 0 0 63 11570154753 14024 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-1.2.10/src/META-INF/qm.libdepends100644 0 0 15 11570154753 14026 0ustar 0 0 vecmath*.jar cdk-1.2.10/src/META-INF/qsar.buildfiles100644 0 0 25 11570154753 14371 0ustar 0 0 qsar-descriptors.set cdk-1.2.10/src/META-INF/qsar.cdkdepends100644 0 0 207 11570154753 14375 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-data.jar cdk-core.jar cdk-standard.jar cdk-valencycheck.jar cdk-reaction.jar cdk-charges.jar cdk-1.2.10/src/META-INF/qsar.datafiles100644 0 0 177 11570154753 14233 0ustar 0 0 org/openscience/cdk/qsar/model/data/*.R org/openscience/cdk/qsar/descriptors/data/*.txt org/openscience/cdk/config/data/whim* cdk-1.2.10/src/META-INF/qsar.extrafiles100644 0 0 21 11570154753 14411 0ustar 0 0 data/arff/*.arff cdk-1.2.10/src/META-INF/qsar.libdepends100644 0 0 116 11570154753 14401 0ustar 0 0 jama-1.0.2.jar JRI.jar jgrapht-0.6.0.jar sjava-0.68.jar vecmath*.jar xom*.jar cdk-1.2.10/src/META-INF/qsaratomic.cdkdepends100644 0 0 327 11570154753 15575 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-data.jar cdk-core.jar cdk-standard.jar cdk-valencycheck.jar cdk-extra.jar cdk-isomorphism.jar cdk-reaction.jar cdk-isomorphism.jar cdk-charges.jar cdk-qsar.jar cdk-dict.jar cdk-1.2.10/src/META-INF/qsaratomic.datafiles100644 0 0 66 11570154753 15405 0ustar 0 0 org/openscience/cdk/qsar/descriptors/atomic/data/*.db cdk-1.2.10/src/META-INF/qsaratomic.libdepends100644 0 0 116 11570154753 15576 0ustar 0 0 jama-1.0.2.jar JRI.jar jgrapht-0.6.0.jar sjava-0.68.jar vecmath*.jar xom*.jar cdk-1.2.10/src/META-INF/qsarbond.cdkdepends100644 0 0 265 11570154753 15244 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-data.jar cdk-core.jar cdk-standard.jar cdk-valencycheck.jar cdk-reaction.jar cdk-isomorphism.jar cdk-charges.jar cdk-qsar.jar cdk-dict.jar cdk-1.2.10/src/META-INF/qsarbond.libdepends100644 0 0 116 11570154753 15244 0ustar 0 0 jama-1.0.2.jar JRI.jar jgrapht-0.6.0.jar sjava-0.68.jar vecmath*.jar xom*.jar cdk-1.2.10/src/META-INF/qsarcml.cdkdepends100644 0 0 157 11570154753 15075 0ustar 0 0 cdk-annotation.jar cdk-core.jar cdk-data.jar cdk-interfaces.jar cdk-libiocml.jar cdk-qsar.jar cdk-standard.jar cdk-1.2.10/src/META-INF/qsarcml.libdepends100644 0 0 33 11570154753 15053 0ustar 0 0 xom*.jar cmlxom-2.5-b1.jar cdk-1.2.10/src/META-INF/qsarionpot.cdkdepends100644 0 0 472 11570154753 15632 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-data.jar cdk-core.jar cdk-standard.jar cdk-valencycheck.jar cdk-extra.jar cdk-reaction.jar cdk-charges.jar cdk-qsar.jar cdk-qsaratomic.jar cdk-qsarbond.jar cdk-qsarmolecular.jar cdk-smiles.jar cdk-smarts.jar cdk-formula.jar cdk-isomorphism.jar cdk-dict.jar cdk-ionpot.jar cdk-1.2.10/src/META-INF/qsarmolecular.cdkdepends100644 0 0 361 11570154753 16302 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-data.jar cdk-core.jar cdk-standard.jar cdk-valencycheck.jar cdk-extra.jar cdk-reaction.jar cdk-charges.jar cdk-qsar.jar cdk-smiles.jar cdk-smarts.jar cdk-formula.jar cdk-isomorphism.jar cdk-dict.jar cdk-1.2.10/src/META-INF/qsarmolecular.datafiles100644 0 0 177 11570154753 16137 0ustar 0 0 org/openscience/cdk/qsar/model/data/*.R org/openscience/cdk/qsar/descriptors/data/*.txt org/openscience/cdk/config/data/whim* cdk-1.2.10/src/META-INF/qsarmolecular.extrafiles100644 0 0 21 11570154753 16315 0ustar 0 0 data/arff/*.arff cdk-1.2.10/src/META-INF/qsarmolecular.libdepends100644 0 0 116 11570154753 16305 0ustar 0 0 jama-1.0.2.jar JRI.jar jgrapht-0.6.0.jar sjava-0.68.jar vecmath*.jar xom*.jar cdk-1.2.10/src/META-INF/qsarprotein.cdkdepends100644 0 0 255 11570154753 16001 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-data.jar cdk-core.jar cdk-standard.jar cdk-valencycheck.jar cdk-reaction.jar cdk-charges.jar cdk-qsar.jar cdk-pdb.jar cdk-diff.jar cdk-1.2.10/src/META-INF/qsarprotein.libdepends100644 0 0 116 11570154753 16002 0ustar 0 0 jama-1.0.2.jar JRI.jar jgrapht-0.6.0.jar sjava-0.68.jar vecmath*.jar xom*.jar cdk-1.2.10/src/META-INF/reaction.buildfiles100644 0 0 24 11570154753 15226 0ustar 0 0 reaction-types.set cdk-1.2.10/src/META-INF/reaction.cdkdepends100644 0 0 230 11570154753 15227 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-data.jar cdk-core.jar cdk-standard.jar cdk-libiocml.jar cdk-valencycheck.jar cdk-isomorphism.jar cdk-dict.jar cdk-1.2.10/src/META-INF/reaction.libdepends100644 0 0 64 11570154753 15221 0ustar 0 0 log4j*.jar jgrapht-0.6.0.jar vecmath*.jar xom*.jar cdk-1.2.10/src/META-INF/render.cdkdepends100644 0 0 104 11570154753 14702 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-1.2.10/src/META-INF/render.libdepends100644 0 0 16 11570154753 14671 0ustar 0 0 vecmath*.jar cdk-1.2.10/src/META-INF/sdg.cdkdepends100644 0 0 144 11570154753 14204 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-io.jar cdk-valencycheck.jar cdk-1.2.10/src/META-INF/sdg.datafiles100644 0 0 137 11570154753 14036 0ustar 0 0 org/openscience/cdk/layout/templates/templates.list org/openscience/cdk/layout/templates/*.cml cdk-1.2.10/src/META-INF/sdg.libdepends100644 0 0 16 11570154753 14167 0ustar 0 0 vecmath*.jar cdk-1.2.10/src/META-INF/smarts.autogenerated100644 0 0 663 11570154753 15471 0ustar 0 0 org/openscience/cdk/smiles/smarts/parser/ParseException.java org/openscience/cdk/smiles/smarts/parser/SMARTSParser.java org/openscience/cdk/smiles/smarts/parser/SMARTSParserConstants.java org/openscience/cdk/smiles/smarts/parser/SMARTSParserTokenManager.java org/openscience/cdk/smiles/smarts/parser/SimpleCharStream.java org/openscience/cdk/smiles/smarts/parser/Token.java org/openscience/cdk/smiles/smarts/parser/TokenMgrError.java cdk-1.2.10/src/META-INF/smarts.cdkdepends100644 0 0 223 11570154753 14736 0ustar 0 0 cdk-annotation.jar cdk-data.jar cdk-core.jar cdk-interfaces.jar cdk-io.jar cdk-standard.jar cdk-valencycheck.jar cdk-isomorphism.jar cdk-extra.jar cdk-1.2.10/src/META-INF/smarts.libdepends100644 0 0 15 11570154753 14722 0ustar 0 0 vecmath*.jar cdk-1.2.10/src/META-INF/smiles.cdkdepends100644 0 0 203 11570154753 14717 0ustar 0 0 cdk-annotation.jar cdk-data.jar cdk-core.jar cdk-interfaces.jar cdk-ioformats.jar cdk-io.jar cdk-standard.jar cdk-valencycheck.jar cdk-1.2.10/src/META-INF/smiles.libdepends100644 0 0 15 11570154753 14705 0ustar 0 0 vecmath*.jar cdk-1.2.10/src/META-INF/standard.cdkdepends100644 0 0 63 11570154753 15207 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-1.2.10/src/META-INF/standard.libdepends100644 0 0 52 11570154753 15212 0ustar 0 0 vecmath*.jar log4j*.jar jgrapht-0.6.0.jar cdk-1.2.10/src/META-INF/structgen.cdkdepends100644 0 0 151 11570154753 15443 0ustar 0 0 cdk-interfaces.jar cdk-annotation.jar cdk-core.jar cdk-standard.jar cdk-formula.jar cdk-valencycheck.jar cdk-1.2.10/src/META-INF/test-atomtype.cdkdepends100644 0 0 340 11570154753 16244 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-data.jar cdk-test.jar cdk-io.jar cdk-nonotify.jar cdk-smiles.jar cdk-standard.jar cdk-valencycheck.jar cdk-atomtype.jar cdk-extra.jar cdk-testdata.jar cdk-test-core.jar cdk-1.2.10/src/META-INF/test-atomtype.devellibdepends100644 0 0 17 11570154753 17252 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-atomtype.libdepends100644 0 0 52 11570154753 16231 0ustar 0 0 log4j*.jar vecmath*.jar jgrapht-0.6.0.jar cdk-1.2.10/src/META-INF/test-builder3d.cdkdepends100644 0 0 577 11570154753 16273 0ustar 0 0 cdk-annotation.jar cdk-core.jar cdk-data.jar cdk-diff.jar cdk-nonotify.jar cdk-interfaces.jar cdk-qsar.jar cdk-io.jar cdk-ioformats.jar cdk-standard.jar cdk-charges.jar cdk-smiles.jar cdk-builder3d.jar cdk-sdg.jar cdk-extra.jar cdk-forcefield.jar cdk-valencycheck.jar cdk-test.jar cdk-isomorphism.jar cdk-testdata.jar cdk-builder3dtools.jar cdk-test-qsaratomic.jar cdk-test-qsar.jar cdk-1.2.10/src/META-INF/test-builder3d.devellibdepends100644 0 0 17 11570154753 17265 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-builder3d.libdepends100644 0 0 71 11570154753 16245 0ustar 0 0 jama-1.0.2.jar vecmath*.jar log4j*.jar jgrapht-0.6.0.jar cdk-1.2.10/src/META-INF/test-charges.cdkdepends100644 0 0 423 11570154753 16020 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-data.jar cdk-nonotify.jar cdk-io.jar cdk-valencycheck.jar cdk-extra.jar cdk-reaction.jar cdk-charges.jar cdk-qsar.jar cdk-qsarmolecular.jar cdk-qsaratomic.jar cdk-smiles.jar cdk-test.jar cdk-1.2.10/src/META-INF/test-charges.devellibdepends100644 0 0 17 11570154753 17024 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-charges.libdepends100644 0 0 52 11570154753 16003 0ustar 0 0 vecmath*.jar log4j*.jar jgrapht-0.6.0.jar cdk-1.2.10/src/META-INF/test-core.cdkdepends100644 0 0 332 11570154753 15333 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-data.jar cdk-standard.jar cdk-extra.jar cdk-smiles.jar cdk-test.jar cdk-io.jar cdk-nonotify.jar cdk-testdata.jar cdk-atomtype.jar cdk-valencycheck.jar cdk-pdb.jar cdk-1.2.10/src/META-INF/test-core.devellibdepends100644 0 0 17 11570154753 16340 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-core.libdepends100644 0 0 52 11570154753 15317 0ustar 0 0 log4j*.jar vecmath*.jar jgrapht-0.6.0.jar cdk-1.2.10/src/META-INF/test-data.cdkdepends100644 0 0 203 11570154753 15311 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-data.jar cdk-nonotify.jar cdk-test.jar cdk-test-interfaces.jar cdk-diff.jar cdk-1.2.10/src/META-INF/test-data.devellibdepends100644 0 0 17 11570154753 16321 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-data.libdepends100644 0 0 30 11570154753 15274 0ustar 0 0 log4j*.jar vecmath*.jar cdk-1.2.10/src/META-INF/test-datadebug.cdkdepends100644 0 0 204 11570154753 16321 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-data.jar cdk-datadebug.jar cdk-test.jar cdk-test-interfaces.jar cdk-diff.jar cdk-1.2.10/src/META-INF/test-datadebug.devellibdepends100644 0 0 17 11570154753 17330 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-datadebug.libdepends100644 0 0 30 11570154753 16303 0ustar 0 0 log4j*.jar vecmath*.jar cdk-1.2.10/src/META-INF/test-dict.cdkdepends100644 0 0 55 11570154753 15310 0ustar 0 0 cdk-annotation.jar cdk-dict.jar cdk-test.jar cdk-1.2.10/src/META-INF/test-dict.devellibdepends100644 0 0 17 11570154753 16333 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-diff.cdkdepends100644 0 0 132 11570154753 15311 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-diff.jar cdk-core.jar cdk-data.jar cdk-test.jar cdk-1.2.10/src/META-INF/test-diff.devellibdepends100644 0 0 16 11570154753 16317 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-diff.libdepends100644 0 0 30 11570154753 15273 0ustar 0 0 vecmath*.jar log4j*.jar cdk-1.2.10/src/META-INF/test-extra.cdkdepends100644 0 0 660 11570154753 15532 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-data.jar cdk-nonotify.jar cdk-io.jar cdk-ioformats.jar cdk-control.jar cdk-sdg.jar cdk-extra.jar cdk-libiocml.jar cdk-pdb.jar cdk-render.jar cdk-builder3d.jar cdk-reaction.jar cdk-valencycheck.jar cdk-forcefield.jar cdk-smiles.jar cdk-charges.jar cdk-test.jar cdk-formula.jar cdk-isomorphism.jar cdk-test-core.jar cdk-test-io.jar cdk-testdata.jar cdk-diff.jar cdk-1.2.10/src/META-INF/test-extra.devellibdepends100644 0 0 17 11570154753 16533 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-extra.libdepends100644 0 0 143 11570154753 15533 0ustar 0 0 jama-1.0.2.jar jgrapht-0.6.0.jar cmlxom-2.5-b1.jar log4j*.jar sjava-0.68.jar vecmath*.jar xom*.jar cdk-1.2.10/src/META-INF/test-fingerprint.cdkdepends100644 0 0 421 11570154753 16731 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-io.jar cdk-isomorphism.jar cdk-valencycheck.jar cdk-smarts.jar cdk-test.jar cdk-smiles.jar cdk-data.jar cdk-nonotify.jar cdk-fingerprint.jar cdk-extra.jar cdk-formula.jar cdk-testdata.jar cdk-diff.jar cdk-1.2.10/src/META-INF/test-fingerprint.devellibdepends100644 0 0 16 11570154753 17736 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-fingerprint.libdepends100644 0 0 52 11570154753 16716 0ustar 0 0 vecmath*.jar jgrapht-0.6.0.jar log4j*.jar cdk-1.2.10/src/META-INF/test-forcefield.cdkdepends100644 0 0 373 11570154753 16512 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-charges.jar cdk-data.jar cdk-io.jar cdk-extra.jar cdk-pdb.jar cdk-qsar.jar cdk-qsaratomic.jar cdk-valencycheck.jar cdk-forcefield.jar cdk-smiles.jar cdk-test.jar cdk-testdata.jar cdk-1.2.10/src/META-INF/test-forcefield.devellibdepends100644 0 0 17 11570154753 17512 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-forcefield.libdepends100644 0 0 71 11570154753 16472 0ustar 0 0 jama-1.0.2.jar jgrapht-0.6.0.jar log4j*.jar vecmath*.jar cdk-1.2.10/src/META-INF/test-formula.cdkdepends100644 0 0 261 11570154753 16051 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-data.jar cdk-nonotify.jar cdk-core.jar cdk-standard.jar cdk-test.jar cdk-formula.jar cdk-extra.jar cdk-smiles.jar cdk-valencycheck.jar cdk-1.2.10/src/META-INF/test-formula.devellibdepends100644 0 0 17 11570154753 17055 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-formula.libdepends100644 0 0 102 11570154753 16050 0ustar 0 0 jama-1.0.2.jar jgrapht-0.6.0.jar log4j*.jar vecmath*.jar xom*.jar cdk-1.2.10/src/META-INF/test-inchi.cdkdepends100644 0 0 233 11570154753 15475 0ustar 0 0 cdk-annotation.jar cdk-data.jar cdk-core.jar cdk-interfaces.jar cdk-io.jar cdk-render.jar cdk-standard.jar cdk-valencycheck.jar cdk-test.jar cdk-inchi.jar cdk-1.2.10/src/META-INF/test-inchi.devellibdepends100644 0 0 17 11570154753 16502 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-inchi.libdepends100644 0 0 104 11570154753 15477 0ustar 0 0 vecmath*.jar xom*.jar jniinchi-0.5.jar cmlxom-2.5-b1.jar log4j*.jar cdk-1.2.10/src/META-INF/test-interfaces.cdkdepends100644 0 0 115 11570154753 16525 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-diff.jar cdk-test.jar cdk-1.2.10/src/META-INF/test-interfaces.devellibdepends100644 0 0 17 11570154753 17533 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-interfaces.libdepends100644 0 0 30 11570154753 16506 0ustar 0 0 vecmath*.jar log4j*.jar cdk-1.2.10/src/META-INF/test-io.cdkdepends100644 0 0 521 11570154753 15012 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-data.jar cdk-datadebug.jar cdk-nonotify.jar cdk-io.jar cdk-ioformats.jar cdk-extra.jar cdk-valencycheck.jar cdk-libiocml.jar cdk-pdb.jar cdk-qsar.jar cdk-qsarmolecular.jar cdk-qsarcml.jar cdk-pdbcml.jar cdk-smiles.jar cdk-nonotify.jar cdk-test.jar cdk-testdata.jar cdk-1.2.10/src/META-INF/test-io.devellibdepends100644 0 0 17 11570154753 16017 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-io.libdepends100644 0 0 125 11570154753 15017 0ustar 0 0 jgrapht-0.6.0.jar cmlxom-2.5-b1.jar log4j*.jar vecmath*.jar xom*.jar xpp3-1.1.4c.jar cdk-1.2.10/src/META-INF/test-ioformats.cdkdepends100644 0 0 271 11570154753 16410 0ustar 0 0 cdk-annotation.jar cdk-ioformats.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-io.jar cdk-smiles.jar cdk-pdb.jar cdk-libiocml.jar cdk-extra.jar cdk-test.jar cdk-testdata.jar cdk-1.2.10/src/META-INF/test-ioformats.devellibdepends100644 0 0 17 11570154753 17413 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-ioformats.libdepends100644 0 0 125 11570154753 16413 0ustar 0 0 jgrapht-0.6.0.jar cmlxom-2.5-b1.jar log4j*.jar vecmath*.jar xom*.jar xpp3-1.1.4c.jar cdk-1.2.10/src/META-INF/test-ionpot.cdkdepends100644 0 0 355 11570154753 15720 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-data.jar cdk-nonotify.jar cdk-core.jar cdk-standard.jar cdk-extra.jar cdk-reaction.jar cdk-io.jar cdk-valencycheck.jar cdk-smiles.jar cdk-test.jar cdk-isomorphism.jar cdk-dict.jar cdk-ionpot.jar cdk-1.2.10/src/META-INF/test-ionpot.devellibdepends100644 0 0 17 11570154753 16720 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-ionpot.libdepends100644 0 0 102 11570154753 15713 0ustar 0 0 jama-1.0.2.jar jgrapht-0.6.0.jar log4j*.jar vecmath*.jar xom*.jar cdk-1.2.10/src/META-INF/test-isomorphism.cdkdepends100644 0 0 141 11570154753 16752 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-data.jar cdk-test.jar cdk-isomorphism.jar cdk-1.2.10/src/META-INF/test-isomorphism.devellibdepends100644 0 0 17 11570154753 17761 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-isomorphism.libdepends100644 0 0 52 11570154753 16740 0ustar 0 0 vecmath*.jar log4j*.jar jgrapht-0.6.0.jar cdk-1.2.10/src/META-INF/test-libiocml.cdkdepends100644 0 0 466 11570154753 16205 0ustar 0 0 cdk-annotation.jar cdk-core.jar cdk-interfaces.jar cdk-standard.jar cdk-data.jar cdk-extra.jar cdk-libiomd.jar cdk-io.jar cdk-libiocml.jar cdk-test.jar cdk-qsar.jar cdk-qsarmolecular.jar cdk-qsarcml.jar cdk-atomtype.jar cdk-nonotify.jar cdk-pdb.jar cdk-pdbcml.jar cdk-formula.jar cdk-testdata.jar cdk-diff.jar cdk-1.2.10/src/META-INF/test-libiocml.devellibdepends100644 0 0 17 11570154753 17202 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-libiocml.libdepends100644 0 0 105 11570154753 16200 0ustar 0 0 vecmath*.jar log4j*.jar cmlxom-2.5-b1.jar xom*.jar jgrapht-0.6.0.jar cdk-1.2.10/src/META-INF/test-libiomd.cdkdepends100644 0 0 250 11570154753 16021 0ustar 0 0 cdk-annotation.jar cdk-core.jar cdk-interfaces.jar cdk-standard.jar cdk-data.jar cdk-extra.jar cdk-libiomd.jar cdk-io.jar cdk-libiocml.jar cdk-test.jar cdk-formula.jar cdk-1.2.10/src/META-INF/test-libiomd.devellibdepends100644 0 0 17 11570154753 17027 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-libiomd.libdepends100644 0 0 63 11570154753 16010 0ustar 0 0 vecmath*.jar log4j*.jar cmlxom-2.5-b1.jar xom*.jar cdk-1.2.10/src/META-INF/test-nonotify.cdkdepends100644 0 0 203 11570154753 16245 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-data.jar cdk-nonotify.jar cdk-test.jar cdk-test-interfaces.jar cdk-diff.jar cdk-1.2.10/src/META-INF/test-nonotify.devellibdepends100644 0 0 17 11570154753 17255 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-nonotify.libdepends100644 0 0 30 11570154753 16230 0ustar 0 0 log4j*.jar vecmath*.jar cdk-1.2.10/src/META-INF/test-pcore.cdkdepends100644 0 0 357 11570154753 15522 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-data.jar cdk-io.jar cdk-ioformats.jar cdk-extra.jar cdk-smiles.jar cdk-valencycheck.jar cdk-test.jar cdk-smarts.jar cdk-pcore.jar cdk-isomorphism.jar cdk-testdata.jar cdk-1.2.10/src/META-INF/test-pcore.devellibdepends100644 0 0 17 11570154753 16520 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-pcore.libdepends100644 0 0 63 11570154753 15501 0ustar 0 0 jgrapht-0.6.0.jar log4j*.jar vecmath*.jar xom*.jar cdk-1.2.10/src/META-INF/test-pdb.cdkdepends100644 0 0 313 11570154753 15147 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-data.jar cdk-datadebug.jar cdk-io.jar cdk-ioformats.jar cdk-standard.jar cdk-pdb.jar cdk-nonotify.jar cdk-test.jar cdk-test-io.jar cdk-testdata.jar cdk-1.2.10/src/META-INF/test-pdb.devellibdepends100644 0 0 17 11570154753 16155 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-pdb.libdepends100644 0 0 46 11570154753 15137 0ustar 0 0 vecmath*.jar log4j*.jar vecmath*.jar cdk-1.2.10/src/META-INF/test-qm.cdkdepends100644 0 0 164 11570154753 15023 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-data.jar cdk-test.jar cdk-io.jar cdk-qm.jar cdk-1.2.10/src/META-INF/test-qm.devellibdepends100644 0 0 21 11570154753 16020 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-qm.libdepends100644 0 0 15 11570154753 15003 0ustar 0 0 vecmath*.jar cdk-1.2.10/src/META-INF/test-qsar.cdkdepends100644 0 0 473 11570154753 15357 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-data.jar cdk-nonotify.jar cdk-io.jar cdk-pdb.jar cdk-valencycheck.jar cdk-extra.jar cdk-reaction.jar cdk-charges.jar cdk-qsar.jar cdk-smiles.jar cdk-test.jar cdk-builder3d.jar cdk-forcefield.jar cdk-sdg.jar cdk-testdata.jar cdk-1.2.10/src/META-INF/test-qsar.devellibdepends100644 0 0 21 11570154753 16351 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-qsar.libdepends100644 0 0 131 11570154753 15353 0ustar 0 0 vecmath*.jar log4j*.jar jama-1.0.2.jar jgrapht-0.6.0.jar xom*.jar JRI.jar sjava-0.68.jar cdk-1.2.10/src/META-INF/test-qsaratomic.cdkdepends100644 0 0 643 11570154753 16553 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-data.jar cdk-nonotify.jar cdk-io.jar cdk-pdb.jar cdk-valencycheck.jar cdk-extra.jar cdk-reaction.jar cdk-isomorphism.jar cdk-charges.jar cdk-qsar.jar cdk-qsaratomic.jar cdk-smiles.jar cdk-test.jar cdk-builder3d.jar cdk-forcefield.jar cdk-sdg.jar cdk-test-qsar.jar cdk-dict.jar cdk-ionpot.jar cdk-diff.jar cdk-testdata.jar cdk-1.2.10/src/META-INF/test-qsaratomic.devellibdepends100644 0 0 21 11570154753 17546 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-qsaratomic.libdepends100644 0 0 131 11570154753 16550 0ustar 0 0 vecmath*.jar log4j*.jar jama-1.0.2.jar jgrapht-0.6.0.jar xom*.jar JRI.jar sjava-0.68.jar cdk-1.2.10/src/META-INF/test-qsarbond.cdkdepends100644 0 0 641 11570154753 16217 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-data.jar cdk-nonotify.jar cdk-io.jar cdk-pdb.jar cdk-valencycheck.jar cdk-extra.jar cdk-reaction.jar cdk-isomorphism.jar cdk-charges.jar cdk-qsar.jar cdk-qsarbond.jar cdk-smiles.jar cdk-test.jar cdk-builder3d.jar cdk-forcefield.jar cdk-sdg.jar cdk-test-qsar.jar cdk-dict.jar cdk-ionpot.jar cdk-testdata.jar cdk-diff.jar cdk-1.2.10/src/META-INF/test-qsarbond.devellibdepends100644 0 0 21 11570154753 17214 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-qsarbond.libdepends100644 0 0 131 11570154753 16216 0ustar 0 0 vecmath*.jar log4j*.jar jama-1.0.2.jar jgrapht-0.6.0.jar xom*.jar JRI.jar sjava-0.68.jar cdk-1.2.10/src/META-INF/test-qsarionpot.cdkdepends100644 0 0 1054 11570154753 16624 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-smarts.jar cdk-core.jar cdk-standard.jar cdk-data.jar cdk-atomtype.jar cdk-nonotify.jar cdk-io.jar cdk-valencycheck.jar cdk-extra.jar cdk-reaction.jar cdk-charges.jar cdk-qsar.jar cdk-qsarmolecular.jar cdk-qsaratomic.jar cdk-qsarbond.jar cdk-smiles.jar cdk-test.jar cdk-test-qsar.jar cdk-formula.jar cdk-dict.jar cdk-isomorphism.jar cdk-dict.jar cdk-ionpot.jar cdk-qsarionpot.jar cdk-test-qsaratomic.jar cdk-test-qsarbond.jar cdk-test-qsarmolecular.jar cdk-testdata.jar cdk-diff.jar cdk-1.2.10/src/META-INF/test-qsarionpot.devellibdepends100644 0 0 21 11570154753 17602 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-qsarionpot.libdepends100644 0 0 131 11570154753 16604 0ustar 0 0 vecmath*.jar log4j*.jar jama-1.0.2.jar jgrapht-0.6.0.jar xom*.jar JRI.jar sjava-0.68.jar cdk-1.2.10/src/META-INF/test-qsarmolecular.cdkdepends100644 0 0 1002 11570154753 17270 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-smarts.jar cdk-core.jar cdk-standard.jar cdk-data.jar cdk-nonotify.jar cdk-io.jar cdk-valencycheck.jar cdk-extra.jar cdk-reaction.jar cdk-charges.jar cdk-qsar.jar cdk-qsarmolecular.jar cdk-qsaratomic.jar cdk-qsarbond.jar cdk-smiles.jar cdk-builder3d.jar cdk-test.jar cdk-test-qsar.jar cdk-test-qsarbond.jar cdk-test-qsaratomic.jar cdk-formula.jar cdk-dict.jar cdk-isomorphism.jar cdk-ionpot.jar cdk-testdata.jar cdk-diff.jar cdk-builder3d.jar cdk-1.2.10/src/META-INF/test-qsarmolecular.devellibdepends100644 0 0 21 11570154753 20255 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-qsarmolecular.libdepends100644 0 0 131 11570154753 17257 0ustar 0 0 vecmath*.jar log4j*.jar jama-1.0.2.jar jgrapht-0.6.0.jar xom*.jar JRI.jar sjava-0.68.jar cdk-1.2.10/src/META-INF/test-qsarprotein.cdkdepends100644 0 0 615 11570154753 16756 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-data.jar cdk-nonotify.jar cdk-diff.jar cdk-io.jar cdk-pdb.jar cdk-valencycheck.jar cdk-extra.jar cdk-reaction.jar cdk-charges.jar cdk-qsar.jar cdk-qsarprotein.jar cdk-smiles.jar cdk-test.jar cdk-builder3d.jar cdk-forcefield.jar cdk-sdg.jar cdk-test-qsar.jar cdk-testdata.jar cdk-test-qsarmolecular.jar cdk-1.2.10/src/META-INF/test-qsarprotein.devellibdepends100644 0 0 21 11570154753 17752 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-qsarprotein.libdepends100644 0 0 131 11570154753 16754 0ustar 0 0 vecmath*.jar log4j*.jar jama-1.0.2.jar jgrapht-0.6.0.jar xom*.jar JRI.jar sjava-0.68.jar cdk-1.2.10/src/META-INF/test-reaction.cdkdepends100644 0 0 357 11570154753 16216 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-data.jar cdk-nonotify.jar cdk-core.jar cdk-standard.jar cdk-extra.jar cdk-reaction.jar cdk-io.jar cdk-valencycheck.jar cdk-smiles.jar cdk-test.jar cdk-isomorphism.jar cdk-dict.jar cdk-testdata.jar cdk-1.2.10/src/META-INF/test-reaction.devellibdepends100644 0 0 17 11570154753 17214 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-reaction.libdepends100644 0 0 102 11570154753 16207 0ustar 0 0 jama-1.0.2.jar jgrapht-0.6.0.jar log4j*.jar vecmath*.jar xom*.jar cdk-1.2.10/src/META-INF/test-render.cdkdepends100644 0 0 155 11570154753 15665 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-data.jar cdk-standard.jar cdk-render.jar cdk-test.jar cdk-1.2.10/src/META-INF/test-render.devellibdepends100644 0 0 17 11570154753 16667 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-render.libdepends100644 0 0 30 11570154753 15642 0ustar 0 0 log4j*.jar vecmath*.jar cdk-1.2.10/src/META-INF/test-sdg.cdkdepends100644 0 0 311 11570154753 15155 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-valencycheck.jar cdk-standard.jar cdk-data.jar cdk-nonotify.jar cdk-io.jar cdk-sdg.jar cdk-smiles.jar cdk-extra.jar cdk-test.jar cdk-testdata.jar cdk-1.2.10/src/META-INF/test-sdg.devellibdepends100644 0 0 17 11570154753 16165 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-sdg.libdepends100644 0 0 52 11570154753 15144 0ustar 0 0 log4j*.jar vecmath*.jar jgrapht-0.6.0.jar cdk-1.2.10/src/META-INF/test-smarts.cdkdepends100644 0 0 340 11570154753 15713 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-data.jar cdk-nonotify.jar cdk-io.jar cdk-extra.jar cdk-smiles.jar cdk-valencycheck.jar cdk-test.jar cdk-smarts.jar cdk-isomorphism.jar cdk-testdata.jar cdk-1.2.10/src/META-INF/test-smarts.devellibdepends100644 0 0 17 11570154753 16721 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-smarts.libdepends100644 0 0 52 11570154753 15700 0ustar 0 0 jgrapht-0.6.0.jar log4j*.jar vecmath*.jar cdk-1.2.10/src/META-INF/test-smiles.cdkdepends100644 0 0 440 11570154753 15677 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-data.jar cdk-datadebug.jar cdk-nonotify.jar cdk-io.jar cdk-ioformats.jar cdk-valencycheck.jar cdk-smiles.jar cdk-extra.jar cdk-test.jar cdk-test-core.jar cdk-sdg.jar cdk-libiocml.jar cdk-test-io.jar cdk-testdata.jar cdk-1.2.10/src/META-INF/test-smiles.devellibdepends100644 0 0 17 11570154753 16704 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-smiles.libdepends100644 0 0 105 11570154753 15702 0ustar 0 0 jgrapht-0.6.0.jar log4j*.jar vecmath*.jar xom*.jar cmlxom-2.5-b1.jar cdk-1.2.10/src/META-INF/test-standard.cdkdepends100644 0 0 342 11570154753 16204 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-data.jar cdk-nonotify.jar cdk-io.jar cdk-extra.jar cdk-valencycheck.jar cdk-standard.jar cdk-smiles.jar cdk-test.jar cdk-isomorphism.jar cdk-testdata.jar cdk-libiocml.jar cdk-1.2.10/src/META-INF/test-standard.devellibdepends100644 0 0 17 11570154753 17210 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-standard.libdepends100644 0 0 105 11570154753 16206 0ustar 0 0 log4j*.jar jgrapht-0.6.0.jar vecmath*.jar cmlxom-2.5-b1.jar xom*.jar cdk-1.2.10/src/META-INF/test-structgen.cdkdepends100644 0 0 341 11570154753 16421 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-data.jar cdk-nonotify.jar cdk-standard.jar cdk-valencycheck.jar cdk-structgen.jar cdk-smiles.jar cdk-extra.jar cdk-test.jar cdk-test-core.jar cdk-formula.jar cdk-sdg.jar cdk-1.2.10/src/META-INF/test-structgen.devellibdepends100644 0 0 17 11570154753 17426 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-structgen.libdepends100644 0 0 52 11570154753 16405 0ustar 0 0 log4j*.jar jgrapht-0.6.0.jar vecmath*.jar cdk-1.2.10/src/META-INF/test-valencycheck.cdkdepends100644 0 0 315 11570154753 17043 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-core.jar cdk-standard.jar cdk-data.jar cdk-nonotify.jar cdk-io.jar cdk-extra.jar cdk-valencycheck.jar cdk-smiles.jar cdk-test.jar cdk-formula.jar cdk-testdata.jar cdk-1.2.10/src/META-INF/test-valencycheck.devellibdepends100644 0 0 17 11570154753 20047 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test-valencycheck.libdepends100644 0 0 52 11570154753 17026 0ustar 0 0 jgrapht-0.6.0.jar log4j*.jar vecmath*.jar cdk-1.2.10/src/META-INF/test.cdkdepends100644 0 0 154 11570154753 14407 0ustar 0 0 cdk-annotation.jar cdk-interfaces.jar cdk-annotation.jar cdk-core.jar cdk-standard.jar cdk-valencycheck.jar cdk-1.2.10/src/META-INF/test.devellibdepends100644 0 0 17 11570154753 15412 0ustar 0 0 junit-4.5.jar cdk-1.2.10/src/META-INF/test.libdepends100644 0 0 30 11570154753 14365 0ustar 0 0 vecmath*.jar log4j*.jar cdk-1.2.10/src/META-INF/valencycheck.cdkdepends100644 0 0 104 11570154753 16062 0ustar 0 0 cdk-interfaces.jar cdk-annotation.jar cdk-core.jar cdk-standard.jar cdk-1.2.10/src/META-INF/valencycheck.libdepends100644 0 0 15 11570154753 16050 0ustar 0 0 vecmath*.jar cdk-1.2.10/src/main/net/sf/cdk/tools/MakeJavafilesFiles.java100644 0 0 23664 11570154753 20670 0ustar 0 0 /* $Revision: 6707 $ $Author: egonw $ $Date: 2006-07-30 16:38:18 -0400 (Sun, 30 Jul 2006) $ * * Copyright (C) 2006 Egon Willighagen * * 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 net.sf.cdk.tools; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.ArrayList; import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Map; /** * Class that creates the ${build}/*.javafiles. * * @author egonw */ public class MakeJavafilesFiles { private Map> cdkPackages; private Map> cdkSets; private String default_module; /** Java files that should not be processed because they are * listed in a *.autogenerated file. */ private List blacklist; private String sourceDir = null; private String outputDir = null; private String metainfDir = null; public MakeJavafilesFiles(String metainfDir, String sourceDir, String outputDir) { cdkPackages = new Hashtable>(); cdkSets = new Hashtable>(); this.sourceDir = sourceDir; this.outputDir = outputDir; this.metainfDir = metainfDir; readBlackList(); if (sourceDir.contains("test")) { default_module = "test-extra"; } else { default_module = "extra"; } } private void readBlackList() { blacklist = new ArrayList(); String metainfDirPath = this.metainfDir; File metinfDir = new File(metainfDirPath); File[] files = metinfDir.listFiles(); for (int i=0; i 0) blacklist.add(line); line = reader.readLine(); } } catch (Exception e) { System.out.println("Error reading a *.autogenerated file: " + e.getMessage()); e.printStackTrace(); System.exit(1); } } } } public void outputResults() { // output information in .javafiles and .classes files try { Iterator keys = cdkPackages.keySet().iterator(); while (keys.hasNext()) { String key = (String)keys.next(); // create one file for each cdk package = key PrintWriter outJava = new PrintWriter( new FileWriter(outputDir + "/" + key + ".javafiles") ); PrintWriter outClass = new PrintWriter( new FileWriter(outputDir + "/" + key + ".classes") ); List packageClasses = cdkPackages.get(key); Iterator classes = packageClasses.iterator(); while (classes.hasNext()) { String packageClass = toAPIPath(classes.next()); if (!blacklist.contains(packageClass + ".java")) { outJava.println(packageClass + ".java"); outClass.println(packageClass + "*.class"); } } outJava.flush(); outJava.close(); outClass.flush(); outClass.close(); } // output information in .set files keys = cdkSets.keySet().iterator(); while (keys.hasNext()) { String key = (String)keys.next(); // create one file for each cdk package = key PrintWriter outJava = new PrintWriter( new FileWriter(outputDir + "/" + key + ".set") ); List packageClasses = cdkSets.get(key); Iterator classes = packageClasses.iterator(); while (classes.hasNext()) { String packageClass = (String)classes.next(); outJava.println(packageClass); } outJava.flush(); outJava.close(); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } public void processJavaSourceFiles(File path) { if (path.isDirectory()) { File[] files = path.listFiles(); for (int i=files.length;i>0;i--) { processJavaSourceFiles(files[i-1]); } } else if (path.isFile() && path.getPath().endsWith(".java") && !(path.getPath().indexOf("net/sf") != -1 || path.getPath().indexOf("net\\sf") != -1)) { String[] moduleAndSet = getModuleAndSet(path); if (moduleAndSet == null) { System.out.println("Something wrong with the Java source file: " + path); } else { if (moduleAndSet[0] != null) { addClassToCDKPackage(getSourceName(path), moduleAndSet[0]); } if (moduleAndSet[1] != null) { addClassToCDKSet(getClassName(path), moduleAndSet[1]); } } } } public String[] getModuleAndSet(File file) { try { String[] results = new String[2]; results[0] = default_module; results[1] = null; BufferedReader reader = new BufferedReader( new FileReader(file) ); String line = null; boolean inComment = false; while ((line = reader.readLine()) != null) { int index = line.indexOf("/**"); if (index != -1) { inComment = true; if (line.substring(index).indexOf("*/") != -1) inComment = false; } else { if (line.indexOf("*/") != -1) inComment = false; } if (!inComment && (line.indexOf("public class") != -1 || line.indexOf("public enum") != -1 || line.indexOf("public interface") != -1 || line.indexOf("public @interface") != -1 || line.indexOf("abstract class") != -1 || line.indexOf("final class") != -1)) { // Nothing specified: return the default 'extra' reader.close(); return results; } index = line.indexOf("@cdk.module"); String name = ""; if (index != -1) { index += 11; // skip the first chars while (Character.isWhitespace(line.charAt(index))) index++; while (index < line.length() && !Character.isWhitespace(line.charAt(index))) { name += line.charAt(index); index++; } results[0] = name; } else { index = line.indexOf("@cdk.set"); String set = ""; if (index != -1) { index += 11; // skip the first chars while (Character.isWhitespace(line.charAt(index))) index++; while (index < line.length() && !Character.isWhitespace(line.charAt(index))) { set += line.charAt(index); index++; } results[1] = set; } } } } catch (Exception e) { e.printStackTrace(); } return null; } public static void main(String[] args) { if (args.length != 3) { System.out.println("Syntax: MakeJavafilesFiles "); System.exit(-1); } MakeJavafilesFiles processor = new MakeJavafilesFiles(args[0], args[1], args[2]); processor.processJavaSourceFiles(new File(args[1])); processor.outputResults(); } private String toAPIPath(String className) { StringBuffer sb = new StringBuffer(); for (int i=0; i packageClasses = cdkPackages.get(cdkPackageName); if (packageClasses == null) { packageClasses = new ArrayList(); cdkPackages.put(cdkPackageName, packageClasses); } packageClasses.add(packageClass); } private void addClassToCDKSet(String packageClass, String cdkPackageName) { List packageClasses = cdkSets.get(cdkPackageName); if (packageClasses == null) { packageClasses = new ArrayList(); cdkSets.put(cdkPackageName, packageClasses); } packageClasses.add(packageClass); } } cdk-1.2.10/src/main/net/sf/cdk/tools/bibtex/BibTeXMLEntry.java100644 0 0 7414 11570154753 21023 0ustar 0 0 /* $Revision: 6707 $ $Author: egonw $ $Date: 2006-07-30 16:38:18 -0400 (Sun, 30 Jul 2006) $ * * Copyright (C) 2007 Egon Willighagen * * 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 net.sf.cdk.tools.bibtex; import nu.xom.Element; import nu.xom.Node; import nu.xom.Nodes; import nu.xom.XPathContext; /** * This is a tool that creates HTML for a subset of the entry types * defined in BibTeXML. It expects the document to be valid according to * the BibTeXML schema, or will fail horribly. * * @author egonw */ public class BibTeXMLEntry { private Node entry; private XPathContext context; public BibTeXMLEntry(Node entry) { this.entry = entry; context = new XPathContext("bibtex", BibTeXMLFile.BIBTEXML_NAMESPACE); context.addNamespace("b", BibTeXMLFile.BIBTEXML_NAMESPACE); } /** * The style is undefined and just made to look nice. */ public String toHTML() { // b:article Nodes results = entry.query("./b:article", context); for (int i=0; i").append(title).append(", "); buffer.append(journal).append(", ").append(year).append(", "); buffer.append(volume).append(":").append(pages); return buffer.toString(); } protected String formatMisc(String authors, String title) { StringBuffer buffer = new StringBuffer(); buffer.append(authors).append(", ").append(title).append(""); return buffer.toString(); } /** * @param node Parent for the child. * @param childElement Localname of the child element. * @param def String to default to if no child element is found. * @return String value for the child node. */ private String getString(Node node, String childElement, String def) { Nodes result = node.query("./b:" + childElement, context); return result.size() > 0 ? ((Element)result.get(0)).getValue() : def; } } cdk-1.2.10/src/main/net/sf/cdk/tools/bibtex/BibTeXMLFile.java100644 0 0 4531 11570154753 20576 0ustar 0 0 /* $Revision: 6707 $ $Author: egonw $ $Date: 2006-07-30 16:38:18 -0400 (Sun, 30 Jul 2006) $ * * Copyright (C) 2007 Egon Willighagen * * 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 net.sf.cdk.tools.bibtex; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import nu.xom.Node; import nu.xom.Nodes; import nu.xom.XPathContext; /** * Wrapper for a BibTeXML file. * * @author egonw */ public class BibTeXMLFile { public final static String BIBTEXML_NAMESPACE = "http://bibtexml.sf.net/"; private Node root; private XPathContext context; public BibTeXMLFile(Node root) { this.root = root; context = new XPathContext("bibtex", BIBTEXML_NAMESPACE); context.addNamespace("b", BIBTEXML_NAMESPACE); } /** * Returns an Iterator<BibTeXMLEntry>. * * @return The BibTeXMLEntry */ public Iterator getEntries() { List entries = new ArrayList(); Nodes results = root.query("//b:entry", context); for (int i=0; i 0) { return new BibTeXMLEntry(results.get(0)); } return null; } } cdk-1.2.10/src/main/net/sf/cdk/tools/copyright/CheckCopyrightStatements.java100644 0 0 17777 11570154753 24201 0ustar 0 0 /* $Revision: 6707 $ $Author: egonw $ $Date: 2006-07-30 16:38:18 -0400 (Sun, 30 Jul 2006) $ * * Copyright (C) 2006-2008 Egon Willighagen * * 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 net.sf.cdk.tools.copyright; import java.io.BufferedReader; import java.io.File; import java.io.FileReader; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * @author egonw */ public class CheckCopyrightStatements { private enum CopyrightField { YEAR_INFO, AUTHOR_NAME, AUTHOR_EMAIL } public void processJavaSourceFiles(File path) { if (path.isDirectory()) { for (File file : path.listFiles()) { processJavaSourceFiles(file); } } else if (path.isFile() && path.getPath().endsWith(".java") && !path.getPath().contains("net" + File.separator + "sf")) { Map>> copyrights = getCopyrightInfo(path); if (copyrights != null) checkCopyrightStatements(copyrights); } } private void checkCopyrightStatements(Map>> copyrights ) { String fileName = copyrights.keySet().iterator().next(); List> copyrightList = copyrights.get(fileName); if (copyrightList.size() == 0) { System.out.println(fileName + ": missing copyright line."); } for (Map holder : copyrightList) { // check year if (holder.get(CopyrightField.YEAR_INFO) == null) { System.out.println(fileName + ": missing copyright year."); } // check copyright holder if (holder.get(CopyrightField.AUTHOR_NAME) == null) { System.out.println(fileName + ": missing copyright holder name."); } else { String holderName = holder.get(CopyrightField.AUTHOR_NAME); // check holder != CDK if (holderName.contains("Chemistry") && holderName.contains("Development") && holderName.contains("Kit")) { System.out.println(fileName + ": copyright is not a legal entity"); } else if (holder.get(CopyrightField.AUTHOR_EMAIL) == null) { System.out.println(fileName + ": copyright holder is not identified by an email address"); } } } } public Map>> getCopyrightInfo(File file) { boolean autoGenerated = false; Map>> results = new HashMap>>(); List> copyrights = new ArrayList>(); try { BufferedReader reader = new BufferedReader( new FileReader(file) ); String line = null; boolean foundPackageClause = false; while ((line = reader.readLine()) != null && !foundPackageClause) { if (line.toLowerCase().contains("do not edit")) { return null; }; foundPackageClause = line.contains("package"); if (line.contains("Copyright")) { Map copyrightProperties = new HashMap(); Pattern copyrightPattern = Pattern.compile(".*Copyright\\s*\\(C\\)\\s*(.*)"); Matcher generalMatch = copyrightPattern.matcher(line); if (generalMatch.matches()) { String interestingInfo = generalMatch.group(1).trim(); String year = null; String author = null; String email = null; Pattern yearsPattern = Pattern.compile("(\\d{4}-\\d{4}).*"); Pattern yearPattern = Pattern.compile("(\\d{4}).*"); Matcher yearMatch = yearPattern.matcher(interestingInfo); Matcher yearsMatch = yearsPattern.matcher(interestingInfo); if (yearsMatch.matches() || yearMatch.matches()) { year = yearsMatch.matches() ? yearsMatch.group(1) : yearMatch.group(1); copyrightProperties.put(CopyrightField.YEAR_INFO, year); if (interestingInfo.length() > year.length()) { interestingInfo = interestingInfo.substring(year.length()+1).trim(); } else { interestingInfo = ""; } } if (year != null) { Pattern authorPattern = Pattern.compile("([^<]*).*"); Matcher authorMatch = authorPattern.matcher(interestingInfo); if (authorMatch.matches()) { author = authorMatch.group(1).trim(); copyrightProperties.put(CopyrightField.AUTHOR_NAME, author); if (interestingInfo.length() > author.length()) { interestingInfo = interestingInfo.substring(author.length()+1).trim(); } else { interestingInfo = ""; } } } if (author != null) { Pattern emailPattern = Pattern.compile("<([^>]*).*"); Matcher emailMatch = emailPattern.matcher(interestingInfo); if (emailMatch.matches()) { email = emailMatch.group(1).trim(); copyrightProperties.put(CopyrightField.AUTHOR_EMAIL, email); } } } copyrights.add(copyrightProperties); } } } catch (Exception e) { e.printStackTrace(); } results.put(toAPIPath(file.getPath()), copyrights); return results; } public static void main(String[] args) { CheckCopyrightStatements processor = new CheckCopyrightStatements(); processor.processJavaSourceFiles(new File("src/main")); } private String toAPIPath(String className) { className = className.replaceFirst("src" + File.separator + "main" + File.separator, ""); className = className.replaceFirst(".java", ""); StringBuffer sb = new StringBuffer(); for (int i=0; i * * 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 net.sf.cdk.tools.coverage; import java.io.BufferedReader; import java.io.File; import java.io.FileFilter; import java.io.FileReader; import java.util.ArrayList; import java.util.List; public class CheckModuleCoverage { /** Modules that do no need to have a test suite */ List blackList = new ArrayList(); List modules = new ArrayList(); private CheckModuleCoverage() { blackList.add("builder3dtools"); blackList.add("interfaces"); blackList.add("jchempaint"); blackList.add("controlold"); blackList.add("experimental"); blackList.add("applications"); } private void findModules() { // construct a list of modules, assuming runDoclet has been run File dir = new File("build"); File[] files = dir.listFiles(new JavaFilesFilter()); for (int i=0; i 0) { System.out.println("Missing test suites: " + missingSuites); } } private void checkModuleSuiteContainsCoverageTest() { int missingCoverages = 0; for (String module : modules) { String expectedSuite = "src/test/org/openscience/cdk/modulesuites/M" + module + "Tests.java"; File file = new File(expectedSuite); boolean coverageTestFound = false; if (file.exists()) { try { BufferedReader reader = new BufferedReader( new FileReader(file) ); String line = reader.readLine(); while (line != null && !coverageTestFound) { if (line.contains(module.substring(0,1).toUpperCase() + module.substring(1) + "CoverageTest")) { coverageTestFound = true; } line = reader.readLine(); } if (!coverageTestFound) { System.out.println("Missing coverage test in suite: " + module); missingCoverages++; } reader.close(); } catch (Exception e) { e.printStackTrace(); } } } if (missingCoverages > 0) { System.out.println("Missing coverage tests in suite: " + missingCoverages); } } private void checkCoverageTesting() { int missingCoverage = 0; for (String module : modules) { String expectedSuite = "src/test/org/openscience/cdk/coverage/" + module.substring(0,1).toUpperCase() + module.substring(1) + "CoverageTest.java"; if (!new File(expectedSuite).exists()) { System.out.println("No code coverage checking found for: " + module); missingCoverage++; } } if (missingCoverage > 0) { System.out.println("Missing coverage checkers: " + missingCoverage); } } public static void main(String[] args) { CheckModuleCoverage checker = new CheckModuleCoverage(); checker.findModules(); checker.checkModuleSuites(); checker.checkCoverageTesting(); checker.checkModuleSuiteContainsCoverageTest(); } class JavaFilesFilter implements FileFilter { public boolean accept(File file) { return file.getName().endsWith(".javafiles"); } } } cdk-1.2.10/src/main/net/sf/cdk/tools/doclets/CDKBugTaglet.java100644 0 0 5462 11570154753 21014 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2004-2007 Egon Willighagen * * 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. * * 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 net.sf.cdk.tools.doclets; import com.sun.tools.doclets.Taglet; import com.sun.javadoc.*; import java.util.Map; /** * Taglet that expands @cdk.bug tag into a weblink to CDK's * SourceForge bug track system. It's typically used as: *
 *   @cdk.bug 1095690
 * 
*/ public class CDKBugTaglet implements Taglet { private static final String NAME = "cdk.bug"; public String getName() { return NAME; } public boolean inField() { return false; } public boolean inConstructor() { return false; } public boolean inMethod() { return false; } public boolean inOverview() { return false; } public boolean inPackage() { return false; } public boolean inType() { return true; } public boolean isInlineTag() { return false; } public static void register(Map tagletMap) { CDKBugTaglet tag = new CDKBugTaglet(); Taglet t = (Taglet) tagletMap.get(tag.getName()); if (t != null) { tagletMap.remove(tag.getName()); } tagletMap.put(tag.getName(), tag); } public String toString(Tag tag) { return "
This class is affected by these bug(s):
" + expand(tag) + "
\n"; } public String toString(Tag[] tags) { if (tags.length == 0) { return null; } else { StringBuffer list = new StringBuffer(); list.append("
This class is affected by these bug(s):
"); for (int i=0; i\n"); return list.toString(); } } private String expand(Tag tag) { return "" + tag.text() + ""; } } cdk-1.2.10/src/main/net/sf/cdk/tools/doclets/CDKCiteTaglet.java100644 0 0 11353 11570154753 21177 0ustar 0 0 /* $Revision: 7327 $ $Author: egonw $ $Date: 2006-11-20 20:22:51 +0100 (Mon, 20 Nov 2006) $ * * Copyright (C) 2004-2007 Egon Willighagen * * 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. * * 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 net.sf.cdk.tools.doclets; import java.io.File; import java.util.Map; import java.util.StringTokenizer; import net.sf.cdk.tools.bibtex.BibTeXMLEntry; import net.sf.cdk.tools.bibtex.BibTeXMLFile; import nu.xom.Builder; import nu.xom.Document; import com.sun.javadoc.Tag; import com.sun.tools.doclets.Taglet; /** * Taglet that expands inline cdk.cite tags into a weblink to the CDK * bibliography webpage. Like all inline tags it's used in the JavaDoc * text as: *
 * This class does nothing {@cdk.cite NULL}.
 * 
* For this code a reference is created like this: *
 * NULL
 * 
* *

Citations can be singular, like {@cdk.cite BLA}, * and multiple, like {@cdk.cite BLA,BLA2,FOO}. */ public class CDKCiteTaglet implements Taglet { private static final String NAME = "cdk.cite"; private static BibTeXMLFile bibtex = null; static { try { Builder parser = new Builder(); Document doc = parser.build(new File("doc/refs/cheminf.bibx")); bibtex = new BibTeXMLFile(doc.getRootElement()); } catch (Exception exc) { System.out.println("Horrible problem: " + exc.getMessage()); exc.printStackTrace(); } } public String getName() { return NAME; } public boolean inField() { return true; } public boolean inConstructor() { return true; } public boolean inMethod() { return true; } public boolean inOverview() { return true; } public boolean inPackage() { return true; } public boolean inType() { return true; } public boolean isInlineTag() { return true; } public static void register(Map tagletMap) { CDKCiteTaglet tag = new CDKCiteTaglet(); Taglet t = (Taglet) tagletMap.get(tag.getName()); if (t != null) { tagletMap.remove(tag.getName()); } tagletMap.put(tag.getName(), tag); } public String toString(Tag tag) { return "[" + expandCitation(tag.text()) + "]"; } public String toString(Tag[] tags) { String result = null; if (tags.length > 0) { result = "["; for (int i=0; i"; if (citation.indexOf(separator) != -1) { StringTokenizer tokenizer = new StringTokenizer(citation, separator); while (tokenizer.hasMoreTokens()) { String token = tokenizer.nextToken().trim(); BibTeXMLEntry entry = bibtex.getEntry(token); if (entry != null) { result += entry.toHTML(); } else { result += token + " (not found in db)"; System.out.println("CDKCiteERROR: entry not found in database: " + token); } if (tokenizer.hasMoreTokens()) { result += ", "; } } } else { citation = citation.trim(); BibTeXMLEntry entry = bibtex.getEntry(citation); if (entry != null) { result += entry.toHTML(); } else { result += citation + " (not found in db)"; System.out.println("CDKCiteERROR: entry not found in database: " + citation); } } return result; } } cdk-1.2.10/src/main/net/sf/cdk/tools/doclets/CDKDictRefTaglet.java100644 0 0 11044 11570154753 21630 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2004-2007 Egon Willighagen * * 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. * * 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 net.sf.cdk.tools.doclets; import com.sun.tools.doclets.Taglet; import com.sun.javadoc.*; import java.util.Map; import java.util.StringTokenizer; import java.util.Hashtable; /** * Taglet that expands inline cdk.dictref tags into a weblink to the appropriate * dictionary. For example. *

 * @cdk.dictref blue-obelisk:graphPartitioning
 * 
* *

The known dictionaries are: *

*/ public class CDKDictRefTaglet implements Taglet { private static final String NAME = "cdk.dictref"; private static final Map dictURLs; private static final Map dictNames; static { dictURLs = new Hashtable(5); dictNames = new Hashtable(5); dictURLs.put("bodf", "http://qsar.sourceforge.net/ontologies/data-features/index.xhtml"); dictNames.put("bodf", "Blue Obelisk Data Features Dictionary"); dictURLs.put("blue-obelisk", "http://qsar.sourceforge.net/dicts/blue-obelisk/index.xhtml"); dictNames.put("blue-obelisk", "Blue Obelisk Chemoinformatics Dictionary"); dictURLs.put("qsar-descriptors", "http://qsar.sourceforge.net/dicts/qsar-descriptors/index.xhtml"); dictNames.put("qsar-descriptors", "QSAR.sf.net Descriptors Dictionary"); } public String getName() { return NAME; } public boolean inField() { return true; } public boolean inConstructor() { return true; } public boolean inMethod() { return true; } public boolean inOverview() { return true; } public boolean inPackage() { return true; } public boolean inType() { return true; } public boolean isInlineTag() { return false; } public static void register(Map tagletMap) { CDKDictRefTaglet tag = new CDKDictRefTaglet(); Taglet t = (Taglet) tagletMap.get(tag.getName()); if (t != null) { tagletMap.remove(tag.getName()); } tagletMap.put(tag.getName(), tag); } public String toString(Tag tag) { String tagText = tag.text(); String separator = ":"; if (tagText.indexOf(separator) != -1) { StringTokenizer tokenizer = new StringTokenizer(tagText, separator); String dictCode = tokenizer.nextToken(); String dictRef = tokenizer.nextToken(); String output = "
Dictionary pointer(s):
"; if (dictURLs.containsKey(dictCode)) { String url = dictURLs.get(dictCode) + "#" + dictRef; output += "" + dictRef + " in the " + dictNames.get(dictCode) + " [" + tagText + "]
\n"; } else { output += "Unknown code: " + tagText + "\n"; } return output; } else { return "
A pointer to a dictionary:
Unknown code: " + tagText + "
\n"; } } public String toString(Tag[] tags) { if (tags.length == 0) { return null; } else { return toString(tags[0]); } } } cdk-1.2.10/src/main/net/sf/cdk/tools/doclets/CDKGitTaglet.java100644 0 0 7053 11570154753 21020 0ustar 0 0 /* $Revision: 7973 $ $Author: egonw $ $Date: 2007-02-19 13:16:03 +0100 (Mon, 19 Feb 2007) $ * * Copyright (C) 2007 Egon Willighagen * * 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. * * 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 net.sf.cdk.tools.doclets; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import com.sun.javadoc.SourcePosition; import com.sun.javadoc.Tag; import com.sun.tools.doclets.Taglet; /** * Source for the cdk.githash JavaDoc tag. When a class is tagged with this * tag, the JavaDoc will contain a link to the source code in the Git repository. * *

The syntax must be as follows: *

 *   @cdk.githash
 * 
*/ public class CDKGitTaglet implements Taglet { private static final String NAME = "cdk.githash"; private final static Pattern pathPattern = Pattern.compile(".*/(src/.*\\.java)"); public String getName() { return NAME; } public boolean inField() { return false; } public boolean inConstructor() { return false; } public boolean inMethod() { return false; } public boolean inOverview() { return false; } public boolean inPackage() { return false; } public boolean inType() { return true; } public boolean isInlineTag() { return false; } public static void register(Map tagletMap) { CDKGitTaglet tag = new CDKGitTaglet(); Taglet t = (Taglet) tagletMap.get(tag.getName()); if (t != null) { tagletMap.remove(tag.getName()); } tagletMap.put(tag.getName(), tag); } public String toString(Tag tag) { return "
Source code:
" + expand(tag) + "
\n"; } public String toString(Tag[] tags) { if (tags.length == 0) { return null; } else { return toString(tags[0]); } } private String expand(Tag tag) { // get the version number String text = tag.text(); // create the URL SourcePosition file = tag.position(); String path = correctSlashes(file.file().getAbsolutePath()); Matcher matcher = pathPattern.matcher(path); if (matcher.matches()) { String url = "http://cdk.git.sourceforge.net/git/gitweb.cgi?p=cdk;a=blob;f=" + matcher.group(1) + ";hb=HEAD"; return "HEAD"; } else { System.out.println("Could not resolve class name from: " + path); } return ""; } private String correctSlashes(String absolutePath) { StringBuffer buffer = new StringBuffer(); for (int i=0; i * * 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. * * 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 net.sf.cdk.tools.doclets; import com.sun.tools.doclets.Taglet; import com.sun.javadoc.*; import java.util.Map; /** * Taglet that expands @cdk.inchi tag into a RDFa marked up HTML * fragment. It's typically used as: *
 *   @cdk.inchi InChI=1/CH4/h1H4
 * 
*/ public class CDKInChITaglet implements Taglet { private static final String NAME = "cdk.inchi"; public String getName() { return NAME; } public boolean inField() { return false; } public boolean inConstructor() { return false; } public boolean inMethod() { return true; } public boolean inOverview() { return false; } public boolean inPackage() { return false; } public boolean inType() { return true; } public boolean isInlineTag() { return false; } public static void register(Map tagletMap) { CDKInChITaglet tag = new CDKInChITaglet(); Taglet t = (Taglet) tagletMap.get(tag.getName()); if (t != null) { tagletMap.remove(tag.getName()); } tagletMap.put(tag.getName(), tag); } public String toString(Tag tag) { return "
InChI:
" + expand(tag) + "
\n"; } public String toString(Tag[] tags) { if (tags.length == 0) { return null; } else { StringBuffer list = new StringBuffer(); list.append("
InChI(s):
"); for (int i=0; i\n"); return list.toString(); } } private String expand(Tag tag) { return "" + tag.text() + ""; } } cdk-1.2.10/src/main/net/sf/cdk/tools/doclets/CDKModuleTaglet.java100644 0 0 4557 11570154753 21530 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2004 Egon Willighagen * * 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. * * 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 net.sf.cdk.tools.doclets; import com.sun.tools.doclets.Taglet; import com.sun.javadoc.*; import java.util.Map; /** * Taglet that expands @cdk.module tag into a weblink to the CDK * webpage. */ public class CDKModuleTaglet implements Taglet { private static final String NAME = "cdk.module"; public String getName() { return NAME; } public boolean inField() { return true; } public boolean inConstructor() { return true; } public boolean inMethod() { return true; } public boolean inOverview() { return true; } public boolean inPackage() { return true; } public boolean inType() { return true; } public boolean isInlineTag() { return false; } public static void register(Map tagletMap) { CDKModuleTaglet tag = new CDKModuleTaglet(); Taglet t = (Taglet) tagletMap.get(tag.getName()); if (t != null) { tagletMap.remove(tag.getName()); } tagletMap.put(tag.getName(), tag); } public String toString(Tag tag) { return "
Belongs to CDK module:
" + "" + tag.text() + "
\n"; } public String toString(Tag[] tags) { if (tags.length == 0) { return null; } else { return toString(tags[0]); } } } cdk-1.2.10/src/main/net/sf/cdk/tools/doclets/CDKThreadNonSafeTaglet.java100644 0 0 4601 11570154753 22752 0ustar 0 0 /* $Revision: 7973 $ $Author: egonw $ $Date: 2007-02-19 13:16:03 +0100 (Mon, 19 Feb 2007) $ * * Copyright (C) 2007 Egon Willighagen * * 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. * * 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 net.sf.cdk.tools.doclets; import com.sun.tools.doclets.Taglet; import com.sun.javadoc.*; import java.util.Map; /** * Taglet used to indicate that the class is annotated to be not safe for * use in threaded environments. It does not have any parameters: *
 *   @cdk.threadnonsafe
 * 
*/ public class CDKThreadNonSafeTaglet implements Taglet { private static final String NAME = "cdk.threadnonsafe"; public String getName() { return NAME; } public boolean inField() { return false; } public boolean inConstructor() { return false; } public boolean inMethod() { return true; } public boolean inOverview() { return false; } public boolean inPackage() { return false; } public boolean inType() { return true; } public boolean isInlineTag() { return false; } public static void register(Map tagletMap) { CDKThreadNonSafeTaglet tag = new CDKThreadNonSafeTaglet(); Taglet t = (Taglet) tagletMap.get(tag.getName()); if (t != null) { tagletMap.remove(tag.getName()); } tagletMap.put(tag.getName(), tag); } public String toString(Tag tag) { return tag != null ? "Thread Safe: No\n" : ""; } public String toString(Tag[] tags) { return tags.length != 0 ? "Thread Safe: No\n" : ""; } } cdk-1.2.10/src/main/net/sf/cdk/tools/doclets/CDKThreadSafeTaglet.java100644 0 0 4604 11570154753 22302 0ustar 0 0 /* $Revision: 7973 $ $Author: egonw $ $Date: 2007-02-19 13:16:03 +0100 (Mon, 19 Feb 2007) $ * * Copyright (C) 2007 Egon Willighagen * * 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. * * 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 net.sf.cdk.tools.doclets; import com.sun.tools.doclets.Taglet; import com.sun.javadoc.*; import java.util.Map; /** * Taglet used to indicate that the class is annotated to be safe for * use in threaded environments. It does not have any parameters: *
 *   @cdk.threadsafe
 * 
*/ public class CDKThreadSafeTaglet implements Taglet { private static final String NAME = "cdk.threadsafe"; public String getName() { return NAME; } public boolean inField() { return false; } public boolean inConstructor() { return false; } public boolean inMethod() { return true; } public boolean inOverview() { return false; } public boolean inPackage() { return false; } public boolean inType() { return true; } public boolean isInlineTag() { return false; } public static void register(Map tagletMap) { CDKThreadSafeTaglet tag = new CDKThreadSafeTaglet(); Taglet t = (Taglet) tagletMap.get(tag.getName()); if (t != null) { tagletMap.remove(tag.getName()); } tagletMap.put(tag.getName(), tag); } public String toString(Tag tag) { return tag != null ? "Thread Safe: Yes\n" : ""; } public String toString(Tag[] tags) { return tags.length != 0 ? "Thread Safe: Yes\n" : ""; } } cdk-1.2.10/src/main/org/openscience/cdk/AminoAcid.java100644 0 0 11714 11570154753 17544 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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 org.openscience.cdk; import java.io.Serializable; import org.openscience.cdk.interfaces.IAminoAcid; import org.openscience.cdk.interfaces.IAtom; /** * A AminoAcid is Monomer which stores additional amino acid specific * informations, like the N-terminus atom. * * @cdk.module data * @cdk.githash * * @author Egon Willighagen * @cdk.created 2005-08-11 * @cdk.keyword amino acid */ public class AminoAcid extends Monomer implements IAminoAcid, Serializable, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = -5032283549467862509L; /** The atom that constitutes the N-terminus. */ private IAtom nTerminus; /** The atom that constitutes the C-terminus. */ private IAtom cTerminus; /** * Constructs a new AminoAcid. */ public AminoAcid() { super(); } /** * Retrieves the N-terminus atom. * * @return The Atom that is the N-terminus * * @see #addNTerminus(IAtom) */ public IAtom getNTerminus() { return nTerminus; } /** * Add an Atom and makes it the N-terminus atom. * * @param atom The Atom that is the N-terminus * * @see #getNTerminus */ public void addNTerminus(IAtom atom) { super.addAtom(atom); nTerminus = atom; } /** * Marks an Atom as being the N-terminus atom. It assumes that the Atom * is already added to the AminoAcid. * * @param atom The Atom that is the N-terminus * * @see #addNTerminus */ private void setNTerminus(IAtom atom) { nTerminus = atom; } /** * Retrieves the C-terminus atom. * * @return The Atom that is the C-terminus * * @see #addCTerminus(IAtom) */ public IAtom getCTerminus() { return cTerminus; } /** * Add an Atom and makes it the C-terminus atom. * * @param atom The Atom that is the C-terminus * * @see #getCTerminus */ public void addCTerminus(IAtom atom) { super.addAtom(atom); setCTerminus(atom); } /** * Marks an Atom as being the C-terminus atom. It assumes that the Atom * is already added to the AminoAcid. * * @param atom The Atom that is the C-terminus * * @see #addCTerminus */ private void setCTerminus(IAtom atom) { cTerminus = atom; } /** * Clones this AminoAcid object. * * @return The cloned object */ public Object clone() throws CloneNotSupportedException { AminoAcid clone = (AminoAcid) super.clone(); // copying the new N-terminus and C-terminus pointers if (getNTerminus() != null) clone.setNTerminus(clone.getAtom(getAtomNumber(getNTerminus()))); if (getCTerminus() != null) clone.setCTerminus(clone.getAtom(getAtomNumber(getCTerminus()))); return clone; } public String toString() { StringBuffer stringContent = new StringBuffer(32); stringContent.append("AminoAcid("); stringContent.append(this.hashCode()); if (nTerminus != null) { stringContent.append(", N:").append(nTerminus.toString()); } if (cTerminus != null) { stringContent.append(", C:").append(cTerminus.toString()); } stringContent.append(", ").append(super.toString()); stringContent.append(')'); return stringContent.toString(); } } cdk-1.2.10/src/main/org/openscience/cdk/Association.java100644 0 0 12726 11570154753 20200 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2004-2007 Egon Willighagen * * 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. * * 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; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IAtom; /** * Base class for storing interactions like hydrogen bonds and ionic interactions. * The ElectronContainer contains zero electrons by default. * * @cdk.module extra * @cdk.githash * * @cdk.keyword orbital * @cdk.keyword association * @cdk.keyword bond */ @TestClass("org.openscience.cdk.AssociationTest") public class Association extends ElectronContainer implements java.io.Serializable, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = -9138919895942850167L; /** Number of electrons in the association. */ protected final int electronCount = 0; /** The atoms which take part in the association. */ protected IAtom[] atoms; protected int atomCount; /** * Constructs an association between two Atom's. * * @param atom1 An atom to be associated with another atom * @param atom2 An atom to be associated with another atom * @see org.openscience.cdk.Atom */ @TestMethod("testAssociation_IAtom_IAtom") public Association(IAtom atom1, IAtom atom2) { atoms = new IAtom[2]; atoms[0] = atom1; atoms[1] = atom2; atomCount = 2; } /** * Constructs an empty association. * * @see org.openscience.cdk.Atom */ @TestMethod("testAssociation") public Association() { atoms = new Atom[2]; atomCount = 0; } /** * Returns the array of atoms making up this Association. * * @return An array of atoms participating in this Association * * @see #setAtoms */ @TestMethod("testGetAtoms") public IAtom[] getAtoms() { IAtom[] returnAtoms = new Atom[atomCount]; System.arraycopy(this.atoms, 0, returnAtoms, 0, returnAtoms.length); return returnAtoms; } /** * Sets the array of atoms making up this Association. * * @param atoms An array of atoms that forms this Association * * @see #getAtoms */ @TestMethod("testSetAtoms") public void setAtoms(IAtom[] atoms) { this.atoms = atoms; notifyChanged(); } /** * Returns the number of Atoms in this Association. * * @return The number of Atoms in this Association */ @TestMethod("testGetAtomCount") public int getAtomCount() { return atomCount; } /** * Returns the number of electrons in a Association. * * @return The number of electrons in a Association. */ @TestMethod("testGetAtomAt") public Integer getElectronCount() { return 0; } /** * Returns an Atom from this Association. * * @param position The position in this bond where the atom is * @return The atom at the specified position * * @see #setAtomAt */ @TestMethod("testGetAtomAt") public IAtom getAtomAt(int position) { return atoms[position]; } /** * Returns true if the given atom participates in this Association. * * @param atom The atom to be tested if it participates in this Association * @return true if the atom participates in this Association */ @TestMethod("testContains") public boolean contains(IAtom atom) { for (IAtom atom1 : atoms) { if (atom1 == atom) { return true; } } return false; } /** * Sets an Atom in this Association. * * @param atom The atom to be set * @param position The position in this Association where the atom is to be inserted * * @see #getAtomAt */ @TestMethod("testSetAtomAt") public void setAtomAt(IAtom atom, int position) { atoms[position] = atom; notifyChanged(); } /** * Returns a one line string representation of this Container. * This method is conform RFC #9. * * @return The string representation of this Container */ @TestMethod("testToString") public String toString() { StringBuffer s = new StringBuffer(); s.append("Association("); s.append(this.hashCode()); for (int i=0; i * * 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 org.openscience.cdk; import java.io.Serializable; import javax.vecmath.Point2d; import javax.vecmath.Point3d; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IElement; /** * Represents the idea of an chemical atom. * *

An Atom class is instantiated with at least the atom symbol: *

 *   Atom a = new Atom("C");
 * 
* *

Once instantiated all field not filled by passing parameters * to the constructor are null. Atoms can be configured by using * the IsotopeFactory.configure() method: *

 *   IsotopeFactory if = IsotopeFactory.getInstance(a.getBuilder());
 *   if.configure(a);
 * 
* *

More examples about using this class can be found in the * Junit test for this class. * * @cdk.module data * @cdk.githash * * @author steinbeck * @cdk.created 2000-10-02 * @cdk.keyword atom * * @see org.openscience.cdk.config.IsotopeFactory#getInstance(org.openscience.cdk.interfaces.IChemObjectBuilder) */ public class Atom extends AtomType implements IAtom, Serializable, Cloneable { /* Let's keep this exact specification * of what kind of point2d we're talking of here, * since there are so many around in the java standard api */ /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = -3137373012494608794L; /** * A 2D point specifying the location of this atom in a 2D coordinate * space. */ protected javax.vecmath.Point2d point2d = (Point2d) CDKConstants.UNSET; /** * A 3 point specifying the location of this atom in a 3D coordinate * space. */ protected javax.vecmath.Point3d point3d = (Point3d) CDKConstants.UNSET; /** * A 3 point specifying the location of this atom in a crystal unit cell. */ protected javax.vecmath.Point3d fractionalPoint3d = (Point3d) CDKConstants.UNSET; /** * The number of implicitly bound hydrogen atoms for this atom. */ protected Integer hydrogenCount = (Integer) CDKConstants.UNSET; /** * A stereo parity descriptor for the stereochemistry of this atom. */ protected Integer stereoParity = (Integer) CDKConstants.UNSET; /** * The partial charge of the atom. * * The default value is {@link CDKConstants#UNSET} and serves to provide a check whether the charge has been * set or not */ protected Double charge = (Double) CDKConstants.UNSET; /** * Constructs an completely unset Atom. */ public Atom() { super((String)null); } /** * Constructs an Atom from a String containing an element symbol. * * @param elementSymbol The String describing the element for the Atom */ public Atom(String elementSymbol) { super(elementSymbol); } /** * Constructs an Atom from an Element and a Point3d. * * @param elementSymbol The symbol of the atom * @param point3d The 3D coordinates of the atom */ public Atom(String elementSymbol, javax.vecmath.Point3d point3d) { this(elementSymbol); this.point3d = point3d; } /** * Constructs an Atom from an Element and a Point2d. * * @param elementSymbol The Element * @param point2d The Point */ public Atom(String elementSymbol, javax.vecmath.Point2d point2d) { this(elementSymbol); this.point2d = point2d; } /** * Constructs an isotope by copying the symbol, atomic number, * flags, identifier, exact mass, natural abundance, mass * number, maximum bond order, bond order sum, van der Waals * and covalent radii, formal charge, hybridization, electron * valency, formal neighbour count and atom type name from the * given IAtomType. It does not copy the listeners and * properties. If the element is an instanceof * IAtom, then the 2D, 3D and fractional coordinates, partial * atomic charge, hydrogen count and stereo parity are copied * too. * * @param element IAtomType to copy information from */ public Atom(IElement element) { super(element); if (element instanceof IAtom) { if (((IAtom)element).getPoint2d() != null) { this.point2d = new Point2d(((IAtom)element).getPoint2d()); } else { this.point2d = null; } if (((IAtom)element).getPoint3d() != null) { this.point3d = new Point3d(((IAtom)element).getPoint3d()); } else { this.point3d = null; } if (((IAtom)element).getFractionalPoint3d() != null) { this.fractionalPoint3d = new Point3d(((IAtom)element).getFractionalPoint3d()); } else { this.fractionalPoint3d = null; } this.hydrogenCount = ((IAtom)element).getHydrogenCount(); this.charge = ((IAtom)element).getCharge(); this.stereoParity = ((IAtom)element).getStereoParity(); } } /** * Sets the partial charge of this atom. * * @param charge The partial charge * * @see #getCharge */ public void setCharge(Double charge) { this.charge = charge; notifyChanged(); } /** * Returns the partial charge of this atom. * * If the charge has not been set the return value is Double.NaN * * @return the charge of this atom * * @see #setCharge */ public Double getCharge() { return this.charge; } /** * Sets the number of implicit hydrogen count of this atom. * * @param hydrogenCount The number of hydrogen atoms bonded to this atom. * * @see #getHydrogenCount */ public void setHydrogenCount(Integer hydrogenCount) { this.hydrogenCount = hydrogenCount; notifyChanged(); } /** * Returns the hydrogen count of this atom. * * @return The hydrogen count of this atom. * * @see #setHydrogenCount */ public Integer getHydrogenCount() { return this.hydrogenCount; } /** * * Sets a point specifying the location of this * atom in a 2D space. * * @param point2d A point in a 2D plane * * @see #getPoint2d */ public void setPoint2d(javax.vecmath.Point2d point2d) { this.point2d = point2d; notifyChanged(); } /** * * Sets a point specifying the location of this * atom in 3D space. * * @param point3d A point in a 3-dimensional space * * @see #getPoint3d */ public void setPoint3d(javax.vecmath.Point3d point3d) { this.point3d = point3d; notifyChanged(); } /** * Sets a point specifying the location of this * atom in a Crystal unit cell. * * @param point3d A point in a 3d fractional unit cell space * * @see #getFractionalPoint3d * @see org.openscience.cdk.Crystal */ public void setFractionalPoint3d(javax.vecmath.Point3d point3d) { this.fractionalPoint3d = point3d; notifyChanged(); } /** * Sets the stereo parity for this atom. * * @param stereoParity The stereo parity for this atom * * @see org.openscience.cdk.CDKConstants for predefined values. * @see #getStereoParity */ public void setStereoParity(Integer stereoParity) { this.stereoParity = stereoParity; notifyChanged(); } /** * Returns a point specifying the location of this * atom in a 2D space. * * @return A point in a 2D plane. Null if unset. * * @see #setPoint2d */ public javax.vecmath.Point2d getPoint2d() { return this.point2d; } /** * Returns a point specifying the location of this * atom in a 3D space. * * @return A point in 3-dimensional space. Null if unset. * * @see #setPoint3d */ public javax.vecmath.Point3d getPoint3d() { return this.point3d; } /** * Returns a point specifying the location of this * atom in a Crystal unit cell. * * @return A point in 3d fractional unit cell space. Null if unset. * * @see #setFractionalPoint3d * @see org.openscience.cdk.CDKConstants for predefined values. */ public javax.vecmath.Point3d getFractionalPoint3d() { return this.fractionalPoint3d; } /** * Returns the stereo parity of this atom. It uses the predefined values * found in CDKConstants. * * @return The stereo parity for this atom * * @see org.openscience.cdk.CDKConstants * @see #setStereoParity */ public Integer getStereoParity() { return this.stereoParity; } /** * Compares a atom with this atom. * * @param object of type Atom * @return true, if the atoms are equal */ public boolean compare(Object object) { if (!(object instanceof IAtom)) { return false; } if (!super.compare(object)) { return false; } Atom atom = (Atom) object; if (((point2d==atom.point2d) || ((point2d!=null) && (point2d.equals(atom.point2d)))) && ((point3d==atom.point3d) || ((point3d!=null) && (point3d.equals(atom.point3d)))) && (hydrogenCount==atom.hydrogenCount) && (stereoParity==atom.stereoParity) && (charge==atom.charge)) { return true; } return false; } /** * Returns a one line string representation of this Atom. * Methods is conform RFC #9. * * @return The string representation of this Atom */ public String toString() { StringBuffer stringContent = new StringBuffer(64); stringContent.append("Atom(").append(hashCode()); if (getSymbol() != null) { stringContent.append(", S:").append(getSymbol()); } if (getHydrogenCount() != null) { stringContent.append(", H:").append(getHydrogenCount()); } if (getStereoParity() != null) { stringContent.append(", SP:").append(getStereoParity()); } if (getPoint2d() != null) { stringContent.append(", 2D:[").append(getPoint2d()).append(']'); } if (getPoint3d() != null) { stringContent.append(", 3D:[").append(getPoint3d()).append(']'); } if (getFractionalPoint3d() != null) { stringContent.append(", F3D:[").append(getFractionalPoint3d()); } if (getCharge() != null) { stringContent.append(", C:").append(getCharge()); } stringContent.append(", ").append(super.toString()); stringContent.append(')'); return stringContent.toString(); } /** * Clones this atom object and its content. * * @return The cloned object */ public Object clone() throws CloneNotSupportedException { Object clone = super.clone(); if (point2d != null) { ((Atom)clone).setPoint2d(new Point2d(point2d.x, point2d.y)); } if (point3d != null) { ((Atom)clone).setPoint3d(new Point3d(point3d.x, point3d.y, point3d.z)); } if (fractionalPoint3d != null) { ((Atom)clone).setFractionalPoint3d(new Point3d(fractionalPoint3d.x, fractionalPoint3d.y, fractionalPoint3d.z)); } return clone; } } cdk-1.2.10/src/main/org/openscience/cdk/AtomContainer.java100644 0 0 133731 11570154753 20507 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 Christoph Steinbeck * * 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. * * 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; import java.io.Serializable; import java.util.ArrayList; import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Map; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomParity; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IElectronContainer; import org.openscience.cdk.interfaces.ILonePair; import org.openscience.cdk.interfaces.ISingleElectron; import org.openscience.cdk.interfaces.IBond.Order; /** * Base class for all chemical objects that maintain a list of Atoms and * ElectronContainers.

* * Looping over all Bonds in the AtomContainer is typically done like:

 * Iterator iter = atomContainer.bonds();
 * while (iter.hasNext()) {
 *   IBond aBond = (IBond) iter.next();
 * }
 *
 *  
* * @cdk.module data * @cdk.githash * * @author steinbeck * @cdk.created 2000-10-02 */ public class AtomContainer extends ChemObject implements IAtomContainer, IChemObjectListener, Serializable, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = 5678100348445919254L; /** * Number of atoms contained by this object. */ protected int atomCount; /** * Number of bonds contained by this object. */ protected int bondCount; /** * Number of lone pairs contained by this object. */ protected int lonePairCount; /** * Number of single electrons contained by this object. */ protected int singleElectronCount; /** * Amount by which the bond and atom arrays grow when elements are added and * the arrays are not large enough for that. */ protected int growArraySize = 10; /** * Internal array of atoms. */ protected IAtom[] atoms; /** * Internal array of bonds. */ protected IBond[] bonds; /** * Internal array of lone pairs. */ protected ILonePair[] lonePairs; /** * Internal array of single electrons. */ protected ISingleElectron[] singleElectrons; /** * Internal list of atom parities. */ protected Map atomParities; /** * Constructs an empty AtomContainer. */ public AtomContainer() { this(10, 10, 0, 0); } /** * Constructs an AtomContainer with a copy of the atoms and electronContainers * of another AtomContainer (A shallow copy, i.e., with the same objects as in * the original AtomContainer). * * @param container An AtomContainer to copy the atoms and electronContainers from */ public AtomContainer(IAtomContainer container) { this.atomCount = container.getAtomCount(); this.bondCount = container.getBondCount(); this.lonePairCount = container.getLonePairCount(); this.singleElectronCount = container.getSingleElectronCount(); this.atoms = new IAtom[this.atomCount]; this.bonds = new IBond[this.bondCount]; this.lonePairs = new ILonePair[this.lonePairCount]; this.singleElectrons = new ISingleElectron[this.singleElectronCount]; atomParities = new Hashtable(atomCount/2); for (int f = 0; f < container.getAtomCount(); f++) { atoms[f] = container.getAtom(f); container.getAtom(f).addListener(this); } for (int f = 0; f < this.bondCount; f++) { bonds[f] = container.getBond(f); container.getBond(f).addListener(this); } for (int f = 0; f < this.lonePairCount; f++) { lonePairs[f] = container.getLonePair(f); container.getLonePair(f).addListener(this); } for (int f = 0; f < this.singleElectronCount; f++) { singleElectrons[f] = container.getSingleElectron(f); container.getSingleElectron(f).addListener(this); } } /** * Constructs an empty AtomContainer that will contain a certain number of * atoms and electronContainers. It will set the starting array lengths to the * defined values, but will not create any Atom or ElectronContainer's. * *@param atomCount Number of atoms to be in this container *@param bondCount Number of bonds to be in this container *@param lpCount Number of lone pairs to be in this container *@param seCount Number of single electrons to be in this container * */ public AtomContainer(int atomCount, int bondCount, int lpCount, int seCount) { this.atomCount = 0; this.bondCount = 0; this.lonePairCount = 0; this.singleElectronCount = 0; atoms = new IAtom[atomCount]; bonds = new IBond[bondCount]; lonePairs = new ILonePair[lpCount]; singleElectrons = new ISingleElectron[seCount]; atomParities = new Hashtable(atomCount/2); } /** * Adds an AtomParity to this container. If a parity is already given for the * affected Atom, it is overwritten. * * @param parity The new AtomParity for this container * @see #getAtomParity */ public void addAtomParity(IAtomParity parity) { atomParities.put(parity.getAtom(), parity); } /** * Returns the atom parity for the given Atom. If no parity is associated * with the given Atom, it returns null. * * @param atom Atom for which the parity must be returned * @return The AtomParity for the given Atom, or null if that Atom does * not have an associated AtomParity * @see #addAtomParity */ public IAtomParity getAtomParity(IAtom atom) { return atomParities.get(atom); } /** * Sets the array of atoms of this AtomContainer. * *@param atoms The array of atoms to be assigned to this AtomContainer *@see #getAtom */ public void setAtoms(IAtom[] atoms) { this.atoms = atoms; for (IAtom atom : atoms) { atom.addListener(this); } this.atomCount = atoms.length; notifyChanged(); } /** * Sets the array of bonds of this AtomContainer. * * @param bonds The array of bonds to be assigned to * this AtomContainer * @see #getBond */ public void setBonds(IBond[] bonds) { this.bonds = bonds; for (IBond bond : bonds) { bond.addListener(this); } this.bondCount = bonds.length; } /** * Sets the array of electronContainers of this AtomContainer. * *@param electronContainers The array of electronContainers to be assigned to * this AtomContainer *@see #getElectronContainers */ // public void setElectronContainers(IElectronContainer[] electronContainers) // { // this.electronContainers = electronContainers; // for (int f = 0; f < electronContainers.length; f++) // { // electronContainers[f].addListener(this); // } // setElectronContainerCount(electronContainers.length); // notifyChanged(); // } /** * Sets the atom at position number in [0,..]. * *@param number The position of the atom to be set. *@param atom The atom to be stored at position number *@see #getAtom(int) */ public void setAtom(int number, IAtom atom) { atom.addListener(this); atoms[number] = atom; notifyChanged(); } /** * Get the atom at position number in [0,..]. * *@param number The position of the atom to be retrieved. *@return The atomAt value * @see #setAtom(int, org.openscience.cdk.interfaces.IAtom) * @see #setAtoms(org.openscience.cdk.interfaces.IAtom[]) * */ public IAtom getAtom(int number) { return atoms[number]; } /** * Get the bond at position number in [0,..]. * *@param number The position of the bond to be retrieved. *@return The bondAt value */ public IBond getBond(int number) { return bonds[number]; } /** * Get the lone pair at position number in [0,..]. * *@param number The position of the LonePair to be retrieved. *@return The lone pair number */ public ILonePair getLonePair(int number) { return lonePairs[number]; } /** * Get the single electron at position number in [0,..]. * *@param number The position of the SingleElectron to be retrieved. *@return The single electron number */ public ISingleElectron getSingleElectron(int number) { return singleElectrons[number]; } /** * Sets the ElectronContainer at position number in [0,..]. * * @param number The position of the ElectronContainer to be set. * @param electronContainer The ElectronContainer to be stored at position number * @see #getElectronContainer(int) */ // public void setElectronContainer(int number, IElectronContainer electronContainer) // { // electronContainer.addListener(this); // electronContainers[number] = electronContainer; // notifyChanged(); // } /** * Sets the number of electronContainers in this container. * * @param electronContainerCount The number of electronContainers in this * container * @see #getElectronContainerCount */ // public void setElectronContainerCount(int electronContainerCount) // { // this.electronContainerCount = electronContainerCount; // notifyChanged(); // } /** * Sets the number of atoms in this container. * *@param atomCount The number of atoms in this container *@see #getAtomCount */ // public void setAtomCount(int atomCount) // { // this.atomCount = atomCount; // notifyChanged(); // } /** * Returns an Iterable for looping over all atoms in this container. * *@return An Iterable with the atoms in this container */ public Iterable atoms() { return new Iterable() { public Iterator iterator() { return new AtomIterator(); } }; } /** * The inner AtomIterator class. * */ private class AtomIterator implements Iterator { private int pointer = 0; public boolean hasNext() { return pointer < atomCount; } public IAtom next() { return atoms[pointer++]; } public void remove() { removeAtom(--pointer); } } /** * Returns an Iterable for looping over all bonds in this container. * *@return An Iterable with the bonds in this container */ public Iterable bonds() { return new Iterable() { public Iterator iterator() { return new BondIterator(); } }; } /** * The inner BondIterator class. * */ private class BondIterator implements Iterator { private int pointer = 0; public boolean hasNext() { return pointer < bondCount; } public IBond next() { return bonds[pointer++]; } public void remove() { removeBond(--pointer); } } /** * Returns an Iterable for looping over all lone pairs in this container. * *@return An Iterable with the lone pairs in this container */ public Iterable lonePairs() { return new Iterable() { public Iterator iterator() { return new LonePairIterator(); } }; } /** * The inner LonePairIterator class. * */ private class LonePairIterator implements Iterator { private int pointer = 0; public boolean hasNext() { return pointer < lonePairCount; } public ILonePair next() { return lonePairs[pointer++]; } public void remove() { removeLonePair(--pointer); } } /** * Returns an Iterable for looping over all single electrons in this container. * *@return An Iterable with the single electrons in this container */ public Iterable singleElectrons() { return new Iterable() { public Iterator iterator() { return new SingleElectronIterator(); } }; } /** * The inner SingleElectronIterator class. * */ private class SingleElectronIterator implements Iterator { private int pointer = 0; public boolean hasNext() { return pointer < singleElectronCount; } public ISingleElectron next() { return singleElectrons[pointer++]; } public void remove() { removeSingleElectron(--pointer); } } /** * Returns an Iterable for looping over all electron containers in this container. * *@return An Iterable with the electron containers in this container */ public Iterable electronContainers() { return new Iterable() { public Iterator iterator() { return new ElectronContainerIterator(); } }; } /** * The inner ElectronContainerIterator class. * */ private class ElectronContainerIterator implements Iterator { private int pointer = 0; public boolean hasNext() { return pointer < (bondCount + lonePairCount + singleElectronCount); } public IElectronContainer next() { if (pointer < bondCount) return bonds[pointer++]; else if (pointer < bondCount+lonePairCount) return lonePairs[(pointer++)-bondCount]; else if (pointer < bondCount+lonePairCount+singleElectronCount) return singleElectrons[(pointer++)-bondCount-lonePairCount]; return null; } public void remove() { if (pointer <= bondCount) removeBond(--pointer); else if (pointer <= bondCount+lonePairCount) removeLonePair((--pointer)-bondCount); else if (pointer <= bondCount+lonePairCount+singleElectronCount) removeSingleElectron((--pointer)-bondCount-lonePairCount); } } /** * Returns the atom at position 0 in the container. * *@return The atom at position 0 . */ public IAtom getFirstAtom() { return atoms[0]; } /** * Returns the atom at the last position in the container. * *@return The atom at the last position */ public IAtom getLastAtom() { return getAtomCount() > 0 ? (Atom)atoms[getAtomCount() - 1] : null; } /** * Returns the position of a given atom in the atoms array. It returns -1 if * the atom does not exist. * *@param atom The atom to be sought *@return The Position of the atom in the atoms array in [0,..]. */ public int getAtomNumber(IAtom atom) { for (int f = 0; f < atomCount; f++) { if (atoms[f] == atom) return f; } return -1; } /** * Returns the position of the bond between two given atoms in the * electronContainers array. It returns -1 if the bond does not exist. * *@param atom1 The first atom *@param atom2 The second atom *@return The Position of the bond between a1 and a2 in the * electronContainers array. */ public int getBondNumber(IAtom atom1, IAtom atom2) { return (getBondNumber(getBond(atom1, atom2))); } /** * Returns the position of a given bond in the electronContainers array. It * returns -1 if the bond does not exist. * *@param bond The bond to be sought *@return The Position of the bond in the electronContainers array in [0,..]. */ public int getBondNumber(IBond bond) { for (int f = 0; f < bondCount; f++) { if (bonds[f] == bond) return f; } return -1; } /** * Returns the position of a given lone pair in the lone pair array. * It returns -1 if the lone pair does not exist. * *@param lonePair The lone pair to be sought *@return The Position of the lone pair in the array.. */ public int getLonePairNumber(ILonePair lonePair) { for (int f = 0; f < lonePairCount; f++) { if (lonePairs[f] == lonePair) return f; } return -1; } /** * Returns the position of a given single electron in the single electron array. * It returns -1 if the single electron does not exist. * *@param singleElectron The single electron to be sought *@return The Position of the single electron in the array. */ public int getSingleElectronNumber(ISingleElectron singleElectron) { for (int f = 0; f < singleElectronCount; f++) { if (singleElectrons[f] == singleElectron) return f; } return -1; } /** * Returns the ElectronContainer at position number in the * container. * * @param number The position of the ElectronContainer to be returned. * @return The ElectronContainer at position number. */ public IElectronContainer getElectronContainer(int number) { if (number < this.bondCount) return bonds[number]; number -= this.bondCount; if (number < this.lonePairCount) return lonePairs[number]; number -= this.lonePairCount; if (number < this.singleElectronCount) return singleElectrons[number]; return null; } /** * Returns the bond that connects the two given atoms. * * @param atom1 The first atom * @param atom2 The second atom * @return The bond that connects the two atoms */ public IBond getBond(IAtom atom1, IAtom atom2) { for (int i = 0; i < getBondCount(); i++) { if (bonds[i].contains(atom1) && bonds[i].getConnectedAtom(atom1) == atom2) { return bonds[i]; } } return null; } /** * Returns the number of Atoms in this Container. * *@return The number of Atoms in this Container */ public int getAtomCount() { return this.atomCount; } /** * Returns the number of Bonds in this Container. * *@return The number of Bonds in this Container */ public int getBondCount() { return this.bondCount; } /** * Returns the number of LonePairs in this Container. * *@return The number of LonePairs in this Container */ public int getLonePairCount() { return this.lonePairCount; } /** * Returns the number of the single electrons in this container, * *@return The number of SingleElectron objects of this AtomContainer */ public int getSingleElectronCount() { return this.singleElectronCount; } /** * Returns the number of ElectronContainers in this Container. * * @return The number of ElectronContainers in this Container */ public int getElectronContainerCount() { return this.bondCount + this.lonePairCount + this.singleElectronCount; } /** * Returns an ArrayList of all atoms connected to the given atom. * *@param atom The atom the bond partners are searched of. *@return The ArrayList with the connected atoms */ public List getConnectedAtomsList(IAtom atom) { List atomsList = new ArrayList(); for (int i = 0; i < bondCount; i++) { if (bonds[i].contains(atom)) atomsList.add(bonds[i].getConnectedAtom(atom)); } return atomsList; } /** * Returns an ArrayList of all Bonds connected to the given atom. * *@param atom The atom the connected bonds are searched of *@return The ArrayList with connected atoms */ public List getConnectedBondsList(IAtom atom) { List bondsList = new ArrayList(); for (int i = 0; i < bondCount; i++) { if (bonds[i].contains(atom)) bondsList.add(bonds[i]); } return bondsList; } /** * Returns the array of lone pairs connected to an atom. * * @param atom The atom for which to get lone pairs * @return The array of LonePairs of this AtomContainer * @see #getElectronContainer * @see #electronContainers() * @see #getBond */ public List getConnectedLonePairsList(IAtom atom) { List lps = new ArrayList(); for (int i = 0; i < lonePairCount; i++) { if (lonePairs[i].contains(atom)) lps.add(lonePairs[i]); } return lps; } /** * Returns an array of all SingleElectron connected to the given atom. * *@param atom The atom on which the single electron is located *@return The array of SingleElectron of this AtomContainer */ public List getConnectedSingleElectronsList(IAtom atom) { List lps = new ArrayList(); for (int i = 0; i < singleElectronCount; i++) { if (singleElectrons[i].contains(atom)) lps.add(singleElectrons[i]); } return lps; } /** * Returns an ArrayList of all electronContainers connected to the given atom. * *@param atom The atom the connected electronContainers are searched of *@return The ArrayList with the connected atoms */ public List getConnectedElectronContainersList(IAtom atom) { List lps = new ArrayList(); for (int i = 0; i < bondCount; i++) { if (bonds[i].contains(atom)) lps.add(bonds[i]); } for (int i = 0; i < lonePairCount; i++) { if (lonePairs[i].contains(atom)) lps.add(lonePairs[i]); } for (int i = 0; i < singleElectronCount; i++) { if (singleElectrons[i].contains(atom)) lps.add(singleElectrons[i]); } return lps; } /** * Returns the number of atoms connected to the given atom. * *@param atom The atom the number of bond partners are searched of. *@return The the size of connected atoms */ public int getConnectedAtomsCount(IAtom atom) { int count = 0; for (int i = 0; i < bondCount; i++) { if (bonds[i].contains(atom)) ++count; } return count; } /** * Returns the number of Bonds for a given Atom. * *@param atom The atom *@return The number of Bonds for this atom */ public int getConnectedBondsCount(IAtom atom) { return getConnectedAtomsCount(atom); } /** * Returns the number of connected atoms (degree) to the given atom. * *@param atomNumber The atomnumber the degree is searched for *@return The number of connected atoms (degree) */ public int getConnectedBondsCount(int atomNumber) { return getConnectedAtomsCount(atoms[atomNumber]); } /** * Returns the number of LonePairs for a given Atom. * *@param atom The atom *@return The number of LonePairs for this atom */ public int getConnectedLonePairsCount(IAtom atom) { int count = 0; for (int i = 0; i < lonePairCount; i++) { if (lonePairs[i].contains(atom)) ++count; } return count; } /** * Returns the sum of the SingleElectron for a given Atom. * *@param atom The atom on which the single electron is located *@return The array of SingleElectron of this AtomContainer */ public int getConnectedSingleElectronsCount(IAtom atom) { int count = 0; for (int i = 0; i < singleElectronCount; i++) { if (singleElectrons[i].contains(atom)) ++count; } return count; } /** * Returns the sum of the bond orders for a given Atom. * * @param atom The atom * @return The number of bond orders for this atom * * @deprecated Replaced by AtomContainerManipulator#getBondOrderSum(IAtomContainer, IAtom) */ public double getBondOrderSum(IAtom atom) { double count = 0; for (int i = 0; i < bondCount; i++) { if (bonds[i].contains(atom)) { if (bonds[i].getOrder() == IBond.Order.SINGLE) { count += 1; } else if (bonds[i].getOrder() == IBond.Order.DOUBLE) { count += 2; } else if (bonds[i].getOrder() == IBond.Order.TRIPLE) { count += 3; } else if (bonds[i].getOrder() == IBond.Order.QUADRUPLE) { count += 4; } } } return count; } /** * Returns the maximum bond order that this atom currently has in the context * of this AtomContainer. * * @param atom The atom * @return The maximum bond order that this atom currently has */ public Order getMaximumBondOrder(IAtom atom) { IBond.Order max = IBond.Order.SINGLE; for (int i = 0; i < bondCount; i++) { if (bonds[i].contains(atom) && bonds[i].getOrder().ordinal() > max.ordinal()) { max = bonds[i].getOrder(); } } return max; } /** * Returns the minimum bond order that this atom currently has in the context * of this AtomContainer. * *@param atom The atom *@return The minimum bond order that this atom currently has */ public Order getMinimumBondOrder(IAtom atom) { IBond.Order min = IBond.Order.QUADRUPLE; for (int i = 0; i < bondCount; i++) { if (bonds[i].contains(atom) && bonds[i].getOrder().ordinal() < min.ordinal()) { min = bonds[i].getOrder(); } } return min; } /** * Adds all atoms and electronContainers of a given atomcontainer to this * container. * *@param atomContainer The atomcontainer to be added */ public void add(IAtomContainer atomContainer) { for (int f = 0; f < atomContainer.getAtomCount(); f++) { if (!contains(atomContainer.getAtom(f))) { addAtom(atomContainer.getAtom(f)); } } for (int f = 0; f < atomContainer.getBondCount(); f++) { if (!contains(atomContainer.getBond(f))) { addBond(atomContainer.getBond(f)); } } for (int f = 0; f < atomContainer.getLonePairCount(); f++) { if (!contains(atomContainer.getLonePair(f))) { addLonePair(atomContainer.getLonePair(f)); } } for (int f = 0; f < atomContainer.getSingleElectronCount(); f++) { if (!contains(atomContainer.getSingleElectron(f))) { addSingleElectron(atomContainer.getSingleElectron(f)); } } notifyChanged(); } /** * Adds the ElectronContainers found in atomContainer to this * container. * *@param atomContainer AtomContainer with the new ElectronContainers */ // public void addElectronContainers(IAtomContainer atomContainer) // { // // notifyChanged(); // } /** * Adds an atom to this container. * *@param atom The atom to be added to this container */ public void addAtom(IAtom atom) { if (contains(atom)) { return; } if (atomCount + 1 >= atoms.length) { growAtomArray(); } atom.addListener(this); atoms[atomCount] = atom; atomCount++; notifyChanged(); } /** * Adds a Bond to this AtomContainer. * *@param bond The bond to added to this container */ public void addBond(IBond bond) { if (bondCount >= bonds.length) growBondArray(); bonds[bondCount] = bond; ++bondCount; notifyChanged(); } /** * Adds a lone pair to this AtomContainer. * *@param lonePair The LonePair to added to this container */ public void addLonePair(ILonePair lonePair) { if (lonePairCount >= lonePairs.length) growLonePairArray(); lonePairs[lonePairCount] = lonePair; ++lonePairCount; notifyChanged(); } /** * Adds a single electron to this AtomContainer. * *@param singleElectron The SingleElectron to added to this container */ public void addSingleElectron(ISingleElectron singleElectron) { if (singleElectronCount >= singleElectrons.length) growSingleElectronArray(); singleElectrons[singleElectronCount] = singleElectron; ++singleElectronCount; notifyChanged(); } /** * Adds a ElectronContainer to this AtomContainer. * *@param electronContainer The ElectronContainer to added to this container */ public void addElectronContainer(IElectronContainer electronContainer) { if (electronContainer instanceof IBond) this.addBond((IBond)electronContainer); if (electronContainer instanceof ILonePair) this.addLonePair((ILonePair)electronContainer); if (electronContainer instanceof ISingleElectron) this.addSingleElectron((ISingleElectron)electronContainer); } /** * Removes all atoms and electronContainers of a given atomcontainer from this * container. * *@param atomContainer The atomcontainer to be removed */ public void remove(IAtomContainer atomContainer) { for (int f = 0; f < atomContainer.getAtomCount(); f++) { removeAtom(atomContainer.getAtom(f)); } for (int f = 0; f < atomContainer.getBondCount(); f++) { removeBond(atomContainer.getBond(f)); } for (int f = 0; f < atomContainer.getLonePairCount(); f++) { removeLonePair(atomContainer.getLonePair(f)); } for (int f = 0; f < atomContainer.getSingleElectronCount(); f++) { removeSingleElectron(atomContainer.getSingleElectron(f)); } } /** * Removes the atom at the given position from the AtomContainer. Note that * the electronContainers are unaffected: you also have to take care of * removing all electronContainers to this atom from the container manually. * *@param position The position of the atom to be removed. */ public void removeAtom(int position) { atoms[position].removeListener(this); for (int i = position; i < atomCount - 1; i++) { atoms[i] = atoms[i + 1]; } atoms[atomCount - 1] = null; atomCount--; notifyChanged(); } /** * Removes the given atom from the AtomContainer. Note that the * electronContainers are unaffected: you also have to take care of removing * all electronContainers to this atom from the container. * *@param atom The atom to be removed */ public void removeAtom(IAtom atom) { int position = getAtomNumber(atom); if (position != -1) { removeAtom(position); } } /** * Removes the bond at the given position from the AtomContainer. * *@param position The position of the bond to be removed. */ public IBond removeBond(int position) { IBond bond = bonds[position]; bond.removeListener(this); for (int i = position; i < bondCount - 1; i++) { bonds[i] = bonds[i + 1]; } bonds[bondCount - 1] = null; bondCount--; notifyChanged(); return bond; } /** * Removes the bond that connects the two given atoms. * * @param atom1 The first atom * @param atom2 The second atom * @return The bond that connects the two atoms */ public IBond removeBond(IAtom atom1, IAtom atom2) { int pos = getBondNumber(atom1, atom2); IBond bond = null; if (pos != -1) { bond = bonds[pos]; removeBond(pos); } return bond; } /** * Removes the bond from this container. * * @param bond The bond to be removed. */ public void removeBond(IBond bond) { int pos = getBondNumber(bond); if (pos != -1) removeBond(pos); } /** * Removes the lone pair at the given position from the AtomContainer. * *@param position The position of the LonePair to be removed. */ public ILonePair removeLonePair(int position) { ILonePair lp = lonePairs[position]; lp.removeListener(this); for (int i = position; i < lonePairCount - 1; i++) { lonePairs[i] = lonePairs[i + 1]; } lonePairs[lonePairCount - 1] = null; lonePairCount--; notifyChanged(); return lp; } /** * Removes the lone pair from the AtomContainer. * *@param lonePair The LonePair to be removed. */ public void removeLonePair(ILonePair lonePair) { int pos = getLonePairNumber(lonePair); if (pos != -1) removeLonePair(pos); } /** * Removes the single electron at the given position from the AtomContainer. * *@param position The position of the SingleElectron to be removed. */ public ISingleElectron removeSingleElectron(int position) { ISingleElectron se = singleElectrons[position]; se.removeListener(this); for (int i = position; i < singleElectronCount - 1; i++) { singleElectrons[i] = singleElectrons[i + 1]; } singleElectrons[singleElectronCount - 1] = null; singleElectronCount--; notifyChanged(); return se; } /** * Removes the single electron from the AtomContainer. * *@param singleElectron The SingleElectron to be removed. */ public void removeSingleElectron(ISingleElectron singleElectron) { int pos = getSingleElectronNumber(singleElectron); if (pos != -1) removeSingleElectron(pos); } /** * Removes the bond at the given position from this container. * * @param number The position of the bond in the electronContainers array * @return Bond that was removed */ public IElectronContainer removeElectronContainer(int number) { if (number < this.bondCount) return removeBond(number); number -= this.bondCount; if (number < this.lonePairCount) return removeLonePair(number); number -= this.lonePairCount; if (number < this.singleElectronCount) return removeSingleElectron(number); return null; } /** * Removes this ElectronContainer from this container. * * @param electronContainer The electronContainer to be removed */ public void removeElectronContainer(IElectronContainer electronContainer) { if (electronContainer instanceof IBond) removeBond((IBond) electronContainer); else if (electronContainer instanceof ILonePair) removeLonePair((ILonePair) electronContainer); else if (electronContainer instanceof ISingleElectron) removeSingleElectron((ISingleElectron) electronContainer); } /** * Removes the given atom and all connected electronContainers from the * AtomContainer. * *@param atom The atom to be removed */ public void removeAtomAndConnectedElectronContainers(IAtom atom) { int position = getAtomNumber(atom); if (position != -1) { for (int i = 0; i < bondCount; i++) { if (bonds[i].contains(atom)) { removeBond(i); --i; } } for (int i = 0; i < lonePairCount; i++) { if (lonePairs[i].contains(atom)) { removeLonePair(i); --i; } } for (int i = 0; i < singleElectronCount; i++) { if (singleElectrons[i].contains(atom)) { removeSingleElectron(i); --i; } } removeAtom(position); } notifyChanged(); } /** * Removes all atoms and bond from this container. */ public void removeAllElements() { removeAllElectronContainers(); for (int f = 0; f < getAtomCount(); f++) { getAtom(f).removeListener(this); } atoms = new IAtom[growArraySize]; atomCount = 0; notifyChanged(); } /** * Removes electronContainers from this container. */ public void removeAllElectronContainers() { removeAllBonds(); for (int f = 0; f < getLonePairCount(); f++) { getLonePair(f).removeListener(this); } for (int f = 0; f < getSingleElectronCount(); f++) { getSingleElectron(f).removeListener(this); } lonePairs = new ILonePair[growArraySize]; singleElectrons = new ISingleElectron[growArraySize]; lonePairCount = 0; singleElectronCount = 0; notifyChanged(); } /** * Removes all Bonds from this container. */ public void removeAllBonds() { for (int f = 0; f < getBondCount(); f++) { getBond(f).removeListener(this); } bonds = new IBond[growArraySize]; bondCount = 0; notifyChanged(); } /** * Adds a bond to this container. * *@param atom1 Id of the first atom of the Bond in [0,..] *@param atom2 Id of the second atom of the Bond in [0,..] *@param order Bondorder *@param stereo Stereochemical orientation */ public void addBond(int atom1, int atom2, IBond.Order order, int stereo) { IBond bond = getBuilder().newBond(getAtom(atom1), getAtom(atom2), order, stereo); if (contains(bond)) { return; } if (bondCount >= bonds.length) { growBondArray(); } addBond(bond); /* no notifyChanged() here because addBond(bond) does it already */ } /** * Adds a bond to this container. * *@param atom1 Id of the first atom of the Bond in [0,..] *@param atom2 Id of the second atom of the Bond in [0,..] *@param order Bondorder */ public void addBond(int atom1, int atom2, IBond.Order order) { IBond bond = getBuilder().newBond(getAtom(atom1), getAtom(atom2), order); if (bondCount >= bonds.length) { growBondArray(); } addBond(bond); /* no notifyChanged() here because addBond(bond) does it already */ } /** * Adds a LonePair to this Atom. * *@param atomID The atom number to which the LonePair is added in [0,..] */ public void addLonePair(int atomID) { ILonePair lonePair = getBuilder().newLonePair(atoms[atomID]); lonePair.addListener(this); addLonePair(lonePair); /* no notifyChanged() here because addElectronContainer() does it already */ } /** * Adds a LonePair to this Atom. * *@param atomID The atom number to which the LonePair is added in [0,..] */ public void addSingleElectron(int atomID) { ISingleElectron singleElectron = getBuilder().newSingleElectron(atoms[atomID]); singleElectron.addListener(this); addSingleElectron(singleElectron); /* no notifyChanged() here because addSingleElectron() does it already */ } /** * True, if the AtomContainer contains the given atom object. * *@param atom the atom this AtomContainer is searched for *@return true if the AtomContainer contains the given atom object */ public boolean contains(IAtom atom) { for (int i = 0; i < getAtomCount(); i++) { if (atom == atoms[i]) return true; } return false; } /** * True, if the AtomContainer contains the given bond object. * *@param bond the bond this AtomContainer is searched for *@return true if the AtomContainer contains the given bond object */ public boolean contains(IBond bond) { for (int i = 0; i < getBondCount(); i++) { if (bond == bonds[i]) return true; } return false; } /** * True, if the AtomContainer contains the given LonePair object. * *@param lonePair the LonePair this AtomContainer is searched for *@return true if the AtomContainer contains the given LonePair object */ public boolean contains(ILonePair lonePair) { for (int i = 0; i < getLonePairCount(); i++) { if (lonePair == lonePairs[i]) return true; } return false; } /** * True, if the AtomContainer contains the given SingleElectron object. * *@param singleElectron the LonePair this AtomContainer is searched for *@return true if the AtomContainer contains the given LonePair object */ public boolean contains(ISingleElectron singleElectron) { for (int i = 0; i < getSingleElectronCount(); i++) { if (singleElectron == singleElectrons[i]) return true; } return false; } /** * True, if the AtomContainer contains the given ElectronContainer object. * *@param electronContainer ElectronContainer that is searched for *@return true if the AtomContainer contains the given bond object */ public boolean contains(IElectronContainer electronContainer) { if (electronContainer instanceof IBond) return contains((IBond)electronContainer); if (electronContainer instanceof ILonePair) return contains((ILonePair)electronContainer); if (electronContainer instanceof ISingleElectron) return contains((SingleElectron)electronContainer); return false; } /** * Returns a one line string representation of this Container. This method is * conform RFC #9. * *@return The string representation of this Container */ public String toString() { StringBuffer stringContent = new StringBuffer(64); stringContent.append("AtomContainer("); stringContent.append(this.hashCode()); if (getAtomCount() > 0) { stringContent.append(", #A:").append(getAtomCount()); for (int i = 0; i < getAtomCount(); i++) { stringContent.append(", ").append(getAtom(i).toString()); } } if (getBondCount() > 0) { stringContent.append(", #B:").append(getBondCount()); for (int i = 0; i < getBondCount(); i++) { stringContent.append(", ").append(getBond(i).toString()); } } if (getLonePairCount() > 0) { stringContent.append(", #LP:").append(getLonePairCount()); for (int i = 0; i < getLonePairCount(); i++) { stringContent.append(", ").append(getLonePair(i).toString()); } } if (getSingleElectronCount() > 0) { stringContent.append(", #SE:").append(getSingleElectronCount()); for (int i = 0; i < getSingleElectronCount(); i++) { stringContent.append(", ").append(getSingleElectron(i).toString()); } } if (atomParities.size() > 0) { stringContent.append(", AP:[#").append(atomParities.size()); for (IAtomParity iAtomParity : atomParities.values()) { stringContent.append(", ").append(iAtomParity.toString()); } stringContent.append(']'); } stringContent.append(')'); return stringContent.toString(); } /** * Clones this AtomContainer object and its content. * * @return The cloned object * @see #shallowCopy */ public Object clone() throws CloneNotSupportedException { IAtom[] newAtoms; IAtomContainer clone = (IAtomContainer) super.clone(); // start from scratch clone.removeAllElements(); // clone all atoms for (int f = 0; f < getAtomCount(); f++) { clone.addAtom((Atom) getAtom(f).clone()); } // clone bonds IBond bond; IBond newBond; for (int i = 0; i < getBondCount(); ++i) { bond = getBond(i); newBond = (IBond)bond.clone(); newAtoms = new IAtom[bond.getAtomCount()]; for (int j = 0; j < bond.getAtomCount(); ++j) { newAtoms[j] = clone.getAtom(getAtomNumber(bond.getAtom(j))); } newBond.setAtoms(newAtoms); clone.addBond(newBond); } ILonePair lp; ILonePair newLp; for (int i = 0; i < getLonePairCount(); ++i) { lp = getLonePair(i); newLp = (ILonePair)lp.clone(); if (lp.getAtom() != null) { newLp.setAtom(clone.getAtom(getAtomNumber(lp.getAtom()))); } clone.addLonePair(newLp); } ISingleElectron se; ISingleElectron newSe; for (int i = 0; i < getSingleElectronCount(); ++i) { se = getSingleElectron(i); newSe = (ISingleElectron)se.clone(); if (se.getAtom() != null) { newSe.setAtom(clone.getAtom(getAtomNumber(se.getAtom()))); } clone.addSingleElectron(newSe); } // for (int f = 0; f < getElectronContainerCount(); f++) { // electronContainer = this.getElectronContainer(f); // newEC = getBuilder().newElectronContainer(); // if (electronContainer instanceof IBond) { // IBond bond = (IBond) electronContainer; // newEC = (IElectronContainer)bond.clone(); // newAtoms = new IAtom[bond.getAtomCount()]; // for (int g = 0; g < bond.getAtomCount(); g++) { // newAtoms[g] = clone.getAtom(getAtomNumber(bond.getAtom(g))); // } // ((IBond) newEC).setAtoms(newAtoms); // } else if (electronContainer instanceof ILonePair) { // IAtom atom = ((ILonePair) electronContainer).getAtom(); // newEC = (ILonePair)electronContainer.clone(); // ((ILonePair) newEC).setAtom(clone.getAtom(getAtomNumber(atom))); // } else if (electronContainer instanceof ISingleElectron) { // IAtom atom = ((ISingleElectron) electronContainer).getAtom(); // newEC = (ISingleElectron)electronContainer.clone(); // ((ISingleElectron) newEC).setAtom(clone.getAtom(getAtomNumber(atom))); // } else { // //logger.debug("Expecting EC, got: " + electronContainer.getClass().getName()); // newEC = (IElectronContainer) electronContainer.clone(); // } // clone.addElectronContainer(newEC); // } return clone; } /** * Grows the ElectronContainer array by a given size. * *@see #growArraySize */ // protected void growElectronContainerArray() // { // growArraySize = (electronContainers.length < growArraySize) ? growArraySize : electronContainers.length; // IElectronContainer[] newelectronContainers = new IElectronContainer[electronContainers.length + growArraySize]; // System.arraycopy(electronContainers, 0, newelectronContainers, 0, electronContainers.length); // electronContainers = newelectronContainers; // } /** * Grows the atom array by a given size. * *@see #growArraySize */ private void growAtomArray() { growArraySize = (atoms.length < growArraySize) ? growArraySize : atoms.length; IAtom[] newatoms = new IAtom[atoms.length + growArraySize]; System.arraycopy(atoms, 0, newatoms, 0, atoms.length); atoms = newatoms; } /** * Grows the bond array by a given size. * *@see #growArraySize */ private void growBondArray() { growArraySize = (bonds.length < growArraySize) ? growArraySize : bonds.length; IBond[] newBonds = new IBond[bonds.length + growArraySize]; System.arraycopy(bonds, 0, newBonds, 0, bonds.length); bonds = newBonds; } /** * Grows the lone pair array by a given size. * *@see #growArraySize */ private void growLonePairArray() { growArraySize = (lonePairs.length < growArraySize) ? growArraySize : lonePairs.length; ILonePair[] newLonePairs = new ILonePair[lonePairs.length + growArraySize]; System.arraycopy(lonePairs, 0, newLonePairs, 0, lonePairs.length); lonePairs = newLonePairs; } /** * Grows the single electron array by a given size. * *@see #growArraySize */ private void growSingleElectronArray() { growArraySize = (singleElectrons.length < growArraySize) ? growArraySize : singleElectrons.length; ISingleElectron[] newSingleElectrons = new ISingleElectron[singleElectrons.length + growArraySize]; System.arraycopy(singleElectrons, 0, newSingleElectrons, 0, singleElectrons.length); singleElectrons = newSingleElectrons; } /** * Called by objects to which this object has * registered as a listener. * *@param event A change event pointing to the source of the change */ public void stateChanged(IChemObjectChangeEvent event) { notifyChanged(event); } } cdk-1.2.10/src/main/org/openscience/cdk/AtomContainerSet.java100644 0 0 26575 11570154753 21152 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2003-2007 Christoph Steinbeck * * 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. * * 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; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomContainerSet; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import java.io.Serializable; import java.util.Iterator; /** * A set of AtomContainers. * * @author hel * @cdk.module data * @cdk.githash */ public class AtomContainerSet extends ChemObject implements Serializable, IAtomContainerSet, IChemObjectListener, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = -521290255592768395L; /** Array of AtomContainers. */ protected IAtomContainer[] atomContainers; /** Number of AtomContainers contained by this container. */ protected int atomContainerCount; /** * Defines the number of instances of a certain molecule * in the set. It is 1 by default. */ protected Double[] multipliers; /** * Amount by which the AtomContainers array grows when elements are added and * the array is not large enough for that. */ protected int growArraySize = 5; /** Constructs an empty AtomContainerSet. */ public AtomContainerSet() { atomContainerCount = 0; atomContainers = new IAtomContainer[growArraySize]; multipliers = new Double[growArraySize]; } /** * Adds an atomContainer to this container. * * @param atomContainer The atomContainer to be added to this container */ public void addAtomContainer(IAtomContainer atomContainer) { atomContainer.addListener(this); addAtomContainer(atomContainer, 1.0); /* * notifyChanged is called below */ } /** * Removes an AtomContainer from this container. * * @param atomContainer The atomContainer to be removed from this container */ public void removeAtomContainer(IAtomContainer atomContainer) { for (int i = atomContainerCount-1; i >= 0; i--) { if (atomContainers[i] == atomContainer) removeAtomContainer(i); } } /** * Removes all AtomContainer from this container. */ public void removeAllAtomContainers() { for (int pos = atomContainerCount - 1; pos >= 0; pos--) { atomContainers[pos].removeListener(this); multipliers[pos] = 0.0; atomContainers[pos] = null; } atomContainerCount = 0; notifyChanged(); } /** * Removes an AtomContainer from this container. * * @param pos The position of the AtomContainer to be removed from this container */ public void removeAtomContainer(int pos) { atomContainers[pos].removeListener(this); for (int i = pos; i < atomContainerCount - 1; i++) { atomContainers[i] = atomContainers[i + 1]; multipliers[i] = multipliers[i + 1]; } atomContainers[atomContainerCount - 1] = null; atomContainerCount--; notifyChanged(); } /** * Replace the AtomContainer at a specific position (array has to be large enough). * * @param position position in array for AtomContainer * @param container the replacement AtomContainer */ public void replaceAtomContainer(int position, IAtomContainer container) { IAtomContainer old = atomContainers[position]; old.removeListener(this); atomContainers[position] = container; container.addListener(this); notifyChanged(); } /** * Sets the coefficient of a AtomContainer to a given value. * * @param container The AtomContainer for which the multiplier is set * @param multiplier The new multiplier for the AtomContatiner * @return true if multiplier has been set * @see #getMultiplier(IAtomContainer) */ public boolean setMultiplier(IAtomContainer container, Double multiplier) { for (int i = 0; i < atomContainers.length; i++) { if (atomContainers[i] == container) { multipliers[i] = multiplier; notifyChanged(); return true; } } return false; } /** * Sets the coefficient of a AtomContainer to a given value. * * @param position The position of the AtomContainer for which the multiplier is * set in [0,..] * @param multiplier The new multiplier for the AtomContatiner at * position * @see #getMultiplier(int) */ public void setMultiplier(int position, Double multiplier) { multipliers[position] = multiplier; notifyChanged(); } /** * Returns an array of double with the stoichiometric coefficients * of the products. * * @return The multipliers for the AtomContainer's in this set * @see #setMultipliers */ public Double[] getMultipliers() { Double[] returnArray = new Double[this.atomContainerCount]; System.arraycopy(this.multipliers, 0, returnArray, 0, this.atomContainerCount); return returnArray; } /** * Sets the multipliers of the AtomContainers. * * @param newMultipliers The new multipliers for the AtomContainers in this set * @return true if multipliers have been set. * @see #getMultipliers */ public boolean setMultipliers(Double[] newMultipliers) { if (newMultipliers.length == atomContainerCount) { if (multipliers == null) { multipliers = new Double[atomContainerCount]; } System.arraycopy(newMultipliers, 0, multipliers, 0, atomContainerCount); notifyChanged(); return true; } return false; } /** * Adds an atomContainer to this container with the given * multiplier. * * @param atomContainer The atomContainer to be added to this container * @param multiplier The multiplier of this atomContainer */ public void addAtomContainer(IAtomContainer atomContainer, double multiplier) { if (atomContainerCount + 1 >= atomContainers.length) { growAtomContainerArray(); } atomContainer.addListener(this); atomContainers[atomContainerCount] = atomContainer; multipliers[atomContainerCount] = multiplier; atomContainerCount++; notifyChanged(); } /** * Adds all atomContainers in the AtomContainerSet to this container. * * @param atomContainerSet The AtomContainerSet */ public void add(IAtomContainerSet atomContainerSet) { for (IAtomContainer iter : atomContainerSet.atomContainers()) { addAtomContainer(iter); } /* * notifyChanged() is called by addAtomContainer() */ } /** * Get an iterator for this AtomContainerSet. * * @return A new Iterator for this AtomContainerSet. */ public Iterable atomContainers() { return new Iterable() { public Iterator iterator() { return new AtomContainerIterator(); } }; } /** * The inner Iterator class. * */ private class AtomContainerIterator implements Iterator { private int pointer = 0; public boolean hasNext() { return pointer < atomContainerCount; } public IAtomContainer next() { return atomContainers[pointer++]; } public void remove() { removeAtomContainer(--pointer); } } /** * Returns the AtomContainer at position number in the * container. * * @param number The position of the AtomContainer to be returned. * @return The AtomContainer at position number . */ public IAtomContainer getAtomContainer(int number) { return atomContainers[number]; } /** * Returns the multiplier for the AtomContainer at position number in the * container. * * @param number The position of the multiplier of the AtomContainer to be returned. * @return The multiplier for the AtomContainer at position number . * @see #setMultiplier(int, Double) */ public Double getMultiplier(int number) { return multipliers[number]; } /** * Returns the multiplier of the given AtomContainer. * * @param container The AtomContainer for which the multiplier is given * @return -1, if the given molecule is not a container in this set * @see #setMultiplier(IAtomContainer, Double) */ public Double getMultiplier(IAtomContainer container) { for (int i = 0; i < atomContainerCount; i++) { if (atomContainers[i].equals(container)) { return multipliers[i]; } } return -1.0; } /** * Grows the atomContainer array by a given size. * * @see growArraySize */ protected void growAtomContainerArray() { growArraySize = atomContainers.length; IAtomContainer[] newatomContainers = new IAtomContainer[atomContainers.length + growArraySize]; System.arraycopy(atomContainers, 0, newatomContainers, 0, atomContainers.length); atomContainers = newatomContainers; Double[] newMultipliers = new Double[multipliers.length + growArraySize]; System.arraycopy(multipliers, 0, newMultipliers, 0, multipliers.length); multipliers = newMultipliers; } /** * Returns the number of AtomContainers in this Container. * * @return The number of AtomContainers in this Container */ public int getAtomContainerCount() { return this.atomContainerCount; } /** * Returns the String representation of this AtomContainerSet. * * @return The String representation of this AtomContainerSet */ public String toString() { StringBuffer buffer = new StringBuffer(32); buffer.append("AtomContainerSet("); buffer.append(this.hashCode()); if (getAtomContainerCount() > 0) { buffer.append(", M=").append(getAtomContainerCount()); for (int i = 0; i < atomContainerCount; i++) { buffer.append(", ").append(atomContainers[i].toString()); } } buffer.append(')'); return buffer.toString(); } /** * Clones this AtomContainerSet and its content. * * @return the cloned Object */ public Object clone() throws CloneNotSupportedException { AtomContainerSet clone = (AtomContainerSet)super.clone(); clone.atomContainers = new IAtomContainer[atomContainerCount]; clone.atomContainerCount = 0; for (int i = 0; i < atomContainerCount; i++) { clone.addAtomContainer((IAtomContainer)atomContainers[i].clone()); clone.setMultiplier(i, getMultiplier(i)); } return clone; } /** * Called by objects to which this object has * registered as a listener. * * @param event A change event pointing to the source of the change */ public void stateChanged(IChemObjectChangeEvent event) { notifyChanged(event); } } cdk-1.2.10/src/main/org/openscience/cdk/AtomParity.java100644 0 0 12104 11570154753 20003 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2004-2007 Egon Willighagen * * 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 org.openscience.cdk; import java.io.Serializable; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomParity; /** * Represents the concept of an atom parity identifying the stereochemistry * around an atom, given four neighbouring atoms. * * @cdk.module data * @cdk.githash * * @cdk.created 2000-10-02 * @cdk.keyword atom parity * @cdk.keyword stereochemistry */ public class AtomParity implements IAtomParity, Serializable, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = -2031408037315976637L; private IAtom centralAtom; private IAtom[] neighbors; private int parity; /** * Constructs an completely unset AtomParity. * * @param centralAtom Atom for which the parity is defined * @param first First Atom of four that define the stereochemistry * @param second Second Atom of four that define the stereochemistry * @param third Third Atom of four that define the stereochemistry * @param fourth Fourth Atom of four that define the stereochemistry * @param parity +1 or -1, defining the parity */ public AtomParity( IAtom centralAtom, IAtom first, IAtom second, IAtom third, IAtom fourth, int parity) { this.centralAtom = centralAtom; this.neighbors = new Atom[4]; this.neighbors[0] = first; this.neighbors[1] = second; this.neighbors[2] = third; this.neighbors[3] = fourth; this.parity = parity; } /** * Returns the atom for which this parity is defined. * * @return The atom for which this parity is defined */ public IAtom getAtom() { return centralAtom; } /** * Returns the four atoms that define the stereochemistry for * this parity. * * @return The four atoms that define the stereochemistry for * this parity */ public IAtom[] getSurroundingAtoms() { return neighbors; } /** * Returns the parity value. * * @return The parity value */ public int getParity() { return parity; } /** * Returns a one line string representation of this AtomParity. * Methods is conform RFC #9. * * @return The string representation of this AtomParity */ public String toString() { StringBuffer resultString = new StringBuffer(32); resultString.append("AtomParity("); resultString.append(this.hashCode()).append(", "); resultString.append(centralAtom.getID()); resultString.append(", F:[").append(neighbors[0].getID()).append(", "); resultString.append(neighbors[1].getID()).append(", "); resultString.append(neighbors[2].getID()).append(", "); resultString.append(neighbors[3].getID()).append("], "); resultString.append(parity); resultString.append(')'); return resultString.toString(); } /** * Clones this AtomParity object. * * @return The cloned object */ public Object clone() throws CloneNotSupportedException { AtomParity clone = (AtomParity)super.clone(); // clone Atom's clone.centralAtom = (IAtom)centralAtom.clone(); clone.neighbors = new IAtom[4]; clone.neighbors[0] = (IAtom)(neighbors[0].clone()); clone.neighbors[1] = (IAtom)(neighbors[1].clone()); clone.neighbors[2] = (IAtom)(neighbors[2].clone()); clone.neighbors[3] = (IAtom)(neighbors[3].clone()); return clone; } } cdk-1.2.10/src/main/org/openscience/cdk/AtomType.java100644 0 0 26732 11570154753 17470 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2001-2007 Christoph Steinbeck * * 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 org.openscience.cdk; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IElement; import java.io.Serializable; /** * The base class for atom types. Atom types are typically used to describe the * behaviour of an atom of a particular element in different environment like * sp3 * hybridized carbon C3, etc., in some molecular modelling applications. * * @author steinbeck * @cdk.created 2001-08-08 * @cdk.module data * @cdk.githash * @cdk.keyword atom, type */ public class AtomType extends Isotope implements IAtomType, Serializable, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = -7950397716808229972L; /** * The maximum bond order allowed for this atom type. */ IBond.Order maxBondOrder = null; /** * The maximum sum of all bond orders allowed for this atom type. */ Double bondOrderSum = (Double) CDKConstants.UNSET; /** * The covalent radius of this atom type. */ Double covalentRadius = (Double) CDKConstants.UNSET; /** * The formal charge of the atom with CDKConstants.UNSET as default. Implements RFC #6. * * Note that some constructors ({@link #AtomType(String)} and * {@link #AtomType(String, String)} ) will explicitly set this field to 0 */ protected Integer formalCharge = (Integer) CDKConstants.UNSET; /** * The hybridization state of this atom with CDKConstants.HYBRIDIZATION_UNSET * as default. */ protected IAtomType.Hybridization hybridization = (Hybridization) CDKConstants.UNSET; /** * The electron Valency of this atom with CDKConstants.UNSET as default. */ protected Integer electronValency = (Integer) CDKConstants.UNSET; /** * The formal number of neighbours this atom type can have with CDKConstants_UNSET * as default. This includes explicitely and implicitely connected atoms, including * implicit hydrogens. */ protected Integer formalNeighbourCount = (Integer) CDKConstants.UNSET; /** * String representing the identifier for this atom type with null as default. */ private String identifier; /** * Constructor for the AtomType object. Defaults to a zero formal charge. * * @param elementSymbol Symbol of the atom */ public AtomType(String elementSymbol) { super(elementSymbol); this.identifier = null; this.formalNeighbourCount = 0; this.electronValency = 0; this.formalCharge = 0; } /** * Constructor for the AtomType object. Defaults to a zero formal charge. * * @param identifier An id for this atom type, like C3 for sp3 carbon * @param elementSymbol The element symbol identifying the element to which this atom type applies */ public AtomType(String identifier, String elementSymbol) { this(elementSymbol); this.identifier = identifier; } /** * Constructs an isotope by copying the symbol, atomic number, * flags, identifier, exact mass, natural abundance and mass * number from the given IIsotope. It does not copy the * listeners and properties. If the element is an instanceof * IAtomType, then the maximum bond order, bond order sum, * van der Waals and covalent radii, formal charge, hybridization, * electron valency, formal neighbour count and atom type name * are copied too. * * @param element IIsotope to copy information from */ public AtomType(IElement element) { super(element); if (element instanceof IAtomType) { this.maxBondOrder = ((IAtomType)element).getMaxBondOrder(); this.bondOrderSum = ((IAtomType)element).getBondOrderSum(); this.covalentRadius = ((IAtomType)element).getCovalentRadius(); this.formalCharge = ((IAtomType)element).getFormalCharge(); this.hybridization = ((IAtomType)element).getHybridization(); this.electronValency = ((IAtomType)element).getValency(); this.formalNeighbourCount = ((IAtomType)element).getFormalNeighbourCount(); this.identifier = ((IAtomType)element).getAtomTypeName(); } } /** * Sets the if attribute of the AtomType object. * * @param identifier The new AtomTypeID value. Null if unset. * * @see #getAtomTypeName */ public void setAtomTypeName(String identifier) { this.identifier = identifier; notifyChanged(); } /** * Sets the MaxBondOrder attribute of the AtomType object. * * @param maxBondOrder The new MaxBondOrder value * * @see #getMaxBondOrder */ public void setMaxBondOrder(IBond.Order maxBondOrder) { this.maxBondOrder = maxBondOrder; notifyChanged(); } /** * Sets the the exact bond order sum attribute of the AtomType object. * * @param bondOrderSum The new bondOrderSum value * * @see #getBondOrderSum */ public void setBondOrderSum(Double bondOrderSum) { this.bondOrderSum = bondOrderSum; notifyChanged(); } /** * Gets the id attribute of the AtomType object. * * @return The id value * * @see #setAtomTypeName */ public String getAtomTypeName() { return this.identifier; } /** * Gets the MaxBondOrder attribute of the AtomType object. * * @return The MaxBondOrder value * * @see #setMaxBondOrder */ public IBond.Order getMaxBondOrder() { return maxBondOrder; } /** * Gets the bondOrderSum attribute of the AtomType object. * * @return The bondOrderSum value * * @see #setBondOrderSum */ public Double getBondOrderSum() { return bondOrderSum; } /** * Sets the formal charge of this atom. * * @param charge The formal charge * * @see #getFormalCharge */ public void setFormalCharge(Integer charge) { this.formalCharge = charge; notifyChanged(); } /** * Returns the formal charge of this atom. * * @return the formal charge of this atom * * @see #setFormalCharge */ public Integer getFormalCharge() { return this.formalCharge; } /** * Sets the formal neighbour count of this atom. * * @param count The neighbour count * * @see #getFormalNeighbourCount */ public void setFormalNeighbourCount(Integer count) { this.formalNeighbourCount = count; notifyChanged(); } /** * Returns the formal neighbour count of this atom. * * @return the formal neighbour count of this atom * * @see #setFormalNeighbourCount */ public Integer getFormalNeighbourCount() { return this.formalNeighbourCount; } /** * Sets the hybridization of this atom. * * @param hybridization The hybridization * * @see #getHybridization */ public void setHybridization(IAtomType.Hybridization hybridization) { this.hybridization = hybridization; notifyChanged(); } /** * Returns the hybridization of this atom. * * @return the hybridization of this atom * * @see #setHybridization */ public IAtomType.Hybridization getHybridization() { return this.hybridization; } /** * Compares a atom type with this atom type. * * @param object Object of type AtomType * @return true if the atom types are equal */ public boolean compare(Object object) { if (!(object instanceof IAtomType)) { return false; } if (!super.compare(object)) { return false; } AtomType type = (AtomType) object; return (getAtomTypeName() == type.getAtomTypeName()) && (maxBondOrder == type.maxBondOrder) && (bondOrderSum == type.bondOrderSum); } /** * Sets the covalent radius for this AtomType. * * @param radius The covalent radius for this AtomType * @see #getCovalentRadius */ public void setCovalentRadius(Double radius) { this.covalentRadius = radius; notifyChanged(); } /** * Returns the covalent radius for this AtomType. * * @return The covalent radius for this AtomType * @see #setCovalentRadius */ public Double getCovalentRadius() { return this.covalentRadius; } /** * Sets the the exact electron valency of the AtomType object. * * @param valency The new valency value * @see #getValency * */ public void setValency(Integer valency) { this.electronValency = valency; notifyChanged(); } /** * Gets the the exact electron valency of the AtomType object. * * @return The valency value * @see #setValency * */ public Integer getValency() { return this.electronValency; } public Object clone() throws CloneNotSupportedException { return super.clone(); } public String toString() { StringBuffer resultString = new StringBuffer(64); resultString.append("AtomType(").append(hashCode()); if (getAtomTypeName() != null) { resultString.append(", N:").append(getAtomTypeName()); } if (getMaxBondOrder() != null) { resultString.append(", MBO:").append(getMaxBondOrder()); } if (getBondOrderSum() != null) { resultString.append(", BOS:").append(getBondOrderSum()); } if (getFormalCharge() != null) { resultString.append(", FC:").append(getFormalCharge()); } if (getHybridization() != null) { resultString.append(", H:").append(getHybridization()); } if (getFormalNeighbourCount() != null) { resultString.append(", NC:").append(getFormalNeighbourCount()); } if (getCovalentRadius() != null) { resultString.append(", CR:").append(getCovalentRadius()); } if (getValency() != null) { resultString.append(", EV:").append(getValency()); } resultString.append(", ").append(super.toString()); resultString.append(')'); return resultString.toString(); } } cdk-1.2.10/src/main/org/openscience/cdk/BioPolymer.java100644 0 0 21476 11570154753 20007 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 Edgar Luttmann * * 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 org.openscience.cdk; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IBioPolymer; import org.openscience.cdk.interfaces.IMonomer; import org.openscience.cdk.interfaces.IStrand; import java.util.Collection; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; /** * A BioPolymer is a subclass of a Polymer which is supposed to store * additional informations about the Polymer which are connected to BioPolymers. * * @cdk.module data * @cdk.githash * * @author Edgar Luttmann * @author Martin Eklund * @cdk.created 2001-08-06 * * @cdk.keyword polymer * @cdk.keyword biopolymer */ public class BioPolymer extends Polymer implements java.io.Serializable, IBioPolymer { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = -5001873073769634393L; private Map strands; // the list of all the contained Strands. /** * Constructs a new Polymer to store the Strands. */ public BioPolymer() { super(); // Strand stuff strands = new Hashtable(); } /** * Adds the atom oAtom to a specified Strand, whereas the Monomer is unspecified. Hence * the atom will be added to a Monomer of type UNKNOWN in the specified Strand. * * @param oAtom The atom to add * @param oStrand The strand the atom belongs to */ public void addAtom(IAtom oAtom, IStrand oStrand) { int atomCount = super.getAtomCount(); // Add atom to AtomContainer super.addAtom(oAtom); if (atomCount != super.getAtomCount() && oStrand != null) { // Maybe better to throw null pointer exception here, so user realises that // Strand == null and Atom only gets added to this BioPolymer, but not to a Strand. oStrand.addAtom(oAtom); if (!strands.containsKey(oStrand.getStrandName())) { strands.put(oStrand.getStrandName(), oStrand); } } /* notifyChanged() is called by addAtom in AtomContainer */ } /** * Adds the atom to a specified Strand and a specified Monomer. * * @param oAtom * @param oMonomer * @param oStrand */ public void addAtom(IAtom oAtom, IMonomer oMonomer, IStrand oStrand) { int atomCount = super.getAtomCount(); // Add atom to AtomContainer super.addAtom(oAtom); if(atomCount != super.getAtomCount() && // OK, super did not yet contain the atom // Add atom to Strand (also adds the atom to the monomer). oStrand != null) { oStrand.addAtom(oAtom, oMonomer); // Same problem as above: better to throw nullpointer exception? if (!strands.containsKey(oStrand.getStrandName())) { strands.put(oStrand.getStrandName(), oStrand); } } /* The reasoning above is: * All Monomers have to belong to a Strand and all atoms belonging to strands have to belong to a Monomer => * ? oMonomer != null and oStrand != null, oAtom is added to BioPolymer and to oMonomer in oStrand * ? oMonomer == null and oStrand != null, oAtom is added to BioPolymer and default Monomer in oStrand * ? oMonomer != null and oStrand == null, oAtom is added to BioPolymer, but not to a Monomer or Strand (especially good to maybe throw exception in this case) * ? oMonomer == null and oStrand == null, oAtom is added to BioPolymer, but not to a Monomer or Strand * */ } /** * Returns the number of monomers present in BioPolymer. * * @return number of monomers */ public int getMonomerCount() { Iterator keys = strands.keySet().iterator(); int number = 0; while(keys.hasNext()) { Strand tmp = (Strand)strands.get(keys.next()); // Cast exception?! number += (tmp.getMonomers()).size() - 1; } return number; } /** * Retrieves a Monomer object by specifying its name. [You have to specify the strand to enable * monomers with the same name in different strands. There is at least one such case: every * strand contains a monomer called "".] * * @param monName The name of the monomer to look for * @return The Monomer object which was asked for * */ public IMonomer getMonomer(String monName, String strandName) { Strand strand = (Strand)strands.get(strandName); if(strand != null) { return (Monomer)strand.getMonomer(monName); } else { return null; } } /* Could look like this if you ensured individual name giving for ALL monomers: * public Monomer getMonomer(String cName) { Enumeration keys = strands.keys(); Monomer oMonomer = null; while(keys.hasMoreElements()) { if(((Strand)strands.get(keys.nextElement())).getMonomers().containsKey(cName)) { Strand oStrand = (Strand)strands.get(keys.nextElement()); oMonomer = oStrand.getMonomer(cName); break; } } return oMonomer; } */ /** * Returns a collection of the names of all Monomers in this * BioPolymer. * * @return a Collection of all the monomer names. */ public Collection getMonomerNames() { Iterator keys = strands.keySet().iterator(); Map monomers = new Hashtable(); while(keys.hasNext()) { Strand oStrand = (Strand)strands.get(keys.next()); monomers.putAll(oStrand.getMonomers()); } return monomers.keySet(); } /** * * Returns the number of strands present in the BioPolymer. * * @return number of strands * */ public int getStrandCount() { return strands.size(); } /** * * Retrieves a Monomer object by specifying its name. * * @param cName The name of the monomer to look for * @return The Monomer object which was asked for * */ public IStrand getStrand(String cName) { return (Strand)strands.get(cName); } /** * Returns a collection of the names of all Strands in this * BioPolymer. * * @return a Collection of all the strand names. */ public Collection getStrandNames() { return strands.keySet(); } /** * Removes a particular strand, specified by its name. * * @param name name of the strand to remove */ public void removeStrand(String name) { if (strands.containsKey(name)) { Strand strand = (Strand)strands.get(name); this.remove(strand); strands.remove(name); } } /** * @return hashtable containing the monomers in the strand. */ public Map getStrands() { return strands; } public String toString() { StringBuffer stringContent = new StringBuffer(); stringContent.append("BioPolymer("); stringContent.append(this.hashCode()).append(", "); stringContent.append(super.toString()); stringContent.append(')'); return stringContent.toString(); } public Object clone() throws CloneNotSupportedException { BioPolymer clone = (BioPolymer)super.clone(); clone.strands.clear(); for (Iterator strands = clone.getStrandNames().iterator(); strands.hasNext();) { Strand strand = (Strand)clone.getStrand(strands.next().toString()).clone(); for (Iterator iter = strand.getMonomerNames().iterator(); iter.hasNext();) { IMonomer monomer = strand.getMonomer(iter.next().toString()); Iterator atoms = monomer.atoms().iterator(); while (atoms.hasNext()) { clone.addAtom((IAtom)atoms.next(), monomer, strand); } } } return clone; } } cdk-1.2.10/src/main/org/openscience/cdk/Bond.java100644 0 0 34643 11570154753 16610 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 Christoph Steinbeck * * 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. * * 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; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IBond; import javax.vecmath.Point2d; import javax.vecmath.Point3d; import java.io.Serializable; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * Implements the concept of a covalent bond between two or more atoms. A bond is * considered to be a number of electrons connecting two or more of atoms. *

* It should be noted that the majority of applications will consider 2-center bonds, * especially since the bond orders currently supported are really only valid for * 2-center bonds. However the code does support multi-center bonds, though the * orders may not make sense at this point. *

* In general code that assumes bonds are 2-centered can use this class seamlessly, as * the semantics are identical to the older versions. Care shoud be exercised when * using multi-center bonds using this class as the orders may not make sense. * * @author steinbeck * @cdk.module data * @cdk.githash * @cdk.created 2003-10-02 * @cdk.keyword bond * @cdk.keyword atom * @cdk.keyword electron */ public class Bond extends ElectronContainer implements IBond, Serializable, Cloneable { /** * Determines if a de-serialized object is compatible with this class. *

* This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = 7057060562283387384L; /** * The bond order of this bond. */ protected IBond.Order order = (Order) CDKConstants.UNSET; /** * Number of atoms contained by this object. */ protected int atomCount = 0; /** * A list of atoms participating in this bond. */ protected IAtom[] atoms = null; /** * A descriptor the stereochemical orientation of this bond. * * @see org.openscience.cdk.CDKConstants for predefined values to be used * here. */ protected int stereo; /** * Constructs an empty bond. */ public Bond() { this(null, null, null, CDKConstants.STEREO_BOND_NONE); atomCount = 0; } /** * Constructs a bond with a single bond order.. * * @param atom1 the first Atom in the bond * @param atom2 the second Atom in the bond */ public Bond(IAtom atom1, IAtom atom2) { this(atom1, atom2, IBond.Order.SINGLE, CDKConstants.STEREO_BOND_NONE); } /** * Constructs a bond with a given order. * * @param atom1 the first Atom in the bond * @param atom2 the second Atom in the bond * @param order the bond order */ public Bond(IAtom atom1, IAtom atom2, Order order) { this(atom1, atom2, order, CDKConstants.STEREO_BOND_NONE); } /** * Constructs a multi-center bond, with undefined order and no stereo information. * * @param atoms An array of IAtom containing the atoms constituting the bond */ public Bond(IAtom[] atoms) { this.atoms = new IAtom[atoms.length]; System.arraycopy(atoms, 0, this.atoms, 0, atoms.length); atomCount = this.atoms.length; } /** * Constructs a multi-center bond, with a specified order and no stereo information. * * @param atoms An array of IAtom containing the atoms constituting the bond * @param order The order of the bond */ public Bond(IAtom[] atoms, Order order) { this.atoms = new IAtom[atoms.length]; System.arraycopy(atoms, 0, this.atoms, 0, atoms.length); atomCount = this.atoms.length; this.order = order; } /** * Constructs a bond with a given order and stereo orientation from an array * of atoms. * * @param atom1 the first Atom in the bond * @param atom2 the second Atom in the bond * @param order the bond order * @param stereo a descriptor the stereochemical orientation of this bond */ public Bond(IAtom atom1, IAtom atom2, Order order, int stereo) { atoms = new Atom[2]; atoms[0] = atom1; atoms[1] = atom2; this.order = order; this.stereo = stereo; this.atomCount = 2; } /** * Returns the Iterator to atoms making up this bond. * Iterator.remove() is not implemented. * * @return An Iterator to atoms participating in this bond * @see #setAtoms */ public Iterable atoms() { return new Iterable() { public Iterator iterator() { return new AtomsIterator(); } }; } /** * The inner Iterator class. */ private class AtomsIterator implements Iterator { private int pointer = 0; public boolean hasNext() { return pointer < atomCount; } public IAtom next() { ++pointer; return atoms[pointer - 1]; } public void remove() { } } /** * Sets the array of atoms making up this bond. * * @param atoms An array of atoms that forms this bond * @see #atoms */ public void setAtoms(IAtom[] atoms) { this.atoms = atoms; atomCount = atoms.length; notifyChanged(); } /** * Returns the number of Atoms in this Bond. * * @return The number of Atoms in this Bond */ public int getAtomCount() { return atomCount; } /** * Returns an Atom from this bond. * * @param position The position in this bond where the atom is * @return The atom at the specified position, null if there are no atoms in the bond * @see #setAtom */ public IAtom getAtom(int position) { if (atoms == null) return null; else return atoms[position]; } /** * Returns the atom connected to the given atom. *

* This method is only strictly relevant for 2-center bonds * since in multi-center bonds, a given atom will be connected * to multiple atoms. *

* If called for a multi-center bond, then the next atom in the * atom list is returned. This is probably not what is expected and * hence the user should instead call * {@link #getConnectedAtoms(org.openscience.cdk.interfaces.IAtom)} * * @param atom The atom the bond partner is searched of * @return the connected atom or null if the atom is not part of the bond * @see #getConnectedAtoms(org.openscience.cdk.interfaces.IAtom) */ public IAtom getConnectedAtom(IAtom atom) { if (atoms[0] == atom) { return atoms[1]; } else if (atoms[1] == atom) { return atoms[0]; } return null; } /** * Returns all the atoms in the bond connected to the specified atom. *

* Though this can be used for traditional 2-center bonds, it is oriented * towards multi-center bonds, where a single atom is connected to multiple * atoms. * * @param atom The atom whose partners are to be searched for * @return An array of the connected atoms, null if the atom is not part of the bond * @see #getConnectedAtom(org.openscience.cdk.interfaces.IAtom) */ public IAtom[] getConnectedAtoms(IAtom atom) { boolean atomIsInBond = false; for (IAtom localAtom : atoms) { if (localAtom == atom) { atomIsInBond = true; break; } } if (!atomIsInBond) return null; List conAtoms = new ArrayList(); for (IAtom localAtom : atoms) { if (localAtom != atom) conAtoms.add(localAtom); } return conAtoms.toArray(new IAtom[]{}); } /** * Returns true if the given atom participates in this bond. * * @param atom The atom to be tested if it participates in this bond * @return true if the atom participates in this bond */ public boolean contains(IAtom atom) { if (atoms == null) return false; for (IAtom localAtom : atoms) { if (localAtom == atom) return true; } return false; } /** * Sets an Atom in this bond. * * @param atom The atom to be set * @param position The position in this bond where the atom is to be inserted * @see #getAtom */ public void setAtom(IAtom atom, int position) { if (atoms[position] == null && atom != null) atomCount++; if (atoms[position] != null && atom == null) atomCount--; atoms[position] = atom; notifyChanged(); } /** * Returns the bond order of this bond. * * @return The bond order of this bond * @see org.openscience.cdk.CDKConstants org.openscience.cdk.CDKConstants * for predefined values. * @see #setOrder */ public Order getOrder() { return this.order; } /** * Sets the bond order of this bond. * * @param order The bond order to be assigned to this bond * @see org.openscience.cdk.CDKConstants * org.openscience.cdk.CDKConstants for predefined values. * @see #getOrder */ public void setOrder(Order order) { this.order = order; notifyChanged(); } /** * Returns the stereo descriptor for this bond. * * @return The stereo descriptor for this bond * @see #setStereo * @see org.openscience.cdk.CDKConstants for predefined values. */ public int getStereo() { return this.stereo; } /** * Sets the stereo descriptor for this bond. * * @param stereo The stereo descriptor to be assigned to this bond. * @see #getStereo * @see org.openscience.cdk.CDKConstants for predefined values. */ public void setStereo(int stereo) { this.stereo = stereo; notifyChanged(); } /** * Returns the geometric 2D center of the bond. * * @return The geometric 2D center of the bond */ public Point2d get2DCenter() { double xOfCenter = 0; double yOfCenter = 0; for (IAtom atom : atoms) { xOfCenter += atom.getPoint2d().x; yOfCenter += atom.getPoint2d().y; } return new Point2d(xOfCenter / ((double) getAtomCount()), yOfCenter / ((double) getAtomCount())); } /** * Returns the geometric 3D center of the bond. * * @return The geometric 3D center of the bond */ public Point3d get3DCenter() { double xOfCenter = 0; double yOfCenter = 0; double zOfCenter = 0; for (IAtom atom : atoms) { xOfCenter += atom.getPoint3d().x; yOfCenter += atom.getPoint3d().y; zOfCenter += atom.getPoint3d().z; } return new Point3d(xOfCenter / getAtomCount(), yOfCenter / getAtomCount(), zOfCenter / getAtomCount()); } /** * Compares a bond with this bond. * * @param object Object of type Bond * @return true if the bond is equal to this bond */ public boolean compare(Object object) { if (object instanceof IBond) { Bond bond = (Bond) object; for (IAtom atom : atoms) { if (!bond.contains(atom)) { return false; } } // not important ??!! //if (order==bond.order) // return false; return true; } return false; } /** * Checks whether a bond is connected to another one. * This can only be true if the bonds have an Atom in common. * * @param bond The bond which is checked to be connect with this one * @return true if the bonds share an atom, otherwise false */ public boolean isConnectedTo(IBond bond) { for (IAtom atom : atoms) { if (bond.contains(atom)) return true; } return false; } /** * Clones this bond object, including clones of the atoms between which the * bond is defined. * * @return The cloned object */ public Object clone() throws CloneNotSupportedException { Bond clone = (Bond) super.clone(); // clone all the Atoms if (atoms != null) { clone.atoms = new IAtom[atoms.length]; for (int f = 0; f < atoms.length; f++) { if (atoms[f] != null) { clone.atoms[f] = (IAtom) ((IAtom) atoms[f]).clone(); } } } return clone; } /** * Returns a one line string representation of this Container. This method is * conform RFC #9. * * @return The string representation of this Container */ public String toString() { StringBuffer resultString = new StringBuffer(32); resultString.append("Bond(").append(this.hashCode()); if (getOrder() != null) { resultString.append(", #O:").append(getOrder()); } resultString.append(", #S:").append(getStereo()); if (getAtomCount() > 0) { resultString.append(", #A:").append(getAtomCount()); for (int i = 0; i < atomCount; i++) { resultString.append(", ").append("" + atoms[i]); } } resultString.append(", ").append(super.toString()); resultString.append(')'); return resultString.toString(); } } cdk-1.2.10/src/main/org/openscience/cdk/CDKConstants.java100644 0 0 30652 11570154753 20220 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 1997-2007 Christoph Steinbeck * * 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 I ask is that proper credit is given for my 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; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.interfaces.IBond; /** * An interface providing predefined values for a number of * constants used throughout the CDK. Classes using these constants should * not implement this interface, but use it like: *

 *   IBond.Order singleBondOrder = CDKConstants.BONDORDER_SINGLE;
 * 
* * @cdk.module core * @cdk.githash * * @cdk.keyword bond order * @cdk.keyword stereochemistry */ @TestClass("org.openscience.cdk.CDKConstantsTest") public class CDKConstants { public final static Object UNSET = null; /** A bond of degree 1.0. */ public final static IBond.Order BONDORDER_SINGLE = IBond.Order.SINGLE; /** A bond of degree 2.0. */ public final static IBond.Order BONDORDER_DOUBLE = IBond.Order.DOUBLE; /** A bond of degree 3.0. */ public final static IBond.Order BONDORDER_TRIPLE = IBond.Order.TRIPLE; public final static IBond.Order BONDORDER_QUADRUPLE = IBond.Order.QUADRUPLE; /** A bonds which end is above the drawing plane. */ public final static int STEREO_BOND_UP = 1; /** A bonds which start is above the drawing plane. */ public final static int STEREO_BOND_UP_INV = 2; /** A bonds for which the stereochemistry is undefined. */ public final static int STEREO_BOND_UNDEFINED = 4; /** A bonds for which there is no stereochemistry. */ public final static int STEREO_BOND_NONE = 0; /** A bonds which end is below the drawing plane. * The bond is draw from the first to the second bond atom. */ public final static int STEREO_BOND_DOWN = -1; /** A bonds which end is below the drawing plane. * The bond is draw from the second to the first bond atom. */ public final static int STEREO_BOND_DOWN_INV = -2; /** A positive atom parity. */ public final static int STEREO_ATOM_PARITY_PLUS = 1; /** A negative atom parity. */ public final static int STEREO_ATOM_PARITY_MINUS = -1; /** A undefined atom parity. */ public final static int STEREO_ATOM_PARITY_UNDEFINED = 0; /** A undefined hybridization. */ public final static int HYBRIDIZATION_UNSET = 0; /** A geometry of neighboring atoms when an s orbital is hybridized * with one p orbital. */ public final static int HYBRIDIZATION_SP1 = 1; /** A geometry of neighboring atoms when an s orbital is hybridized * with two p orbitals. */ public final static int HYBRIDIZATION_SP2 = 2; /** A geometry of neighboring atoms when an s orbital is hybridized * with three p orbitals. */ public final static int HYBRIDIZATION_SP3 = 3; /** A geometry of neighboring atoms when an s orbital is hybridized * with three p orbitals with one d orbital. */ public final static int HYBRIDIZATION_SP3D1 = 4; /** A geometry of neighboring atoms when an s orbital is hybridized * with three p orbitals with two d orbitals. */ public final static int HYBRIDIZATION_SP3D2 = 5; /** A geometry of neighboring atoms when an s orbital is hybridized * with three p orbitals with three d orbitals. */ public final static int HYBRIDIZATION_SP3D3 = 6; /** A geometry of neighboring atoms when an s orbital is hybridized * with three p orbitals with four d orbitals. */ public final static int HYBRIDIZATION_SP3D4 = 7; /** A geometry of neighboring atoms when an s orbital is hybridized * with three p orbitals with five d orbitals. */ public final static int HYBRIDIZATION_SP3D5 = 8; /** * Carbon NMR shift constant for use as a key in the * IChemObject.physicalProperties hashtable. * @see org.openscience.cdk.ChemObject */ public final static String NMRSHIFT_CARBON = "carbon nmr shift"; /** Hydrogen NMR shift constant for use as a key in the * IChemObject.physicalProperties hashtable. * @see org.openscience.cdk.ChemObject */ public final static String NMRSHIFT_HYDROGEN = "hydrogen nmr shift"; /** Nitrogen NMR shift constant for use as a key in the * IChemObject.physicalProperties hashtable. * @see org.openscience.cdk.ChemObject */ public final static String NMRSHIFT_NITROGEN = "nitrogen nmr shift"; /** Phosphorus NMR shift constant for use as a key in the * IChemObject.physicalProperties hashtable. * @see org.openscience.cdk.ChemObject */ public final static String NMRSHIFT_PHOSPORUS = "phosphorus nmr shift"; /** Fluorine NMR shift constant for use as a key in the * IChemObject.physicalProperties hashtable. * @see org.openscience.cdk.ChemObject */ public final static String NMRSHIFT_FLUORINE = "fluorine nmr shift"; /** Deuterium NMR shift constant for use as a key in the * IChemObject.physicalProperties hashtable. * @see org.openscience.cdk.ChemObject */ public final static String NMRSHIFT_DEUTERIUM = "deuterium nmr shift"; /**************************************** * Some predefined flags - keep the * * numbers below 50 free for other * * purposes * ****************************************/ /** Flag that is set if the chemobject is placed (somewhere). */ public final static int ISPLACED = 0; /** Flag that is set when the chemobject is part of a ring. */ public final static int ISINRING = 1; /** Flag that is set when the chemobject is part of a ring. */ public final static int ISNOTINRING = 2; /** Flag that is set if a chemobject is part of an aliphatic chain. */ public final static int ISALIPHATIC = 3; /** Flag is set if chemobject has been visited. */ public final static int VISITED = 4; // Use in tree searches /** Flag is set if chemobject is part of an aromatic system. */ public final static int ISAROMATIC = 5; /** Flag is set if chemobject is part of a conjugated system. */ public final static int ISCONJUGATED = 6; /** Flag is set if a chemobject is mapped to another chemobject. * It is used for example in subgraph isomorphism search. */ public final static int MAPPED = 7; /** Sets to true if the atom is an hydrogen bond donor. */ public final static int IS_HYDROGENBOND_DONOR = 8; /** Sets to true if the atom is an hydrogen bond acceptor. */ public final static int IS_HYDROGENBOND_ACCEPTOR = 9; /** Flag is set if a chemobject has reactive center. * It is used for example in reaction. */ public static final int REACTIVE_CENTER = 10; /** * Maximum flags array index. */ public final static int MAX_FLAG_INDEX = 10; /** * Flag used for JUnit testing the pointer functionality. */ public final static int DUMMY_POINTER = 1; /** * Maximum pointers array index. */ public final static int MAX_POINTER_INDEX = 1; /**************************************** * Some predefined property names for * * ChemObjects * ****************************************/ /** The title for a IChemObject. */ public static final String TITLE = "cdk:Title"; /** A remark for a IChemObject.*/ public static final String REMARK = "cdk:Remark"; /** A String comment. */ public static final String COMMENT = "cdk:Comment"; /** A List of names. */ public static final String NAMES = "cdk:Names"; /** A List of annotation remarks. */ public static final String ANNOTATIONS = "cdk:Annotations"; /** A description for a IChemObject. */ public static final String DESCRIPTION = "cdk:Description"; /**************************************** * Some predefined property names for * * Molecules * ****************************************/ /** The Daylight SMILES. */ public static final String SMILES = "cdk:SMILES"; /** The IUPAC International Chemical Identifier. */ public static final String INCHI = "cdk:InChI"; /** The Molecular Formula Identifier. */ public static final String FORMULA = "cdk:Formula"; /** The IUPAC compatible name generated with AutoNom. */ public static final String AUTONOMNAME = "cdk:AutonomName"; /** The Beilstein Registry Number. */ public static final String BEILSTEINRN = "cdk:BeilsteinRN"; /** The CAS Registry Number. */ public static final String CASRN = "cdk:CasRN"; /** A set of all rings computed for this molecule. */ public static final String ALL_RINGS = "cdk:AllRings"; /** A smallest set of smallest rings computed for this molecule. */ public static final String SMALLEST_RINGS = "cdk:SmallestRings"; /** The essential rings computed for this molecule. * The concept of Essential Rings is defined in * SSSRFinder */ public static final String ESSENTIAL_RINGS = "cdk:EssentialRings"; /** The relevant rings computed for this molecule. * The concept of relevant Rings is defined in * SSSRFinder */ public static final String RELEVANT_RINGS = "cdk:RelevantRings"; /**************************************** * Some predefined property names for * * Atoms * ****************************************/ /** * This property will contain an ArrayList of Integers. Each * element of the list indicates the size of the ring the given * atom belongs to (if it is a ring atom at all). */ public static final String RING_SIZES = "cdk:RingSizes"; /** * This property indicates how many ring bonds are connected to * the given atom. */ public static final String RING_CONNECTIONS = "cdk:RingConnections"; /* *This property indicate how many bond are present on the atom. * */ public static final String TOTAL_CONNECTIONS = "cdk:TotalConnections"; /* *Hydrogen count * */ public static final String TOTAL_H_COUNT = "cdk:TotalHydrogenCount"; /** The Isotropic Shielding, usually calculated by * a quantum chemistry program like Gaussian. * This is a property used for calculating NMR chemical * shifts by subtracting the value from the * isotropic shielding value of a standard (e.g. TMS). */ public static final String ISOTROPIC_SHIELDING = "cdk:IsotropicShielding"; /**************************************** * Some predefined property names for * * AtomTypes * ****************************************/ /** Used as property key for indicating the ring size of a certain atom type. */ public static final String PART_OF_RING_OF_SIZE = "cdk:Part of ring of size"; /** Used as property key for indicating the chemical group of a certain atom type. */ public static final String CHEMICAL_GROUP_CONSTANT = "cdk:Chemical Group"; /** Used as property key for indicating the HOSE code for a certain atom type. */ public static final String SPHERICAL_MATCHER = "cdk:HOSE code spherical matcher"; /** Used as property key for indicating the HOSE code for a certain atom type. */ public static final String PI_BOND_COUNT = "cdk:Pi Bond Count"; /** Used as property key for indicating the HOSE code for a certain atom type. */ public static final String LONE_PAIR_COUNT = "cdk:Lone Pair Count"; } cdk-1.2.10/src/main/org/openscience/cdk/ChemFile.java100644 0 0 14744 11570154753 17402 0ustar 0 0 /* * $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 Christoph Steinbeck * * 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. * * 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; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IChemSequence; import java.io.Serializable; import java.util.Iterator; /** * A Object containing a number of ChemSequences. This is supposed to be the * top level container, which can contain all the concepts stored in a chemical * document * *@author steinbeck * @cdk.githash *@cdk.module data */ public class ChemFile extends ChemObject implements Serializable, Cloneable, IChemFile, IChemObjectListener { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = 1926781734333430132L; /** * Array of ChemSquences. */ protected IChemSequence[] chemSequences; /** * Number of ChemSequences contained by this container. */ protected int chemSequenceCount; /** * Amount by which the chemsequence array grows when elements are added and * the array is not large enough for that. */ protected int growArraySize = 4; /** * Constructs an empty ChemFile. */ public ChemFile() { chemSequenceCount = 0; chemSequences = new ChemSequence[growArraySize]; } /** * Adds a ChemSequence to this container. * *@param chemSequence The chemSequence to be added to this container *@see #chemSequences */ public void addChemSequence(IChemSequence chemSequence) { chemSequence.addListener(this); if (chemSequenceCount + 1 >= chemSequences.length) { growChemSequenceArray(); } chemSequences[chemSequenceCount] = chemSequence; chemSequenceCount++; notifyChanged(); } /** * Removes a ChemSequence from this container. * * @param pos The position from which to remove * @see #chemSequences * @see #addChemSequence(org.openscience.cdk.interfaces.IChemSequence) */ public void removeChemSequence(int pos) { chemSequences[pos].removeListener(this); for (int i = pos; i < chemSequenceCount - 1; i++) { chemSequences[i] = chemSequences[i + 1]; } chemSequences[chemSequenceCount - 1] = null; chemSequenceCount--; notifyChanged(); } /** * Returns the Iterable to ChemSequences of this container. * *@return The Iterable to ChemSequences of this container *@see #addChemSequence */ public Iterable chemSequences() { return new Iterable(){ public Iterator iterator() { return new ChemSequenceIterator(); } }; } /** * The inner Iterator class. * */ private class ChemSequenceIterator implements Iterator { private int pointer = 0; public boolean hasNext() { return pointer < chemSequenceCount; } public IChemSequence next() { return chemSequences[pointer++]; } public void remove() { removeChemSequence(--pointer); } } /** * Returns the ChemSequence at position number in the container. * *@param number The position of the ChemSequence to be returned. *@return The ChemSequence at position number. *@see #addChemSequence */ public IChemSequence getChemSequence(int number) { return chemSequences[number]; } /** * Grows the ChemSequence array by a given size. * *@see #growArraySize */ protected void growChemSequenceArray() { growArraySize = chemSequences.length; IChemSequence[] newchemSequences = new ChemSequence[chemSequences.length + growArraySize]; System.arraycopy(chemSequences, 0, newchemSequences, 0, chemSequences.length); chemSequences = newchemSequences; } /** * Returns the number of ChemSequences in this Container. * *@return The number of ChemSequences in this Container */ public int getChemSequenceCount() { return this.chemSequenceCount; } /** * Returns a String representation of this class. It implements * RFC #9. * *@return String representation of the Object */ public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("ChemFile(#S="); buffer.append(chemSequenceCount); if (chemSequenceCount > 0) { for (IChemSequence iChemSequence : chemSequences()) { buffer.append(", "); buffer.append(iChemSequence.toString()); } } buffer.append(')'); return buffer.toString(); } /** * Allows for getting an clone of this object. * *@return a clone of this object */ public Object clone() throws CloneNotSupportedException { ChemFile clone = (ChemFile) super.clone(); // clone the chemModels clone.chemSequenceCount = getChemSequenceCount(); clone.chemSequences = new ChemSequence[clone.chemSequenceCount]; for (int f = 0; f < clone.chemSequenceCount; f++) { clone.chemSequences[f] = (ChemSequence)((ChemSequence)chemSequences[f]).clone(); } return clone; } /** * Called by objects to which this object has * registered as a listener. * *@param event A change event pointing to the source of the change */ public void stateChanged(IChemObjectChangeEvent event) { notifyChanged(event); } } cdk-1.2.10/src/main/org/openscience/cdk/ChemModel.java100644 0 0 15173 11570154753 17560 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 Christoph Steinbeck * * 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. * * 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; import org.openscience.cdk.interfaces.*; import java.io.Serializable; /** * An object containing multiple MoleculeSet and * the other lower level concepts like rings, sequences, * fragments, etc. * * @cdk.module data * @cdk.githash */ public class ChemModel extends ChemObject implements Serializable, IChemModel, IChemObjectListener, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = -5213425310451366185L; /** * A MoleculeSet. */ protected IMoleculeSet setOfMolecules = null; /** * A ReactionSet. */ protected IReactionSet setOfReactions = null; /** * A RingSet. */ protected IRingSet ringSet = null; /** * A Crystal. */ protected ICrystal crystal = null; /** * Constructs an new ChemModel with a null setOfMolecules. */ public ChemModel() {} /** * Returns the MoleculeSet of this ChemModel. * * @return The MoleculeSet of this ChemModel * * @see #setMoleculeSet */ public IMoleculeSet getMoleculeSet() { return this.setOfMolecules; } /** * Sets the MoleculeSet of this ChemModel. * * @param setOfMolecules the content of this model * * @see #getMoleculeSet */ public void setMoleculeSet(IMoleculeSet setOfMolecules) { if (this.setOfMolecules != null) this.setOfMolecules.removeListener(this); this.setOfMolecules = setOfMolecules; if (this.setOfMolecules != null) this.setOfMolecules.addListener(this); notifyChanged(); } /** * Returns the RingSet of this ChemModel. * * @return the ringset of this model * * @see #setRingSet */ public IRingSet getRingSet() { return this.ringSet; } /** * Sets the RingSet of this ChemModel. * * @param ringSet the content of this model * * @see #getRingSet */ public void setRingSet(IRingSet ringSet) { if (this.ringSet != null) this.ringSet.removeListener(this); this.ringSet = ringSet; if (this.ringSet != null) this.ringSet.addListener(this); notifyChanged(); } /** * Gets the Crystal contained in this ChemModel. * * @return The crystal in this model * * @see #setCrystal */ public ICrystal getCrystal() { return this.crystal; } /** * Sets the Crystal contained in this ChemModel. * * @param crystal the Crystal to store in this model * * @see #getCrystal */ public void setCrystal(ICrystal crystal) { if (this.crystal != null) this.crystal.removeListener(this); this.crystal = crystal; if (this.crystal != null) this.crystal.addListener(this); notifyChanged(); } /** * Gets the ReactionSet contained in this ChemModel. * * @return The ReactionSet in this model * * @see #setReactionSet */ public IReactionSet getReactionSet() { return this.setOfReactions; } /** * Sets the ReactionSet contained in this ChemModel. * * @param sor the ReactionSet to store in this model * * @see #getReactionSet */ public void setReactionSet(IReactionSet sor) { if (this.setOfReactions != null) this.setOfReactions.removeListener(this); this.setOfReactions = sor; if (this.setOfReactions != null) this.setOfReactions.addListener(this); notifyChanged(); } /** * Returns a String representation of the contents of this * IChemObject. * * @return String representation of content */ public String toString() { StringBuffer buffer = new StringBuffer(64); buffer.append("ChemModel("); buffer.append(hashCode()); if (getMoleculeSet() != null) { buffer.append(", "); buffer.append(getMoleculeSet().toString()); } if (getCrystal() != null) { buffer.append(", "); buffer.append(getCrystal().toString()); } if (getReactionSet() != null) { buffer.append(", "); buffer.append(getReactionSet().toString()); } buffer.append(')'); return buffer.toString(); } /** * Clones this ChemModel and its content. * * @return The cloned object */ public Object clone() throws CloneNotSupportedException { ChemModel clone = (ChemModel)super.clone(); // clone the content if (setOfMolecules != null) { clone.setOfMolecules = (MoleculeSet)((MoleculeSet)setOfMolecules).clone(); } else { clone.setOfMolecules = null; } if (setOfReactions != null) { clone.setOfReactions = (IReactionSet)((ReactionSet)setOfReactions).clone(); } else { clone.setOfReactions = null; } if (crystal != null) { clone.crystal = (Crystal)((Crystal)crystal).clone(); } else { clone.crystal = null; } if (ringSet != null) { clone.ringSet = (RingSet)((RingSet)ringSet).clone(); } else { clone.ringSet = null; } return clone; } /** * Called by objects to which this object has * registered as a listener. * *@param event A change event pointing to the source of the change */ public void stateChanged(IChemObjectChangeEvent event) { notifyChanged(event); } } cdk-1.2.10/src/main/org/openscience/cdk/ChemObject.java100644 0 0 30053 11570154753 17720 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 1997-2007 Christoph Steinbeck * * 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 org.openscience.cdk; import java.io.Serializable; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.openscience.cdk.event.ChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; /** * The base class for all chemical objects in this cdk. It provides methods for * adding listeners and for their notification of events, as well a a hash * table for administration of physical or chemical properties * *@author steinbeck * @cdk.githash *@cdk.module data */ public class ChemObject implements Serializable, IChemObject, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = 2798134548764323328L; /** * List for listener administration. */ private List chemObjectListeners; /** * A hashtable for the storage of any kind of properties of this IChemObject. */ private Map properties; /** * You will frequently have to use some flags on a IChemObject. For example, if * you want to draw a molecule and see if you've already drawn an atom, or in * a ring search to check whether a vertex has been visited in a graph * traversal. Use these flags while addressing particular positions in the * flag array with self-defined constants (flags[VISITED] = true). 100 flags * per object should be more than enough. */ private boolean[] flags; /** * The ID is null by default. */ private String identifier; /** * Constructs a new IChemObject. */ public ChemObject() { flags = new boolean[CDKConstants.MAX_FLAG_INDEX + 1]; chemObjectListeners = null; properties = null; identifier = null; } /** * Constructs a new IChemObject by copying the flags, and the * identifier. It does not copy the listeners and properties. * * @param chemObject the object to copy */ public ChemObject(IChemObject chemObject) { // copy the flags boolean[] oldflags = chemObject.getFlags(); flags = new boolean[oldflags.length]; System.arraycopy(oldflags, 0, flags, 0, flags.length); // copy the identifier identifier = chemObject.getID(); } /** * Lazy creation of chemObjectListeners List. * *@return List with the ChemObjects associated. */ private List lazyChemObjectListeners() { if (chemObjectListeners == null) { chemObjectListeners = new ArrayList(); } return chemObjectListeners; } /** * Use this to add yourself to this IChemObject as a listener. In order to do * so, you must implement the ChemObjectListener Interface. * *@param col the ChemObjectListener *@see #removeListener */ public void addListener(IChemObjectListener col) { List listeners = lazyChemObjectListeners(); if (!listeners.contains(col)) { listeners.add(col); } // Should we throw an exception if col is already in here or // just silently ignore it? } /** * Returns the number of ChemObjectListeners registered with this object. * *@return the number of registered listeners. */ public int getListenerCount() { if (chemObjectListeners == null) { return 0; } return lazyChemObjectListeners().size(); } /** * Use this to remove a ChemObjectListener from the ListenerList of this * IChemObject. It will then not be notified of change in this object anymore. * *@param col The ChemObjectListener to be removed *@see #addListener */ public void removeListener(IChemObjectListener col) { if (chemObjectListeners == null) { return; } List listeners = lazyChemObjectListeners(); if (listeners.contains(col)) { listeners.remove(col); } } /** * This should be triggered by an method that changes the content of an object * to that the registered listeners can react to it. */ public void notifyChanged() { if (getNotification() && getListenerCount() > 0) { List listeners = lazyChemObjectListeners(); for (Object listener : listeners) { ((IChemObjectListener) listener).stateChanged( new ChemObjectChangeEvent(this) ); } } } /** * This should be triggered by an method that changes the content of an object * to that the registered listeners can react to it. This is a version of * notifyChanged() which allows to propagate a change event while preserving * the original origin. * *@param evt A ChemObjectChangeEvent pointing to the source of where * the change happend */ public void notifyChanged(IChemObjectChangeEvent evt) { if (getNotification() && getListenerCount() > 0) { List listeners = lazyChemObjectListeners(); for (Object listener : listeners) { ((IChemObjectListener) listener).stateChanged(evt); } } } /** * Lazy creation of properties hash. * * @return Returns in instance of the properties */ private Map lazyProperties() { if (properties == null) { properties = new HashMap(); } return properties; } /** * Sets a property for a IChemObject. * *@param description An object description of the property (most likely a * unique string) *@param property An object with the property itself *@see #getProperty *@see #removeProperty */ public void setProperty(Object description, Object property) { lazyProperties().put(description, property); notifyChanged(); } /** * Removes a property for a IChemObject. * *@param description The object description of the property (most likely a * unique string) *@see #setProperty *@see #getProperty */ public void removeProperty(Object description) { if (properties == null) { return; } lazyProperties().remove(description); } /** * Returns a property for the IChemObject. * *@param description An object description of the property (most likely a * unique string) *@return The object containing the property. Returns null if * propert is not set. *@see #setProperty *@see #removeProperty */ public Object getProperty(Object description) { if (properties != null) { return lazyProperties().get(description); } return null; } /** * Returns a Map with the IChemObject's properties. * *@return The object's properties as an Hashtable *@see #setProperties */ public Map getProperties() { return lazyProperties(); } /** * Clones this IChemObject. It clones the identifier, flags, * properties and pointer vectors. The ChemObjectListeners are not cloned, and * neither is the content of the pointer vectors. * *@return The cloned object */ public Object clone() throws CloneNotSupportedException { ChemObject clone = (ChemObject)super.clone(); // clone the flags clone.flags = new boolean[CDKConstants.MAX_FLAG_INDEX + 1]; System.arraycopy(flags, 0, clone.flags, 0, flags.length); // clone the properties if (properties != null) { Map clonedHashtable = new HashMap(); Iterator keys = properties.keySet().iterator(); while (keys.hasNext()) { Object key = keys.next(); Object value = properties.get(key); clonedHashtable.put(key, value); } clone.properties = clonedHashtable; } // delete all listeners clone.chemObjectListeners = null; return clone; } /** * Compares a IChemObject with this IChemObject. * *@param object Object of type AtomType *@return true if the atom types are equal */ public boolean compare(Object object) { if (!(object instanceof IChemObject)) { return false; } ChemObject chemObj = (ChemObject) object; return identifier == chemObj.identifier; } /** * Returns the identifier (ID) of this object. * *@return a String representing the ID value *@see #setID */ public String getID() { return this.identifier; } /** * Sets the identifier (ID) of this object. * *@param identifier a String representing the ID value *@see #getID */ public void setID(String identifier) { this.identifier = identifier; notifyChanged(); } /** * Sets the value of some flag. * *@param flag_type Flag to set *@param flag_value Value to assign to flag *@see #getFlag */ public void setFlag(int flag_type, boolean flag_value) { flags[flag_type] = flag_value; notifyChanged(); } /** * Returns the value of some flag. * *@param flag_type Flag to retrieve the value of *@return true if the flag flag_type is set *@see #setFlag */ public boolean getFlag(int flag_type) { return flags[flag_type]; } /** * Sets the properties of this object. * *@param properties a Hashtable specifying the property values *@see #getProperties */ public void setProperties(Map properties) { Iterator keys = properties.keySet().iterator(); while (keys.hasNext()) { Object key = keys.next(); lazyProperties().put(key, properties.get(key)); } notifyChanged(); } /** * Sets the whole set of flags. * * @param flagsNew the new flags. * @see #getFlags */ public void setFlags(boolean[] flagsNew){ flags=flagsNew; } /** * Returns the whole set of flags. * *@return the flags. *@see #setFlags */ public boolean[] getFlags(){ return(flags); } /** * Clones this IChemObject, but preserves references to Objects. * * @return Shallow copy of this IChemObject * @see #clone */ public Object shallowCopy() { Object copy = null; try { copy = super.clone(); } catch (Exception e) { e.printStackTrace(System.err); } return copy; } public IChemObjectBuilder getBuilder() { return DefaultChemObjectBuilder.getInstance(); } private boolean doNotification = true; public void setNotification(boolean bool) { this.doNotification = bool; } public boolean getNotification() { return this.doNotification; } } cdk-1.2.10/src/main/org/openscience/cdk/ChemSequence.java100644 0 0 14004 11570154753 20260 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 Christoph Steinbeck * * 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. * * 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; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IChemSequence; import java.io.Serializable; import java.util.Iterator; /** * A sequence of ChemModels, which can, for example, be used to * store the course of a reaction. Each state of the reaction would be * stored in one ChemModel. * * @cdk.module data * @cdk.githash * * @cdk.keyword animation * @cdk.keyword reaction */ public class ChemSequence extends ChemObject implements Serializable, IChemSequence, IChemObjectListener, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = 2199218627455492000L; /** * Array of ChemModels. */ protected IChemModel[] chemModels; /** * Number of ChemModels contained by this container. */ protected int chemModelCount; /** * Amount by which the chemModels array grows when elements are added and * the array is not large enough for that. */ protected int growArraySize = 4; /** * Constructs an empty ChemSequence. */ public ChemSequence() { chemModelCount = 0; chemModels = new ChemModel[growArraySize]; } /** * Adds an chemModel to this container. * * @param chemModel The chemModel to be added to this container * * @see #getChemModel */ public void addChemModel(IChemModel chemModel) { if (chemModelCount + 1 >= chemModels.length) { growChemModelArray(); } chemModels[chemModelCount] = chemModel; chemModelCount++; chemModel.addListener(this); notifyChanged(); } /** * Remove a ChemModel from this ChemSequence. * * @param pos The position of the ChemModel to be removed. */ public void removeChemModel(int pos) { chemModels[pos].removeListener(this); for (int i = pos; i < chemModelCount - 1; i++) { chemModels[i] = chemModels[i + 1]; } chemModels[chemModelCount - 1] = null; chemModelCount--; notifyChanged(); } /** * Returns an Iterable to ChemModels in this container. * * @return The Iterable to ChemModels in this container * @see #addChemModel */ public Iterable chemModels() { return new Iterable(){ public Iterator iterator() { return new ChemModelIterator(); } }; } /** * The inner Iterator class. * */ private class ChemModelIterator implements Iterator { private int pointer = 0; public boolean hasNext() { return pointer < chemModelCount; } public IChemModel next() { return chemModels[pointer++]; } public void remove() { removeChemModel(--pointer); } } /** * * Returns the ChemModel at position number in the * container. * * @param number The position of the ChemModel to be returned. * @return The ChemModel at position number. * * @see #addChemModel */ public IChemModel getChemModel(int number) { return chemModels[number]; } /** * Grows the chemModel array by a given size. * * @see growArraySize */ protected void growChemModelArray() { ChemModel[] newchemModels = new ChemModel[chemModels.length + growArraySize]; System.arraycopy(chemModels, 0, newchemModels, 0, chemModels.length); chemModels = newchemModels; } /** * Returns the number of ChemModels in this Container. * * @return The number of ChemModels in this Container */ public int getChemModelCount() { return this.chemModelCount; } public String toString() { StringBuffer buffer = new StringBuffer(32); buffer.append("ChemSequence(#M="); buffer.append(chemModelCount); if (chemModelCount > 0) { buffer.append(", "); for (int i=0; i * * 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. * * 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; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import javax.vecmath.Point3d; import java.util.*; /** * A memory-efficient data structure to store conformers for a single molecule. *

* Since all the conformers for a given molecule only differ in their 3D coordinates * this data structure stores a single {@link IAtomContainer} containing the atom and bond * details and a List of 3D coordinate sets, each element being the set of 3D coordinates * for a given conformer. *

* The class behaves in many ways as a List object, though a few methods are not * implemented. Though it is possible to add conformers by hand, this data structure is * probably best used in combination with {@link org.openscience.cdk.io.iterator.IteratingMDLConformerReader} as *

 * IteratingMDLConformerReader reader = new IteratingMDLConformerReader(
 *          new FileReader(new File(filename)),
 *          DefaultChemObjectBuilder.getInstance());
 * while (reader.hasNext()) {
 *     ConformerContainer cc = (ConformerContainer) reader.next();
 *     for (IAtomContainer conformer : cc) {
 *         // do something with each conformer
 *     }
 * }
 * 
* * @cdk.module data * @cdk.githash * @author Rajarshi Guha * @see org.openscience.cdk.io.iterator.IteratingMDLConformerReader */ @TestClass("org.openscience.cdk.ConformerContainer") public class ConformerContainer implements List { private IAtomContainer atomContainer = null; private String title = null; private List coordinates; private Point3d[] getCoordinateList(IAtomContainer atomContainer) { Point3d[] tmp = new Point3d[atomContainer.getAtomCount()]; for (int i = 0; i < atomContainer.getAtomCount(); i++) { IAtom atom = atomContainer.getAtom(i); if (atom.getPoint3d() == null) throw new NullPointerException("Molecule must have 3D coordinates"); tmp[i] = new Point3d(atom.getPoint3d()); } return tmp; } public ConformerContainer() { coordinates = new ArrayList(); } /** * Create a ConformerContainer object from a single molecule object. *

* Using this constructor, the resultant conformer container will * contain a single conformer. More conformers can be added using the * {@link #add} method. *

* Note that the constructor will use the title of the input molecule * when adding new molecules as conformers. That is, the title of any molecule * to be added as a conformer should match the title of the input molecule. * * @param atomContainer The base molecule (or first conformer). */ public ConformerContainer(IAtomContainer atomContainer) { this.atomContainer = atomContainer; title = (String) atomContainer.getProperty(CDKConstants.TITLE); coordinates = new ArrayList(); coordinates.add(getCoordinateList(atomContainer)); } /** * Create a ConformerContainer from an array of molecules. *

* This constructor can be used when you have an array of conformers of a given * molecule. Note that this constructor will assume that all molecules in the * input array will have the same title. * * @param atomContainers The array of conformers */ public ConformerContainer(IAtomContainer[] atomContainers) { if (atomContainers.length == 0) throw new IllegalArgumentException("Can't use a zero-length molecule array"); // lets check that the titles match title = (String) atomContainers[0].getProperty(CDKConstants.TITLE); for (IAtomContainer atomContainer : atomContainers) { String nextTitle = (String) atomContainer.getProperty(CDKConstants.TITLE); if (title != null && !nextTitle.equals(title)) throw new IllegalArgumentException("Titles of all molecules must match"); } this.atomContainer = atomContainers[0]; coordinates = new ArrayList(); for (IAtomContainer container : atomContainers) { coordinates.add(getCoordinateList(container)); } } /** * Get the title of the conformers. *

* Note that all conformers for a given molecule will have the same * title. * * @return The title for the conformers */ @TestMethod("testGetTitle") public String getTitle() { return title; } /** * Get the number of conformers stored. * * @return The number of conformers */ @TestMethod("testSize") public int size() { return coordinates.size(); } /** * Checks whether any conformers are stored or not. * * @return true if there is at least one conformer, otherwise false */ @TestMethod("testIsEmpty") public boolean isEmpty() { return coordinates.isEmpty(); } /** * Checks to see whether the specified conformer is currently stored. *

* This method first checks whether the title of the supplied molecule * matches the stored title. If not, it returns false. If the title matches * it then checks all the coordinates to see whether they match. If all * coordinates match it returns true else false. * * @param o The IAtomContainer to check for * @return true if it is present, false otherwise */ @TestMethod("testContains, testContains_Object") public boolean contains(Object o) { return indexOf(o) != -1; } /** * Gets an iterator over the conformers. * * @return an iterator over the conformers. Each iteration will return an IAtomContainer object * corresponding to the current conformer. */ @TestMethod("testIterator, testIterator2") public Iterator iterator() { return new CCIterator(); } /** * Returns the conformers in the form of an array of IAtomContainers. *

* Beware that if you have a large number of conformers you may run out * memory during construction of the array since IAtomContainer's are not * light weight objects! * * @return The conformers as an array of individual IAtomContainers. */ @TestMethod("testToArray") public Object[] toArray() { IAtomContainer[] ret = new IAtomContainer[coordinates.size()]; int index = 0; for (Point3d[] coords : coordinates) { try { IAtomContainer conf = (IAtomContainer) atomContainer.clone(); for (int i = 0; i < coords.length; i++) { IAtom atom = conf.getAtom(i); atom.setPoint3d(coords[i]); } ret[index++] = conf; } catch (CloneNotSupportedException e) { e.printStackTrace(); } } return ret; } @TestMethod("testToArray_arrayObject") public IAtomContainer[] toArray(IAtomContainer[] ts) { throw new UnsupportedOperationException(); } /** * Add a conformer to the end of the list. *

* This method allows you to add a IAtomContainer object as another conformer. * Before adding it ensures that the title of specific object matches the * stored title for these conformers. It will also check that the number of * atoms in the specified molecule match the number of atoms in the current set * of conformers. *

* This method will not check for duplicate conformers. * * @param atomContainer The new conformer to add. * @return true */ @TestMethod("testAdd_IAtomContainer") public boolean add(IAtomContainer atomContainer) { if (this.atomContainer == null) { this.atomContainer = atomContainer; title = (String) atomContainer.getProperty(CDKConstants.TITLE); } if (title==null){ throw new IllegalArgumentException( "At least one of the input molecules does not have a title"); } if (!title.equals(atomContainer.getProperty(CDKConstants.TITLE))) throw new IllegalArgumentException( "The input molecules does not have the same title ('" + title + "') as the other conformers ('" + atomContainer.getProperty(CDKConstants.TITLE) + "')"); if (atomContainer.getAtomCount() != this.atomContainer.getAtomCount()) throw new IllegalArgumentException("Doesn't have the same number of atoms as the rest of the conformers"); coordinates.add(getCoordinateList(atomContainer)); return true; } /** * Remove the specified conformer. * * @param o The conformer to remove (should be castable to IAtomContainer) * @return true if the specified conformer was present and removed, false if not found */ @TestMethod("testRemove_Object") public boolean remove(Object o) { IAtomContainer atomContainer = (IAtomContainer) o; // we should never have a null conformer if (atomContainer == null) return false; int index = indexOf(atomContainer); if (index >= 0) { remove(index); return true; } return false; } @TestMethod("testContainsAll_Collection") public boolean containsAll(Collection objects) { throw new UnsupportedOperationException(); } @TestMethod("testAddAll_Collection") public boolean addAll(Collection atomContainers) { throw new UnsupportedOperationException(); } @TestMethod("testAddAll_int_Collection") public boolean addAll(int i, Collection iAtomContainers) { throw new UnsupportedOperationException(); } @TestMethod("testRemoveAll_Collectio") public boolean removeAll(Collection objects) { throw new UnsupportedOperationException(); } @TestMethod("testRetainAll_Collection") public boolean retainAll(Collection objects) { throw new UnsupportedOperationException(); } /** * Get rid of all the conformers but keeps atom and bond information. */ @TestMethod("testClear") public void clear() { coordinates.clear(); } /** * Get the conformer at a specified position. * * @param i The position of the requested conformer * @return The conformer */ @TestMethod("testGet_int, testGet2") public IAtomContainer get(int i) { Point3d[] tmp = coordinates.get(i); for (int j = 0; j < atomContainer.getAtomCount(); j++) { IAtom atom = atomContainer.getAtom(j); atom.setPoint3d(tmp[j]); } return atomContainer; } @TestMethod("testSet_int_IAtomContainer") public IAtomContainer set(int i, IAtomContainer atomContainer) { if (!title.equals(atomContainer.getProperty(CDKConstants.TITLE))) throw new IllegalArgumentException("The input molecules does not have the same title as the other conformers"); Point3d[] tmp = getCoordinateList(atomContainer); IAtomContainer oldAtomContainer = get(i); coordinates.set(i, tmp); return oldAtomContainer; } @TestMethod("testAdd_int_IAtomContainer") public void add(int i, IAtomContainer atomContainer) { if (this.atomContainer == null) { this.atomContainer = atomContainer; title = (String) atomContainer.getProperty(CDKConstants.TITLE); } if (!title.equals(atomContainer.getProperty(CDKConstants.TITLE))) throw new IllegalArgumentException("The input molecules does not have the same title as the other conformers"); if (atomContainer.getAtomCount() != this.atomContainer.getAtomCount()) throw new IllegalArgumentException("Doesn't have the same number of atoms as the rest of the conformers"); Point3d[] tmp = getCoordinateList(atomContainer); coordinates.add(i, tmp); } /** * Removes the conformer at the specified position. * * @param i The position in the list to remove * @return The conformer that was at the specified position */ @TestMethod("testRemove_int") public IAtomContainer remove(int i) { IAtomContainer oldAtomContainer = get(i); coordinates.remove(i); return oldAtomContainer; } /** * Returns the lowest index at which the specific IAtomContainer appears in the list or -1 if is not found. *

* A given IAtomContainer will occur in the list if the title matches the stored title for * the conformers in this container and if the coordinates for each atom in the specified molecule * are equal to the coordinates of the corresponding atoms in a conformer. * * @param o The IAtomContainer whose presence is being tested * @return The index where o was found */ @TestMethod("testIndexOf_Object") public int indexOf(Object o) { IAtomContainer atomContainer = (IAtomContainer) o; if (!atomContainer.getProperty(CDKConstants.TITLE).equals(title)) return -1; if (atomContainer.getAtomCount() != this.atomContainer.getAtomCount()) return -1; boolean coordsMatch; int index = 0; for (Point3d[] coords : coordinates) { coordsMatch = true; for (int i = 0; i < atomContainer.getAtomCount(); i++) { Point3d p = atomContainer.getAtom(i).getPoint3d(); if (!(p.x == coords[i].x && p.y == coords[i].y && p.z == coords[i].z)) { coordsMatch = false; break; } } if (coordsMatch) return index; index++; } return -1; } /** * Returns the highest index at which the specific IAtomContainer appears in the list or -1 if is not found. *

* A given IAtomContainer will occur in the list if the title matches the stored title for * the conformers in this container and if the coordinates for each atom in the specified molecule * are equal to the coordinates of the corresponding atoms in a conformer. * * @param o The IAtomContainer whose presence is being tested * @return The index where o was found */ @TestMethod("testLastIndexOf_Object") public int lastIndexOf(Object o) { IAtomContainer atomContainer = (IAtomContainer) o; if (!atomContainer.getProperty(CDKConstants.TITLE).equals(title)) return -1; if (atomContainer.getAtomCount() != coordinates.get(0).length) return -1; boolean coordsMatch; for (int j = coordinates.size() - 1; j >= 0; j--) { Point3d[] coords = coordinates.get(j); coordsMatch = true; for (int i = 0; i < atomContainer.getAtomCount(); i++) { Point3d p = atomContainer.getAtom(i).getPoint3d(); if (!(p.x == coords[i].x && p.y == coords[i].y && p.z == coords[i].z)) { coordsMatch = false; break; } } if (coordsMatch) return j; } return -1; } @TestMethod("testListIterator") public ListIterator listIterator() { throw new UnsupportedOperationException(); } @TestMethod("testListIterator_int") public ListIterator listIterator(int i) { throw new UnsupportedOperationException(); } @TestMethod("testSubList_int_int") public List subList(int i, int i1) { throw new UnsupportedOperationException(); } private class CCIterator implements Iterator { int current = 0; int last = -1; public boolean hasNext() { return current != coordinates.size(); } public IAtomContainer next() { Point3d[] tmp = coordinates.get(current); for (int j = 0; j < atomContainer.getAtomCount(); j++) { IAtom atom = atomContainer.getAtom(j); atom.setPoint3d(tmp[j]); } last = current++; return atomContainer; } public void remove() { throw new UnsupportedOperationException(); } } } cdk-1.2.10/src/main/org/openscience/cdk/Crystal.java100644 0 0 15446 11570154753 17347 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2002-2007 Egon Willighagen * * 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. * * 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; import java.io.Serializable; import javax.vecmath.Vector3d; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.ICrystal; /** * Class representing a molecular crystal. * The crystal is described with molecules in fractional * coordinates and three cell axes: a,b and c. * *

The crystal is designed to store only the asymmetric atoms. * Though this is not enforced, it is assumed by all methods. * * @cdk.module data * @cdk.githash * * @cdk.keyword crystal */ public class Crystal extends AtomContainer implements Serializable, ICrystal, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = 5919649450390509278L; /** The a axis. */ private Vector3d aAxis; /** The b axis. */ private Vector3d bAxis; /** The c axis. */ private Vector3d cAxis; /** * Number of symmetry related atoms. */ private Integer zValue = 1; /** * Number of symmetry related atoms. */ private String spaceGroup = "P1"; /** * Constructs a new crystal with zero length cell axis. */ public Crystal() { super(); setZeroAxes(); } /** * Constructs a new crystal with zero length cell axis * and adds the atoms in the AtomContainer as cell content. * * @param container the AtomContainer providing the atoms and bonds */ public Crystal(IAtomContainer container) { super(container); setZeroAxes(); } /** * Sets the A unit cell axes in Cartesian coordinates in a * Euclidean space. * * @param newAxis the new A axis * * @see #getA */ public void setA(Vector3d newAxis) { aAxis = newAxis; notifyChanged(); } /** * Gets the A unit cell axes in Cartesian coordinates * as a three element double array. * * @return a Vector3D representing the A axis * * @see #setA */ public Vector3d getA() { return aAxis; } /** * Sets the B unit cell axes in Cartesian coordinates. * * @param newAxis the new B axis * * @see #getB */ public void setB(Vector3d newAxis) { bAxis = newAxis; notifyChanged(); } /** * Gets the B unit cell axes in Cartesian coordinates * as a three element double array. * * @return a Vector3D representing the B axis * * @see #setB */ public Vector3d getB() { return bAxis; } /** * Sets the C unit cell axes in Cartesian coordinates. * * @param newAxis the new C axis * * @see #getC */ public void setC(Vector3d newAxis) { cAxis = newAxis; notifyChanged(); } /** * Gets the C unit cell axes in Cartesian coordinates * as a three element double array. * * @return a Vector3D representing the C axis * * @see #setC */ public Vector3d getC() { return cAxis; } /** * Gets the space group of this crystal. * * @return the space group of this crystal structure * * @see #setSpaceGroup */ public String getSpaceGroup() { return spaceGroup; } /** * Sets the space group of this crystal. * * @param group the space group of this crystal structure * * @see #getSpaceGroup */ public void setSpaceGroup(String group) { spaceGroup = group; notifyChanged(); } /** * Gets the number of asymmetric parts in the unit cell. * * @return the number of asymmetric parts in the unit cell * @see #setZ */ public Integer getZ() { return zValue; } /** * Sets the number of asymmetric parts in the unit cell. * * @param value the number of asymmetric parts in the unit cell * @see #getZ */ public void setZ(Integer value) { this.zValue = value; notifyChanged(); } /** * Makes a clone of this crystal. * * @return The cloned crystal. */ public Object clone() throws CloneNotSupportedException { Crystal clone = (Crystal)super.clone(); // clone the axes clone.setA(new Vector3d(this.aAxis)); clone.setB(new Vector3d(this.bAxis)); clone.setC(new Vector3d(this.cAxis)); return clone; } /** * Returns a String representation of this crystal. */ public String toString() { StringBuffer resultString = new StringBuffer(64); resultString.append("Crystal(").append(hashCode()); if (getSpaceGroup() != null) { resultString.append(", SG=").append(getSpaceGroup()); } if (getZ() > 0) { resultString.append(", Z=").append(getZ()); } if (getA() != null) { resultString.append(", a=(").append(aAxis.x).append(", ").append(aAxis.y).append(", ").append(aAxis.z); } if (getB() != null) { resultString.append("), b=(").append(bAxis.x).append(", ").append(bAxis.y).append(", ").append(bAxis.z); } if (getC() != null) { resultString.append("), c=(").append(cAxis.x).append(", ").append(cAxis.y).append(", ").append(cAxis.z); } resultString.append(", ").append(super.toString()); return resultString.toString(); } /** * Initializes the unit cell axes to zero length. */ private void setZeroAxes() { aAxis = new Vector3d(0.0, 0.0, 0.0); bAxis = new Vector3d(0.0, 0.0, 0.0); cAxis = new Vector3d(0.0, 0.0, 0.0); } } cdk-1.2.10/src/main/org/openscience/cdk/DefaultChemObjectBuilder.java100644 0 0 21750 11570154753 22540 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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; import org.openscience.cdk.formula.AdductFormula; import org.openscience.cdk.formula.MolecularFormula; import org.openscience.cdk.formula.MolecularFormulaSet; import org.openscience.cdk.interfaces.*; import org.openscience.cdk.protein.data.PDBAtom; import org.openscience.cdk.protein.data.PDBMonomer; import org.openscience.cdk.protein.data.PDBPolymer; import org.openscience.cdk.protein.data.PDBStructure; import javax.vecmath.Point2d; import javax.vecmath.Point3d; /** * A helper class to instantiate a IChemObject for a specific implementation. * * @author egonw * @cdk.module data * @cdk.githash */ public class DefaultChemObjectBuilder implements IChemObjectBuilder { private static DefaultChemObjectBuilder instance = null; private DefaultChemObjectBuilder() {} public static DefaultChemObjectBuilder getInstance() { if (instance == null) { instance = new DefaultChemObjectBuilder(); } return instance; } public IAminoAcid newAminoAcid() { return new AminoAcid(); } public IAtom newAtom() { return new Atom(); } public IAtom newAtom(String elementSymbol) { return new Atom(elementSymbol); } public IAtom newAtom(String elementSymbol, javax.vecmath.Point2d point2d) { return new Atom(elementSymbol, point2d); } public IAtom newAtom(String elementSymbol, javax.vecmath.Point3d point3d) { return new Atom(elementSymbol, point3d); } public IAtomContainer newAtomContainer() { return new AtomContainer(); } public IAtomContainer newAtomContainer(int atomCount, int bondCount, int lonePairCount, int singleElectronCount) { return new AtomContainer(atomCount, bondCount, lonePairCount, singleElectronCount); } public IAtomContainer newAtomContainer(IAtomContainer container) { return new AtomContainer(container); } public IAtomParity newAtomParity(IAtom centralAtom, IAtom first, IAtom second, IAtom third, IAtom fourth, int parity) { return new AtomParity(centralAtom, first, second, third, fourth, parity); } public IAtomType newAtomType(String elementSymbol) { return new AtomType(elementSymbol); } public IAtomType newAtomType(String identifier, String elementSymbol) { return new AtomType(identifier, elementSymbol); } public IBioPolymer newBioPolymer(){ return new BioPolymer(); } public IBond newBond() { return new Bond(); } public IBond newBond(IAtom atom1, IAtom atom2) { return new Bond(atom1, atom2); } public IBond newBond(IAtom atom1, IAtom atom2, IBond.Order order) { return new Bond(atom1, atom2, order); } public IBond newBond(IAtom atom1, IAtom atom2, IBond.Order order, int stereo) { return new Bond(atom1, atom2, order, stereo); } public IBond newBond(IAtom[] atoms) { return new Bond(atoms); } public IBond newBond(IAtom[] atoms, IBond.Order order) { return new Bond(atoms, order); } public IChemFile newChemFile() { return new ChemFile(); } public IChemModel newChemModel() { return new ChemModel(); } public IChemObject newChemObject() { return new ChemObject(); } public IChemSequence newChemSequence() { return new ChemSequence(); } public ICrystal newCrystal() { return new Crystal(); } public ICrystal newCrystal(IAtomContainer container) { return new Crystal(container); } public IElectronContainer newElectronContainer() { return new ElectronContainer(); } public IElement newElement() { return new Element(); } public IElement newElement(String symbol) { return new Element(symbol); } public IElement newElement(String symbol, int atomicNumber) { return new Element(symbol, atomicNumber); } public IIsotope newIsotope(String elementSymbol) { return new Isotope(elementSymbol); } public IIsotope newIsotope(int atomicNumber, String elementSymbol, int massNumber, double exactMass, double abundance) { return new Isotope(atomicNumber, elementSymbol, massNumber, exactMass, abundance); } public IIsotope newIsotope(int atomicNumber, String elementSymbol, double exactMass, double abundance) { return new Isotope(atomicNumber, elementSymbol, exactMass, abundance); } public IIsotope newIsotope(String elementSymbol, int massNumber) { return new Isotope(elementSymbol, massNumber); } public ILonePair newLonePair() { return new LonePair(); } public ILonePair newLonePair(IAtom atom) { return new LonePair(atom); } public IMapping newMapping(IChemObject objectOne, IChemObject objectTwo) { return new Mapping(objectOne, objectTwo); } public IMolecule newMolecule() { return new Molecule(); } public IMolecule newMolecule(int atomCount, int electronContainerCount, int lonePairCount, int singleElectronCount) { return new Molecule(atomCount, electronContainerCount, lonePairCount, singleElectronCount); } public IMolecule newMolecule(IAtomContainer container) { return new Molecule(container); } public IMonomer newMonomer () { return new Monomer(); } public IPolymer newPolymer() { return new Polymer(); } public IPDBAtom newPDBAtom(IElement element){ return new PDBAtom(element); } public IPDBAtom newPDBAtom(String symbol){ return new PDBAtom(symbol); } public IPDBAtom newPDBAtom(String symbol, Point3d coordinate){ return new PDBAtom(symbol, coordinate); } public IPDBPolymer newPDBPolymer() { return new PDBPolymer(); } public IPDBStructure newPDBStructure() { return new PDBStructure(); } public IPDBMonomer newPDBMonomer() { return new PDBMonomer(); } public IReaction newReaction() { return new Reaction(); } public IRing newRing() { return new Ring(); } public IRing newRing(IAtomContainer container) { return new Ring(container); } public IRing newRing(int ringSize, String elementSymbol) { return new Ring(ringSize, elementSymbol); } public IRing newRing(int ringSize) { return new Ring(ringSize); } public IRingSet newRingSet() { return new RingSet(); } public IAtomContainerSet newAtomContainerSet() { return new AtomContainerSet(); } public IMoleculeSet newMoleculeSet() { return new MoleculeSet(); } public IReactionSet newReactionSet() { return new ReactionSet(); } public IReactionScheme newReactionScheme() { return new ReactionScheme(); } public ISingleElectron newSingleElectron() { return new SingleElectron(); } public ISingleElectron newSingleElectron(IAtom atom) { return new SingleElectron(atom); } public IStrand newStrand() { return new Strand(); } public IPseudoAtom newPseudoAtom() { return new PseudoAtom(); } public IPseudoAtom newPseudoAtom(String label) { return new PseudoAtom(label); } public IPseudoAtom newPseudoAtom(IAtom atom) { return new PseudoAtom(atom); } public IPseudoAtom newPseudoAtom(String label, Point3d point3d) { return new PseudoAtom(label, point3d); } public IPseudoAtom newPseudoAtom(String label, Point2d point2d) { return new PseudoAtom(label, point2d); } public IAtom newAtom(IElement element) { return new Atom(element); } public IAtomType newAtomType(IElement element) { return new AtomType(element); } public IChemObject newChemObject(IChemObject object) { return new ChemObject(object); } public IElement newElement(IElement element) { return new Element(element); } public IIsotope newIsotope(IElement element) { return new Isotope(element); } public IPseudoAtom newPseudoAtom(IElement element) { return new PseudoAtom(element); } public IFragmentAtom newFragmentAtom() { return new FragmentAtom(); } public IAdductFormula newAdductFormula() { return new AdductFormula(); } public IMolecularFormula newMolecularFormula() { return new MolecularFormula(); } public IMolecularFormulaSet newMolecularFormulaSet() { return new MolecularFormulaSet(); } public IAdductFormula newAdductFormula(IMolecularFormula formula) { return new AdductFormula(formula); } public IMolecularFormulaSet newMolecularFormulaSet(IMolecularFormula formula) { return new MolecularFormulaSet(formula); } } cdk-1.2.10/src/main/org/openscience/cdk/ElectronContainer.java100644 0 0 5736 11570154753 21325 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 Christoph Steinbeck * * 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. * * 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; import java.io.Serializable; import org.openscience.cdk.interfaces.IElectronContainer; /** * Base class for entities containing electrons, like bonds, orbitals, lone-pairs. * * @cdk.module data * @cdk.githash * * @cdk.keyword orbital * @cdk.keyword lone-pair * @cdk.keyword bond */ public class ElectronContainer extends ChemObject implements Serializable, IElectronContainer, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = -2207894536767670743L; /** Number of electrons in the ElectronContainer. */ protected Integer electronCount; /** * Constructs an empty ElectronContainer. */ public ElectronContainer() { electronCount = 0; } /** * Returns the number of electrons in this electron container. * * @return The number of electrons in this electron container. * * @see #setElectronCount */ public Integer getElectronCount() { return this.electronCount; } /** * Sets the number of electrons in this electron container. * * @param electronCount The number of electrons in this electron container. * * @see #getElectronCount */ public void setElectronCount(Integer electronCount) { this.electronCount = electronCount; notifyChanged(); } public Object clone() throws CloneNotSupportedException { return super.clone(); } public String toString() { StringBuffer resultString = new StringBuffer(64); resultString.append("ElectronContainer(").append(hashCode()); if (getElectronCount() > -1) { resultString.append("EC:").append(getElectronCount()); } resultString.append(')'); return resultString.toString(); } } cdk-1.2.10/src/main/org/openscience/cdk/Element.java100644 0 0 13633 11570154753 17313 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 Christoph Steinbeck * * 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. * * 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; import org.openscience.cdk.interfaces.IElement; import java.io.Serializable; /** * Implements the idea of an element in the periodic table. * *

Use the IsotopeFactory to get a ready-to-use elements * by symbol or atomic number: *

 *   IsotopeFactory if = IsotopeFactory.getInstance(new Element().getBuilder());
 *   Element e1 = if.getElement("C");
 *   Element e2 = if.getElement(12);
 * 
* * @cdk.module data * @cdk.githash * * @cdk.keyword element * * @see org.openscience.cdk.config.IsotopeFactory */ public class Element extends ChemObject implements Serializable, IElement, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = 3062529834691231436L; /** The element symbol for this element as listed in the periodic table. */ protected String symbol; /** The atomic number for this element giving their position in the periodic table. */ protected Integer atomicNumber = (Integer) CDKConstants.UNSET; /** * Constructs an empty Element. */ public Element() { super(); this.symbol = null; } /** * Constructs an empty by copying the symbol, atomic number, * flags, and identifier from the given IElement. It does * not copy the listeners and properties. * * @param element IElement to copy information from */ public Element(IElement element) { super(element); this.symbol = element.getSymbol(); this.atomicNumber = element.getAtomicNumber(); } /** * Constructs an Element with a given * element symbol. * * @param symbol The element symbol that this element should have. */ public Element(String symbol) { this(); this.symbol = symbol; } /** * Constructs an Element with a given element symbol, * atomic number and atomic mass. * * @param symbol The element symbol of this element. * @param atomicNumber The atomicNumber of this element. */ public Element(String symbol, int atomicNumber) { this(symbol); this.atomicNumber = atomicNumber; } /** * Returns the atomic number of this element. * *

Once instantiated all field not filled by passing parameters * to the constructor are null. Elements can be configured by using * the IsotopeFactory.configure() method: *

	 *   Element element = new Element("C");
	 *   IsotopeFactory if = IsotopeFactory.getInstance(element.getBuilder());
	 *   if.configure(element);
	 * 
*

* * @return The atomic number of this element * * @see #setAtomicNumber */ public Integer getAtomicNumber() { return this.atomicNumber; } /** * Sets the atomic number of this element. * * @param atomicNumber The atomic mass to be assigned to this element * * @see #getAtomicNumber */ public void setAtomicNumber(Integer atomicNumber) { this.atomicNumber = atomicNumber; notifyChanged(); } /** * Returns the element symbol of this element. * * @return The element symbol of this element. Null if unset. * * @see #setSymbol */ public String getSymbol() { return this.symbol; } /** * Sets the element symbol of this element. * * @param symbol The element symbol to be assigned to this atom * * @see #getSymbol */ public void setSymbol(String symbol) { this.symbol = symbol; notifyChanged(); } public String toString() { StringBuffer resultString = new StringBuffer(32); resultString.append("Element(").append(hashCode()); if (getSymbol() != null) { resultString.append(", S:").append(getSymbol()); } if (getID() != null) { resultString.append(", ID:").append(getID()); } if (getAtomicNumber() != null) { resultString.append(", AN:").append(getAtomicNumber()); } resultString.append(')'); return resultString.toString(); } public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Compares an Element with this Element. * * @param object Object of type AtomType * @return true if the atom types are equal */ public boolean compare(Object object) { if (!(object instanceof Element)) { return false; } if (!super.compare(object)) { return false; } Element elem = (Element)object; return atomicNumber == elem.atomicNumber && symbol.equals(elem.symbol); } } cdk-1.2.10/src/main/org/openscience/cdk/EnzymeResidueLocator.java100644 0 0 4555 11570154753 22021 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 Egon Willighagen * * 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 org.openscience.cdk; /** * Atom that represents part of an residue in an enzyme, like Arg255. * * @see PseudoAtom */ public class EnzymeResidueLocator extends PseudoAtom { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = -4267555433142927412L; /** * Constructs an EnzymeResidueLocator from a String containing the locator. * * @param label The String describing the residue and its location. */ public EnzymeResidueLocator(String label) { super(label); } /** * Constructs an EnzymeResidueLocator from an existing Atom. * * @param atom Atom that should be converted into a EnzymeResidueLocator. */ public EnzymeResidueLocator(Atom atom) { super(atom); if (atom instanceof PseudoAtom) { this.setLabel(((PseudoAtom)atom).getLabel()); } } } cdk-1.2.10/src/main/org/openscience/cdk/FragmentAtom.java100644 0 0 5477 11570154753 20275 0ustar 0 0 /* $Revision$ $Author$$Date$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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 org.openscience.cdk; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IFragmentAtom; /** * Class to represent an IPseudoAtom which embeds an IAtomContainer. Very much * like the MDL Molfile Group concept. * * @cdk.module data * @cdk.githash * * @author egonw */ public class FragmentAtom extends PseudoAtom implements IFragmentAtom { private static final long serialVersionUID = -6144605920605752463L; private IAtomContainer fragment; private boolean isExpanded; public FragmentAtom() { fragment = this.getBuilder().newAtomContainer(); isExpanded = false; } public boolean isExpanded() { return isExpanded; } public void setExpanded(boolean bool) { this.isExpanded = bool; } public IAtomContainer getFragment() { return fragment; } public void setFragment(IAtomContainer fragment) { this.fragment = fragment; } public void setExactMass(Double mass) { throw new IllegalAccessError("Cannot set the mass of a IFragmentAtom."); } /** * The exact mass of an FragmentAtom is defined as the sum of exact masses * of the IAtom's in the fragment. */ public Double getExactMass() { double totalMass = 0.0; for (IAtom atom : fragment.atoms()) { totalMass += atom.getExactMass(); } return totalMass; } public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("FragmentAtom{").append(hashCode()); buffer.append(", A=").append(super.toString()); if (fragment != null) { buffer.append(", F=").append(fragment.toString()); } buffer.append('}'); return buffer.toString(); } } cdk-1.2.10/src/main/org/openscience/cdk/IImplementationSpecification.java100644 0 0 4015 11570154753 23473 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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; /** * Interface that is used to describe the specification of a certain * implementation of an algorithm. * * @cdk.module standard * @cdk.githash */ public interface IImplementationSpecification { /** * Pointer to a dictionary or ontology describing a unique * algorithm. * * @return the URN pointing to a (virtual) dictionary or ontology. */ public String getSpecificationReference(); /** * Human-readable name for the implementation for the algorithm * specified by the reference. * * @return the name of this implementation */ public String getImplementationTitle(); /** * Identifier for this implementation which must include * version information. The format is free. * * @return a free format identifier for this implementation */ public String getImplementationIdentifier(); /** * Human-readable name for the vendor that holds copyright for this * implementation. * * @return the copyright holder of the implementation */ public String getImplementationVendor(); } cdk-1.2.10/src/main/org/openscience/cdk/Isotope.java100644 0 0 22111 11570154753 17333 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 Christoph Steinbeck * * 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 I ask is that proper credit is given for my 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; import org.openscience.cdk.interfaces.IElement; import org.openscience.cdk.interfaces.IIsotope; import java.io.Serializable; /** * Used to store and retrieve data of a particular isotope. * For example, an carbon 13 isotope can be created with: *
 *   Isotope carbon = new Isotope("C", 13);
 * 
* *

A full specification can be constructed with: *

 *   // make deuterium
 *   Isotope carbon = new Isotope(1, "H", 2, 2.01410179, 100.0);
 * 
* *

Once instantiated all field not filled by passing parameters * to the constructor are null. Isotopes can be configured by using * the IsotopeFactory.configure() method: *

 *   Isotope isotope = new Isotope("C", 13);
 *   IsotopeFactory if = IsotopeFactory.getInstance(isotope.getBuilder());
 *   if.configure(isotope);
 * 
* * @cdk.module data * @cdk.githash * * @author steinbeck * @cdk.created 2001-08-21 * * @cdk.keyword isotope */ public class Isotope extends Element implements Serializable, IIsotope, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = 6389365978927575858L; /** Exact mass of this isotope. */ public Double exactMass; /** Natural abundance of this isotope. */ public Double naturalAbundance; /** The mass number for this isotope. */ private Integer massNumber; /** * Constructor for the Isotope object. * * @param elementSymbol The element symbol, "O" for Oxygen, etc. */ public Isotope(String elementSymbol) { super(elementSymbol); } /** * Constructor for the Isotope object. * * @param atomicNumber The atomic number of the isotope * @param elementSymbol The element symbol, "O" for Oxygen, etc. * @param massNumber The atomic mass of the isotope, 16 for Oxygen, e.g. * @param exactMass The exact mass of the isotope, be a little more explicit here :-) * @param abundance The natural abundance of the isotope */ public Isotope(int atomicNumber, String elementSymbol, int massNumber, double exactMass, double abundance) { this(atomicNumber, elementSymbol, exactMass, abundance); this.massNumber = massNumber; } /** * Constructor for the Isotope object. * * @param atomicNumber The atomic number of the isotope, 8 for Oxygen * @param elementSymbol The element symbol, "O" for Oxygen, etc. * @param exactMass The exact mass of the isotope, be a little more explicit here :-) * @param abundance The natural abundance of the isotope */ public Isotope(int atomicNumber, String elementSymbol, double exactMass, double abundance) { super(elementSymbol, atomicNumber); this.exactMass = exactMass; this.naturalAbundance = abundance; } /** * Constructor for the Isotope object. * * @param elementSymbol The element symbol, "O" for Oxygen, etc. * @param massNumber The atomic mass of the isotope, 16 for Oxygen, e.g. */ public Isotope(String elementSymbol, int massNumber) { super(elementSymbol); this.massNumber = massNumber; } /** * Constructs an empty by copying the symbol, atomic number, * flags, and identifier from the given IElement. It does * not copy the listeners and properties. If the element is * an instanceof IIsotope, then the exact mass, natural * abundance and mass number are copied too. * * @param element IElement to copy information from */ public Isotope(IElement element) { super(element); if (element instanceof IIsotope) { this.exactMass = ((IIsotope)element).getExactMass(); this.naturalAbundance = ((IIsotope)element).getNaturalAbundance(); this.massNumber = ((IIsotope)element).getMassNumber(); } } /** * Sets the NaturalAbundance attribute of the Isotope object. * * @param naturalAbundance The new NaturalAbundance value * * @see #getNaturalAbundance */ public void setNaturalAbundance(Double naturalAbundance) { this.naturalAbundance = naturalAbundance; notifyChanged(); } /** * Sets the ExactMass attribute of the Isotope object. * * @param exactMass The new ExactMass value * * @see #getExactMass */ public void setExactMass(Double exactMass) { this.exactMass = exactMass; notifyChanged(); } /** * Gets the NaturalAbundance attribute of the Isotope object. * *

Once instantiated all field not filled by passing parameters * to the constructor are null. Isotopes can be configured by using * the IsotopeFactory.configure() method: *

	 *   Isotope isotope = new Isotope("C", 13);
	 *   IsotopeFactory if = IsotopeFactory.getInstance(isotope.getBuilder());
	 *   if.configure(isotope);
	 * 
*

* * @return The NaturalAbundance value * * @see #setNaturalAbundance */ public Double getNaturalAbundance() { return this.naturalAbundance; } /** * Gets the ExactMass attribute of the Isotope object. *

Once instantiated all field not filled by passing parameters * to the constructor are null. Isotopes can be configured by using * the IsotopeFactory.configure() method: *

	 *   Isotope isotope = new Isotope("C", 13);
	 *   IsotopeFactory if = IsotopeFactory.getInstance(isotope.getBuilder());
	 *   if.configure(isotope);
	 * 
*

* * @return The ExactMass value * * @see #setExactMass */ public Double getExactMass() { return this.exactMass; } /** * Returns the atomic mass of this element. * *

Once instantiated all field not filled by passing parameters * to the constructor are null. Isotopes can be configured by using * the IsotopeFactory.configure() method: *

	 *   Isotope isotope = new Isotope("C", 13);
	 *   IsotopeFactory if = IsotopeFactory.getInstance(isotope.getBuilder());
	 *   if.configure(isotope);
	 * 
*

* * @return The atomic mass of this element * * @see #setMassNumber(Integer) */ public Integer getMassNumber() { return this.massNumber; } /** * Sets the atomic mass of this element. * * @param massNumber The atomic mass to be assigned to this element * * @see #getMassNumber */ public void setMassNumber(Integer massNumber) { this.massNumber = massNumber; notifyChanged(); } /** * A string representation of this isotope. * * @return A string representation of this isotope */ public String toString() { StringBuffer resultString = new StringBuffer(32); resultString.append("Isotope(").append(hashCode()); if (massNumber != null) { resultString.append(", MN:").append(massNumber); } if (exactMass != null) { resultString.append(", EM:"); resultString.append(exactMass); } if (naturalAbundance != null) { resultString.append(", AB:"); resultString.append(naturalAbundance); } resultString.append(", ").append(super.toString()); resultString.append(')'); return resultString.toString(); } /** * Compares a atom type with this atom type. * * @param object Object of type AtomType * @return true if the atom types are equal */ public boolean compare(Object object) { if (!(object instanceof Isotope)) { return false; } if (!super.compare(object)) { return false; } Isotope isotope = (Isotope)object; return massNumber == isotope.massNumber && exactMass == isotope.exactMass && naturalAbundance == isotope.naturalAbundance; } public Object clone() throws CloneNotSupportedException { return super.clone(); } } cdk-1.2.10/src/main/org/openscience/cdk/LonePair.java100644 0 0 10063 11570154753 17425 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2002-2007 Egon Willighagen * * 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. * * 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; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.ILonePair; import java.io.Serializable; /** * A LonePair is an orbital primarily located with one Atom, containing * two electrons. * * @cdk.module data * @cdk.githash * * @cdk.keyword orbital * @cdk.keyword lone-pair */ public class LonePair extends ElectronContainer implements Serializable, ILonePair, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = 51311422004885329L; /** Number of electrons in the lone pair. */ protected final int electronCount = 2; /** The atom with which this lone pair is associated. */ protected IAtom atom; /** * Constructs an unconnected lone pair. * */ public LonePair() { this.atom = null; } /** * Constructs an lone pair on an Atom. * * @param atom Atom to which this lone pair is connected */ public LonePair(IAtom atom) { this.atom = atom; } /** * Returns the number of electrons in a LonePair. * * @return The number of electrons in a LonePair. */ public Integer getElectronCount() { return this.electronCount; } /** * Returns the associated Atom. * * @return the associated Atom. * * @see #setAtom */ public IAtom getAtom() { return this.atom; } /** * Sets the associated Atom. * * @param atom the Atom this lone pair will be associated with * * @see #getAtom */ public void setAtom(IAtom atom) { this.atom = atom; notifyChanged(); } /** * Returns true if the given atom participates in this lone pair. * * @param atom The atom to be tested if it participates in this bond * @return true if this lone pair is associated with the atom */ public boolean contains(IAtom atom) { return (this.atom == atom); } /** * Clones this LonePair object, including a clone of the atom for which the * lone pair is defined. * * @return The cloned object */ public Object clone() throws CloneNotSupportedException { LonePair clone = (LonePair) super.clone(); // clone the Atom if (atom != null) { clone.atom = (IAtom)((IAtom)atom).clone(); } return clone; } /** * Returns a one line string representation of this LonePair. * This method is conform RFC #9. * * @return The string representation of this LonePair */ public String toString() { StringBuffer resultString = new StringBuffer(); resultString.append("LonePair("); resultString.append(this.hashCode()); if (atom != null) { resultString.append(", ").append(atom.toString()); } resultString.append(')'); return resultString.toString(); } } cdk-1.2.10/src/main/org/openscience/cdk/Mapping.java100644 0 0 7742 11570154753 17301 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 Egon Willighagen * * 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. * * 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; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IMapping; import java.util.Iterator; /** * A Mapping is an relation between two ChemObjects in a non-chemical * entity. It is not a Bond, nor a Association, merely a relation. * An example of such a mapping, is the mapping between corresponding atoms * in a Reaction. * * @cdk.module data * @cdk.githash * * @cdk.keyword reaction, atom mapping * * @author Egon Willighagen * @cdk.created 2003-08-16 */ public class Mapping extends ChemObject implements java.io.Serializable, Cloneable, IMapping { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = -6541914644492043503L; private IChemObject[] relation; /** * Constructs an unconnected lone pair. * * @param objectOne The first IChemObject of the mapping * @param objectTwo The second IChemObject of the mapping */ public Mapping(IChemObject objectOne, IChemObject objectTwo) { relation = new IChemObject[2]; relation[0] = objectOne; relation[1] = objectTwo; } /** * Returns an Iterable to the two IChemObjects. * Iterable.remove() is not implemented. * * @return An Iterable to two IChemObjects that define the mapping */ public Iterable relatedChemObjects() { return new Iterable(){ public Iterator iterator() { return new ChemObjectIterator(); } }; } /** * The inner Iterator class. * */ private class ChemObjectIterator implements Iterator { private int pointer = 0; public boolean hasNext() { return pointer < 2; } public IChemObject next() { return relation[pointer++]; } public void remove() {} } /** * Retrieves the first or second of the related IChemObjects. * * @param pos The position of the IChemObject. * @return The IChemObject to retrieve. */ public IChemObject getChemObject(int pos) { return relation[pos]; } /** * Clones this Mapping and the mapped IChemObjects. * * @return The cloned object */ public Object clone() throws CloneNotSupportedException { Mapping clone = (Mapping)super.clone(); // clone the related IChemObject's if (relation != null) { clone.relation = new IChemObject[relation.length]; for (int f = 0; f < relation.length; f++) { if (relation[f] != null) { clone.relation[f] = (IChemObject)relation[f].clone(); } } } return clone; } } cdk-1.2.10/src/main/org/openscience/cdk/Molecule.java100644 0 0 6412 11570154753 17444 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 1997-2007 Christoph Steinbeck * * 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. * * 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; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IMolecule; import java.io.Serializable; /** * Represents the concept of a chemical molecule, an object composed of * atoms connected by bonds. * * @cdk.module data * @cdk.githash * * @author steinbeck * @cdk.created 2000-10-02 * * @cdk.keyword molecule */ public class Molecule extends AtomContainer implements Serializable, IMolecule, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = 6451193093484831136L; /** * Creates an Molecule without Atoms and Bonds. */ public Molecule() { super(); } /** * Constructor for the Molecule object. The parameters define the * initial capacity of the arrays. * * @param atomCount init capacity of Atom array * @param bondCount init capacity of Bond array * @param lonePairCount number of lone pairs * @param singleElectronCount number of single electrons */ public Molecule(int atomCount, int bondCount, int lonePairCount, int singleElectronCount) { super(atomCount, bondCount, lonePairCount, singleElectronCount); } /** * Constructs a Molecule with * a shallow copy of the atoms and bonds of an AtomContainer. * * @param container An Molecule to copy the atoms and bonds from */ public Molecule(IAtomContainer container) { super(container); } /** * Returns a one line string representation of this Atom. * Methods is conform RFC #9. * * @return The string representation of this Atom */ public String toString() { StringBuffer description = new StringBuffer(); description.append("Molecule("); description.append(hashCode()); if (getID() != null) { description.append(", ID=").append(getID()); } description.append(", ").append(super.toString()); description.append(')'); return description.toString(); } public Object clone() throws CloneNotSupportedException { return super.clone(); } } cdk-1.2.10/src/main/org/openscience/cdk/MoleculeSet.java100644 0 0 13336 11570154753 20143 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 Christoph Steinbeck * * 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. * * 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; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; /** * A set of molecules, for example those taking part in a reaction. * * To retrieve the molecules from the set, there are two options: * *
 * Molecule[] mols = setOfMolecules.getMolecules();
 * for (int i=0; i < mols.length; i++) {
 *     Molecule mol = mols[i];
 * }
 * 
* * and * *
 * for (int i=0; i < setOfMolecules.getMoleculeCount(); i++) {
 *    Molecule mol = setOfMolecules.getMolecule(i);
 * }
 * 
* * @cdk.module data * @cdk.githash * * @cdk.keyword reaction * @cdk.keyword molecule */ public class MoleculeSet extends AtomContainerSet implements IMoleculeSet, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. * */ private static final long serialVersionUID = -861287315770869699L; public MoleculeSet() {} /** * Adds an atomContainer to this container. * * @param atomContainer The IMolecule to be added to this container * @throws IllegalArgumentException when the passed IAtomContainer is not * an IMolecule. */ public void addAtomContainer(IAtomContainer atomContainer) { if (!(atomContainer instanceof IMolecule)) throw new IllegalArgumentException( "Only IMolecule's can be stored in an IMoleculeSet" ); super.addAtomContainer(atomContainer); } /** * Adds an atomContainer to this container with the given * multiplier. * * @param atomContainer The atomContainer to be added to this container * @param multiplier The multiplier of this atomContainer * @throws IllegalArgumentException when the passed IAtomContainer is not * an IMolecule. */ public void addAtomContainer(IAtomContainer atomContainer, double multiplier) { if (!(atomContainer instanceof IMolecule)) throw new IllegalArgumentException( "Only IMolecule's can be stored in an IMoleculeSet" ); super.addAtomContainer(atomContainer, multiplier); } /** * Adds an molecule to this container. * * @param molecule The molecule to be added to this container */ public void addMolecule(IMolecule molecule) { super.addAtomContainer(molecule); /* notifyChanged() called in super.addAtomContainer() */ } /** * Adds all molecules in the MoleculeSet to this container. * * @param moleculeSet The MoleculeSet */ public void add(IMoleculeSet moleculeSet) { for (IAtomContainer mol : moleculeSet.molecules()) { addAtomContainer(mol); } } public void setMolecules(IMolecule[] molecules) { if (atomContainerCount > 0) removeAllAtomContainers(); for (IMolecule molecule : molecules) { addMolecule(molecule); } } /** * Returns the array of Molecules of this container. * * @return The array of Molecules of this container * @see #setMolecules */ public Iterable molecules() { return super.atomContainers(); } /** * * Returns the Molecule at position number in the * container. * * @param number The position of the Molecule to be returned. * @return The Molecule at position number . */ public IMolecule getMolecule(int number) { return (IMolecule)super.getAtomContainer(number); } /** * Returns the number of Molecules in this Container. * * @return The number of Molecules in this Container */ public int getMoleculeCount() { return super.getAtomContainerCount(); } /** * Clones this MoleculeSet and its content. * *@return the cloned object */ public Object clone() throws CloneNotSupportedException { return (MoleculeSet)super.clone(); } public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("MoleculeSet("); buffer.append(super.toString()); buffer.append(')'); return buffer.toString(); } /** * Called by objects to which this object has * registered as a listener. * *@param event A change event pointing to the source of the change */ public void stateChanged(IChemObjectChangeEvent event) { notifyChanged(event); } } cdk-1.2.10/src/main/org/openscience/cdk/Monomer.java100644 0 0 6766 11570154753 17327 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2001-2007 Edgar Luttmann * * 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 org.openscience.cdk; import java.io.Serializable; import org.openscience.cdk.interfaces.IMonomer; /** * A Monomer is an AtomContainer which stores additional monomer specific * informations for a group of Atoms. * * @cdk.module data * @cdk.githash * * @author Edgar Luttmann * @cdk.created 2001-08-06 * * @cdk.keyword monomer * */ public class Monomer extends AtomContainer implements Serializable, IMonomer, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = -6084164963937650703L; /** The name of this monomer (e.g. Trp42). */ private String monomerName; /** The type of this monomer (e.g. TRP). */ private String monomerType; /** * * Constructs a new Monomer. * */ public Monomer () { super(); } /** * * Retrieves the monomer name. * * @return The name of the Monomer object * * @see #setMonomerName */ public String getMonomerName() { return monomerName; } /** * * Retrieves the monomer type. * * @return The type of the Monomer object * * @see #setMonomerType */ public String getMonomerType() { return monomerType; } /** * * Sets the name of the Monomer object. * * @param cMonomerName The new name for this monomer * * @see #getMonomerName */ public void setMonomerName(String cMonomerName) { monomerName = cMonomerName; notifyChanged(); } /** * * Sets the type of the Monomer object. * * @param cMonomerType The new type for this monomer * * @see #getMonomerType */ public void setMonomerType(String cMonomerType) { monomerType = cMonomerType; notifyChanged(); } public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("Monomer{").append(this.hashCode()); if (getMonomerName() != null) { buffer.append(", N=").append(getMonomerName()); } if (getMonomerType() != null) { buffer.append(", T=").append(getMonomerType()); } buffer.append("}"); return buffer.toString(); } } cdk-1.2.10/src/main/org/openscience/cdk/PeriodicTableElement.java100644 0 0 25150 11570154753 21737 0ustar 0 0 /* * $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2005-2007 Miguel Rojasch * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.tools.LoggingTool; /** *

An PeriodicTableElement class is instantiated with at least the atom symbol: *

 *   PeriodicTableElement pte = new PeriodicTableElement("C");
 * 
* *

This class is not the same than IElement class. Once instantiated all field not filled by passing parameters * to the constructor are null. PeriodicTableElement can be configured by using * the PeriodicTableElement.configure() method: *

 *   ElementPTFactory eptf = ElementPTFactory.getInstance(a.getBuilder());
 *   ElementPTFactory.configure(pte);
 * 
* *

More examples about using this class can be found in the * Junit test for this class. * * @author Miguel Rojas * @cdk.created May 8, 2005 * @cdk.keyword element * @cdk.module extra * @cdk.githash */ @TestClass("org.openscience.cdk.PeriodicTableElementTest") public class PeriodicTableElement extends Element { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = -2508810950266128526L; private static LoggingTool logger; /** The name for this element. */ protected String name; /** The chemical series for this element. * A chemical series is a group of chemical elements whose physical and * chemical characteristics vary progressively from one end of the series * to another. * Chemical series were discovered before the creation of the periodic * table of the chemical elements, which was created to try to organize * the elements according to their chemical properties. */ protected String chemicalSerie; /** The period which this element belong. * In the periodic table of the elements, a period is a row of the table. */ protected Integer period = (Integer) CDKConstants.UNSET; /** The group which this element belong. * In the periodic table of the elements, a period is a row of the table. * the elements in a same group have similar configurations of the outermost * electron shells of their atoms */ protected Integer group = (Integer) CDKConstants.UNSET; /** The phase which this element find. * In the physical sciences, a phase is a set of states of a macroscopic * physical system that have relatively uniform chemical composition * and physical properties. * Most familiar examples of phases are solids, liquids, and gases */ protected String phase; /** * The CAS (Chemical Abstracts Service) number which this element has. */ protected String casId; /** * The Van der Waals radius of the element. */ protected Double vdwRadius = (Double) CDKConstants.UNSET; /** * The covalent radius of the element. */ protected Double covalentRadius = (Double) CDKConstants.UNSET; /** * The Pauling electronegativity of the element. */ protected Double paulingEneg = (Double) CDKConstants.UNSET; /** * Constructor for the PeriodicTableElement object. * * @param symbol The symbol of the element */ @TestMethod("testConstructor") public PeriodicTableElement(String symbol) { this.symbol = symbol; logger = new LoggingTool(this); } /** * Returns the name of this element. * * @return The name of this element. Null if unset. * * @see #setName */ @TestMethod("testGetName") public String getName() { return this.name; } /** * Sets the name of this element. * * @param name The name to be assigned to this element * * @see #getName */ @TestMethod("testSetName") public void setName(String name) { this.name=name; notifyChanged(); } /** * Returns the chemical series of this element. * * @return The chemical series of this element. Null if unset. * * @see #setChemicalSerie */ @TestMethod("testGetSeries") public String getChemicalSerie() { return this.chemicalSerie; } /** * Sets the chemical series of this element. * * @param chemicalSerie The chemical series to be assigned to this element * * @see #getChemicalSerie */ @TestMethod("testSetSeries") public void setChemicalSerie(String chemicalSerie) { this.chemicalSerie = chemicalSerie; notifyChanged(); } /** * Returns the period which this element belongs. * * @return The period of this element. Null if unset. * * @see #setPeriod */ @TestMethod("testGetPeriod") public Integer getPeriod() { return this.period; } /** * Sets the chemical series of this element. * * @param period The period to be assigned to this element * * @see #getPeriod */ @TestMethod("testSetPeriod") public void setPeriod(Integer period) { this.period = period; notifyChanged(); } /** * Returns the Group which this element belongs. * * @return The group of this element. Null if unset. * * @see #setGroup */ @TestMethod("testGetGroup") public Integer getGroup() { return this.group; } /** * Sets the group, which this element belongs. * * @param group The group to be assigned to this atom * @throws org.openscience.cdk.exception.CDKException * if an invalid IUPAC group number is specified. * @see #getGroup */ @TestMethod("testSetGroup") public void setGroup(Integer group) throws CDKException { if (group < 1 || group > 18) throw new CDKException("Invalid group number specified. Must be between 1 and 18"); this.group = group; notifyChanged(); } /** * Returns the phase which this element find. * * @return The phase of this element. Null if unset. * * @see #setPhase */ @TestMethod("testGetPhase") public String getPhase() { return this.phase; } /** * Sets the phase, which this element finds. * * @param phase The phase to be assigned to this element * * @see #getGroup * @see #getPhase */ @TestMethod("testSetPhase") public void setPhase(String phase) { this.phase = phase; notifyChanged(); } /** * Returns the CAS (Chemical Abstracts Service), which this element has. * * @return The CAS of this element. Null if unset. * * @see #setCASid */ @TestMethod("testGetCASid") public String getCASid() { return this.casId; } /** * Sets the CAS (Chemical Abstracts Service), which this element has. * * @param casId The CAS number to be assigned to this element * * @see #getCASid */ @TestMethod("testSetCASid") public void setCASid(String casId) { this.casId = casId; notifyChanged(); } /** * Get the VdW radius for this element. * * @return The VdW radius, or null if it is unavailable */ @TestMethod("testGetVdw") public Double getVdwRadius() { return vdwRadius; } /** * Set the VdW radius of this element. * * @param vdwRadius The VdW radius */ @TestMethod("testSetVdw") public void setVdwRadius(Double vdwRadius) { this.vdwRadius = vdwRadius; } /** * Get the covalent radius. * * @return the covalent radius, or null if it is unavailable */ @TestMethod("testGetCovalentRadius") public Double getCovalentRadius() { return covalentRadius; } /** * Set the covalent radius. * * @param covalentRadius the covalent radius */ @TestMethod("testSetCovalentRadius") public void setCovalentRadius(Double covalentRadius) { this.covalentRadius = covalentRadius; } /** * Get the Pauling electronegativity of this element. * * @return The electronegativity, null if not available for the element */ @TestMethod("testGetEneg") public Double getPaulingEneg() { return paulingEneg; } /** * Set the Pauling electronegativity for this element. * * @param paulingEneg The electronegativity */ @TestMethod("testSetEneg") public void setPaulingEneg(Double paulingEneg) { this.paulingEneg = paulingEneg; } /** * Clones this element object. * * @return The cloned object */ @TestMethod("testClone") public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.debug(exception); } return clone; } /** * *@return resultString String */ @TestMethod("testString") public String toString() { StringBuffer resultString = new StringBuffer(); resultString.append("PeriodicTableElement("); resultString.append(getSymbol()); resultString.append(", AN:"); resultString.append(getAtomicNumber()); resultString.append(", N:"); resultString.append(getName()); resultString.append(", CS:"); resultString.append(getChemicalSerie()); resultString.append(", P:"); resultString.append(getPeriod()); resultString.append(", G:"); resultString.append(getGroup()); resultString.append(", Ph:"); resultString.append(getPhase()); resultString.append(", CAS:"); resultString.append(getCASid()); resultString.append(", VdW:"); resultString.append(getVdwRadius()); resultString.append(", Cov:"); resultString.append(getCovalentRadius()); resultString.append(", Eneg:"); resultString.append(getPaulingEneg()); resultString.append(')'); return resultString.toString(); } } cdk-1.2.10/src/main/org/openscience/cdk/PhysicalConstants.java100644 0 0 2672 11570154753 21354 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2002-2007 Egon Willighagen * * 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. * * 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; /** * An class providing predefined properties of physical constants. * * @cdk.keyword physical properties * @cdk.githash */ public class PhysicalConstants { /** * Mass of a proton. */ public final static double MASS_PROTON = 1.6726485E-27; /** * Mass of an electron. */ public final static double MASS_ELECTRON = 9.109534E-31; /** * Factor for the conversion of Bohr's to Angstrom's. */ public static final double BOHR_TO_ANGSTROM = 0.529177249; } cdk-1.2.10/src/main/org/openscience/cdk/Polymer.java100644 0 0 15462 11570154753 17353 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2001-2007 Edgar Luttmann * * 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 org.openscience.cdk; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.ILonePair; import org.openscience.cdk.interfaces.IMonomer; import org.openscience.cdk.interfaces.IPolymer; import org.openscience.cdk.interfaces.ISingleElectron; import java.util.Collection; import java.util.Hashtable; import java.util.Map; /** * Subclass of Molecule to store Polymer specific attributes that a Polymer has. * * @cdk.module data * @cdk.githash * * @author Edgar Luttmann * @author Martin Eklund * @cdk.created 2001-08-06 * @cdk.keyword polymer */ public class Polymer extends Molecule implements java.io.Serializable, IPolymer { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = -2596790658835319339L; private Map monomers; // the list of all the contained Monomers. /** * Constructs a new Polymer to store the Monomers. */ public Polymer() { super(); monomers = new Hashtable(); } /** * Adds the atom oAtom to a specified Monomer. * * @param oAtom The atom to add * @param oMonomer The monomer the atom belongs to */ public void addAtom(IAtom oAtom, IMonomer oMonomer) { if(!contains(oAtom)) { super.addAtom(oAtom); if(oMonomer != null) { // Not sure what's better here...throw nullpointer exception? oMonomer.addAtom(oAtom); if (! monomers.containsKey(oMonomer.getMonomerName())) { monomers.put(oMonomer.getMonomerName(), oMonomer); } } } /* notifyChanged() is called by addAtom in AtomContainer */ } /** * Returns the number of monomers present in the Polymer. * * @return number of monomers */ public int getMonomerCount() { return monomers.size(); } /** * Retrieves a Monomer object by specifying its name. * * @param cName The name of the monomer to look for * @return The Monomer object which was asked for */ public IMonomer getMonomer(String cName) { return monomers.get(cName); } /** * Returns a collection of the names of all Monomers in this * polymer. * * @return a Collection of all the monomer names. */ public Collection getMonomerNames() { return monomers.keySet(); } /** * Removes a particular monomer, specified by its name. * * @param name The name of the monomer to remove */ public void removeMonomer(String name) { if (monomers.containsKey(name)) { Monomer monomer = (Monomer)monomers.get(name); this.remove(monomer); monomers.remove(name); } } public String toString() { StringBuffer stringContent = new StringBuffer(); stringContent.append("Polymer("); stringContent.append(this.hashCode()).append(", "); stringContent.append(super.toString()); stringContent.append(')'); return stringContent.toString(); } /* TODO it's not clear why we need to remove all elements after the clone Looks like we should only clone the monomer related stuff */ public Object clone() throws CloneNotSupportedException { Polymer clone = (Polymer)super.clone(); clone.removeAllElements(); clone.monomers = new Hashtable(); for (String monomerName : getMonomerNames()) { Monomer monomerClone = (Monomer) getMonomer(monomerName).clone(); for (IAtom atomInMonomer : monomerClone.atoms()) { clone.addAtom(atomInMonomer, monomerClone); } } // now consider atoms that are not associated with any monomer for (IAtom atom : atoms()) { if (!atomIsInMonomer(atom)) clone.addAtom((IAtom) atom.clone()); } // since we already removed bonds we'll have to add them back IBond newBond; for (IBond bond : bonds()) { newBond = (IBond)bond.clone(); IAtom[] newAtoms = new IAtom[bond.getAtomCount()]; for (int j = 0; j < bond.getAtomCount(); ++j) { newAtoms[j] = clone.getAtom(getAtomNumber(bond.getAtom(j))); } newBond.setAtoms(newAtoms); clone.addBond(newBond); } // put back lone pairs ILonePair lp; ILonePair newLp; for (int i = 0; i < getLonePairCount(); ++i) { lp = getLonePair(i); newLp = (ILonePair) lp.clone(); if (lp.getAtom() != null) { newLp.setAtom(clone.getAtom(getAtomNumber(lp.getAtom()))); } clone.addLonePair(newLp); } // put back single electrons ISingleElectron singleElectron; ISingleElectron newSingleElectron; for (int i = 0; i < getSingleElectronCount(); ++i) { singleElectron = getSingleElectron(i); newSingleElectron = (ISingleElectron) singleElectron.clone(); if (singleElectron.getAtom() != null) { newSingleElectron.setAtom(clone.getAtom(getAtomNumber(singleElectron.getAtom()))); } clone.addSingleElectron(newSingleElectron); } return clone; } private boolean atomIsInMonomer(IAtom atom) { for (String monomerName : getMonomerNames()) { IMonomer monomer = getMonomer(monomerName); if (monomer.contains(atom)) return true; } return false; } } cdk-1.2.10/src/main/org/openscience/cdk/PseudoAtom.java100644 0 0 11602 11570154753 17774 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 Egon Willighagen * * 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 org.openscience.cdk; import org.openscience.cdk.interfaces.IElement; import org.openscience.cdk.interfaces.IPseudoAtom; /** * Represents the idea of a non-chemical atom-like entity, like Me, * R, X, Phe, His, etc. * *

This should be replaced by the mechanism explained in RFC #8. * * @cdk.module data * @cdk.githash * * @see Atom */ public class PseudoAtom extends Atom implements java.io.Serializable, Cloneable, IPseudoAtom { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = 1L; private String label; /** * Constructs an empty PseudoAtom. */ public PseudoAtom() { this("*"); } /** * Constructs an Atom from a String containing an element symbol. * * @param label The String describing the PseudoAtom */ public PseudoAtom(String label) { super("R"); this.label = label; super.fractionalPoint3d = null; super.point3d = null; super.point2d = null; // set these default, unchangeable values super.stereoParity = 0; } /** * Constructs an PseudoAtom from a IAtom. * * @param element IAtom from which the PseudoAtom is constructed */ public PseudoAtom(IElement element) { super(element); if (element instanceof IPseudoAtom) { this.label = ((IPseudoAtom)element).getLabel(); } else { super.symbol = "R"; this.label = element.getSymbol(); } } /** * Constructs an Atom from an Element and a Point3d. * * @param label The String describing the PseudoAtom * @param point3d The 3D coordinates of the atom */ public PseudoAtom(String label, javax.vecmath.Point3d point3d) { this(label); this.point3d = point3d; } /** * Constructs an Atom from an Element and a Point2d. * * @param label The String describing the PseudoAtom * @param point2d The Point */ public PseudoAtom(String label, javax.vecmath.Point2d point2d) { this(label); this.point2d = point2d; } /** * Returns the label of this PseudoAtom. * * @return The label for this PseudoAtom * @see #setLabel */ public String getLabel() { return label; } /** * Sets the label of this PseudoAtom. * * @param label The new label for this PseudoAtom * @see #getLabel */ public void setLabel(String label) { this.label = label; notifyChanged(); } /** * Dummy method: the stereo parity is undefined, final. */ public void setStereoParity(Integer stereoParity) { // this is undefined, always } /** * Returns a one line string representation of this Atom. * Methods is conform RFC #9. * * @return The string representation of this Atom */ public String toString() { StringBuffer description = new StringBuffer(); description.append("PseudoAtom("); description.append(this.hashCode()); if (getLabel() != null) { description.append(", ").append(getLabel()); } description.append(", ").append(super.toString()); description.append(')'); return description.toString(); } public Object clone() throws CloneNotSupportedException { return super.clone(); } } cdk-1.2.10/src/main/org/openscience/cdk/Reaction.java100644 0 0 35103 11570154753 17462 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2003-2008 Egon Willighagen * * 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 org.openscience.cdk; import org.openscience.cdk.interfaces.*; import java.io.Serializable; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; /** * Represents the idea of a chemical reaction. The reaction consists of * a set of reactants and a set of products. * *

The class mostly represents abstract reactions, such as 2D diagrams, * and is not intended to represent reaction trajectories. Such can better * be represented with a ChemSequence. * * @cdk.module data * @cdk.githash * * @author Egon Willighagen * @cdk.created 2003-02-13 * @cdk.keyword reaction */ public class Reaction extends ChemObject implements Serializable, IReaction, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = -554752558363533678L; protected int growArraySize = 3; protected IMoleculeSet reactants; protected IMoleculeSet products; /** These are the used solvent, catalysts etc that normally appear above the reaction arrow */ protected IMoleculeSet agents; protected IMapping[] map; protected int mappingCount; private IReaction.Direction reactionDirection; /** * Constructs an empty, forward reaction. */ public Reaction() { this.reactants = new MoleculeSet(); this.products = new MoleculeSet(); this.agents = new MoleculeSet(); this.map = new Mapping[growArraySize]; mappingCount = 0; reactionDirection = IReaction.Direction.FORWARD; } /** * Returns the number of reactants in this reaction. * * @return The number of reactants in this reaction */ public int getReactantCount() { return reactants.getAtomContainerCount(); } /** * Returns the number of products in this reaction. * * @return The number of products in this reaction */ public int getProductCount() { return products.getAtomContainerCount(); } /** * Returns a MoleculeSet containing the reactants in this reaction. * * @return A MoleculeSet containing the reactants in this reaction * @see #setReactants */ public IMoleculeSet getReactants() { return reactants; } /** * Assigns a MoleculeSet to the reactants in this reaction. * * @param setOfMolecules The new set of reactants * @see #getReactants */ public void setReactants(IMoleculeSet setOfMolecules) { reactants = setOfMolecules; notifyChanged(); } /** * Returns a MoleculeSet containing the products of this reaction. * * @return A MoleculeSet containing the products in this reaction * @see #setProducts */ public IMoleculeSet getProducts() { return products; } /** * Assigns a MoleculeSet to the products of this reaction. * * @param setOfMolecules The new set of products * @see #getProducts */ public void setProducts(IMoleculeSet setOfMolecules) { products = setOfMolecules; notifyChanged(); } /** * Returns a MoleculeSet containing the agents in this reaction. * * @return A MoleculeSet containing the agents in this reaction * @see #addAgent */ public IMoleculeSet getAgents() { return agents; } /** * Returns the mappings between the reactant and the product side. * * @return An Iterator to the Mappings. * @see #addMapping */ public Iterable mappings() { return new Iterable() { public Iterator iterator() { return new MappingIterator(); } }; } /** * The inner Mapping Iterator class. * */ private class MappingIterator implements Iterator { private int pointer = 0; public boolean hasNext() { return pointer < mappingCount; } public IMapping next() { return map[pointer++]; } public void remove() { removeMapping(--pointer); } } /** * Adds a reactant to this reaction. * * @param reactant Molecule added as reactant to this reaction * @see #getReactants */ public void addReactant(IMolecule reactant) { addReactant(reactant, 1.0); /* notifyChanged() is called by addReactant(Molecule reactant, double coefficient) */ } /** * Adds an agent to this reaction. * * @param agent Molecule added as agent to this reaction * @see #getAgents */ public void addAgent(IMolecule agent) { agents.addAtomContainer(agent); notifyChanged(); } /** * Adds a reactant to this reaction with a stoichiometry coefficient. * * @param reactant Molecule added as reactant to this reaction * @param coefficient Stoichiometry coefficient for this molecule * @see #getReactants */ public void addReactant(IMolecule reactant, Double coefficient) { reactants.addAtomContainer(reactant, coefficient); notifyChanged(); } /** * Adds a product to this reaction. * * @param product Molecule added as product to this reaction * @see #getProducts */ public void addProduct(IMolecule product) { this.addProduct(product, 1.0); /* notifyChanged() is called by addProduct(Molecule product, double coefficient)*/ } /** * Adds a product to this reaction. * * @param product Molecule added as product to this reaction * @param coefficient Stoichiometry coefficient for this molecule * @see #getProducts */ public void addProduct(IMolecule product, Double coefficient) { products.addAtomContainer(product, coefficient); /* notifyChanged() is called by addReactant(Molecule reactant, double coefficient) */ } /** * Returns the stoichiometry coefficient of the given reactant. * * @param reactant Reactant for which the coefficient is returned. * @return -1, if the given molecule is not a product in this Reaction * @see #setReactantCoefficient */ public Double getReactantCoefficient(IMolecule reactant) { return reactants.getMultiplier(reactant); } /** * Returns the stoichiometry coefficient of the given product. * * @param product Product for which the coefficient is returned. * @return -1, if the given molecule is not a product in this Reaction * @see #setProductCoefficient */ public Double getProductCoefficient(IMolecule product) { return products.getMultiplier(product); } /** * Sets the coefficient of a a reactant to a given value. * * @param reactant Reactant for which the coefficient is set * @param coefficient The new coefficient for the given reactant * @return true if Molecule has been found and stoichiometry has been set. * @see #getReactantCoefficient */ public boolean setReactantCoefficient(IMolecule reactant, Double coefficient) { boolean result = reactants.setMultiplier(reactant, coefficient); notifyChanged(); return result; } /** * Sets the coefficient of a a product to a given value. * * @param product Product for which the coefficient is set * @param coefficient The new coefficient for the given product * @return true if Molecule has been found and stoichiometry has been set. * @see #getProductCoefficient */ public boolean setProductCoefficient(IMolecule product, Double coefficient) { boolean result = products.setMultiplier(product, coefficient); notifyChanged(); return result; } /** * Returns an array of double with the stoichiometric coefficients * of the reactants. * * @return An array of double's containing the coefficients of the reactants * @see #setReactantCoefficients */ public Double[] getReactantCoefficients() { return reactants.getMultipliers(); } /** * Returns an array of double with the stoichiometric coefficients * of the products. * * @return An array of double's containing the coefficients of the products * @see #setProductCoefficients */ public Double[] getProductCoefficients() { return products.getMultipliers(); } /** * Sets the coefficients of the reactants. * * @param coefficients An array of double's containing the coefficients of the reactants * @return true if coefficients have been set. * @see #getReactantCoefficients */ public boolean setReactantCoefficients(Double[] coefficients) { boolean result = reactants.setMultipliers(coefficients); notifyChanged(); return result; } /** * Sets the coefficient of the products. * * @param coefficients An array of double's containing the coefficients of the products * @return true if coefficients have been set. * @see #getProductCoefficients */ public boolean setProductCoefficients(Double[] coefficients) { boolean result = products.setMultipliers(coefficients); notifyChanged(); return result; } /** * Sets the direction of the reaction. * * @param direction The new reaction direction * @see #getDirection */ public void setDirection(IReaction.Direction direction) { reactionDirection = direction; notifyChanged(); } /** * Returns the direction of the reaction. * * @return The direction of this reaction (FORWARD, BACKWARD or BIDIRECTIONAL). * @see org.openscience.cdk.interfaces.IReaction.Direction * @see #setDirection */ public IReaction.Direction getDirection() { return reactionDirection; } /** * Adds a mapping between the reactant and product side to this * Reaction. * * @param mapping Mapping to add. * @see #mappings */ public void addMapping(IMapping mapping) { if (mappingCount + 1 >= map.length) growMappingArray(); map[mappingCount] = mapping; mappingCount++; notifyChanged(); } /** * Removes a mapping between the reactant and product side to this * Reaction. * * @param pos Position of the Mapping to remove. * @see #mappings */ public void removeMapping(int pos) { for (int i = pos; i < mappingCount - 1; i++) { map[i] = map[i + 1]; } map[mappingCount - 1] = null; mappingCount--; notifyChanged(); } /** * Retrieves a mapping between the reactant and product side to this * Reaction. * * @param pos Position of Mapping to get. */ public IMapping getMapping(int pos) { return map[pos]; } /** * Get the number of mappings between the reactant and product side to this * Reaction. * * @return Number of stored Mappings. */ public int getMappingCount() { return mappingCount; } private void growMappingArray() { Mapping[] newMap = new Mapping[map.length + growArraySize]; System.arraycopy(map, 0, newMap, 0, map.length); map = newMap; } /** * Returns a one line string representation of this Atom. * Methods is conform RFC #9. * * @return The string representation of this Atom */ public String toString() { StringBuffer description = new StringBuffer(64); description.append("Reaction("); description.append(getID()); description.append(", #M:").append(mappingCount); description.append(", reactants=").append(reactants.toString()); description.append(", products=").append(products.toString()); description.append(", agents=").append(agents.toString()); description.append(')'); return description.toString(); } /** * Clones this Reaction and its content. * * @return The cloned object */ public Object clone() throws CloneNotSupportedException { Reaction clone = (Reaction)super.clone(); // clone the reactants, products and agents clone.reactants = (MoleculeSet)((MoleculeSet)reactants).clone(); clone.agents = (MoleculeSet)((MoleculeSet)agents).clone(); clone.products = (MoleculeSet)((MoleculeSet)products).clone(); // create a Map of corresponding atoms for molecules (key: original Atom, // value: clone Atom) Map atomatom = new Hashtable(); for (int i = 0; i < reactants.getMoleculeCount(); ++i) { Molecule mol = (Molecule)((MoleculeSet)reactants).getMolecule(i); Molecule mol2 = (Molecule)clone.reactants.getMolecule(i); for (int j = 0; j < mol.getAtomCount(); ++j) atomatom.put(mol.getAtom(j), mol2.getAtom(j)); } // clone the maps clone.map = new Mapping[map.length]; for (int f = 0; f < mappingCount; f++) { clone.map[f] = new Mapping((ChemObject)atomatom.get(map[f].getChemObject(0)), (ChemObject)atomatom.get(map[f].getChemObject(1))); } return clone; } } cdk-1.2.10/src/main/org/openscience/cdk/ReactionScheme.java100644 0 0 7562 11570154753 20577 0ustar 0 0 /* * $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Miguel Rojas * * 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. * * 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; import java.util.ArrayList; import java.util.List; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IReaction; import org.openscience.cdk.interfaces.IReactionScheme; /** * Classes that extends the definition of reaction to a scheme. * This is designed to contain a set of reactions which are linked in * some way but without hard coded semantics. * * @author miguelrojasch * @cdk.module data * @cdk.keyword reaction */ public class ReactionScheme extends ReactionSet implements IReactionScheme{ /** A List of reaction schemes*/ private List reactionScheme; /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = -3676327644698347260L; /** Constructs an empty ReactionScheme. */ public ReactionScheme() { reactionScheme = new ArrayList(); } /** * Add a Scheme of Reactions. * * @param scheme The IReactionScheme to include */ @TestMethod("testAdd_IReactionScheme") public void add(IReactionScheme scheme) { reactionScheme.add(scheme); } /** * Returns an Iterable for looping over all IMolecularScheme * in this ReactionScheme. * * @return An Iterable with the IMolecularScheme in this ReactionScheme */ @TestMethod("testReactionSchemes") public Iterable reactionSchemes() { return reactionScheme; } /** * Returns the number of ReactionScheme in this Scheme. * * @return The number of ReactionScheme in this Scheme */ @TestMethod("testGetReactionSchemeCount") public int getReactionSchemeCount(){ return reactionScheme.size(); } /** * Removes all IReactionScheme from this chemObject. */ @TestMethod("testRemoveAllReactionSchemes") public void removeAllReactionSchemes() { reactionScheme.clear(); } /** * Removes an IReactionScheme from this chemObject. * * @param scheme The IReactionScheme to be removed from this chemObject */ @TestMethod("testRemoveReactionScheme_IReactionScheme") public void removeReactionScheme(IReactionScheme scheme) { reactionScheme.remove(scheme); } /** * Clones this ReactionScheme object and its content. * * @return The cloned object */ @TestMethod("testClone") public Object clone() throws CloneNotSupportedException { IReactionScheme clone = new ReactionScheme(); for (IReactionScheme scheme : this.reactionSchemes()){ clone.add((IReactionScheme) scheme.clone()); } for (IReaction reaction : reactions()) { clone.addReaction((IReaction)reaction.clone()); } return clone; } } cdk-1.2.10/src/main/org/openscience/cdk/ReactionSet.java100644 0 0 14652 11570154753 20144 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 Egon Willighagen * * 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. * * 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; import java.io.Serializable; import java.util.Iterator; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IReaction; import org.openscience.cdk.interfaces.IReactionSet; /** * A set of reactions, for example those taking part in a reaction. * * To retrieve the reactions from the set, there are two options: * *

 * Iterator reactions = reactionSet.reactions();
 * while (reactions.hasNext()) {
 *     IReaction reaction = (IReaction)reactions.next();
 * }
 * 
* * and * *
 * for (int i=0; i < reactionSet.getReactionCount(); i++) {
 *    IReaction reaction = reactionSet.getReaction(i);
 * }
 * 
* * @cdk.module data * @cdk.githash * * @cdk.keyword reaction */ public class ReactionSet extends ChemObject implements Serializable, IReactionSet, IChemObjectListener, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = 1555749911904585204L; /** * Array of Reactions. */ private IReaction[] reactions; /** * Number of Reactions contained by this container. */ private int reactionCount; /** * Amount by which the Reactions array grows when elements are added and * the array is not large enough for that. */ private int growArraySize = 5; /** * Constructs an empty ReactionSet. */ public ReactionSet() { reactionCount = 0; reactions = new Reaction[growArraySize]; } /** * Adds an reaction to this container. * * @param reaction The reaction to be added to this container */ public void addReaction(IReaction reaction) { if (reactionCount + 1 >= reactions.length) growReactionArray(); reactions[reactionCount] = reaction; reactionCount++; notifyChanged(); } /** * Remove a reaction from this set. * * @param pos The position of the reaction to be removed. */ public void removeReaction(int pos) { reactions[pos].removeListener(this); for (int i = pos; i < reactionCount - 1; i++) { reactions[i] = reactions[i + 1]; } reactions[reactionCount - 1] = null; reactionCount--; notifyChanged(); } /** * * Returns the Reaction at position number in the * container. * * @param number The position of the Reaction to be returned * @return The Reaction at position number */ public IReaction getReaction(int number) { return (Reaction)reactions[number]; } /** * Get an iterator for this reaction set. * * @return A new Iterator for this ReactionSet. */ public Iterable reactions() { return new Iterable() { public Iterator iterator() { return new ReactionIterator(); } }; } /** * The inner Iterator class. * */ private class ReactionIterator implements Iterator { private int pointer = 0; public boolean hasNext() { if (pointer < reactionCount) return true; return false; } public IReaction next() { return reactions[pointer++]; } public void remove() { removeReaction(--pointer); } } /** * Grows the reaction array by a given size. * * @see growArraySize */ private void growReactionArray() { growArraySize = reactions.length; Reaction[] newreactions = new Reaction[reactions.length + growArraySize]; System.arraycopy(reactions, 0, newreactions, 0, reactions.length); reactions = newreactions; } /** * Returns the number of Reactions in this Container. * * @return The number of Reactions in this Container */ public int getReactionCount() { return this.reactionCount; } public String toString() { StringBuffer buffer = new StringBuffer(32); buffer.append("ReactionSet("); buffer.append(this.hashCode()); buffer.append(", R=").append(getReactionCount()).append(", "); for (IReaction reaction : reactions()) { buffer.append(reaction.toString()); } buffer.append(')'); return buffer.toString(); } /** * Clones this ReactionSet and the contained Reactions * too. * * @return The cloned ReactionSet */ public Object clone() throws CloneNotSupportedException { ReactionSet clone = (ReactionSet)super.clone(); // clone the reactions clone.reactionCount = this.reactionCount; clone.reactions = new Reaction[clone.reactionCount]; for (int f = 0; f < clone.reactionCount; f++) { clone.reactions[f] = (Reaction)((Reaction)reactions[f]).clone(); } return clone; } /** * Removes all Reactions from this container. */ public void removeAllReactions() { for (int pos = this.reactionCount - 1; pos >= 0; pos--) { this.reactions[pos] = null; } this.reactionCount = 0; notifyChanged(); } public void stateChanged(IChemObjectChangeEvent event) { notifyChanged(event); } public void removeReaction(IReaction relevantReaction) { for (int i = reactionCount-1; i >= 0; i--) { if (reactions[i] == relevantReaction) removeReaction(i); } } } cdk-1.2.10/src/main/org/openscience/cdk/Ring.java100644 0 0 11326 11570154753 16616 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 Christoph Steinbeck * * 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. * * 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; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IRing; /** * Class representing a ring structure in a molecule. * A ring is a linear sequence of * N atoms interconnected to each other by covalent bonds, * such that atom i (1 < i < N) is bonded to * atom i-1 and atom i + 1 and atom 1 is bonded to atom N and atom 2. * * @cdk.module data * @cdk.githash * @cdk.keyword ring */ public class Ring extends AtomContainer implements java.io.Serializable, IRing { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = 6604894792331865990L; /** * Constructs an empty ring. * */ public Ring() { super(); } /** * Constructs a ring from the atoms in an IAtomContainer object. * * @param atomContainer The IAtomContainer object containing the atoms to form the ring */ public Ring(IAtomContainer atomContainer) { super(atomContainer); } /** * Constructs a ring that will have a certain number of atoms of the given elements. * * @param ringSize The number of atoms and bonds the ring will have * @param elementSymbol The element of the atoms the ring will have */ public Ring(int ringSize, String elementSymbol) { this(ringSize); super.atomCount = ringSize; super.bondCount = ringSize; atoms[0] = new Atom(elementSymbol); for (int i = 1; i < ringSize; i++) { atoms[i] = new Atom(elementSymbol); super.bonds[i-1] = new Bond(atoms[i - 1], atoms[i], IBond.Order.SINGLE); } super.bonds[ringSize-1] = new Bond(atoms[ringSize - 1], atoms[0], IBond.Order.SINGLE); } /** * Constructs an empty ring that will have a certain size. * * @param ringSize The size (number of atoms) the ring will have */ public Ring(int ringSize) { super(ringSize, ringSize, 0, 0); } /** * Returns the number of atoms\edges in this ring. * * @return The number of atoms\edges in this ring */ public int getRingSize() { return this.atomCount; } /** * Returns the next bond in order, relative to a given bond and atom. * Example: Let the ring be composed of 0-1, 1-2, 2-3 and 3-0. A request getNextBond(1-2, 2) * will return Bond 2-3. * * @param bond A bond for which an atom from a consecutive bond is sought * @param atom A atom from the bond above to assign a search direction * @return The next bond in the order given by the above assignment */ public IBond getNextBond(IBond bond, IAtom atom) { IBond tempBond; for (int f = 0; f < getBondCount(); f++) { tempBond = getBond(f); if (tempBond.contains(atom) && bond != tempBond) return tempBond; } return null; } /** * Returns the sum of all bond orders in the ring. * * @return the sum of all bond orders in the ring */ public int getBondOrderSum() { int orderSum = 0; for (int i = 0; i < getBondCount(); i++) { if (getBond(i).getOrder() == IBond.Order.SINGLE) { orderSum += 1; } else if (getBond(i).getOrder() == IBond.Order.DOUBLE) { orderSum += 2; } else if (getBond(i).getOrder() == IBond.Order.TRIPLE) { orderSum += 3; } else if (getBond(i).getOrder() == IBond.Order.QUADRUPLE) { orderSum += 4; } } return orderSum; } public String toString() { StringBuffer buffer = new StringBuffer(); buffer.append("Ring("); buffer.append(super.toString()); buffer.append(')'); return buffer.toString(); } } cdk-1.2.10/src/main/org/openscience/cdk/RingSet.java100644 0 0 12635 11570154753 17276 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 Christoph Steinbeck * * 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. * * 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; import org.openscience.cdk.interfaces.*; import java.io.Serializable; /** * Maintains a set of Ring objects. * * @cdk.module data * @cdk.githash * * @cdk.keyword ring, set of */ public class RingSet extends AtomContainerSet implements Serializable, IRingSet, Cloneable { private static final long serialVersionUID = 7168431521057961434L; /** Flag to denote that the set is order with the largest ring first? */ public final static int LARGE_FIRST = 1; /** Flag to denote that the set is order with the smallest ring first? */ public final static int SMALL_FIRST = 2; /** * The constructor. * */ public RingSet() { super(); } /** * Returns a vector of all rings that this bond is part of. * * @param bond The bond to be checked * @return A vector of all rings that this bond is part of */ public IRingSet getRings(IBond bond) { IRingSet rings = bond.getBuilder().newRingSet(); Ring ring; for (int i = 0; i < getAtomContainerCount(); i++) { ring = (Ring)getAtomContainer(i); if (ring.contains(bond)) { rings.addAtomContainer(ring); } } return rings; } /** * Returns a vector of all rings that this atom is part of. * * @param atom The atom to be checked * @return A vector of all rings that this bond is part of */ public IRingSet getRings(IAtom atom) { IRingSet rings = new RingSet(); IRing ring; for (int i = 0; i < getAtomContainerCount();i++) { ring = (Ring)getAtomContainer(i); if (ring.contains(atom)) { rings.addAtomContainer(ring); } } return rings; } /** * Returns all the rings in the RingSet that share * one or more atoms with a given ring. * * @param ring A ring with which all return rings must share one or more atoms * @return All the rings that share one or more atoms with a given ring. */ public IRingSet getConnectedRings(IRing ring) { IRingSet connectedRings = ring.getBuilder().newRingSet(); IRing tempRing; IAtom atom; for (int i = 0; i < ring.getAtomCount(); i++) { atom = ring.getAtom(i); for (int j = 0; j < getAtomContainerCount(); j++) { tempRing = (IRing)getAtomContainer(j); if (tempRing != ring && !connectedRings.contains(tempRing) && tempRing.contains(atom)) { connectedRings.addAtomContainer(tempRing); } } } return connectedRings; } /** * Adds all rings of another RingSet if they are not already part of this ring set. * * If you want to add a single ring to the set use {@link #addAtomContainer(org.openscience.cdk.interfaces.IAtomContainer)} * * @param ringSet the ring set to be united with this one. */ public void add(IRingSet ringSet) { for (int f = 0; f < ringSet.getAtomContainerCount(); f++) { if (!contains(ringSet.getAtomContainer(f))) { addAtomContainer(ringSet.getAtomContainer(f)); } } } /** * True, if at least one of the rings in the ringset contains * the given atom. * * @param atom Atom to check * @return true, if the ringset contains the atom */ public boolean contains(IAtom atom) { for (int i = 0; i < getAtomContainerCount(); i++) { if (getAtomContainer(i).contains(atom)) { return true; } } return false; } /** * Checks for presence of a ring in this RingSet. * * @param ring The ring to check * @return true if ring is part of RingSet * */ public boolean contains(IAtomContainer ring) { for (int i = 0; i < getAtomContainerCount(); i++) { if (ring == getAtomContainer(i)) { return true; } } return false; } /** * Clones this RingSet including the Rings. * * @return The cloned object */ public Object clone() throws CloneNotSupportedException { return super.clone(); } /** * Returns the String representation of this RingSet. * * @return The String representation of this RingSet */ public String toString() { StringBuffer buffer = new StringBuffer(32); buffer.append("RingSet("); buffer.append(this.hashCode()); if (getAtomContainerCount() > 0) { buffer.append(", R=").append(getAtomContainerCount()).append(", "); for (int i = 0; i < atomContainerCount; i++) { IRing possibleRing = (IRing)atomContainers[i]; buffer.append(possibleRing.toString()); if (i+1 < atomContainerCount) { buffer.append(", "); } } } buffer.append(')'); return buffer.toString(); } } cdk-1.2.10/src/main/org/openscience/cdk/SingleElectron.java100644 0 0 11126 11570154753 20632 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2004-2007 Egon Willighagen * * 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. * * 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; import java.io.Serializable; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.ISingleElectron; /** * A Single Electron is an orbital which is occupied by only one electron. * A radical in CDK is represented by an AtomContainer that contains an Atom * and a SingleElectron type ElectronContainer: *
 *   AtomContainer radical = new AtomContainer();
 *   Atom carbon = new Atom("C");
 *   carbon.setImplicitHydrogens(3);
 *   radical.addElectronContainer(new SingleElectron(carbon));
 * 
* * @cdk.module data * @cdk.githash * * @cdk.keyword radical * @cdk.keyword electron, unpaired */ public class SingleElectron extends ElectronContainer implements Serializable, ISingleElectron, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = 7796574734668490940L; /** Number of electron for this class is defined as one. */ protected final int electronCount = 1; /** The atom with which this single electron is associated. */ protected IAtom atom; /** * Constructs an single electron orbital on an Atom. * * @param atom The atom to which the single electron belongs. */ public SingleElectron(IAtom atom) { this.atom = atom; } /** * Constructs an single electron orbital with an associated Atom. */ public SingleElectron() { this.atom = null; } /** * Returns the number of electrons in this SingleElectron. * * @return The number of electrons in this SingleElectron. */ public Integer getElectronCount() { return this.electronCount; } /** * Returns the associated Atom. * * @return the associated Atom. * * @see #setAtom */ public IAtom getAtom() { return (Atom)this.atom; } /** * Sets the associated Atom. * * @param atom the Atom this SingleElectron will be associated with * * @see #getAtom */ public void setAtom(IAtom atom) { this.atom = atom; notifyChanged(); } /** * Returns true if the given atom participates in this SingleElectron. * * @param atom The atom to be tested if it participates in this bond * @return true if this SingleElectron is associated with the atom */ public boolean contains(IAtom atom) { return (this.atom == atom) ? true : false; } /** * Returns a one line string representation of this SingleElectron. * This method is conform RFC #9. * * @return The string representation of this SingleElectron */ public String toString() { StringBuffer stringContent = new StringBuffer(); stringContent.append("SingleElectron("); stringContent.append(this.hashCode()); if (atom != null) { stringContent.append(", "); stringContent.append(atom.toString()); } stringContent.append(')'); return stringContent.toString(); } /** * Clones this SingleElectron object, including a clone of the atom for which the * SingleElectron is defined. * * @return The cloned object */ public Object clone() throws CloneNotSupportedException { SingleElectron clone = (SingleElectron) super.clone(); // clone the Atom if (atom != null) { clone.atom = (IAtom)((IAtom)atom).clone(); } return clone; } } cdk-1.2.10/src/main/org/openscience/cdk/Strand.java100644 0 0 16224 11570154753 17154 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2004-2007 Martin Eklund * * 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 org.openscience.cdk; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IMonomer; import org.openscience.cdk.interfaces.IStrand; import java.util.Collection; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; /** * A Strand is an AtomContainer which stores additional strand specific * informations for a group of Atoms. * * @cdk.module data * @cdk.githash * @cdk.created 2004-12-20 * @author Martin Eklund * @author Ola Spjuth */ public class Strand extends AtomContainer implements java.io.Serializable, IStrand { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = 4200943086350928356L; /** The list of all Monomers in the Strand.*/ private Map monomers; /** The name of this strand (e.g. A, B). */ private String strandName; /** The type of this strand (e.g. PEPTIDE, DNA, RNA). */ private String strandType; /** * Constructs a new Strand. */ public Strand () { super(); // Stand stuff monomers = new Hashtable(); Monomer oMonomer = new Monomer(); oMonomer.setMonomerName(""); oMonomer.setMonomerType("UNKNOWN"); monomers.put("", oMonomer); strandName = ""; } /** * Retrieves the strand name. * * @return The name of the Strand object * @see #setStrandName */ public String getStrandName() { return strandName; } /** * Retrieves the strand type. * * @return The type of the Strand object * @see #setStrandType */ public String getStrandType() { return strandType; } /** * Sets the name of the Strand object. * * @param cStrandName The new name for this strand * @see #getStrandName */ public void setStrandName(String cStrandName) { strandName = cStrandName; } /** * Sets the type of the Strand object. * * @param cStrandType The new type for this strand * @see #getStrandType */ public void setStrandType(String cStrandType) { strandType = cStrandType; } /** * * Adds the atom oAtom without specifying a Monomer or a Strand. Therefore the * atom gets added to a Monomer of type UNKNOWN in a Strand of type UNKNOWN. * * @param oAtom The atom to add * */ public void addAtom(IAtom oAtom) { addAtom(oAtom, getMonomer("")); } /** * * Adds the atom oAtom to a specific Monomer. * * @param oAtom The atom to add * @param oMonomer The monomer the atom belongs to * */ public void addAtom(IAtom oAtom, IMonomer oMonomer) { int atomCount = super.getAtomCount(); // Add atom to AtomContainer super.addAtom(oAtom); if(atomCount != super.getAtomCount()) { // ok, super did not yet contain the atom if (oMonomer == null) { oMonomer = getMonomer(""); } oMonomer.addAtom(oAtom); if (! monomers.containsKey(oMonomer.getMonomerName())) { monomers.put(oMonomer.getMonomerName(), oMonomer); } } } /** * * Returns the number of monomers present in the Strand. * * @return number of monomers * */ public int getMonomerCount() { return monomers.size() - 1; } /** * * Retrieves a Monomer object by specifying its name. * * @param cName The name of the monomer to look for * @return The Monomer object which was asked for * */ public IMonomer getMonomer(String cName) { return (Monomer)monomers.get(cName); } /** * Returns a collection of the names of all Monomers in this * polymer. * * @return a Collection of all the monomer names. */ public Collection getMonomerNames() { return monomers.keySet(); } /** * * Adds a Monomer to this Strand. All atoms and * bonds in the Monomer are added. NB: The Monomer will *not* * "automatically" be connected to the Strand. That has to be * done "manually" (as the "connection point" is not known). * @param monomer */ /*public void addMonomer(Monomer monomer) { if (! monomers.contains(monomer.getMonomerName())) { monomers.put(monomer.getMonomerName(), monomer); } }*/ /** * Removes a particular monomer, specified by its name. * * @param name The name of the monomer to remove */ public void removeMonomer(String name) { if (monomers.containsKey(name)) { Monomer monomer = (Monomer)monomers.get(name); this.remove(monomer); monomers.remove(name); } } /** * Returns a hashtable containing the monomers in the strand. * * @return hashtable containing the monomers in the strand. */ public Map getMonomers() { return monomers; } public String toString() { StringBuffer stringContent = new StringBuffer(32); stringContent.append("Strand("); stringContent.append(this.hashCode()); if (getStrandName() != null) { stringContent.append(", N:").append(getStrandName()); } if (getStrandType() != null) { stringContent.append(", T:").append(getStrandType()).append(", "); } stringContent.append(super.toString()); stringContent.append(')'); return stringContent.toString(); } public Object clone() throws CloneNotSupportedException { Strand clone = (Strand)super.clone(); clone.monomers.clear(); for (Iterator iter = clone.getMonomerNames().iterator(); iter.hasNext();) { Monomer monomerClone = (Monomer)(clone.getMonomer(iter.next().toString()).clone()); Iterator atoms = monomerClone.atoms().iterator(); while (atoms.hasNext()) { clone.addAtom(atoms.next(), monomerClone); } } return clone; } } cdk-1.2.10/src/main/org/openscience/cdk/Vibration.java100644 0 0 6042 11570154753 17633 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2002-2007 Bradley A. Smith * * Contact: jmol-developers@lists.sf.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * A molecular vibration composed of a set of atom vectors. * The atom vectors represent forces acting on the atoms. They * are specified by double[3] arrays containing the components * of the vector. * * @author Bradley A. Smith * @cdk.githash */ public class Vibration { /** * Label identifying this vibration. For example, the * frequency in reciprocal centimeters could be used. */ private String label; /** * List of atom vectors of type double[3] */ private List atomVectors = new ArrayList(); /** * Create a vibration identified by the label. * * @param label identification for this vibration */ public Vibration(String label) { this.label = label; } /** * Gets the label identifying this vibration. * * @return label identifying this vibration */ public String getLabel() { return label; } /** * Adds a atom vector to the vibration. * * @param atomVector atom vector in double[3] array */ public void addAtomVector(double[] atomVector) { atomVectors.add(atomVector); } /** * Gets a atom vector at index given. * * @param index number for the atom vector to be returned * @return atom vector in double[3] array */ public double[] getAtomVector(int index) { return atomVectors.get(index); } /** * Gets the number of atom vectors in the vibration. * * @return number of atom vectors */ public int getAtomVectorCount() { return atomVectors.size(); } /** * Returns an Enumeration of the atom vectors of this vibration. * * @return an enumeration of the atom vectors of this vibration */ public Iterator getAtomVectors() { return atomVectors.iterator(); } /** * Removes all atom vectors from this vibration. */ public void removeAtomVectors() { atomVectors.clear(); } } cdk-1.2.10/src/main/org/openscience/cdk/annotations/TestClass.java100644 0 0 3062 11570154753 22137 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2007 Egon Willighagen * * 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 org.openscience.cdk.annotations; import java.lang.annotation.Documented; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; /** * An annotation for source classes to indicate the JUnit test * class tests the functionality. * * @author Egon Willighagen * @cdk.githash * @cdk.module annotation */ @Documented @Retention(RetentionPolicy.RUNTIME) public @interface TestClass { String value(); } cdk-1.2.10/src/main/org/openscience/cdk/annotations/TestMethod.java100644 0 0 3025 11570154753 22311 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2007 Rajarshi Guha * * 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 org.openscience.cdk.annotations; import java.lang.annotation.*; /** * An annotation for source classes to indicate the specific test class and method that tests the source class. * * @author Rajarshi Guha * @cdk.githash * @cdk.module annotation */ @Documented @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD,ElementType.CONSTRUCTOR}) public @interface TestMethod { String value(); } cdk-1.2.10/src/main/org/openscience/cdk/aromaticity/AromaticityCalculator.java100644 0 0 10712 11570154753 24541 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2001-2007 The Chemistry Development Kit (CDK) Project * * 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 org.openscience.cdk.aromaticity; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IRing; /** * @cdk.module standard * @cdk.githash * * @author Oliver Horlacher * @cdk.created 2002-03-14 * * @cdk.keyword aromaticity detector */ @TestClass("org.openscience.cdk.aromaticity.AromaticityCalculatorTest") public class AromaticityCalculator { /** * Tests the ring in the molecule for aromaticity. Uses the * Hückel rule (4n + 2) pie electrons. sp2 hybridized C contibute 1 electron non * sp2 hybridized heteroatoms contribute 2 electrons (N and O should never be sp in * or anything else in a ring and d electron elements get to complicated) * sp2 hybridized heteroatoms contribute 1 electron hybridization is worked out by * counting the number of bonds with order 2. Therefore sp2 hybridization is assumed * if there is one bond of order 2. Otherwise sp3 hybridization is assumed. * * @param ring the ring to test * @param atomContainer the AtomContainer the ring is in * @return true if the ring is aromatic false otherwise. */ @TestMethod("testIsAromatic_IRing_IAtomContainer") public static boolean isAromatic(IRing ring, IAtomContainer atomContainer) { java.util.Iterator ringAtoms = ring.atoms().iterator(); int eCount = 0; java.util.List conectedBonds; int numDoubleBond = 0; boolean allConnectedBondsSingle; while (ringAtoms.hasNext()) { IAtom atom = ringAtoms.next(); numDoubleBond = 0; allConnectedBondsSingle = true; conectedBonds = atomContainer.getConnectedBondsList(atom); for (IBond conectedBond : conectedBonds) { if (conectedBond.getOrder() == IBond.Order.DOUBLE && ring.contains(conectedBond)) { numDoubleBond++; } // Count the Electron if bond order = 1.5 else if (conectedBond.getFlag(CDKConstants.ISAROMATIC) && ring.contains(conectedBond)) { numDoubleBond = 1; } if (conectedBond.getOrder() != IBond.Order.SINGLE) { allConnectedBondsSingle = false; } } if (numDoubleBond == 1) { //C or heteroatoms both contibute 1 electron in sp2 hybridized form eCount++; } else if (!atom.getSymbol().equals("C")) { //Heteroatom probably in sp3 hybrid therefore 2 electrons contributed. eCount = eCount + 2; } else if (atom.getFlag(CDKConstants.ISAROMATIC)) { eCount++; } else if (allConnectedBondsSingle && atom.getSymbol().equals("C") && atom.getFormalCharge() == 1.0) { // This is for tropylium and kinds. // Dependence on hybridisation would be better: // empty p-orbital is needed continue; } else { return false; } } return eCount - 2 != 0 && (eCount - 2) % 4 == 0; } } cdk-1.2.10/src/main/org/openscience/cdk/aromaticity/CDKHueckelAromaticityDetector.java100644 0 0 23020 11570154753 26040 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2007 Egon Willighagen * * 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 org.openscience.cdk.aromaticity; import java.util.Iterator; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.atomtype.CDKAtomTypeMatcher; import org.openscience.cdk.config.AtomTypeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.graph.ConnectivityChecker; import org.openscience.cdk.graph.SpanningTree; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IRingSet; import org.openscience.cdk.interfaces.IAtomType.Hybridization; import org.openscience.cdk.ringsearch.AllRingsFinder; import org.openscience.cdk.ringsearch.SSSRFinder; /** * This aromaticity detector detects the aromaticity based on the Hückel * 4n+2 pi-electrons rule applied to isolated ring systems. It assumes * CDK atom types to be perceived with the {@link CDKAtomTypeMatcher} or with * any compatible class. For example: *
 * Molecule molecule = MoleculeFactory.makePyridineOxide();
 * AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
 * CDKHueckelAromaticityDetector.detectAromaticity(molecule);
 * 
* * @author egonw * @cdk.module standard * @cdk.githash * @cdk.created 2007-10-05 * * @see org.openscience.cdk.CDKConstants */ @TestClass("org.openscience.cdk.aromaticity.CDKHueckelAromaticityDetectorTest") public class CDKHueckelAromaticityDetector { private static AtomTypeFactory factory = null; @TestMethod("testDetectAromaticity_IAtomContainer") public static boolean detectAromaticity(IAtomContainer atomContainer) throws CDKException { SpanningTree spanningTree = new SpanningTree(atomContainer); IAtomContainer ringSystems = spanningTree.getCyclicFragmentsContainer(); if (ringSystems.getAtomCount() == 0) { // If there are no rings, then there cannot be any aromaticity return false; } // disregard all atoms we know that cannot be aromatic anyway for (IAtom atom : ringSystems.atoms()) if (!atomIsPotentiallyAromatic(atom)) ringSystems.removeAtomAndConnectedElectronContainers(atom); // FIXME: should not really mark them here Iterator atoms = ringSystems.atoms().iterator(); while (atoms.hasNext()) atoms.next().setFlag(CDKConstants.ISINRING, true); Iterator bonds = ringSystems.bonds().iterator(); while (bonds.hasNext()) bonds.next().setFlag(CDKConstants.ISINRING, true); boolean foundSomeAromaticity = false; Iterator isolatedRingSystems = ConnectivityChecker.partitionIntoMolecules(ringSystems).atomContainers().iterator(); while (isolatedRingSystems.hasNext()) { IAtomContainer isolatedSystem = isolatedRingSystems.next(); IRingSet singleRings = new SSSRFinder(isolatedSystem).findSSSR(); Iterator singleRingsIterator = singleRings.atomContainers().iterator(); int maxRingSize = 20; boolean atLeastOneRingIsSprouted = false; boolean allRingsAreAromatic = true; // test single rings in SSSR while (singleRingsIterator.hasNext()) { IAtomContainer singleRing = singleRingsIterator.next(); if (singleRing.getAtomCount() > maxRingSize) maxRingSize = singleRing.getAtomCount(); if (isRingSystemSproutedWithNonRingDoubleBonds(atomContainer, singleRing)) { // OK, this ring is not aromatic atLeastOneRingIsSprouted = true; allRingsAreAromatic = false; } else { // possibly aromatic boolean ringIsAromatic = isHueckelValid(singleRing); foundSomeAromaticity |= ringIsAromatic; allRingsAreAromatic &= ringIsAromatic; if (ringIsAromatic) markRingAtomsAndBondsAromatic(singleRing); } } // OK, what about the one larger ring (if no aromaticity found in SSSR)? if (!allRingsAreAromatic && !atLeastOneRingIsSprouted && singleRings.getAtomContainerCount() <= 3) { // every ring system consisting of more than two rings is too difficult Iterator allRingsIterator = new AllRingsFinder().findAllRingsInIsolatedRingSystem(isolatedSystem).atomContainers().iterator(); while (allRingsIterator.hasNext()) { // there should be exactly three rings, of which only one has a size larger // than the two previous ones IAtomContainer ring = allRingsIterator.next(); if (ring.getAtomCount() <= maxRingSize) { // possibly aromatic boolean ringIsAromatic = isHueckelValid(ring); foundSomeAromaticity |= ringIsAromatic; if (ringIsAromatic) markRingAtomsAndBondsAromatic(ring); } } } } return foundSomeAromaticity; } /** * Tests if the electron count matches the Hückel 4n+2 rule. */ private static boolean isHueckelValid(IAtomContainer singleRing) throws CDKException { int electronCount = 0; for (IAtom ringAtom : singleRing.atoms()) { if (ringAtom.getHybridization() != CDKConstants.UNSET && (ringAtom.getHybridization() == Hybridization.SP2) || ringAtom.getHybridization() == Hybridization.PLANAR3) { // for example, a carbon // note: the double bond is in the ring, that has been tested earlier // FIXME: this does assume bond orders to be resolved too, when detecting // sprouting double bonds if ("N.planar3".equals(ringAtom.getAtomTypeName())) { electronCount += 2; } else if ("N.minus.planar3".equals(ringAtom.getAtomTypeName())) { electronCount += 2; } else if ("N.amide".equals(ringAtom.getAtomTypeName())) { electronCount += 2; } else if ("S.2".equals(ringAtom.getAtomTypeName())) { electronCount += 2; } else if ("S.planar3".equals(ringAtom.getAtomTypeName())) { electronCount += 2; } else if ("C.minus.planar".equals(ringAtom.getAtomTypeName())) { electronCount += 2; } else if ("O.planar3".equals(ringAtom.getAtomTypeName())) { electronCount += 2; } else { if (factory == null) { factory = AtomTypeFactory.getInstance( "org/openscience/cdk/dict/data/cdk-atom-types.owl", ringAtom.getBuilder() ); } IAtomType type = factory.getAtomType(ringAtom.getAtomTypeName()); Object property = type.getProperty(CDKConstants.PI_BOND_COUNT); if (property != null && property instanceof Integer) { electronCount += ((Integer)property).intValue(); } } } else if (ringAtom.getHybridization() != null && ringAtom.getHybridization() == Hybridization.SP3 && getLonePairCount(ringAtom) > 0) { // for example, a nitrogen or oxygen electronCount += 2; } } return (electronCount % 4 == 2) && (electronCount > 2); } private static boolean atomIsPotentiallyAromatic(IAtom atom) { if (atom.getHybridization() == Hybridization.SP2) return true; if (atom.getHybridization() == Hybridization.PLANAR3) return true; if (atom.getHybridization() == Hybridization.SP3 && getLonePairCount(atom) > 0) return true; return false; } /** * Determines if the isolatedRingSystem has attached double bonds, which are not part of the ring system itself, * and not part of any other ring system. */ private static boolean isRingSystemSproutedWithNonRingDoubleBonds(IAtomContainer fullContainer, IAtomContainer isolatedRingSystem) { Iterator atoms = isolatedRingSystem.atoms().iterator(); while (atoms.hasNext()) { Iterator neighborBonds = fullContainer.getConnectedBondsList(atoms.next()).iterator(); while (neighborBonds.hasNext()) { IBond neighborBond = neighborBonds.next(); if (!neighborBond.getFlag(CDKConstants.ISINRING) && neighborBond.getOrder() == CDKConstants.BONDORDER_DOUBLE || neighborBond.getOrder() == CDKConstants.BONDORDER_TRIPLE) { return true; } } } return false; } private static int getLonePairCount(IAtom atom) { Integer count = (Integer)atom.getProperty(CDKConstants.LONE_PAIR_COUNT); if (count == null) { return 0; } else { return count; } } private static void markRingAtomsAndBondsAromatic(IAtomContainer container) { for (IAtom atom : container.atoms()) atom.setFlag(CDKConstants.ISAROMATIC, true); for (IBond bond : container.bonds()) bond.setFlag(CDKConstants.ISAROMATIC, true); } } cdk-1.2.10/src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java100644 0 0 231431 11570154753 23172 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2007-2008 Egon Willighagen * * 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, version 2.1. * * 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.atomtype; import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Map; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.AtomTypeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.exception.NoSuchAtomException; import org.openscience.cdk.graph.SpanningTree; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IPseudoAtom; import org.openscience.cdk.interfaces.IRing; import org.openscience.cdk.interfaces.IRingSet; import org.openscience.cdk.interfaces.ISingleElectron; import org.openscience.cdk.interfaces.IAtomType.Hybridization; /** * Atom Type matcher that perceives atom types as defined in the CDK atom type list * org/openscience/cdk/dict/data/cdk-atom-types.owl. * If there is not an atom type defined for the tested atom, then NULL * is returned. * * @author egonw * @cdk.created 2007-07-20 * @cdk.module core * @cdk.githash * @cdk.bug 1802998 */ @TestClass("org.openscience.cdk.atomtype.CDKAtomTypeMatcherTest") public class CDKAtomTypeMatcher implements IAtomTypeMatcher { public final static int REQUIRE_NOTHING = 1; public final static int REQUIRE_EXPLICIT_HYDROGENS = 2; private AtomTypeFactory factory; private int mode; private static Map> factories = new Hashtable>(1); // private static LoggingTool logger = new LoggingTool(CDKAtomTypeMatcher.class); private CDKAtomTypeMatcher(IChemObjectBuilder builder, int mode) { factory = AtomTypeFactory.getInstance( "org/openscience/cdk/dict/data/cdk-atom-types.owl", builder ); this.mode = mode; } @TestMethod("testGetInstance_IChemObjectBuilder") public static CDKAtomTypeMatcher getInstance(IChemObjectBuilder builder) { return getInstance(builder, REQUIRE_NOTHING); } @TestMethod("testGetInstance_IChemObjectBuilder_int") public static CDKAtomTypeMatcher getInstance(IChemObjectBuilder builder, int mode) { if (!factories.containsKey(mode)) factories.put(mode, new Hashtable(1)); if (!factories.get(mode).containsKey(builder)) factories.get(mode).put(builder, new CDKAtomTypeMatcher(builder, mode)); return factories.get(mode).get(builder); } @TestMethod("testFindMatchingAtomType_IAtomContainer") public IAtomType[] findMatchingAtomType(IAtomContainer atomContainer) throws CDKException { IAtomType[] types = new IAtomType[atomContainer.getAtomCount()]; int typeCounter = 0; for (IAtom atom : atomContainer.atoms()) { types[typeCounter] = findMatchingAtomType(atomContainer, atom); typeCounter++; } return types; } @TestMethod("testFindMatchingAtomType_IAtomContainer_IAtom") public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom) throws CDKException { IAtomType type = null; if (atom instanceof IPseudoAtom) { return factory.getAtomType("X"); } if ("C".equals(atom.getSymbol())) { type = perceiveCarbons(atomContainer, atom); } else if ("Li".equals(atom.getSymbol())) { type = perceiveLithium(atomContainer, atom); } else if ("O".equals(atom.getSymbol())) { type = perceiveOxygens(atomContainer, atom); } else if ("N".equals(atom.getSymbol())) { type = perceiveNitrogens(atomContainer, atom); } else if ("H".equals(atom.getSymbol())) { type = perceiveHydrogens(atomContainer, atom); } else if ("S".equals(atom.getSymbol())) { type = perceiveSulphurs(atomContainer, atom); } else if ("P".equals(atom.getSymbol())) { type = perceivePhosphors(atomContainer, atom); } else if ("Si".equals(atom.getSymbol())) { type = perceiveSilicon(atomContainer, atom); } else if ("B".equals(atom.getSymbol())) { type = perceiveBorons(atomContainer, atom); } else if ("Be".equals(atom.getSymbol())) { type = perceiveBeryllium(atomContainer, atom); } else if ("Se".equals(atom.getSymbol())) { type = perceiveSelenium(atomContainer, atom); } else if ("Te".equals(atom.getSymbol())) { type = perceiveTellurium(atomContainer, atom); } else if ("Ga".equals(atom.getSymbol())) { type = perceiveGallium(atomContainer, atom); } else if ("Ge".equals(atom.getSymbol())) { type = perceiveGermanium(atomContainer, atom); } else { if (type == null) type = perceiveHalogens(atomContainer, atom); if (type == null) type = perceiveCommonSalts(atomContainer, atom); if (type == null) type = perceiveOrganometallicCenters(atomContainer, atom); if (type == null) type = perceiveNobelGases(atomContainer, atom); } return type; } private IAtomType perceiveGallium(IAtomContainer atomContainer, IAtom atom) throws CDKException { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (!isCharged(atom) && maxBondOrder == IBond.Order.SINGLE && atomContainer.getConnectedAtomsCount(atom) <= 3) { IAtomType type = getAtomType("Ga"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getFormalCharge() == 3) { IAtomType type = getAtomType("Ga.3plus"); if (isAcceptable(atom, atomContainer, type)) return type; } return null; } private IAtomType perceiveGermanium(IAtomContainer atomContainer, IAtom atom) throws CDKException { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (!isCharged(atom) && maxBondOrder == IBond.Order.SINGLE && atomContainer.getConnectedAtomsCount(atom) <= 4) { IAtomType type = getAtomType("Ge"); if (isAcceptable(atom, atomContainer, type)) return type; } return null; } private IAtomType perceiveSelenium(IAtomContainer atomContainer, IAtom atom) throws CDKException { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (!isCharged(atom) && maxBondOrder == IBond.Order.SINGLE && atomContainer.getConnectedAtomsCount(atom) <= 2) { IAtomType type = getAtomType("Se.3"); if (isAcceptable(atom, atomContainer, type)) return type; } return null; } private IAtomType perceiveTellurium(IAtomContainer atomContainer, IAtom atom) throws CDKException { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (!isCharged(atom) && maxBondOrder == IBond.Order.SINGLE && atomContainer.getConnectedAtomsCount(atom) <= 2) { IAtomType type = getAtomType("Te.3"); if (isAcceptable(atom, atomContainer, type)) return type; } return null; } private IAtomType perceiveBorons(IAtomContainer atomContainer, IAtom atom) throws CDKException { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (atom.getFormalCharge() == -1 && maxBondOrder == IBond.Order.SINGLE && atomContainer.getConnectedAtomsCount(atom) <= 4) { IAtomType type = getAtomType("B.minus"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atomContainer.getConnectedAtomsCount(atom) <= 3) { IAtomType type = getAtomType("B"); if (isAcceptable(atom, atomContainer, type)) return type; } return null; } private IAtomType perceiveBeryllium(IAtomContainer atomContainer, IAtom atom) throws CDKException { if (atom.getFormalCharge() == -2 && atomContainer.getMaximumBondOrder(atom) == IBond.Order.SINGLE && atomContainer.getConnectedAtomsCount(atom) <= 4) { IAtomType type = getAtomType("Be.2minus"); if (isAcceptable(atom, atomContainer, type)) return type; } return null; } private IAtomType perceiveCarbonRadicals(IAtomContainer atomContainer, IAtom atom) throws CDKException { if (atomContainer.getConnectedBondsCount(atom) == 0) { IAtomType type = getAtomType("C.radical.planar"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atomContainer.getConnectedBondsCount(atom) <= 3) { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == IBond.Order.SINGLE) { IAtomType type = getAtomType("C.radical.planar"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (maxBondOrder == IBond.Order.DOUBLE) { IAtomType type = getAtomType("C.radical.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (maxBondOrder == IBond.Order.TRIPLE) { IAtomType type = getAtomType("C.radical.sp1"); if (isAcceptable(atom, atomContainer, type)) return type; } } return null; } private IAtomType perceiveCarbons(IAtomContainer atomContainer, IAtom atom) throws CDKException { // if hybridization is given, use that if (hasOneSingleElectron(atomContainer, atom)) { return perceiveCarbonRadicals(atomContainer, atom); } else if (hasHybridization(atom) && !isCharged(atom)) { if (atom.getHybridization() == Hybridization.SP2) { IAtomType type = getAtomType("C.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getHybridization() == Hybridization.SP3) { IAtomType type = getAtomType("C.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getHybridization() == Hybridization.SP1) { IAtomType type = getAtomType("C.sp"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (atom.getFlag(CDKConstants.ISAROMATIC)) { IAtomType type = getAtomType("C.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (isCharged(atom)) { if (atom.getFormalCharge() == 1) { if (atomContainer.getConnectedBondsCount(atom) == 0) { IAtomType type = getAtomType("C.plus.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; } else { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == CDKConstants.BONDORDER_TRIPLE) { IAtomType type = getAtomType("C.plus.sp1"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE) { IAtomType type = getAtomType("C.plus.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (maxBondOrder == CDKConstants.BONDORDER_SINGLE) { IAtomType type = getAtomType("C.plus.planar"); if (isAcceptable(atom, atomContainer, type)) return type; } } } else if (atom.getFormalCharge() == -1) { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == CDKConstants.BONDORDER_SINGLE && atomContainer.getConnectedBondsCount(atom) <= 3) { if (isRingAtom(atom, atomContainer) && bothNeighborsAreSp2(atom, atomContainer)) { IAtomType type = getAtomType("C.minus.planar"); if (isAcceptable(atom, atomContainer, type)) return type; } IAtomType type = getAtomType("C.minus.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE && atomContainer.getConnectedBondsCount(atom) <= 3) { IAtomType type = getAtomType("C.minus.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (maxBondOrder == CDKConstants.BONDORDER_TRIPLE && atomContainer.getConnectedBondsCount(atom) <= 1) { IAtomType type = getAtomType("C.minus.sp1"); if (isAcceptable(atom, atomContainer, type)) return type; } } return null; } else if (atomContainer.getConnectedBondsCount(atom) > 4) { // FIXME: I don't perceive carbons with more than 4 connections yet return null; } else { // OK, use bond order info IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == IBond.Order.QUADRUPLE) { // WTF?? return null; } else if (maxBondOrder == CDKConstants.BONDORDER_TRIPLE) { IAtomType type = getAtomType("C.sp"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE) { // OK, one or two double bonds? int doubleBondCount = countAttachedDoubleBonds(atomContainer, atom); if (doubleBondCount == 2) { IAtomType type = getAtomType("C.sp"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (doubleBondCount == 1) { IAtomType type = getAtomType("C.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; } } else { if (hasAromaticBond(atomContainer, atom)) { IAtomType type = getAtomType("C.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; } IAtomType type = getAtomType("C.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } } return null; } private boolean hasOneSingleElectron(IAtomContainer atomContainer, IAtom atom) { Iterator singleElectrons = atomContainer.singleElectrons().iterator(); while (singleElectrons.hasNext()) { if (singleElectrons.next().contains(atom)) return true; } return false; } private int countSingleElectrons(IAtomContainer atomContainer, IAtom atom) { Iterator singleElectrons = atomContainer.singleElectrons().iterator(); int count = 0; while (singleElectrons.hasNext()) { if (singleElectrons.next().contains(atom)) count++; } return count; } private IAtomType perceiveOxygenRadicals(IAtomContainer atomContainer, IAtom atom) throws CDKException { if (atom.getFormalCharge() == 0) { if (atomContainer.getConnectedBondsCount(atom) <= 1) { IAtomType type = getAtomType("O.sp3.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (atom.getFormalCharge() == +1) { if (atomContainer.getConnectedBondsCount(atom) == 0) { IAtomType type = getAtomType("O.plus.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atomContainer.getConnectedBondsCount(atom) <= 2) { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == IBond.Order.SINGLE) { IAtomType type = getAtomType("O.plus.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (maxBondOrder == IBond.Order.DOUBLE) { IAtomType type = getAtomType("O.plus.sp2.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } } } return null; } private boolean isCharged(IAtom atom) { return (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() != 0); } private boolean hasHybridization(IAtom atom) { return atom.getHybridization() != CDKConstants.UNSET; } private IAtomType perceiveOxygens(IAtomContainer atomContainer, IAtom atom) throws CDKException { if (hasOneSingleElectron(atomContainer, atom)) { return perceiveOxygenRadicals(atomContainer, atom); } // if hybridization is given, use that if (hasHybridization(atom) && !isCharged(atom)) { if (atom.getHybridization() == Hybridization.SP2) { int connectedAtomsCount = atomContainer.getConnectedAtomsCount(atom); if (connectedAtomsCount == 1) { if (isCarboxylate(atom, atomContainer)) { IAtomType type = getAtomType("O.sp2.co2"); if (isAcceptable(atom, atomContainer, type)) return type; } else { IAtomType type = getAtomType("O.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (connectedAtomsCount == 2) { IAtomType type = getAtomType("O.planar3"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (atom.getHybridization() == Hybridization.SP3) { IAtomType type = getAtomType("O.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getHybridization() == Hybridization.PLANAR3) { IAtomType type = getAtomType("O.planar3"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (isCharged(atom)) { if (atom.getFormalCharge() == -1 && atomContainer.getConnectedAtomsCount(atom) <= 1) { if (isCarboxylate(atom, atomContainer)) { IAtomType type = getAtomType("O.minus.co2"); if (isAcceptable(atom, atomContainer, type)) return type; } else { IAtomType type = getAtomType("O.minus"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (atom.getFormalCharge() == -2 && atomContainer.getConnectedAtomsCount(atom) == 0) { IAtomType type = getAtomType("O.minus2"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getFormalCharge() == +1) { if (atomContainer.getConnectedBondsCount(atom) == 0) { IAtomType type = getAtomType("O.plus"); if (isAcceptable(atom, atomContainer, type)) return type; } IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE) { IAtomType type = getAtomType("O.plus.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (maxBondOrder == CDKConstants.BONDORDER_TRIPLE) { IAtomType type = getAtomType("O.plus.sp1"); if (isAcceptable(atom, atomContainer, type)) return type; } else { IAtomType type = getAtomType("O.plus"); if (isAcceptable(atom, atomContainer, type)) return type; } } return null; } else if (atomContainer.getConnectedBondsCount(atom) > 2) { // FIXME: I don't perceive carbons with more than 4 connections yet return null; } else if (atomContainer.getConnectedBondsCount(atom) == 0) { IAtomType type = getAtomType("O.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } else { // OK, use bond order info IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE) { if (isCarboxylate(atom, atomContainer)) { IAtomType type = getAtomType("O.sp2.co2"); if (isAcceptable(atom, atomContainer, type)) return type; } else { IAtomType type = getAtomType("O.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (maxBondOrder == CDKConstants.BONDORDER_SINGLE) { int explicitHydrogens = countExplicitHydrogens(atom, atomContainer); int connectedHeavyAtoms = atomContainer.getConnectedBondsCount(atom) - explicitHydrogens; if (connectedHeavyAtoms == 2) { // a O.sp3 which is expected to take part in an aromatic system if (isRingAtom(atom, atomContainer) && bothNeighborsAreSp2(atom, atomContainer)) { IAtomType type = getAtomType("O.planar3"); if (isAcceptable(atom, atomContainer, type)) return type; } IAtomType type = getAtomType("O.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } else { IAtomType type = getAtomType("O.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } } } return null; } private boolean isCarboxylate(IAtom atom, IAtomContainer container) { // assumes that the oxygen only has one neighbor (C=O, or C-[O-]) List neighbors = container.getConnectedAtomsList(atom); if (neighbors.size() != 1) return false; IAtom carbon = neighbors.get(0); if (!"C".equals(carbon.getSymbol())) return false; int oxygenCount = 0; int singleBondedNegativeOxygenCount = 0; int doubleBondedOxygenCount = 0; for (IBond cBond : container.getConnectedBondsList(carbon)) { IAtom neighbor = cBond.getConnectedAtom(carbon); if ("O".equals(neighbor.getSymbol())) { oxygenCount++; IBond.Order order = cBond.getOrder(); Integer charge = neighbor.getFormalCharge(); if (order == IBond.Order.SINGLE && charge != null && charge == -1) { singleBondedNegativeOxygenCount++; } else if (order == IBond.Order.DOUBLE) { doubleBondedOxygenCount++; } } } return (oxygenCount == 2) && (singleBondedNegativeOxygenCount == 1) && (doubleBondedOxygenCount == 1); } private boolean atLeastTwoNeighborsAreSp2(IAtom atom, IAtomContainer atomContainer) { int count = 0; Iterator atoms = atomContainer.getConnectedAtomsList(atom).iterator(); while (atoms.hasNext() && (count < 2)) { IAtom nextAtom = atoms.next(); if (!nextAtom.getSymbol().equals("H")) { if (nextAtom.getHybridization() != CDKConstants.UNSET && nextAtom.getHybridization() == Hybridization.SP2) { // OK, it's SP2 count++; } else if (countAttachedDoubleBonds(atomContainer, nextAtom) > 0) { // OK, it's SP2 count++; } // OK, not SP2 } } return count >= 2; } private boolean bothNeighborsAreSp2(IAtom atom, IAtomContainer atomContainer) { return atLeastTwoNeighborsAreSp2(atom, atomContainer); } private IAtomType perceiveNitrogenRadicals(IAtomContainer atomContainer, IAtom atom) throws CDKException { if (atomContainer.getConnectedBondsCount(atom) >= 1 && atomContainer.getConnectedBondsCount(atom) <= 2) { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +1) { if (maxBondOrder == IBond.Order.DOUBLE) { IAtomType type = getAtomType("N.plus.sp2.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (maxBondOrder == IBond.Order.SINGLE) { IAtomType type = getAtomType("N.plus.sp3.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0) { if (maxBondOrder == IBond.Order.SINGLE) { IAtomType type = getAtomType("N.sp3.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (maxBondOrder == IBond.Order.DOUBLE) { IAtomType type = getAtomType("N.sp2.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } } } else { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +1 && maxBondOrder == IBond.Order.SINGLE) { IAtomType type = getAtomType("N.plus.sp3.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } } return null; } private IAtomType perceiveNitrogens(IAtomContainer atomContainer, IAtom atom) throws CDKException { // if hybridization is given, use that if (hasOneSingleElectron(atomContainer, atom)) { return perceiveNitrogenRadicals(atomContainer, atom); } else if (hasHybridization(atom) && !isCharged(atom)) { if (atom.getHybridization() == Hybridization.SP1) { int neighborCount = atomContainer.getConnectedAtomsCount(atom); if (neighborCount > 1) { IAtomType type = getAtomType("N.sp1.2"); if (isAcceptable(atom, atomContainer, type)) return type; } else { IAtomType type = getAtomType("N.sp1"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (atom.getHybridization() == Hybridization.SP2) { if (isAmide(atom, atomContainer)) { IAtomType type = getAtomType("N.amide"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (isThioAmide(atom, atomContainer)) { IAtomType type = getAtomType("N.thioamide"); if (isAcceptable(atom, atomContainer, type)) return type; } // but an sp2 hyb N might N.sp2 or N.planar3 (pyrrole), so check for the latter int neighborCount = atomContainer.getConnectedAtomsCount(atom); if (neighborCount == 4 && IBond.Order.DOUBLE == atomContainer.getMaximumBondOrder(atom)) { IAtomType type = getAtomType("N.oxide"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (neighborCount > 1 && bothNeighborsAreSp2(atom, atomContainer)) { IRing ring = getRing(atom, atomContainer); int ringSize = ring == null ? 0 : ring.getAtomCount(); if (ring != null && ring.getAtomCount() > 0) { if (neighborCount == 3) { IBond.Order maxOrder = atomContainer.getMaximumBondOrder(atom); if (maxOrder == IBond.Order.DOUBLE) { IAtomType type = getAtomType("N.sp2.3"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (maxOrder == IBond.Order.SINGLE) { IAtomType type = getAtomType("N.planar3"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (neighborCount == 2) { IBond.Order maxOrder = atomContainer.getMaximumBondOrder(atom); if (maxOrder == IBond.Order.SINGLE) { if (atom.getHydrogenCount() != CDKConstants.UNSET && atom.getHydrogenCount() == 1) { IAtomType type = getAtomType("N.planar3"); if (isAcceptable(atom, atomContainer, type)) return type; } else { IAtomType type = getAtomType("N.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (maxOrder == IBond.Order.DOUBLE) { IAtomType type = getAtomType("N.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; } } } } IAtomType type = getAtomType("N.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getHybridization() == Hybridization.SP3) { IAtomType type = getAtomType("N.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getHybridization() == Hybridization.PLANAR3) { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (atomContainer.getConnectedAtomsCount(atom) == 3 && maxBondOrder == CDKConstants.BONDORDER_DOUBLE && countAttachedDoubleBonds(atomContainer, atom, "O") == 2) { IAtomType type = getAtomType("N.nitro"); if (isAcceptable(atom, atomContainer, type)) return type; } IAtomType type = getAtomType("N.planar3"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (isCharged(atom)) { if (atom.getFormalCharge() == 1) { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == CDKConstants.BONDORDER_SINGLE || atomContainer.getConnectedBondsCount(atom) == 0) { if (atom.getHybridization() == IAtomType.Hybridization.SP2) { IAtomType type = getAtomType("N.plus.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; } IAtomType type = getAtomType("N.plus"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE) { int doubleBonds= countAttachedDoubleBonds(atomContainer, atom); if (doubleBonds == 1) { IAtomType type = getAtomType("N.plus.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (doubleBonds == 2) { IAtomType type = getAtomType("N.plus.sp1"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (maxBondOrder == CDKConstants.BONDORDER_TRIPLE) { if (atomContainer.getConnectedBondsCount(atom) == 2) { IAtomType type = getAtomType("N.plus.sp1"); if (isAcceptable(atom, atomContainer, type)) return type; } } } else if (atom.getFormalCharge() == -1) { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == CDKConstants.BONDORDER_SINGLE) { if (atomContainer.getConnectedAtomsCount(atom) >= 2 && bothNeighborsAreSp2(atom,atomContainer) && isRingAtom(atom, atomContainer)) { IAtomType type = getAtomType("N.minus.planar3"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atomContainer.getConnectedBondsCount(atom) <= 2) { IAtomType type = getAtomType("N.minus.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE) { if (atomContainer.getConnectedBondsCount(atom) <= 1) { IAtomType type = getAtomType("N.minus.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; } } } } else if (atomContainer.getConnectedBondsCount(atom) > 3) { if (atomContainer.getConnectedBondsCount(atom) == 4 && countAttachedDoubleBonds(atomContainer, atom) == 1) { IAtomType type = getAtomType("N.oxide"); if (isAcceptable(atom, atomContainer, type)) return type; } return null; } else if (atomContainer.getConnectedBondsCount(atom) == 0) { IAtomType type = getAtomType("N.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } else { // OK, use bond order info IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == CDKConstants.BONDORDER_SINGLE) { if (isAmide(atom, atomContainer)) { IAtomType type = getAtomType("N.amide"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (isThioAmide(atom, atomContainer)) { IAtomType type = getAtomType("N.thioamide"); if (isAcceptable(atom, atomContainer, type)) return type; } int explicitHydrogens = countExplicitHydrogens(atom, atomContainer); int connectedHeavyAtoms = atomContainer.getConnectedBondsCount(atom) - explicitHydrogens; if (connectedHeavyAtoms == 2) { List bonds = atomContainer.getConnectedBondsList(atom); if (bonds.get(0).getFlag(CDKConstants.ISAROMATIC) && bonds.get(1).getFlag(CDKConstants.ISAROMATIC)) { Integer hCount = atom.getHydrogenCount(); if (hCount == CDKConstants.UNSET || hCount == 0) { IAtomType type = getAtomType("N.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (hCount == 1) { IAtomType type = getAtomType("N.planar3"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (bothNeighborsAreSp2(atom, atomContainer) && isRingAtom(atom, atomContainer)) { // a N.sp3 which is expected to take part in an aromatic system IAtomType type = getAtomType("N.planar3"); if (isAcceptable(atom, atomContainer, type)) return type; } else { IAtomType type = getAtomType("N.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (connectedHeavyAtoms == 3) { if (bothNeighborsAreSp2(atom, atomContainer) && isRingAtom(atom, atomContainer)) { IAtomType type = getAtomType("N.planar3"); if (isAcceptable(atom, atomContainer, type)) return type; } IAtomType type = getAtomType("N.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (connectedHeavyAtoms == 1) { IAtomType type = getAtomType("N.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (connectedHeavyAtoms == 0) { IAtomType type = getAtomType("N.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE) { if (atomContainer.getConnectedAtomsCount(atom) == 3 && countAttachedDoubleBonds(atomContainer, atom, "O") == 2) { IAtomType type = getAtomType("N.nitro"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atomContainer.getConnectedAtomsCount(atom) == 3 && countAttachedDoubleBonds(atomContainer, atom) > 0) { IAtomType type = getAtomType("N.sp2.3"); if (isAcceptable(atom, atomContainer, type)) return type; } IAtomType type = getAtomType("N.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (maxBondOrder == CDKConstants.BONDORDER_TRIPLE) { int neighborCount = atomContainer.getConnectedAtomsCount(atom); if (neighborCount > 1) { IAtomType type = getAtomType("N.sp1.2"); if (isAcceptable(atom, atomContainer, type)) return type; } else { IAtomType type = getAtomType("N.sp1"); if (isAcceptable(atom, atomContainer, type)) return type; } } } return null; } private boolean isRingAtom(IAtom atom, IAtomContainer atomContainer) { SpanningTree st = new SpanningTree(atomContainer); return st.getCyclicFragmentsContainer().contains(atom); } private IRing getRing(IAtom atom, IAtomContainer atomContainer) { SpanningTree st = new SpanningTree(atomContainer); try { if (st.getCyclicFragmentsContainer().contains(atom)) { IRingSet set = st.getAllRings(); for (int i=0; i neighbors = atomContainer.getConnectedAtomsList(atom); for (IAtom neighbor : neighbors) { if (neighbor.getSymbol().equals("C")) { if (countAttachedDoubleBonds(atomContainer, neighbor, "O") == 1) return true; } } return false; } private boolean isThioAmide(IAtom atom, IAtomContainer atomContainer) { List neighbors = atomContainer.getConnectedAtomsList(atom); for (IAtom neighbor : neighbors) { if (neighbor.getSymbol().equals("C")) { if (countAttachedDoubleBonds(atomContainer, neighbor, "S") == 1) return true; } } return false; } private int countExplicitHydrogens(IAtom atom, IAtomContainer atomContainer) { int count = 0; for (IAtom aAtom : atomContainer.getConnectedAtomsList(atom)) { if (aAtom.getSymbol().equals("H")) { count++; } } return count; } private IAtomType perceiveSulphurs(IAtomContainer atomContainer, IAtom atom) throws CDKException { List neighbors = atomContainer.getConnectedBondsList(atom); int neighborcount = neighbors.size(); if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if (atom.getHybridization() != CDKConstants.UNSET && atom.getHybridization() == Hybridization.SP2 && atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +1) { if (neighborcount == 3) { IAtomType type = getAtomType("S.inyl.charged"); if (isAcceptable(atom, atomContainer, type)) return type; } else { IAtomType type = getAtomType("S.plus"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() != 0) { if (atom.getFormalCharge() == -1 && neighborcount == 1) { IAtomType type = getAtomType("S.minus"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getFormalCharge() == +1 && neighborcount == 2) { IAtomType type = getAtomType("S.plus"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getFormalCharge() == +1 && neighborcount == 3) { IAtomType type = getAtomType("S.inyl.charged"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getFormalCharge() == +2 && neighborcount == 4) { IAtomType type = getAtomType("S.onyl.charged"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (neighborcount == 6) { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == CDKConstants.BONDORDER_SINGLE) { IAtomType type = getAtomType("S.octahedral"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (neighborcount == 6) { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == CDKConstants.BONDORDER_SINGLE) { IAtomType type = getAtomType("S.octahedral"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (neighborcount == 2) { if (isRingAtom(atom, atomContainer) && bothNeighborsAreSp2(atom, atomContainer)) { IAtomType type = getAtomType("S.planar3"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (countAttachedDoubleBonds(atomContainer, atom, "O") == 2) { IAtomType type = getAtomType("S.oxide"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (countAttachedDoubleBonds(atomContainer, atom) == 2) { IAtomType type = getAtomType("S.inyl.2"); if (isAcceptable(atom, atomContainer, type)) return type; } else { IAtomType type = getAtomType("S.3"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (neighborcount == 1) { if (atomContainer.getConnectedBondsList(atom).get(0).getOrder() == CDKConstants.BONDORDER_DOUBLE) { IAtomType type = getAtomType("S.2"); if (isAcceptable(atom, atomContainer, type)) return type; } else { IAtomType type = getAtomType("S.3"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (neighborcount == 0) { IAtomType type = getAtomType("S.3"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (neighborcount == 3) { int doubleBondedAtoms = countAttachedDoubleBonds(atomContainer, atom); if (doubleBondedAtoms == 1) { IAtomType type = getAtomType("S.inyl"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (doubleBondedAtoms == 3) { IAtomType type = getAtomType("S.trioxide"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (doubleBondedAtoms == 0) { IAtomType type = getAtomType("S.anyl"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (neighborcount == 4) { // count the number of double bonded oxygens int doubleBondedOxygens = countAttachedDoubleBonds(atomContainer, atom, "O"); int doubleBondedNitrogens = countAttachedDoubleBonds(atomContainer, atom, "N"); if (doubleBondedOxygens + doubleBondedNitrogens == 2){ IAtomType type = getAtomType("S.onyl"); if (isAcceptable(atom, atomContainer, type)) return type; } IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == CDKConstants.BONDORDER_SINGLE) { IAtomType type = getAtomType("S.anyl"); if (isAcceptable(atom, atomContainer, type)) return type; } } return null; } private IAtomType perceivePhosphors(IAtomContainer atomContainer, IAtom atom) throws CDKException { List neighbors = atomContainer.getConnectedBondsList(atom); int neighborcount = neighbors.size(); IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (countSingleElectrons(atomContainer, atom) == 3) { IAtomType type = getAtomType("P.se.3"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if (neighborcount == 0) { if (atom.getFormalCharge() == null || atom.getFormalCharge().intValue() == 0) { IAtomType type = getAtomType("P.ine"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (neighborcount == 3) { int doubleBonds = countAttachedDoubleBonds(atomContainer, atom); if (doubleBonds == 1) { IAtomType type = getAtomType("P.ate"); if (isAcceptable(atom, atomContainer, type)) return type; } IAtomType type = getAtomType("P.ine"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (neighborcount == 2) { if (maxBondOrder == CDKConstants.BONDORDER_DOUBLE) { IAtomType type = getAtomType("P.irane"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (maxBondOrder == CDKConstants.BONDORDER_SINGLE) { IAtomType type = getAtomType("P.ine"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (neighborcount == 4) { // count the number of double bonded oxygens int doubleBonds = countAttachedDoubleBonds(atomContainer, atom); if (atom.getFormalCharge() == 1 && doubleBonds == 0) { IAtomType type = getAtomType("P.ate.charged"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (doubleBonds == 1){ IAtomType type = getAtomType("P.ate"); if (isAcceptable(atom, atomContainer, type)) return type; } } return null; } private IAtomType perceiveHydrogens(IAtomContainer atomContainer, IAtom atom) throws CDKException { int neighborcount = atomContainer.getConnectedBondsCount(atom); if (hasOneSingleElectron(atomContainer, atom)) { if ((atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0) && neighborcount == 0) { IAtomType type = getAtomType("H.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } return null; } else if (neighborcount == 2) { // FIXME: bridging hydrogen as in B2H6 return null; } else if (neighborcount == 1) { if (atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0) { IAtomType type = getAtomType("H"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (neighborcount == 0) { if (atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0) { IAtomType type = getAtomType("H"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getFormalCharge() == 1){ IAtomType type = getAtomType("H.plus"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getFormalCharge() == -1){ IAtomType type = getAtomType("H.minus"); if (isAcceptable(atom, atomContainer, type)) return type; } } return null; } private IAtomType perceiveLithium(IAtomContainer atomContainer, IAtom atom) throws CDKException { int neighborcount = atomContainer.getConnectedBondsCount(atom); if (neighborcount == 1) { if (atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0) { IAtomType type = getAtomType("Li"); if (isAcceptable(atom, atomContainer, type)) return type; } } return null; } private IAtomType perceiveHalogens(IAtomContainer atomContainer, IAtom atom) throws CDKException { if ("Cl".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { if (atomContainer.getConnectedBondsCount(atom) == 0) { if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +1) { IAtomType type = getAtomType("Cl.plus.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0) { IAtomType type = getAtomType("Cl.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (atomContainer.getConnectedBondsCount(atom) <= 1) { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == IBond.Order.SINGLE) { IAtomType type = getAtomType("Cl.plus.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } } return null; } else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == -1)) { IAtomType type = getAtomType("Cl.minus"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == 1) { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == IBond.Order.DOUBLE) { IAtomType type = getAtomType("Cl.plus.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; }else if (maxBondOrder == IBond.Order.SINGLE){ IAtomType type = getAtomType("Cl.plus.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } }else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +3) && atomContainer.getConnectedBondsCount(atom) == 4) { IAtomType type = getAtomType("Cl.perchlorate.charged"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atomContainer.getConnectedBondsCount(atom) == 1 || atomContainer.getConnectedBondsCount(atom) == 0) { IAtomType type = getAtomType("Cl"); if (isAcceptable(atom, atomContainer, type)) return type; } else { int doubleBonds = countAttachedDoubleBonds(atomContainer, atom); if (atomContainer.getConnectedBondsCount(atom) == 3 && doubleBonds == 2) { IAtomType type = getAtomType("Cl.chlorate"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atomContainer.getConnectedBondsCount(atom) == 4 && doubleBonds == 3) { IAtomType type = getAtomType("Cl.perchlorate"); if (isAcceptable(atom, atomContainer, type)) return type; } } } else if ("Br".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { if (atomContainer.getConnectedBondsCount(atom) == 0) { if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +1) { IAtomType type = getAtomType("Br.plus.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0) { IAtomType type = getAtomType("Br.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (atomContainer.getConnectedBondsCount(atom) <= 1) { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == IBond.Order.SINGLE) { IAtomType type = getAtomType("Br.plus.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } } return null; } else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == -1)) { IAtomType type = getAtomType("Br.minus"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getFormalCharge() == 1) { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == IBond.Order.DOUBLE) { IAtomType type = getAtomType("Br.plus.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; }else if (maxBondOrder == IBond.Order.SINGLE){ IAtomType type = getAtomType("Br.plus.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (atomContainer.getConnectedBondsCount(atom) == 1 || atomContainer.getConnectedBondsCount(atom) == 0) { IAtomType type = getAtomType("Br"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("F".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { if (atomContainer.getConnectedBondsCount(atom) == 0) { if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +1) { IAtomType type = getAtomType("F.plus.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0) { IAtomType type = getAtomType("F.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (atomContainer.getConnectedBondsCount(atom) <= 1) { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == IBond.Order.SINGLE) { IAtomType type = getAtomType("F.plus.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } } return null; } else if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() != 0) { if (atom.getFormalCharge() == -1) { IAtomType type = getAtomType("F.minus"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getFormalCharge() == 1) { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == IBond.Order.DOUBLE) { IAtomType type = getAtomType("F.plus.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; }else if (maxBondOrder == IBond.Order.SINGLE){ IAtomType type = getAtomType("F.plus.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } } } else if (atomContainer.getConnectedBondsCount(atom) == 1 || atomContainer.getConnectedBondsCount(atom) == 0) { IAtomType type = getAtomType("F"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("I".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { if (atomContainer.getConnectedBondsCount(atom) == 0) { if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +1) { IAtomType type = getAtomType("I.plus.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0) { IAtomType type = getAtomType("I.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (atomContainer.getConnectedBondsCount(atom) <= 1) { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == IBond.Order.SINGLE) { IAtomType type = getAtomType("I.plus.radical"); if (isAcceptable(atom, atomContainer, type)) return type; } } return null; } else if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() != 0) { if (atom.getFormalCharge() == -1) { if (atomContainer.getConnectedAtomsCount(atom) == 0) { IAtomType type = getAtomType("I.minus"); if (isAcceptable(atom, atomContainer, type)) return type; } else { IAtomType type = getAtomType("I.minus.5"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (atom.getFormalCharge() == 1) { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == IBond.Order.DOUBLE) { IAtomType type = getAtomType("I.plus.sp2"); if (isAcceptable(atom, atomContainer, type)) return type; }else if (maxBondOrder == IBond.Order.SINGLE){ IAtomType type = getAtomType("I.plus.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } } } else if (atomContainer.getConnectedBondsCount(atom) == 3) { int doubleBondCount = countAttachedDoubleBonds(atomContainer, atom); if (doubleBondCount == 2) { IAtomType type = getAtomType("I.5"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (atomContainer.getConnectedBondsCount(atom) == 2) { IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); if (maxBondOrder == IBond.Order.DOUBLE) { IAtomType type = getAtomType("I.3"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if (atomContainer.getConnectedBondsCount(atom) == 1 || atomContainer.getConnectedBondsCount(atom) == 0) { IAtomType type = getAtomType("I"); if (isAcceptable(atom, atomContainer, type)) return type; } } return null; } private IAtomType perceiveCommonSalts(IAtomContainer atomContainer, IAtom atom) throws CDKException { if ("Na".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +1)) { IAtomType type = getAtomType("Na.plus"); if (isAcceptable(atom, atomContainer, type)) return type; } else if ((atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0) && atomContainer.getConnectedAtomsCount(atom) == 1) { IAtomType type = getAtomType("Na"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("Ca".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +2)) { IAtomType type = getAtomType("Ca.2plus"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("Mg".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +2)) { IAtomType type = getAtomType("Mg.2plus"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("Fe".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +2)) { IAtomType type = getAtomType("Fe.2plus"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("Co".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +2)) { IAtomType type = getAtomType("Co.2plus"); if (isAcceptable(atom, atomContainer, type)) return type; } else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +3)) { IAtomType type = getAtomType("Co.3plus"); if (isAcceptable(atom, atomContainer, type)) return type; } else if ((atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0)) { IAtomType type = getAtomType("Co.metallic"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("Cu".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +2)) { IAtomType type = getAtomType("Cu.2plus"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("Mn".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +2)) { IAtomType type = getAtomType("Mn.2plus"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("Pt".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +2)) { IAtomType type = getAtomType("Pt.2plus"); if (isAcceptable(atom, atomContainer, type)) return type; } else if ((atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0)) { int neighbors = atomContainer.getConnectedAtomsCount(atom); if (neighbors == 4) { IAtomType type = getAtomType("Pt.4"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (neighbors == 6) { IAtomType type = getAtomType("Pt.6"); if (isAcceptable(atom, atomContainer, type)) return type; } } } else if ("Ni".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +2)) { IAtomType type = getAtomType("Ni.2plus"); if (isAcceptable(atom, atomContainer, type)) return type; } else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == 0) && atomContainer.getConnectedAtomsCount(atom) <= 2) { IAtomType type = getAtomType("Ni"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("K".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +1)) { IAtomType type = getAtomType("K.plus"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0) { IAtomType type = getAtomType("K.metallic"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("W".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0)) { IAtomType type = getAtomType("W.metallic"); if (isAcceptable(atom, atomContainer, type)) return type; } } return null; } private IAtomType perceiveOrganometallicCenters(IAtomContainer atomContainer, IAtom atom) throws CDKException { if ("Hg".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == -1)) { IAtomType type = getAtomType("Hg.minus"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("Po".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if (atomContainer.getConnectedBondsCount(atom) == 2) { IAtomType type = getAtomType("Po"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("Zn".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if (atomContainer.getConnectedBondsCount(atom) == 2 && (atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0)) { IAtomType type = getAtomType("Zn"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getFormalCharge() != CDKConstants.UNSET || atom.getFormalCharge() == 2) { IAtomType type = getAtomType("Zn.2plus"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("Sn".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == 0 && atomContainer.getConnectedBondsCount(atom) <= 4)) { IAtomType type = getAtomType("Sn.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("As".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == +1 && atomContainer.getConnectedBondsCount(atom) <= 4)) { IAtomType type = getAtomType("As.plus"); if (isAcceptable(atom, atomContainer, type)) return type; } else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == 0 && atomContainer.getConnectedBondsCount(atom) <= 3)) { IAtomType type = getAtomType("As"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("Ti".equals(atom.getSymbol())) { if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == -3 && atomContainer.getConnectedBondsCount(atom) == 6) { IAtomType type = getAtomType("Ti.3minus"); if (isAcceptable(atom, atomContainer, type)) return type; } else if ((atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0) && atomContainer.getConnectedBondsCount(atom) == 4) { IAtomType type = getAtomType("Ti.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("V".equals(atom.getSymbol())) { if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == -3 && atomContainer.getConnectedBondsCount(atom) == 6) { IAtomType type = getAtomType("V.3minus"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("Al".equals(atom.getSymbol())) { if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == 3 && atomContainer.getConnectedBondsCount(atom) == 0) { IAtomType type = getAtomType("Al.3plus"); if (isAcceptable(atom, atomContainer, type)) return type; } else if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == 0 && atomContainer.getConnectedBondsCount(atom) == 3){ IAtomType type = getAtomType("Al"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("Sc".equals(atom.getSymbol())) { if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == -3 && atomContainer.getConnectedBondsCount(atom) == 6) { IAtomType type = getAtomType("Sc.3minus"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("Cr".equals(atom.getSymbol())) { if (atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == 0 && atomContainer.getConnectedBondsCount(atom) == 6) { IAtomType type = getAtomType("Cr"); if (isAcceptable(atom, atomContainer, type)) return type; } } return null; } private IAtomType perceiveNobelGases(IAtomContainer atomContainer, IAtom atom) throws CDKException { if ("He".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0)) { IAtomType type = getAtomType("He"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("Ne".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0)) { IAtomType type = getAtomType("Ne"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("Ar".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0)) { IAtomType type = getAtomType("Ar"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("Kr".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0)) { IAtomType type = getAtomType("Kr"); if (isAcceptable(atom, atomContainer, type)) return type; } } else if ("Xe".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0)) { if (atomContainer.getConnectedBondsCount(atom) == 0) { IAtomType type = getAtomType("Xe"); if (isAcceptable(atom, atomContainer, type)) return type; } else { IAtomType type = getAtomType("Xe.3"); if (isAcceptable(atom, atomContainer, type)) return type; } } } else if ("Rn".equals(atom.getSymbol())) { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() == CDKConstants.UNSET || atom.getFormalCharge() == 0)) { IAtomType type = getAtomType("Rn"); if (isAcceptable(atom, atomContainer, type)) return type; } } return null; } private IAtomType perceiveSilicon(IAtomContainer atomContainer, IAtom atom) throws CDKException { if (hasOneSingleElectron(atomContainer, atom)) { // no idea how to deal with this yet return null; } else if ((atom.getFormalCharge() != CDKConstants.UNSET && atom.getFormalCharge() == 0 && atomContainer.getConnectedBondsCount(atom) <= 4)) { IAtomType type = getAtomType("Si.sp3"); if (isAcceptable(atom, atomContainer, type)) return type; } return null; } private int countAttachedDoubleBonds(IAtomContainer container, IAtom atom) { return countAttachedDoubleBonds(container, atom, null); } private boolean hasAromaticBond(IAtomContainer container, IAtom atom) { List neighbors = container.getConnectedBondsList(atom); for (IBond bond : neighbors) { if (bond.getFlag(CDKConstants.ISAROMATIC)) return true; } return false; } /** * Count the number of doubly bonded atoms. * * @param container the molecule in which to look * @param atom the atom being looked at * @param symbol If not null, then it only counts the double bonded atoms which * match the given symbol. * @return the number of doubly bonded atoms */ private int countAttachedDoubleBonds(IAtomContainer container, IAtom atom, String symbol) { // count the number of double bonded oxygens List neighbors = container.getConnectedBondsList(atom); int neighborcount = neighbors.size(); int doubleBondedAtoms = 0; for (int i=neighborcount-1;i>=0;i--) { if (neighbors.get(i).getOrder() == CDKConstants.BONDORDER_DOUBLE) { IBond bond = neighbors.get(i); if (bond.getAtomCount() == 2 && bond.contains(atom)) { if (symbol != null) { if (bond.getAtom(0).getSymbol().equals(symbol) || bond.getAtom(1).getSymbol().equals(symbol)) { doubleBondedAtoms++; } } else { doubleBondedAtoms++; } } } } return doubleBondedAtoms; } private IAtomType getAtomType(String identifier) throws CDKException { IAtomType type = factory.getAtomType(identifier); type.setValency((Integer)type.getProperty(CDKConstants.PI_BOND_COUNT) + type.getFormalNeighbourCount()); return type; } private boolean isAcceptable(IAtom atom, IAtomContainer container, IAtomType type) { if (mode == REQUIRE_EXPLICIT_HYDROGENS) { // make sure no implicit hydrogens were assumed int actualContainerCount = container.getConnectedAtomsCount(atom); int requiredContainerCount = type.getFormalNeighbourCount(); if (actualContainerCount != requiredContainerCount) return false; } else if (atom.getHydrogenCount() != CDKConstants.UNSET) { // confirm correct neighbour count int connectedAtoms = container.getConnectedAtomsCount(atom); int hCount = atom.getHydrogenCount(); int actualNeighbourCount = connectedAtoms + hCount; int requiredNeighbourCount = type.getFormalNeighbourCount(); if (actualNeighbourCount > requiredNeighbourCount) return false; } // confirm correct bond orders if (type.getProperty(CDKConstants.PI_BOND_COUNT) != null && container.getMaximumBondOrder(atom).ordinal() + 1 > (Integer) type.getProperty(CDKConstants.PI_BOND_COUNT) + 1) return false; // confirm correct valency if (type.getValency() != CDKConstants.UNSET && container.getBondOrderSum(atom) > type.getValency()) return false; // confirm correct formal charge if (atom.getFormalCharge() != CDKConstants.UNSET && !atom.getFormalCharge().equals(type.getFormalCharge())) return false; return true; } private boolean isHueckelNumber(int electronCount) { return (electronCount % 4 == 2) && (electronCount >= 2); } } cdk-1.2.10/src/main/org/openscience/cdk/atomtype/EStateAtomTypeMatcher.java100644 0 0 13012 11570154753 23727 0ustar 0 0 /* $RCSfile: $ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Todd Martin (Environmental Protection Agency) * * 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. * * 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.atomtype; import java.util.List; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IRing; import org.openscience.cdk.interfaces.IRingSet; /** * Determines the EState atom types. * * @author Todd Martin * @author nick * @cdk.module standard * @cdk.githash * @cdk.keyword atom type, E-state */ @TestClass("org.openscience.cdk.atomtype.EStateAtomTypeMatcherTest") public class EStateAtomTypeMatcher implements IAtomTypeMatcher { IRingSet ringSet = null; public void setRingSet(IRingSet rs) { ringSet = rs; } @TestMethod("testFindMatchingAtomType_IAtomContainer") public IAtomType[] findMatchingAtomType(IAtomContainer atomContainer) throws CDKException { IAtomType[] types = new IAtomType[atomContainer.getAtomCount()]; int typeCounter = 0; for (IAtom atom : atomContainer.atoms()) { types[typeCounter] = findMatchingAtomType(atomContainer, atom); typeCounter++; } return types; } @TestMethod("testSP3Atoms,testNaCl,testNaphthalene,testSP2Atoms,testSPAtoms,testBenzeneFromSmiles") public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom) { IAtomType atomType = null; try { String fragment = ""; int NumHAtoms = 0; int NumSingleBonds2 = 0; int NumDoubleBonds2 = 0; int NumTripleBonds2 = 0; int NumAromaticBonds2 = 0; int NumAromaticBondsTotal2 = 0; String element = atom.getSymbol(); List attachedAtoms = atomContainer.getConnectedAtomsList(atom); for (int j = 0; j <= attachedAtoms.size() - 1; j++) { IAtom attached = (IAtom)attachedAtoms.get(j); IBond b = atomContainer.getBond(atom, attached); if(attached.getSymbol().equals("H")) NumHAtoms++; if (atom.getFlag(CDKConstants.ISAROMATIC) && attached.getFlag(CDKConstants.ISAROMATIC)) { boolean SameRing = inSameAromaticRing(atomContainer, atom, attached, ringSet); if (SameRing) { NumAromaticBonds2++; if (element.equals("N")) { if (b.getOrder() == IBond.Order.SINGLE) NumAromaticBondsTotal2++; if (b.getOrder() == IBond.Order.DOUBLE) NumAromaticBondsTotal2 = NumAromaticBondsTotal2 + 2; } } else { if (b.getOrder() == IBond.Order.SINGLE) NumSingleBonds2++; if (b.getOrder() == IBond.Order.DOUBLE) NumDoubleBonds2++; if (b.getOrder() == IBond.Order.TRIPLE) NumTripleBonds2++; } } else { if (b.getOrder() == IBond.Order.SINGLE) NumSingleBonds2++; if (b.getOrder() == IBond.Order.DOUBLE) NumDoubleBonds2++; if (b.getOrder() == IBond.Order.TRIPLE) NumTripleBonds2++; } } NumSingleBonds2 = NumSingleBonds2 - NumHAtoms; // assign frag here fragment = "S"; for (int j = 0; j <= NumTripleBonds2 - 1; j++) { fragment += "t"; } for (int j = 0; j <= NumDoubleBonds2 - 1; j++) { fragment += "d"; } for (int j = 0; j <= NumSingleBonds2 - 1; j++) { fragment += "s"; } for (int j = 0; j <= NumAromaticBonds2 - 1; j++) { fragment += "a"; } fragment += element; if (atom.getFormalCharge() == 1) { fragment += "p"; } else if (atom.getFormalCharge() == -1) { fragment += "m"; } if (NumHAtoms == 1) fragment += "H"; else if (NumHAtoms > 1) fragment += ("H" + NumHAtoms); atomType = atom.getBuilder().newAtomType(fragment, atom.getSymbol()); atomType.setFormalCharge(atom.getFormalCharge()); if (atom.getFlag(CDKConstants.ISAROMATIC)) atomType.setFlag(CDKConstants.ISAROMATIC, true); } catch (Exception e) { e.printStackTrace(); } return atomType; } @TestMethod("testAromaticAtoms") public static boolean inSameAromaticRing(IAtomContainer m, IAtom atom1, IAtom atom2, IRingSet rs) { if (rs == null) return false; for (int i = 0; i <= rs.getAtomContainerCount() - 1; i++) { IRing r = (IRing) rs.getAtomContainer(i); if (r.contains(atom1) && r.contains(atom2)) { if (isAromaticRing(r)) return(true); } } return false; } @TestMethod("testAromaticAtoms") static boolean isAromaticRing(IRing ring) { for (int i = 0; i < ring.getAtomCount(); i++) if(!ring.getAtom(i).getFlag(CDKConstants.ISAROMATIC)) return(false); return(true); } } cdk-1.2.10/src/main/org/openscience/cdk/atomtype/IAtomTypeGuesser.java100644 0 0 3765 11570154753 22762 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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; version 2.1. * * 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.atomtype; import java.util.List; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomType; /** * Classes that implement this interface are atom type guessers. As compared * to the IAtomTypeMatcher, this guesser has room for missing information. * Not uncommonly, one bit of information is missing. * * @author egonw * @cdk.created 2006-09-22 * @cdk.module core * @cdk.githash * * @see IAtomTypeMatcher */ public interface IAtomTypeGuesser { /** * Method that returns an iterator with a suitable list of atom types * given the provided atom. * * @param container AtomContainer of which the atom is part * @param atom Atom for which a matching atom type is searched * @return The matching AtomTypes * @throws CDKException when something went wrong with going through * the AtomType's */ public List possibleAtomTypes(IAtomContainer container, IAtom atom) throws CDKException; } cdk-1.2.10/src/main/org/openscience/cdk/atomtype/IAtomTypeMatcher.java100644 0 0 4720 11570154753 22720 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Matteo Floris * 2008 Egon Willighagen * * 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. * * 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.atomtype; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomType; /** * Classes that implement this interface are atom type matchers. They find the * most appropriate AtomType matching the given Atom in a given atom type list. * * @author mfe4 * @cdk.created 2004-12-02 * @cdk.module core * @cdk.githash * * @see IAtomTypeGuesser */ public interface IAtomTypeMatcher { /** * Method that assigns an atom type to a given atom belonging to an atom * container. * * @param container AtomContainer of which the atom is part * @param atom Atom for which a matching atom type is searched * @return The matching AtomType * @throws CDKException when something went wrong with going through * the AtomType's */ public IAtomType findMatchingAtomType(IAtomContainer container, IAtom atom) throws CDKException; /** * Method that assigns atom types to atoms in the given atom container. * * @param container AtomContainer for which atom types are perceived * @return The matching AtomType * @throws CDKException when something went wrong with going through * the AtomType's */ public IAtomType[] findMatchingAtomType(IAtomContainer container) throws CDKException; } cdk-1.2.10/src/main/org/openscience/cdk/atomtype/MM2AtomTypeMatcher.java100644 0 0 24164 11570154753 23147 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2005-2007 Christian Hoppe * * 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. * * 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.atomtype; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.PseudoAtom; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.AtomTypeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.tools.AtomTypeTools; import org.openscience.cdk.tools.LoggingTool; /** * Class implements methods to assign mmff94 atom types for a specific atom in an molecule. * * @author cho * @cdk.created 2005-18-07 * @cdk.module extra * @cdk.githash */ public class MM2AtomTypeMatcher implements IAtomTypeMatcher { private LoggingTool logger; IBond.Order maxBondOrder = IBond.Order.SINGLE; private AtomTypeFactory factory = null; AtomTypeTools atomTypeTools=null; String [] atomTypeIds={"C","Csp2","C=","Csp","HC","O","O=","N","Nsp2","Nsp", "F","CL","BR","I","S","S+",">SN","SO2","Sthi","SI","LP","HO", "CR3R","HN","HOCO","P","B","BTET","HN2","C.","C+","GE", "SN","PB","SE","TE","D","-N=","CE3R","N+","NPYL","Oar", "Sthi","N2OX","HS","=N=","NO2","OM","HN+","OR","Car","HE", "NE","AR","KR","XE","MG+2","PTET","FE+2","FE+3","NI+2","NI+3","CO+2","CO+3", "OX","OK","C++","N=C","NPD+","N+=","N2OX" }; /** * Constructor for the MMFF94AtomTypeMatcher object. */ public MM2AtomTypeMatcher() { logger = new LoggingTool(this); atomTypeTools=new AtomTypeTools(); } private String getSphericalMatcher(IAtomType type) throws CDKException {//NOPMD return (String)type.getProperty(CDKConstants.SPHERICAL_MATCHER); } private String getSphericalMatcher(String type) throws CDKException {//NOPMD return getSphericalMatcher(factory.getAtomType(type)); } @TestMethod("testFindMatchingAtomType_IAtomContainer") public IAtomType[] findMatchingAtomType(IAtomContainer atomContainer) throws CDKException { IAtomType[] types = new IAtomType[atomContainer.getAtomCount()]; int typeCounter = 0; for (IAtom atom : atomContainer.atoms()) { types[typeCounter] = findMatchingAtomType(atomContainer, atom); typeCounter++; } return types; } /** * Assign the mm2 atom type to a given atom. * Before this method can be called the following has to be done: *
	 * atomContainer = (AtomContainer)atomTypeTools.assignAtomTypePropertiesToAtom(
	 *   new Molecule(atomContainer)
	 * );
	 * 
* * @param atomContainer AtomContainer * @param atomInterface the target atom * @exception CDKException Description of the Exception * @return the matching AtomType (AtomType class) */ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atomInterface) throws CDKException { if (factory == null) { try { factory = AtomTypeFactory.getInstance("org/openscience/cdk/config/data/mm2_atomtypes.xml", atomContainer.getBuilder()); } catch (Exception ex1) { logger.error("Could not instantiate the AtomType list!", ex1.getMessage()); logger.debug(ex1); throw new CDKException("Could not instantiate the AtomType list!", ex1); } } org.openscience.cdk.Atom atom = (org.openscience.cdk.Atom)atomInterface; logger.debug("****** Configure MM2 AtomType via findMatching ******"); String atomSphericalMatcher = (String)atom.getProperty(CDKConstants.SPHERICAL_MATCHER); int atomChemicalGroupConstant = (Integer) atom.getProperty(CDKConstants.CHEMICAL_GROUP_CONSTANT); int atomRingSize = 0; // not all atom types have ring sizes define; 0 is default Object oRingSize = atom.getProperty(CDKConstants.PART_OF_RING_OF_SIZE); if (oRingSize != null) { atomRingSize = (Integer) oRingSize; } logger.debug(" Symbol:" + atom.getSymbol() +" HoseCode>" + atomSphericalMatcher + " "); if (atom instanceof PseudoAtom) { return factory.getAtomTypes("DU")[0]; } Pattern p1 = null; String ID = ""; boolean atomTypeFlag = false; Matcher mat1=null; IBond.Order tmpMaxBondOrder = IBond.Order.SINGLE; maxBondOrder = atomContainer.getMaximumBondOrder(atom); logger.debug("Atom maxBond"+maxBondOrder+" ChemicalGroupConstant "+atomChemicalGroupConstant); for (int j = 0; j < atomTypeIds.length; j++){ tmpMaxBondOrder = factory.getAtomType(atomTypeIds[j]).getMaxBondOrder(); logger.debug(j + "ATOM TYPE "+ tmpMaxBondOrder + " " +getSphericalMatcher(atomTypeIds[j])); p1 =Pattern.compile(getSphericalMatcher(atomTypeIds[j])); mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches()) { ID = atomTypeIds[j]; if (atomTypeIds[j].equals("C")) { if (atomChemicalGroupConstant!=-1) { if (atomRingSize==3) { ID="CR3R"; }else if (atomChemicalGroupConstant==5){ ID="Car"; }else if (maxBondOrder != IBond.Order.SINGLE) { ID="Csp2"; } } if (atom.getSymbol().equals("S")){ if (atomChemicalGroupConstant==8){ ID="Sthi"; }else{ p1 = Pattern.compile(getSphericalMatcher("S")); mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches()) { ID="S"; } } } } else if (atomTypeIds[j].equals("Csp2")) { if (atomChemicalGroupConstant!=-1) { if (atomChemicalGroupConstant==5) { ID="Car"; }else if (atomRingSize==3) { ID="CE3R"; } } p1 = Pattern.compile(getSphericalMatcher("C=")); mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches()) { ID="C="; } } else if (atomTypeIds[j].equals("O")) { //OH/Ether if (atomChemicalGroupConstant!=-1) { if (atomChemicalGroupConstant==6){ ID="Oar";//furan }else if (atomRingSize==3) { ID="OR";//epoxy } } p1 = Pattern.compile(getSphericalMatcher("OX")); mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches() & atomChemicalGroupConstant==-1) { ID="OX"; } } else if (atomTypeIds[j].equals("N")) {//n sp3 if (atomContainer.getMaximumBondOrder(atom) == IBond.Order.DOUBLE){ ID="Nsp2"; } if (atomChemicalGroupConstant==4) { ID="NPYL";//Pyrole }else if (atomChemicalGroupConstant==10){ ID="-N="; p1 = Pattern.compile(getSphericalMatcher("NPD+")); mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches()) { ID="NPD+"; } }else{ //Amid p1 = Pattern.compile(getSphericalMatcher("Namid")); mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches() & atomChemicalGroupConstant==-1) { ID="Nsp2"; }else{ p1 = Pattern.compile(getSphericalMatcher("N2OX")); mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches() & atomChemicalGroupConstant==-1) { ID="N2OX"; } } } } else if (atomTypeIds[j].equals("Nsp2")) { if (atomChemicalGroupConstant==12) { ID="=N-";//Pyridin } //Azo p1 = Pattern.compile(getSphericalMatcher("-N=")); mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches() & atomChemicalGroupConstant==-1) { ID="-N="; }else{ p1 = Pattern.compile(getSphericalMatcher("N=C")); mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches()) { ID="N=C"; } p1 = Pattern.compile(getSphericalMatcher("N2OX")); mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches()) { ID="N2OX"; } p1 = Pattern.compile(getSphericalMatcher("NO2")); mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches()) { ID="NO2"; } p1 = Pattern.compile(getSphericalMatcher("=N=")); mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches()) { ID="=N="; } } } else if (atomTypeIds[j].equals("HS")) { if (atom.getMaxBondOrder() != null && atom.getMaxBondOrder() != IBond.Order.SINGLE) { ID="HC"; } } else if (atomTypeIds[j].equals("HO")) { //Enol,amid p1 = Pattern.compile(getSphericalMatcher("HOC")); mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches() & atomChemicalGroupConstant==-1) { ID="HN2"; } //COOH p1 = Pattern.compile(getSphericalMatcher("HOCO")); mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches() & atomChemicalGroupConstant==-1) { ID="HOCO"; } } else if (atomTypeIds[j].equals("HN")) { p1 = Pattern.compile(getSphericalMatcher("HN2")); mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches()) { ID="HN2"; } } atomTypeFlag = true; logger.debug(" MATCH AtomTypeID:"+j+ " " + ID); break; }//IF }//for end if (atomTypeFlag) { atomTypeFlag = false; logger.debug("ID in factory true:"+ID); return factory.getAtomType(ID); } else { logger.debug("NoSuchAtomTypeException: Atom is unkown with Symbol:" + atom.getSymbol() + " does not MATCH AtomType. HoseCode:" + atomSphericalMatcher); logger.debug("ID in factory false:"+ID); return factory.getAtomType("DU"); } } } cdk-1.2.10/src/main/org/openscience/cdk/atomtype/MMFF94AtomTypeMatcher.java100644 0 0 31413 11570154753 23451 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2005-2007 Christian Hoppe * * 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. * * 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.atomtype; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.PseudoAtom; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.AtomTypeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.tools.AtomTypeTools; import org.openscience.cdk.tools.LoggingTool; /** * Class implements methods to assign mmff94 atom types for a specific atom in * an molecule. The full list of mmff94 atom types is defined in the file * cdk/config/data/mmff94_atomtypes.xml. * * @author cho * @cdk.created 2005-18-07 * @cdk.module extra * @cdk.githash */ public class MMFF94AtomTypeMatcher implements IAtomTypeMatcher { private LoggingTool logger; IBond.Order maxBondOrder = IBond.Order.SINGLE; private AtomTypeFactory factory = null; AtomTypeTools atomTypeTools=null; String [] atomTypeIds={"C","Csp2","C=","Csp","CO2M","CNN+","C%","CIM+","CR4R","CR3R","CE4R", "Car","C5A","C5B","C5","HC","HO","HN","HOCO","HN=C","HN2", "HOCC","HOH","HOS","HN+","HO+","HO=+","HP","O","O=","OX", "OM","O+","O=+","OH2","Oar","N","N=C","NC=C","NSP","=N=", "NAZT","N+","N2OX","N3OX","NC#N","NO3","N=O","NC=O","NSO","N+=", "NCN+","NGD+","NR%","NM","N5M","NPYD","NPYL","NPD+","N5A","N5B", "NPOX","N5OX","N5+","N5","S","S=C",">SN","SO2","SX","SO2M", "=SO","Sthi","PTET","P","-P=C","F","CL","BR","I","SI", "CL04","FE+2","FE+3","F-","CL-","BR-","LI+","NA+","K+","ZN+2", "CA+2","CU+1","CU+2","MG+2","DU"}; /** * Constructor for the MMFF94AtomTypeMatcher object. */ public MMFF94AtomTypeMatcher() { logger = new LoggingTool(this); atomTypeTools=new AtomTypeTools(); } private String getSphericalMatcher(IAtomType type) throws CDKException {//NOPMD return (String)type.getProperty(CDKConstants.SPHERICAL_MATCHER); } private String getSphericalMatcher(String type) throws CDKException {//NOPMD return getSphericalMatcher(factory.getAtomType(type)); } @TestMethod("testFindMatchingAtomType_IAtomContainer") public IAtomType[] findMatchingAtomType(IAtomContainer atomContainer) throws CDKException { IAtomType[] types = new IAtomType[atomContainer.getAtomCount()]; int typeCounter = 0; for (IAtom atom : atomContainer.atoms()) { types[typeCounter] = findMatchingAtomType(atomContainer, atom); typeCounter++; } return types; } /** * Assign the mmff94 atom type to a given atom. * Before this method can be called the following has to be done: * atomContainer=(AtomContainer)atomTypeTools.assignAtomTypePropertiesToAtom(new Molecule(atomContainer)); * * @param atomContainer AtomContainer * @param atomInterface the target atom * @exception CDKException Description of the Exception * @return the matching AtomType (AtomType class) */ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atomInterface) throws CDKException { if (factory == null) { try { factory = AtomTypeFactory.getInstance("org/openscience/cdk/config/data/mmff94_atomtypes.xml", atomContainer.getBuilder() ); } catch (Exception ex1) { logger.error(ex1.getMessage()); logger.debug(ex1); throw new CDKException("Could not instantiate the AtomType list!", ex1); } } org.openscience.cdk.Atom atom = (org.openscience.cdk.Atom)atomInterface; //logger.debug("****** Configure MMFF94 AtomType via findMatching ******"); //logger.debug(" Symbol:" + atom.getSymbol() +" HoseCode>" + atom.getSphericalMatcher() + " "); logger.debug(" Symbol:" + atom.getSymbol() +" HoseCode>" + atom.getProperty(CDKConstants.SPHERICAL_MATCHER) + " "); //System.out.print("IN MMFF94AtomTypeMatcher Symbol:" + atom.getSymbol() +" HoseCode>" + atom.getProperty(CDKConstants.SPHERICAL_MATCHER) + " "); if (atom instanceof PseudoAtom) { return factory.getAtomTypes("DU")[0]; } Pattern p1 = null; Pattern p2 = null; String ID = ""; boolean atomTypeFlag = false; Matcher mat1=null; Matcher mat2=null; IBond.Order tmpMaxBondOrder; maxBondOrder = atomContainer.getMaximumBondOrder(atom); for (int j = 0; j < atomTypeIds.length; j++){ tmpMaxBondOrder = factory.getAtomType(atomTypeIds[j]).getMaxBondOrder(); String atomSphericalMatcher = (String)factory.getAtomType(atomTypeIds[j]).getProperty(CDKConstants.SPHERICAL_MATCHER); logger.debug(j + " ATOM TYPE "+ tmpMaxBondOrder + " " +atomSphericalMatcher); p1 =Pattern.compile(atomSphericalMatcher); mat1 = p1.matcher((String)atom.getProperty(CDKConstants.SPHERICAL_MATCHER)); if (mat1.matches()) { ID = atomTypeIds[j]; Object property = atom.getProperty(CDKConstants.CHEMICAL_GROUP_CONSTANT); int atomChemGroupConstant = (Integer) property; Object ringSize = atom.getProperty(CDKConstants.PART_OF_RING_OF_SIZE); int atomRingSize = -1; if (ringSize != null) { atomRingSize = (Integer) ringSize; } if (atomTypeIds[j].equals("C")) { if (atomChemGroupConstant != -1) {//in Ring if (ringSize != null && maxBondOrder == IBond.Order.SINGLE){ if (atomRingSize == 3) { ID = atomTypeIds[9];//sp3 3mem rings }else if (atomRingSize == 4) { ID = atomTypeIds[8];//sp3 4mem rings } }else{//sp2 String type13Matcher = getSphericalMatcher(atomTypeIds[13]); p1 = Pattern.compile(type13Matcher);//C5B mat1 = p1.matcher(atomSphericalMatcher); String type12Matcher = getSphericalMatcher(atomTypeIds[12]); p2 =Pattern.compile(type12Matcher);//C5A mat2 = p2.matcher(atomSphericalMatcher); if (mat1.matches() && atomChemGroupConstant%2==0 && atom.getFlag(CDKConstants.ISAROMATIC) && atomRingSize==5){ ID = atomTypeIds[13]; }else if (mat2.matches() && atomChemGroupConstant%2==0 && atom.getFlag(CDKConstants.ISAROMATIC) && atomRingSize==5){ ID = atomTypeIds[12]; }else if (atomChemGroupConstant%2==0 && atom.getFlag(CDKConstants.ISAROMATIC) && atomRingSize==5) { ID = atomTypeIds[14];//C5 in het 5 ring }else if (atom.getFlag(CDKConstants.ISAROMATIC)) { ID = atomTypeIds[11];//Car in benzene, pyroll } } }else{//not in Ring p1 = Pattern.compile(getSphericalMatcher(atomTypeIds[66]));//S=C mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches()){ ID = atomTypeIds[66];//S=C } } } else if (atomTypeIds[j].equals("Csp2")) { if (atomChemGroupConstant%2==0 & atomRingSize==4 & !atom.getFlag(CDKConstants.ISAROMATIC)) { ID = atomTypeIds[10];//CE4R } } else if (atomTypeIds[j].equals("C=")) { if (atomChemGroupConstant%2==0 && atom.getFlag(CDKConstants.ISAROMATIC)) { ID = atomTypeIds[12];//C5A } } else if (atomTypeIds[j].equals("N")) { //Amid p1 = Pattern.compile(getSphericalMatcher(atomTypeIds[48]));//NC=0 mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches() & atomChemGroupConstant==-1) { ID = atomTypeIds[48];//NC=O } //nsp3 oxide p1 = Pattern.compile(getSphericalMatcher(atomTypeIds[44]));//sp3 n-oxide mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches() && maxBondOrder==tmpMaxBondOrder){ ID = atomTypeIds[44]; } //ring sytems p1 = Pattern.compile(getSphericalMatcher(atomTypeIds[56])); mat1 = p1.matcher(atomSphericalMatcher); if (atomChemGroupConstant==10){ ID = atomTypeIds[56]; }else if (atomChemGroupConstant==4){ ID = atomTypeIds[57]; }else if (atomChemGroupConstant%2==0 & atomRingSize==5 & atom.getFlag(CDKConstants.ISAROMATIC)){ ID=atomTypeIds[64]; } //Nsp2-Oxides p1 = Pattern.compile(getSphericalMatcher(atomTypeIds[61]));//npox mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches() && maxBondOrder==tmpMaxBondOrder){ ID=atomTypeIds[43]; } if (atom.getFlag(CDKConstants.ISAROMATIC)){ if(mat1.matches()&& atomChemGroupConstant==12){ ID = atomTypeIds[61]; }else if(mat1.matches()&& atomRingSize==5){ ID = atomTypeIds[62]; } } //NC#N p1 = Pattern.compile(getSphericalMatcher(atomTypeIds[45])); mat1 = p1.matcher(getSphericalMatcher(atom)); if (mat1.matches()){ ID = atomTypeIds[45]; } }else if (atomTypeIds[j].equals("N=C")) { //n beta heteroaromatic ring p1 = Pattern.compile(getSphericalMatcher(atomTypeIds[59])); mat1 = p1.matcher(getSphericalMatcher(atom)); if (atomChemGroupConstant!=-1) { if (mat1.matches() && atomChemGroupConstant%2==0 && atom.getFlag(CDKConstants.ISAROMATIC) && atomRingSize==5){ ID = atomTypeIds[59];//N5A }else if(atomChemGroupConstant==10){//NPYD ID = atomTypeIds[56]; }else if(atomChemGroupConstant==4){//NPYL ID = atomTypeIds[57]; } } //N2OX p1 = Pattern.compile(getSphericalMatcher(atomTypeIds[43])); mat1 = p1.matcher(getSphericalMatcher(atom)); if (mat1.matches()){ if (atomChemGroupConstant==10){ ID = atomTypeIds[61];//npox }else if (atom.getFlag(CDKConstants.ISAROMATIC) && atomRingSize==5){ ID = atomTypeIds[62];//n5ox }else { ID = atomTypeIds[43];//n2ox } } }else if (atomTypeIds[j].equals("N2OX")){ //NO3 p1 = Pattern.compile(getSphericalMatcher(atomTypeIds[46])); mat1 = p1.matcher(getSphericalMatcher(atom)); if (mat1.matches() && atomChemGroupConstant==-1){ ID = atomTypeIds[46];//NO3 } if (atomChemGroupConstant==12){ ID = atomTypeIds[61];//NPOX }else if (atomChemGroupConstant!=-1 && atom.getFlag(CDKConstants.ISAROMATIC) && atomRingSize==5){ ID = atomTypeIds[62];//N5OX } }else if (atomTypeIds[j].equals("=N=") || atomTypeIds[j].equals("NAZT")){ if (atomChemGroupConstant!=-1 && atom.getFlag(CDKConstants.ISAROMATIC) && atomRingSize==5){ ID = atomTypeIds[59];//aromatic N5A } }else if (atomTypeIds[j].equals("N+=")){ if (atomChemGroupConstant!=-1 && atom.getFlag(CDKConstants.ISAROMATIC) && atomRingSize==5){ ID = atomTypeIds[63];//n5+ }else if (atomChemGroupConstant==12){ ID = atomTypeIds[58];//npd+ } }else if (atomTypeIds[j].equals("O")){ if (atomChemGroupConstant==6){ ID = atomTypeIds[35];//Oar } }else if (atomTypeIds[j].equals("HO")){ p1 = Pattern.compile(getSphericalMatcher(atomTypeIds[21])); mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches()){ ID = atomTypeIds[21];//HOCC } p1 = Pattern.compile(getSphericalMatcher(atomTypeIds[18])); mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches()){ ID = atomTypeIds[18];//HOCO } }else if (atomTypeIds[j].equals("P")){ p1 = Pattern.compile(getSphericalMatcher(atomTypeIds[75])); mat1 = p1.matcher(atomSphericalMatcher); if (mat1.matches()){ ID = atomTypeIds[75];//-P=C } }else if (atomTypeIds[j].equals("S")){ if (atomRingSize==5 && atom.getFlag(CDKConstants.ISAROMATIC)){ ID = atomTypeIds[72];//Sthiophen } }else if (atomTypeIds[j].equals("HC")){ p1 =Pattern.compile(getSphericalMatcher("HP")); mat1 = p1.matcher((String)atom.getProperty(CDKConstants.SPHERICAL_MATCHER)); if (mat1.matches()){ ID = "HP"; } } atomTypeFlag = true; logger.debug(" MATCH AtomTypeID:"+j+ " " + ID); break; }//IF }//for end if (atomTypeFlag) { atomTypeFlag = false; //System.out.println(" "+ID); return factory.getAtomType(ID); } else { return factory.getAtomType("DU"); } } } cdk-1.2.10/src/main/org/openscience/cdk/atomtype/StructGenAtomTypeGuesser.java100644 0 0 7236 11570154753 24505 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2008 Egon Willighagen * * 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, version 2.1. * * 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.atomtype; import java.util.ArrayList; import java.util.List; import org.openscience.cdk.config.AtomTypeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.manipulator.BondManipulator; /** * AtomTypeMatcher that finds an AtomType by matching the Atom's element symbol. * This atom type matcher takes into account formal charge and number of * implicit hydrogens, and requires bond orders to be given. * *

This class uses the cdk/config/data/structgen_atomtypes.xml * list. If there is not an atom type defined for the tested atom, then null * is returned. * * @author egonw * @cdk.created 2006-09-22 * @cdk.module structgen * @cdk.githash */ public class StructGenAtomTypeGuesser implements IAtomTypeGuesser { private static AtomTypeFactory factory = null; private LoggingTool logger; /** * Constructor for the StructGenMatcher object. */ public StructGenAtomTypeGuesser() { logger = new LoggingTool(this); } /** * Finds the AtomType matching the Atom's element symbol, formal charge and * hybridization state. * * @param atomContainer AtomContainer * @param atom the target atom * @exception CDKException Exception thrown if something goed wrong * @return the matching AtomType */ public List possibleAtomTypes(IAtomContainer atomContainer, IAtom atom) throws CDKException { if (factory == null) { try { factory = AtomTypeFactory.getInstance("org/openscience/cdk/config/data/structgen_atomtypes.xml", atom.getBuilder()); } catch (Exception ex1) { logger.error(ex1.getMessage()); logger.debug(ex1); throw new CDKException("Could not instantiate the AtomType list!", ex1); } } double bondOrderSum = atomContainer.getBondOrderSum(atom); IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); int charge = atom.getFormalCharge(); int hcount = atom.getHydrogenCount(); List matchingTypes = new ArrayList(); IAtomType[] types = factory.getAtomTypes(atom.getSymbol()); for (IAtomType type : types) { logger.debug(" ... matching atom ", atom, " vs ", type); if (bondOrderSum - charge + hcount <= type.getBondOrderSum() && !BondManipulator.isHigherOrder(maxBondOrder, type.getMaxBondOrder())) { matchingTypes.add(type); } } logger.debug(" No Match"); return matchingTypes; } } cdk-1.2.10/src/main/org/openscience/cdk/atomtype/StructGenMatcher.java100644 0 0 10107 11570154753 22777 0ustar 0 0 /* $Revision: 5855 $ $Author: egonw $ $Date: 2006-03-29 10:27:08 +0200 (Wed, 29 Mar 2006) $ * * Copyright (C) 2005-2007 Egon Willighagen * * 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, version 2.1. * * 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.atomtype; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.AtomTypeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.manipulator.BondManipulator; /** * AtomTypeMatcher that finds an AtomType by matching the Atom's element symbol. * This atom type matcher takes into account formal charge and number of * implicit hydrogens, and requires bond orders to be given. * *

This class uses the cdk/config/data/structgen_atomtypes.xml * list. If there is not an atom type defined for the tested atom, then null * is returned. * * @author egonw * @cdk.created 2006-09-22 * @cdk.module structgen * @cdk.githash */ public class StructGenMatcher implements IAtomTypeMatcher { private static AtomTypeFactory factory = null; private LoggingTool logger; /** * Constructor for the StructGenMatcher object. */ public StructGenMatcher() { logger = new LoggingTool(this); } @TestMethod("testFindMatchingAtomType_IAtomContainer") public IAtomType[] findMatchingAtomType(IAtomContainer atomContainer) throws CDKException { IAtomType[] types = new IAtomType[atomContainer.getAtomCount()]; int typeCounter = 0; for (IAtom atom : atomContainer.atoms()) { types[typeCounter] = findMatchingAtomType(atomContainer, atom); typeCounter++; } return types; } /** * Finds the AtomType matching the Atom's element symbol, formal charge and * hybridization state. * * @param atomContainer AtomContainer * @param atom the target atom * @exception CDKException Exception thrown if something goes wrong * @return the matching AtomType */ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom) throws CDKException { if (factory == null) { try { factory = AtomTypeFactory.getInstance("org/openscience/cdk/config/data/structgen_atomtypes.xml", atom.getBuilder()); } catch (Exception ex1) { logger.error(ex1.getMessage()); logger.debug(ex1); throw new CDKException("Could not instantiate the AtomType list!", ex1); } } double bondOrderSum = atomContainer.getBondOrderSum(atom); IBond.Order maxBondOrder = atomContainer.getMaximumBondOrder(atom); int charge = atom.getFormalCharge(); int hcount = atom.getHydrogenCount() == null ? 0 : atom.getHydrogenCount(); IAtomType[] types = factory.getAtomTypes(atom.getSymbol()); for (IAtomType type : types) { logger.debug(" ... matching atom ", atom, " vs ", type); if (bondOrderSum - charge + hcount == type.getBondOrderSum() && !BondManipulator.isHigherOrder(maxBondOrder, type.getMaxBondOrder())) { return type; } } logger.debug(" No Match"); return null; } } cdk-1.2.10/src/main/org/openscience/cdk/atomtype/SybylAtomTypeMatcher.java100644 0 0 12733 11570154753 23655 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2008 Egon Willighagen * * 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, version 2.1. * * 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.atomtype; import java.io.InputStream; import java.util.Hashtable; import java.util.Map; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.aromaticity.CDKHueckelAromaticityDetector; import org.openscience.cdk.atomtype.mapper.AtomTypeMapper; import org.openscience.cdk.config.AtomTypeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IChemObjectBuilder; /** * Atom Type matcher for Sybyl atom types. It uses the {@link CDKAtomTypeMatcher} * for perception and then maps CDK to Sybyl atom types. * * @author egonw * @cdk.created 2008-07-13 * @cdk.module atomtype * @cdk.githash * @cdk.keyword atom type, Sybyl */ @TestClass("org.openscience.cdk.atomtype.SybylAtomTypeMatcherTest") public class SybylAtomTypeMatcher implements IAtomTypeMatcher { private final static String SYBYL_ATOM_TYPE_LIST = "org/openscience/cdk/dict/data/sybyl-atom-types.owl"; private final static String CDK_TO_SYBYL_MAP = "org/openscience/cdk/dict/data/cdk-sybyl-mappings.owl"; private AtomTypeFactory factory; private CDKAtomTypeMatcher cdkMatcher; private AtomTypeMapper mapper; private static Map factories = new Hashtable(1); private SybylAtomTypeMatcher(IChemObjectBuilder builder) { InputStream stream = this.getClass().getClassLoader().getResourceAsStream(SYBYL_ATOM_TYPE_LIST); factory = AtomTypeFactory.getInstance(stream, "owl", builder); cdkMatcher = CDKAtomTypeMatcher.getInstance(builder); InputStream mapStream = this.getClass().getClassLoader().getResourceAsStream(CDK_TO_SYBYL_MAP); mapper = AtomTypeMapper.getInstance(CDK_TO_SYBYL_MAP, mapStream); } @TestMethod("testGetInstance_IChemObjectBuilder") public static SybylAtomTypeMatcher getInstance(IChemObjectBuilder builder) { if (!factories.containsKey(builder)) factories.put(builder, new SybylAtomTypeMatcher(builder)); return factories.get(builder); } @TestMethod("testFindMatchingAtomType_IAtomContainer") public IAtomType[] findMatchingAtomType(IAtomContainer atomContainer) throws CDKException { for (IAtom atom : atomContainer.atoms()) { IAtomType type = cdkMatcher.findMatchingAtomType(atomContainer, atom); atom.setAtomTypeName(type == null ? null : type.getAtomTypeName()); atom.setHybridization(type == null ? null : type.getHybridization()); } CDKHueckelAromaticityDetector.detectAromaticity(atomContainer); IAtomType[] types = new IAtomType[atomContainer.getAtomCount()]; int typeCounter = 0; for (IAtom atom : atomContainer.atoms()) { String mappedType = mapCDKToSybylType(atom); if (mappedType == null) { types[typeCounter] = null; } else { types[typeCounter] = factory.getAtomType(mappedType); } typeCounter++; } return types; } /** * Sybyl atom type perception for a single atom. The molecular property aromaticity is not perceived; * Aromatic carbons will, therefore, be perceived as C.2 and not C.ar. If the latter is * required, please use findMatchingAtomType(IAtomContainer) instead. */ @TestMethod("testFindMatchingAtomType_IAtomContainer_IAtom") public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom) throws CDKException { IAtomType type = cdkMatcher.findMatchingAtomType(atomContainer, atom); if (type == null) return null; else atom.setAtomTypeName(type.getAtomTypeName()); String mappedType = mapCDKToSybylType(atom); if (mappedType == null) return null; return factory.getAtomType(mappedType); } private String mapCDKToSybylType(IAtom atom) { String typeName = atom.getAtomTypeName(); if (typeName == null) return null; String mappedType = mapper.mapAtomType(typeName); if ("C.2".equals(mappedType) && atom.getFlag(CDKConstants.ISAROMATIC)) { mappedType = "C.ar"; } else if ("N.2".equals(mappedType) && atom.getFlag(CDKConstants.ISAROMATIC)) { mappedType = "N.ar"; } else if ("N.pl3".equals(mappedType) && atom.getFlag(CDKConstants.ISAROMATIC)) { mappedType = "N.ar"; } return mappedType; } } cdk-1.2.10/src/main/org/openscience/cdk/atomtype/mapper/AtomTypeMapper.java100644 0 0 7042 11570154753 23734 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2008 Egon Willighagen * * 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, version 2.1. * * 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.atomtype.mapper; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.atomtypes.OWLAtomTypeMappingReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.HashMap; import java.util.Map; /** * An AtomTypeMapper allows the mapping of atom types between atom type * schemes. For example, it allows to convert atom types from the CDK scheme to the * Sybyl scheme; using this approach it is possible to use the CDK atom type perception * algorithm and write the resulting atom types using the Sybyl atom type scheme. * * @cdk.module atomtype */ @TestClass("org.openscience.cdk.atomtype.mapper.AtomTypeMapperTest") public class AtomTypeMapper { private static Map mappers = new HashMap(); private String mappingFile; private Map mappings; private AtomTypeMapper(String mappingFile) { this.mappingFile = mappingFile; InputStream stream = this.getClass().getClassLoader().getResourceAsStream(mappingFile); OWLAtomTypeMappingReader reader = new OWLAtomTypeMappingReader( new InputStreamReader(stream) ); mappings = reader.readAtomTypeMappings(); } private AtomTypeMapper(String mappingFile, InputStream stream) { this.mappingFile = mappingFile; OWLAtomTypeMappingReader reader = new OWLAtomTypeMappingReader( new InputStreamReader(stream) ); mappings = reader.readAtomTypeMappings(); } /** * Instantiates an atom type to atom type mapping, based on the given mapping file. * For example, the mapping file org.openscience.cdk.config.data.cdk-sybyl-mappings.owl * which defines how CDK atom types are mapped to Sybyl atom types. * * @param mappingFile File name of the OWL file defining the atom type to atom type mappings. * @return An instance of AtomTypeMapper for the given mapping file. */ @TestMethod("testGetInstance_String") public static AtomTypeMapper getInstance(String mappingFile) { if (!mappers.containsKey(mappingFile)) { mappers.put(mappingFile, new AtomTypeMapper(mappingFile)); } return mappers.get(mappingFile); } @TestMethod("testGetInstance_String_InputStream") public static AtomTypeMapper getInstance(String mappingFile, InputStream stream) { if (!mappers.containsKey(mappingFile)) { mappers.put(mappingFile, new AtomTypeMapper(mappingFile, stream)); } return mappers.get(mappingFile); } @TestMethod("testMapAtomType_String") public String mapAtomType(String type) { return mappings.get(type); } @TestMethod("testGetMapping") public String getMapping() { return mappingFile; } } cdk-1.2.10/src/main/org/openscience/cdk/charges/AtomTypeCharges.java100644 0 0 11457 11570154753 22377 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Christian Hoppe * 2008 Egon Willighagen * * Contact: cdk-devel@list.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. * * 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.charges; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.tools.HOSECodeGenerator; /** * Assigns charges to atom types. * * @author chhoppe * @cdk.created 2004-11-03 * @cdk.module charges * @cdk.githash */ @TestClass("org.openscience.cdk.charges.AtomTypeChargesTest") public class AtomTypeCharges implements IChargeCalculator { HOSECodeGenerator hcg = new HOSECodeGenerator(); Pattern pOC = Pattern.compile("O-[1][-];=?+C[(]=?+O.*+"); Pattern pOP = Pattern.compile("O-[1][-];=?+P.*+"); Pattern pOS = Pattern.compile("O-[1][-];=?+S.*+"); Pattern p_p = Pattern.compile("[A-Za-z]{1,2}+[-][0-6].?+[+].*+"); Pattern p_n = Pattern.compile("[A-Za-z]{1,2}+[-][0-6].?+[-].*+"); /** * Constructor for the AtomTypeCharges object */ AtomTypeCharges() { } /** * Sets initial charges for atom types * +1 for cationic atom types * -1 for anionic atom types * carboxylic oxygen -0.5 * phosphorylic oxygen -0.66 * sulfanilic oxygen -0.5 * or to formal charge (which must be determined elsewhere or set manually) * polycations are not handled by this approach * *@param atomContainer AtomContainer *@return AtomContainer with set charges *@exception Exception Description of the Exception */ @TestMethod("testCharges_pOC,testCharges_pOP,testCharges_pOS,testCharges_p_p,testCharges_p_n") public IAtomContainer setCharges(IAtomContainer atomContainer) throws Exception { atomContainer = setInitialCharges(atomContainer); return atomContainer; } private String removeAromaticityFlagsFromHoseCode(String hoseCode){ //clean hosecode String hosecode=""; for (int i=0;i * * Contact: cdk-devel@list.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. * * 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.charges; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IMolecule; /** * Calculation of the electronegativity of orbitals of a molecule * by the method Gasteiger based on electronegativity is given by X = a + bq + c(q*q). * * @author Miguel Rojas Cherto * @cdk.created 2008-104-31 * @cdk.module charges * @cdk.keyword electronegativity */ @TestClass("org.openscience.cdk.charges.ElectronegativityTest") public class Electronegativity { private GasteigerMarsiliPartialCharges peoe = null; /**Number of maximum iterations*/ private int maxI = 6; /**Number of maximum resonance structures*/ private int maxRS = 50; private IMolecule molSigma; private IAtomContainer acOldS; private double[] marsiliFactors; /** * Constructor for the PiElectronegativity object. */ public Electronegativity() { this(6, 50); } /** * Constructor for the Electronegativity object. * * @param maxIterations The maximal number of Iteration * @param maxResonStruc The maximal number of Resonance Structures */ public Electronegativity( int maxIterations, int maxResonStruc) { peoe = new GasteigerMarsiliPartialCharges(); maxI = maxIterations; maxRS = maxResonStruc; } /** * calculate the electronegativity of orbitals sigma. * * @param ac IAtomContainer * @param atom atom for which effective atom electronegativity should be calculated * * @return piElectronegativity */ @TestMethod("testCalculateSigmaElectronegativity_IAtomContainer_IAtom") public double calculateSigmaElectronegativity(IAtomContainer ac, IAtom atom){ return calculateSigmaElectronegativity(ac, atom, maxI, maxRS); } /** * calculate the electronegativity of orbitals sigma. * * @param ac IAtomContainer * @param atom atom for which effective atom electronegativity should be calculated * @param maxIterations The maximal number of Iteration * @param maxResonStruc The maximal number of Resonance Structures * * @return piElectronegativity */ @TestMethod("testCalculateSigmaElectronegativity_IAtomContainer_IAtom_Int_Int") public double calculateSigmaElectronegativity(IAtomContainer ac, IAtom atom, int maxIterations, int maxResonStruc) { maxI = maxIterations; maxRS = maxResonStruc; double electronegativity = 0; try { if(!ac.equals(acOldS)){ molSigma = ac.getBuilder().newMolecule(ac); peoe.setMaxGasteigerIters(maxI); peoe.assignGasteigerMarsiliSigmaPartialCharges(molSigma, true); marsiliFactors = peoe.assignGasteigerSigmaMarsiliFactors(molSigma); acOldS = ac; } int stepSize = peoe.getStepSize(); int atomPosition =ac.getAtomNumber(atom); int start = (stepSize * (atomPosition) + atomPosition); electronegativity = ((marsiliFactors[start]) + (molSigma.getAtom(atomPosition).getCharge() * marsiliFactors[start + 1]) + (marsiliFactors[start + 2] * ((molSigma.getAtom(atomPosition).getCharge() * molSigma.getAtom(atomPosition).getCharge())))); return electronegativity; } catch (Exception e) { e.printStackTrace(); } return electronegativity; } /** * set the maximal number of Iterations. * * @param maxIterations The number maximal of iterations */ @TestMethod("testSetMaxIterations_Int") public void setMaxIterations(int maxIterations){ maxI = maxIterations; } /** * set the maximal number of resonance structures. * * @param maxResonStruc The number maximal of resonance structures */ @TestMethod("testSetMaxResonStruc_Int") public void setMaxResonStruc(int maxResonStruc){ maxRS = maxResonStruc; } /** * get the maximal number of Iterations. * * @return The number maximal of iterations */ @TestMethod("testGetMaxIterations") public int getMaxIterations(){ return maxI; } /** * get the maximal number of resonance structures. * * @return The number maximal of resonance structures */ @TestMethod("testGetMaxResonStruc") public int getMaxResonStruc(){ return maxRS; } } cdk-1.2.10/src/main/org/openscience/cdk/charges/GasteigerMarsiliPartialCharges.java100644 0 0 33555 11570154753 25410 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2005-2007 Christian Hoppe * * Contact: cdk-devel@list.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. * * 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.charges; import java.util.Iterator; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; /** *

The calculation of the Gasteiger Marsili (PEOE) partial charges is based on * {@cdk.cite GM80}. This class only implements the original method which only * applies to σ-bond systems.

* * * @author chhoppe * @author rojas * * @cdk.module charges * @cdk.githash * @cdk.created 2004-11-03 * @cdk.keyword partial atomic charges * @cdk.keyword charge distribution * @cdk.keyword electronegativities, partial equalization of orbital * @cdk.keyword PEOE */ @TestClass("org.openscience.cdk.charges.GasteigerMarsiliPartialChargesTest") public class GasteigerMarsiliPartialCharges implements IChargeCalculator { private double DEOC_HYDROGEN = 20.02; private double MX_DAMP = 0.5; private double MX_ITERATIONS = 20; private int STEP_SIZE = 5; /** Flag is set if the formal charge of a chemobject is changed due to resonance.*/ /** * Constructor for the GasteigerMarsiliPartialCharges object */ public GasteigerMarsiliPartialCharges() { } /** * Sets chi_cat value for hydrogen, because H poses a special problem due to lack of possible second ionisation * *@param chiCat The new DEOC_HYDROGEN value */ @TestMethod("testSetChiCatHydrogen_Double") public void setChiCatHydrogen(double chiCat) { DEOC_HYDROGEN = chiCat; } /** * Sets the maxGasteigerDamp attribute of the GasteigerMarsiliPartialCharges * object * *@param damp The new maxGasteigerDamp value */ @TestMethod("testSetMaxGasteigerDamp_Double") public void setMaxGasteigerDamp(double damp) { MX_DAMP = damp; } /** * Sets the maxGasteigerIters attribute of the GasteigerMarsiliPartialCharges * object * *@param iters The new maxGasteigerIters value */ @TestMethod("testSetMaxGasteigerIters_Double") public void setMaxGasteigerIters(double iters) { MX_ITERATIONS = iters; } /** * Gets chi_cat value for hydrogen, because H poses a special problem due to lack of possible second ionisation * * @return The new DEOC_HYDROGEN value */ @TestMethod("testGetChiCatHydrogen") public double getChiCatHydrogen() { return DEOC_HYDROGEN; } /** * Gets the maxGasteigerDamp attribute of the GasteigerMarsiliPartialCharges * object * * @return The new maxGasteigerDamp value */ @TestMethod("testGetMaxGasteigerDamp") public double getMaxGasteigerDamp() { return MX_DAMP; } /** * Gets the maxGasteigerIters attribute of the GasteigerMarsiliPartialCharges * object * * @return The new maxGasteigerIters value */ @TestMethod("testGetMaxGasteigerIters") public double getMaxGasteigerIters() { return MX_ITERATIONS; } /** * Main method which assigns Gasteiger Marisili partial sigma charges * *@param ac AtomContainer *@param setCharge The Charge *@return AtomContainer with partial charges *@exception Exception Possible Exceptions */ @TestMethod("testAssignGasteigerMarsiliSigmaPartialCharges_IAtomContainer_Boolean") public IAtomContainer assignGasteigerMarsiliSigmaPartialCharges(IAtomContainer ac, boolean setCharge) throws Exception { // if (setCharge) { // atomTypeCharges.setCharges(ac); // not necessary initial charge // } /*add the initial charge to 0. According results of Gasteiger*/ for(int i = 0; i < ac.getAtomCount(); i++) ac.getAtom(i).setCharge(0.0); double[] gasteigerFactors = assignGasteigerSigmaMarsiliFactors(ac);//a,b,c,deoc,chi,q double alpha = 1.0; double q; double deoc; IAtom[] atoms = null; int atom1 = 0; int atom2 = 0; double[] q_old = new double[ac.getAtomCount()]; for(int i = 0 ; i < q_old.length ; i++) q_old[0] = 20.0; out: for (int i = 0; i < MX_ITERATIONS; i++) { alpha *= MX_DAMP; boolean isDifferent = false; for (int j = 0; j < ac.getAtomCount(); j++) { q = gasteigerFactors[STEP_SIZE * j + j + 5]; double difference = Math.abs(q_old[j])-Math.abs(q); if(Math.abs(difference) > 0.001) isDifferent = true; q_old[j] = q; gasteigerFactors[STEP_SIZE * j + j + 4] = gasteigerFactors[STEP_SIZE * j + j + 2] * q * q + gasteigerFactors[STEP_SIZE * j + j + 1] * q + gasteigerFactors[STEP_SIZE * j + j]; // logger.debug("g4: "+gasteigerFactors[STEP_SIZE * j + j + 4]); } if(!isDifferent)/* automatically break the maximum iterations*/ break out; // bonds = ac.getBonds(); Iterator bonds = ac.bonds().iterator(); while (bonds.hasNext()) { IBond bond = (IBond) bonds.next(); atom1 = ac.getAtomNumber(bond.getAtom(0)); atom2 = ac.getAtomNumber(bond.getAtom(1)); if (gasteigerFactors[STEP_SIZE * atom1 + atom1 + 4] >= gasteigerFactors[STEP_SIZE * atom2 + atom2 + 4]) { if (ac.getAtom(atom2).getSymbol().equals("H")) { deoc = DEOC_HYDROGEN; } else { deoc = gasteigerFactors[STEP_SIZE * atom2 + atom2 + 3]; } } else { if (ac.getAtom(atom1).getSymbol().equals("H")) { deoc = DEOC_HYDROGEN; } else { deoc = gasteigerFactors[STEP_SIZE * atom1 + atom1 + 3]; } } q = (gasteigerFactors[STEP_SIZE * atom1 + atom1 + 4] - gasteigerFactors[STEP_SIZE * atom2 + atom2 + 4]) / deoc; // logger.debug("qq: "+q); gasteigerFactors[STEP_SIZE * atom1 + atom1 + 5] -= (q*alpha); gasteigerFactors[STEP_SIZE * atom2 + atom2 + 5] += (q*alpha); } } for (int i = 0; i < ac.getAtomCount(); i++) { ac.getAtom(i).setCharge(gasteigerFactors[STEP_SIZE * i + i + 5]); } return ac; } @TestMethod("testCalculateCharges_IAtomContainer") public void calculateCharges(IAtomContainer container) throws CDKException { try { this.assignGasteigerMarsiliSigmaPartialCharges(container, true); } catch (Exception exception) { throw new CDKException( "Could not calculate Gasteiger-Marsili sigma charges: " + exception.getMessage(), exception ); } } /** * Get the StepSize attribute of the GasteigerMarsiliPartialCharges * object * *@return STEP_SIZE */ @TestMethod("testGetStepSize") public int getStepSize(){ return STEP_SIZE; } /** * Set the StepSize attribute of the GasteigerMarsiliPartialCharges * object * *@param step */ @TestMethod("testSetStepSize") public void setStepSize(int step){ STEP_SIZE = step; } /** * Method which stores and assigns the factors a,b,c and CHI+ * *@param ac AtomContainer *@return Array of doubles [a1,b1,c1,denom1,chi1,q1...an,bn,cn...] 1:Atom 1-n in AtomContainer */ @TestMethod("testAssignGasteigerSigmaMarsiliFactors_IAtomContainer") public double[] assignGasteigerSigmaMarsiliFactors(IAtomContainer ac) { //a,b,c,denom,chi,q double[] gasteigerFactors = new double[(ac.getAtomCount() * (STEP_SIZE+1))]; String AtomSymbol = ""; double[] factors = new double[]{0.0, 0.0, 0.0}; for (int i = 0; i < ac.getAtomCount(); i++) { factors[0] = 0.0; factors[1] = 0.0; factors[2] = 0.0; AtomSymbol = ac.getAtom(i).getSymbol(); if (AtomSymbol.equals("H")) { factors[0] = 7.17; factors[1] = 6.24; factors[2] = -0.56; } else if (AtomSymbol.equals("C")) { if ((ac.getMaximumBondOrder(ac.getAtom(i)) == IBond.Order.SINGLE)&& (ac.getAtom(i).getFormalCharge() != -1)){ factors[0] = 7.98; factors[1] = 9.18; factors[2] = 1.88; } else if (ac.getMaximumBondOrder(ac.getAtom(i)) == IBond.Order.DOUBLE ||((ac.getMaximumBondOrder(ac.getAtom(i)) == IBond.Order.SINGLE) && ac.getAtom(i).getFormalCharge() == -1)) { factors[0] = 8.79;/*8.79*//*8.81*/ factors[1] = 9.32;/*9.32*//*9.34*/ factors[2] = 1.51;/*1.51*//*1.52*/ } else if (ac.getMaximumBondOrder(ac.getAtom(i)) == IBond.Order.TRIPLE || ac.getMaximumBondOrder(ac.getAtom(i)) == IBond.Order.QUADRUPLE) { factors[0] = 10.39;/*10.39*/ factors[1] = 9.45;/*9.45*/ factors[2] = 0.73; } } else if(AtomSymbol.equals("N")){ if((ac.getMaximumBondOrder(ac.getAtom(i)) == IBond.Order.SINGLE) && (ac.getAtom(i).getFormalCharge() != -1)) { factors[0] = 11.54; factors[1] = 10.82; factors[2] = 1.36; } else if ((ac.getMaximumBondOrder(ac.getAtom(i)) == IBond.Order.DOUBLE) ||((ac.getMaximumBondOrder(ac.getAtom(i)) == IBond.Order.SINGLE)&& ac.getAtom(i).getFormalCharge() == -1)) { factors[0] = 12.87; factors[1] = 11.15; factors[2] = 0.85; } else if (ac.getMaximumBondOrder(ac.getAtom(i)) == IBond.Order.TRIPLE || ac.getMaximumBondOrder(ac.getAtom(i)) == IBond.Order.QUADRUPLE) { factors[0] = 17.68;/*15.68*/ factors[1] = 12.70;/*11.70*/ factors[2] = -0.27;/*-0.27*/ } } else if (AtomSymbol.equals("O")) { if ((ac.getMaximumBondOrder(ac.getAtom(i)) == IBond.Order.SINGLE) && (ac.getAtom(i).getFormalCharge() != -1)){ factors[0] = 14.18; factors[1] = 12.92; factors[2] = 1.39; } else if((ac.getMaximumBondOrder(ac.getAtom(i)) == IBond.Order.DOUBLE) ||((ac.getMaximumBondOrder(ac.getAtom(i)) == IBond.Order.SINGLE) && ac.getAtom(i).getFormalCharge() == -1)){ factors[0] = 17.07;/* paramaters aren'T correct parametrized. */ factors[1] = 13.79; factors[2] = 0.47;/*0.47*/ } } else if (AtomSymbol.equals("Si")) {// <--not correct factors[0] = 8.10;// <--not correct factors[1] = 7.92;// <--not correct factors[2] = 1.78;// <--not correct } else if (AtomSymbol.equals("P")) { factors[0] = 8.90; factors[1] = 8.32; factors[2] = 1.58; } else if (AtomSymbol.equals("S") /*&& ac.getMaximumBondOrder(ac.getAtomAt(i)) == 1*/) { factors[0] = 10.14;/*10.14*/ factors[1] = 9.13;/*9.13*/ factors[2] = 1.38;/*1.38*/ } else if (AtomSymbol.equals("F")) { factors[0] = 14.66; factors[1] = 13.85; factors[2] = 2.31; } else if (AtomSymbol.equals("Cl")) { factors[0] = 12.31;/*11.0*//*12.31*/ factors[1] = 10.84;/*9.69*//*10.84*/ factors[2] = 1.512;/*1.35*//*1.512*/ } else if (AtomSymbol.equals("Br")) { factors[0] = 11.44;/*10.08*//*11.2*/ factors[1] = 9.63;/*8.47*//*9.4*/ factors[2] = 1.31;/*1.16*//*1.29*/ } else if (AtomSymbol.equals("I")) { factors[0] = 9.88;/*9.90*/ factors[1] = 7.95;/*7.96*/ factors[2] = 0.945;/*0.96*/ } gasteigerFactors[STEP_SIZE * i + i] = factors[0]; gasteigerFactors[STEP_SIZE * i + i + 1] = factors[1]; gasteigerFactors[STEP_SIZE * i + i + 2] = factors[2]; gasteigerFactors[STEP_SIZE * i + i + 5] = ac.getAtom(i).getCharge(); if (factors[0] == 0 && factors[1] == 0 && factors[2] == 0) { gasteigerFactors[STEP_SIZE * i + i + 3] = 1; } else { gasteigerFactors[STEP_SIZE * i + i + 3] = factors[0] + factors[1] + factors[2]; } } return gasteigerFactors; } } cdk-1.2.10/src/main/org/openscience/cdk/charges/GasteigerPEPEPartialCharges.java100644 0 0 101460 11570154753 24550 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2004-2007 Miguel Rojas * * Contact: cdk-devel@list.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. * * 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.charges; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.aromaticity.CDKHueckelAromaticityDetector; import org.openscience.cdk.config.AtomTypeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomContainerSet; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.interfaces.IReactionSet; import org.openscience.cdk.reaction.IReactionProcess; import org.openscience.cdk.reaction.type.HeterolyticCleavagePBReaction; import org.openscience.cdk.reaction.type.HeterolyticCleavageSBReaction; import org.openscience.cdk.reaction.type.HyperconjugationReaction; import org.openscience.cdk.reaction.type.SharingAnionReaction; import org.openscience.cdk.reaction.type.parameters.IParameterReact; import org.openscience.cdk.reaction.type.parameters.SetReactionCenter; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.StructureResonanceGenerator; import org.openscience.cdk.tools.manipulator.AtomContainerManipulator; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** *

The calculation of the Gasteiger (PEPE) partial charges is based on * {@cdk.cite Saller85}. This class doesn't implement the original method of the Marsili but the * method based on H. Saller which is described from Petra manual version 2.6

*

They are calculated by generating all valence bond (resonance) structures * for this system and then weighting them on the basis of pi-orbital electronegativities * and formal considerations based on PEPE (Partial Equalization of pi-electronegativity).

* * @author Miguel Rojas * * @cdk.module charges * @cdk.githash * @cdk.created 2006-05-14 * @cdk.keyword partial atomic charges * @cdk.keyword charge distribution * @cdk.keyword electronegativities, partial equalization of orbital * @cdk.keyword PEPE * @see GasteigerMarsiliPartialCharges */ @TestClass("org.openscience.cdk.charges.GasteigerPEPEPartialChargesTest") public class GasteigerPEPEPartialCharges implements IChargeCalculator { /** max iterations */ private int MX_ITERATIONS = 8; /** max number of resonance structures to be searched*/ private int MX_RESON = 50; private int STEP_SIZE = 5; private AtomTypeFactory factory; /** Flag is set if the formal charge of a chemobject is changed due to resonance.*/ private static int ISCHANGEDFC = 0; /** Corresponds an empirical influence between the electrostatic potential and * the neighbours.*/ private double fE = 1.1;/*1.1*/ /** Scale factor which makes same heavy for all structures*/ private double fS = 0.37; private LoggingTool logger = new LoggingTool(GasteigerPEPEPartialCharges.class); /** * Constructor for the GasteigerPEPEPartialCharges object */ public GasteigerPEPEPartialCharges() { } /** * Sets the maxGasteigerIters attribute of the GasteigerPEPEPartialCharges * object * *@param iters The new maxGasteigerIters value */ @TestMethod("testSetMaxGasteigerIters_Double") public void setMaxGasteigerIters(int iters) { MX_ITERATIONS = iters; } /** * Sets the maximum resonance structures to be searched * *@param numbReson The number of resonance Structures to be searched */ @TestMethod("testSetMaxResoStruc_Int") public void setMaxResoStruc(int numbReson) { MX_RESON = numbReson; } /** * Gets the maxGasteigerIters attribute of the GasteigerPEPEPartialCharges * object * *@return The new maxGasteigerIters value */ @TestMethod("testGetMaxGasteigerIters") public int getMaxGasteigerIters() { return MX_ITERATIONS; } /** * Gets the maximum resonance structures to be searched * * @return the maximum numebr of resonance structures that will be returned */ @TestMethod("testGetMaxResoStruc") public int getMaxResoStruc() { return MX_RESON; } /** * Main method which assigns Gasteiger partial pi charges. * * *@param ac AtomContainer *@param setCharge currently unused *@return AtomContainer with partial charges *@exception Exception Possible Exceptions */ @TestMethod("testAssignGasteigerPiPartialCharges_IAtomContainer_Boolean") public IAtomContainer assignGasteigerPiPartialCharges(IAtomContainer ac, boolean setCharge) throws Exception { // we save the aromaticity flags for the input molecule so that // we can add them back before we return boolean[] oldBondAromaticity = new boolean[ac.getBondCount()]; boolean[] oldAtomAromaticity = new boolean[ac.getAtomCount()]; for (int i = 0; i < ac.getAtomCount(); i++) oldAtomAromaticity[i] = ac.getAtom(i).getFlag(CDKConstants.ISAROMATIC); for (int i = 0; i < ac.getBondCount(); i++) oldBondAromaticity[i] = ac.getBond(i).getFlag(CDKConstants.ISAROMATIC); IAtomContainerSet setHI = null; /*0: remove charge, and possible flag ac*/ for(int j = 0 ; j < ac.getAtomCount(); j++){ ac.getAtom(j).setCharge(0.0); ac.getAtom(j).setFlag(ISCHANGEDFC, false); } for(int j = 0 ; j < ac.getBondCount(); j++){ ac.getBond(j).setFlag(ISCHANGEDFC, false); } /*1: detect resonance structure*/ StructureResonanceGenerator gR1 = new StructureResonanceGenerator();/*according G. should be integrated the breaking bonding*/ List reactionList1 = gR1.getReactions(); List paramList1 = new ArrayList(); IParameterReact param = new SetReactionCenter(); param.setParameter(Boolean.TRUE); paramList1.add(param); HeterolyticCleavagePBReaction reactionHCPB = new HeterolyticCleavagePBReaction(); reactionHCPB.setParameterList(paramList1); reactionList1.add(new SharingAnionReaction()); Iterator itReaction = reactionList1.iterator(); while(itReaction.hasNext()){ IReactionProcess reaction = itReaction.next(); reaction.setParameterList(paramList1); } gR1.setReactions(reactionList1); StructureResonanceGenerator gR2 = new StructureResonanceGenerator();/*according G. should be integrated the breaking bonding*/ gR2.setMaximalStructures(MX_RESON); List reactionList2 = gR2.getReactions(); List paramList = new ArrayList(); IParameterReact paramA = new SetReactionCenter(); paramA.setParameter(Boolean.TRUE); paramList.add(paramA); reactionList2.add(new HeterolyticCleavagePBReaction()); reactionList2.add(new SharingAnionReaction()); itReaction = reactionList2.iterator(); while(itReaction.hasNext()){ IReactionProcess reaction = itReaction.next(); reaction.setParameterList(paramList); } gR2.setReactions(reactionList2); /*find resonance containers, which eliminates the repetitions*/ StructureResonanceGenerator gRN = new StructureResonanceGenerator();/*according G. should be integrated the breaking bonding*/ IAtomContainerSet acSet = gRN.getContainers((IMolecule) removingFlagsAromaticity(ac)); // IAtomContainerSet acSet = ConjugatedPiSystemsDetector.detect(removingFlagsAromaticity(ac)); IMoleculeSet iSet = ac.getBuilder().newMoleculeSet(); iSet.addAtomContainer(ac); if(acSet != null) for(Iterator it = acSet.atomContainers().iterator(); it.hasNext();){ IAtomContainer container = it.next(); ac = setFlags(container, ac, true); // Aromatic don't brake its double bond homolitically if(CDKHueckelAromaticityDetector.detectAromaticity(ac)) reactionList1.remove(reactionHCPB); else reactionList1.add(reactionHCPB); IMoleculeSet a = gR1.getStructures((IMolecule) removingFlagsAromaticity(ac)); if(a.getAtomContainerCount() > 1){ for(int j = 1; j < a.getAtomContainerCount(); j ++){ // the first is already added iSet.addAtomContainer(a.getMolecule(j)); } } ac = setFlags(container, ac, false); /*processing for which bonds which are not in resonance*/ for(int number = 0; number < ac.getBondCount() ; number++){ IAtomContainer aa = setAntiFlags(container,ac, number,true); if(aa != null){ IMoleculeSet ab = gR2.getStructures((IMolecule) aa); if(ab.getAtomContainerCount() > 1) for(int j = 1; j < ab.getAtomContainerCount(); j ++){ // the first is already added iSet.addAtomContainer(ab.getMolecule(j)); } ac = setAntiFlags(container, aa, number, false); } } } /* detect hyperconjugation interactions */ setHI = getHyperconjugationInteractions(ac, iSet); if(setHI != null) { if( setHI.getAtomContainerCount() != 0) iSet.add(setHI); logger.debug("setHI: "+iSet.getAtomContainerCount()); } if (iSet.getAtomContainerCount() < 2) { for (int i = 0; i < ac.getAtomCount(); i++) ac.getAtom(i).setFlag(CDKConstants.ISAROMATIC, oldAtomAromaticity[i]); for (int i = 0; i < ac.getBondCount(); i++) ac.getBond(i).setFlag(CDKConstants.ISAROMATIC, oldBondAromaticity[i]); return ac; } /*2: search whose atoms which don't keep their formal charge and set flags*/ double[][] sumCharges = new double[iSet.getAtomContainerCount()][ac.getAtomCount( )]; for(int i = 1; i < iSet.getAtomContainerCount() ; i++){ IAtomContainer iac = iSet.getAtomContainer(i); for(int j = 0 ; j < iac.getAtomCount(); j++) sumCharges[i][j] = iac.getAtom(j).getFormalCharge(); } for(int i = 1; i < iSet.getAtomContainerCount() ; i++){ IAtomContainer iac = iSet.getAtomContainer(i); int count = 0; for(int j = 0 ; j < ac.getAtomCount(); j++) if(count < 2) if(sumCharges[i][j] != ac.getAtom(j).getFormalCharge()){ ac.getAtom(j).setFlag(ISCHANGEDFC, true); iac.getAtom(j).setFlag(ISCHANGEDFC, true); count++; /* TODO- error*/ } } /*3: set sigma charge (PEOE). Initial start point*/ GasteigerMarsiliPartialCharges peoe = new GasteigerMarsiliPartialCharges();; peoe.setMaxGasteigerIters(6); IAtomContainer acCloned; double[][] gasteigerFactors = assignPiFactors(iSet);//a,b,c,deoc,chi,q /*4: calculate topological weight factors Wt=fQ*fB*fA*/ double[] Wt = new double[iSet.getAtomContainerCount()-1]; for(int i = 1; i < iSet.getAtomContainerCount() ; i++){ Wt[i-1]= getTopologicalFactors(iSet.getAtomContainer(i),ac); logger.debug(", W:"+Wt[i-1]); try { acCloned = (IAtomContainer)iSet.getAtomContainer(i).clone(); acCloned = peoe.assignGasteigerMarsiliSigmaPartialCharges(acCloned, true); for(int j = 0 ; j 0){ gasteigerFactors[k][STEP_SIZE * atom1 + atom1 + 5] = W; }else{ gasteigerFactors[k][STEP_SIZE * atom1 + atom1 + 5] = -1*W; } /* atom2*/ if(iac.getAtom(atom2).getFormalCharge() == 0){ if(ac.getAtom(atom2).getFormalCharge() < 0){ gasteigerFactors[k][STEP_SIZE * atom2 + atom2 + 5] = -1*W; }else{ gasteigerFactors[k][STEP_SIZE * atom2 + atom2 + 5] = W; } }else if(iac.getAtom(atom2).getFormalCharge() > 0){ gasteigerFactors[k][STEP_SIZE * atom2 + atom2 + 5] = W; }else{ gasteigerFactors[k][STEP_SIZE * atom2 + atom2 + 5] = -1*W; } } for(int k = 1 ; k < iSet.getAtomContainerCount() ; k++){ for (int i = 0; i < ac.getAtomCount(); i++) if(iSet.getAtomContainer(k).getAtom(i).getFlag(ISCHANGEDFC)){ double charge = ac.getAtom(i).getCharge(); double chargeT = 0.0; chargeT = charge + gasteigerFactors[k][STEP_SIZE * i + i + 5]; logger.debug("i<|"+ac.getAtom(i).getSymbol()+", "+chargeT+"=c:" +charge + "+g: "+gasteigerFactors[k][STEP_SIZE * i + i + 5]); ac.getAtom(i).setCharge(chargeT); } } }// iterations logger.debug("final"); // before getting back we should set back the aromatic flags for (int i = 0; i < ac.getAtomCount(); i++) ac.getAtom(i).setFlag(CDKConstants.ISAROMATIC, oldAtomAromaticity[i]); for (int i = 0; i < ac.getBondCount(); i++) ac.getBond(i).setFlag(CDKConstants.ISAROMATIC, oldBondAromaticity[i]); return ac; } @TestMethod("testCalculateCharges_IAtomContainer") public void calculateCharges(IAtomContainer container) throws CDKException { try { this.assignGasteigerPiPartialCharges(container, true); } catch (Exception exception) { throw new CDKException( "Could not calculate Gasteiger-Marsili PEPE charges: " + exception.getMessage(), exception ); } } /** * remove the aromaticity flags. * * @param ac The IAtomContainer to remove flags * @return The IATomContainer with the flags removed */ private IAtomContainer removingFlagsAromaticity(IAtomContainer ac) { Iterator atoms = ac.atoms().iterator(); while (atoms.hasNext()) atoms.next().setFlag(CDKConstants.ISAROMATIC, false); Iterator bonds = ac.bonds().iterator(); while (bonds.hasNext()) bonds.next().setFlag(CDKConstants.ISAROMATIC, false); return ac; } /** * Set the Flags to atoms and bonds from an atomContainer. * * @param container Container with the flags * @param ac Container to put the flags * @param b True, if the the flag is true * @return Container with added flags */ private IAtomContainer setFlags(IAtomContainer container, IAtomContainer ac, boolean b) { for(Iterator it = container.atoms().iterator(); it.hasNext();){ int positionA = ac.getAtomNumber(it.next()); ac.getAtom(positionA).setFlag(CDKConstants.REACTIVE_CENTER,b); } for(Iterator it = container.bonds().iterator(); it.hasNext();){ int positionB = ac.getBondNumber(it.next()); ac.getBond(positionB).setFlag(CDKConstants.REACTIVE_CENTER,b); } return ac; } /** * Set the Flags to atoms and bonds which are not contained * in an atomContainer. * * @param container Container with the flags * @param ac Container to put the flags * @param b True, if the the flag is true * @return Container with added flags */ private IAtomContainer setAntiFlags(IAtomContainer container, IAtomContainer ac, int number, boolean b) { IBond bond = ac.getBond(number); if(!container.contains(bond)){ bond.setFlag(CDKConstants.REACTIVE_CENTER,b); bond.getAtom(0).setFlag(CDKConstants.REACTIVE_CENTER,b); bond.getAtom(1).setFlag(CDKConstants.REACTIVE_CENTER,b); }else return null; return ac; } /** * get the possibles structures after hyperconjugation interactions for bonds which * do not belong to any resonance structure. * * @param ac IAtomContainer * @return IAtomContainerSet * @throws CDKException * @throws ClassNotFoundException * @throws IOException */ private IAtomContainerSet getHyperconjugationInteractions(IAtomContainer ac, IAtomContainerSet iSet) throws IOException, ClassNotFoundException, CDKException { IAtomContainerSet set = ac.getBuilder().newAtomContainerSet(); IReactionProcess type = new HeterolyticCleavageSBReaction(); cleanFlagReactiveCenter(ac); boolean found = false; /* control obtained containers */ IMoleculeSet setOfReactants = ac.getBuilder().newMoleculeSet(); /* search of reactive center.*/ out: for(int i = 0 ; i < ac.getBondCount() ; i++){ if(ac.getBond(i).getOrder() != IBond.Order.SINGLE ){ for(int j = 0 ; j < iSet.getAtomContainerCount(); j++){ IAtomContainer ati = iSet.getAtomContainer(j); if(!ati.equals(ac)) for(int k = 0; k < ati.getBondCount(); k++){ IAtom a0 = ati.getBond(k).getAtom(0); IAtom a1 = ati.getBond(k).getAtom(1); if(!a0.getSymbol().equals("H") || !a1.getSymbol().equals("H")) if((a0.getID().equals(ac.getBond(i).getAtom(0).getID()) && a1.getID().equals(ac.getBond(i).getAtom(1).getID())) || (a1.getID().equals(ac.getBond(i).getAtom(0).getID()) && a0.getID().equals(ac.getBond(i).getAtom(1).getID()))){ if(a0.getFormalCharge() != 0 || a1.getFormalCharge() != 0) continue out; } } } ac.getBond(i).getAtom(0).setFlag(CDKConstants.REACTIVE_CENTER,true); ac.getBond(i).getAtom(1).setFlag(CDKConstants.REACTIVE_CENTER,true); ac.getBond(i).setFlag(CDKConstants.REACTIVE_CENTER,true); found = true; } } if(!found) return null; setOfReactants.addMolecule((IMolecule) ac); List paramList = new ArrayList(); IParameterReact param = new SetReactionCenter(); param.setParameter(Boolean.TRUE); paramList.add(param); type.setParameterList(paramList); IReactionSet setOfReactions = type.initiate(setOfReactants, null); for(int i = 0; i < setOfReactions.getReactionCount(); i++){ type = new HyperconjugationReaction(); IMoleculeSet setOfM2 = ac.getBuilder().newMoleculeSet(); IMolecule mol= setOfReactions.getReaction(i).getProducts().getMolecule(0); for(int k = 0; k < mol.getBondCount(); k++){ mol.getBond(k).setFlag(CDKConstants.REACTIVE_CENTER,false); mol.getBond(k).getAtom(0).setFlag(CDKConstants.REACTIVE_CENTER,false); mol.getBond(k).getAtom(1).setFlag(CDKConstants.REACTIVE_CENTER,false); } setOfM2.addMolecule((IMolecule) mol); List paramList2 = new ArrayList(); IParameterReact param2 = new SetReactionCenter(); param2.setParameter(Boolean.FALSE); paramList2.add(param); type.setParameterList(paramList2); IReactionSet setOfReactions2 = type.initiate(setOfM2, null); if(setOfReactions2.getReactionCount() > 0){ IMolecule react = setOfReactions2.getReaction(0).getReactants().getMolecule(0); set.addAtomContainer(react); } } return set; } /** * get the electrostatic potential of the neighbours of a atom. * * @param ac The IAtomContainer to study * @param ds * @param atom1 The position of the IAtom to study * @return The sum of electrostatic potential of the neighbours */ private double getElectrostaticPotentialN(IAtomContainer ac, int atom1, double[] ds) { // double CoulombForceConstant = 1/(4*Math.PI*8.81/*Math.pow(10, -12)*/); double CoulombForceConstant = 0.048; double sum = 0.0; try { if (factory == null) factory = AtomTypeFactory.getInstance( "org/openscience/cdk/config/data/jmol_atomtypes.txt", ac.getBuilder() ); List atoms = ac.getConnectedAtomsList(ac.getAtom(atom1)); for (IAtom atom : atoms) { double covalentradius = 0; String symbol = atom.getSymbol(); IAtomType type = factory.getAtomType(symbol); covalentradius = type.getCovalentRadius(); double charge = ds[STEP_SIZE * atom1 + atom1 + 5]; logger.debug("sum_("+sum+") = CFC("+CoulombForceConstant+")*charge("+charge+"/ret("+covalentradius); sum += CoulombForceConstant * charge / (covalentradius * covalentradius); } } catch (CDKException e) { logger.debug(e); } return sum; } /** * get the topological weight factor for each atomContainer * * @param atomContainer The IAtomContainer to study. * @param ac The IAtomContainer to study. * @return The value */ private double getTopologicalFactors(IAtomContainer atomContainer,IAtomContainer ac) { /*factor for separation of charge*/ int totalNCharge1 = AtomContainerManipulator.getTotalNegativeFormalCharge(atomContainer); int totalPCharge1 = AtomContainerManipulator.getTotalPositiveFormalCharge(atomContainer); double fQ = 1.0; if(totalNCharge1 != 0.0){ fQ = 0.5; for(int i = 0; i < atomContainer.getBondCount(); i++){ IBond bond = atomContainer.getBond(i); if(bond.getAtom(0).getFormalCharge() != 0.0 && bond.getAtom(1).getFormalCharge() != 0.0){ fQ = 0.25; break; } } } /*factor, if the number of covalents bonds is decreased*/ double fB = 1.0; int numBond1 = 0; int numBond2 = 0; for (int i = 0; i < atomContainer.getBondCount(); i++) { if (atomContainer.getBond(i).getOrder() == IBond.Order.DOUBLE) numBond1 += 1; if (ac.getBond(i).getOrder() == IBond.Order.DOUBLE) numBond2 += 1; } if(numBond1 */ numBond2) fB = 0.8; double fPlus = 1.0; if(totalNCharge1 == 0.0 && totalPCharge1 == 0.0 ) fPlus = 0.1; /*aromatic*/ double fA = 1.0; try { if(CDKHueckelAromaticityDetector.detectAromaticity(ac)) if(!CDKHueckelAromaticityDetector.detectAromaticity(atomContainer)) fA = 0.3; } catch (CDKException e) { e.printStackTrace(); } logger.debug("return "+fQ*fB*fPlus*fA+"= sp:"+fQ+", dc:"+fB+", fPlus:"+fPlus+", fA:"+fA); return fQ*fB*fPlus*fA; } /** * Get the StepSize attribute of the GasteigerMarsiliPartialCharges * object * *@return STEP_SIZE */ @TestMethod("testGetStepSize") public int getStepSize(){ return STEP_SIZE; } /** * Set the StepSize attribute of the GasteigerMarsiliPartialCharges * object * *@param step */ @TestMethod("testSetStepSize") public void setStepSize(int step){ STEP_SIZE = step; } /** * Method which stores and assigns the factors a,b,c and CHI+ * * @return Array of doubles [a1,b1,c1,denom1,chi1,q1...an,bn,cn...] 1:Atom 1-n in AtomContainer */ private double[][] assignPiFactors(IAtomContainerSet setAc) { //a,b,c,denom,chi,q double[][] gasteigerFactors = new double[setAc.getAtomContainerCount()][(setAc.getAtomContainer(0).getAtomCount() * (STEP_SIZE+1))]; String AtomSymbol = ""; double[] factors = new double[]{0.0, 0.0, 0.0}; for( int k = 1 ; k < setAc.getAtomContainerCount(); k ++){ IAtomContainer ac = setAc.getAtomContainer(k); for (int i = 0; i < ac.getAtomCount(); i++) { factors[0] = 0.0; factors[1] = 0.0; factors[2] = 0.0; AtomSymbol = ac.getAtom(i).getSymbol(); if (AtomSymbol.equals("H")) { factors[0] = 0.0; factors[1] = 0.0; factors[2] = 0.0; } else if (AtomSymbol.equals("C")) {/* if(ac.getAtom(i).getFlag(ISCHANGEDFC))*/{ factors[0] = 5.60; factors[1] = 8.93; factors[2] = 2.94; } } else if (AtomSymbol.equals("O")) { if(ac.getMaximumBondOrder(ac.getAtom(i)) == IBond.Order.SINGLE){ factors[0] = 10.0; factors[1] = 13.86; factors[2] = 9.68; }else { factors[0] = 7.91; factors[1] = 14.76; factors[2] = 6.85; } } else if (AtomSymbol.equals("N")) { if(ac.getMaximumBondOrder(ac.getAtom(i)) != IBond.Order.SINGLE){ factors[0] = 7.95;/*7.95*/ factors[1] = 9.73;/*9.73*/ factors[2] = 2.67;/*2.67*/ }else { factors[0] = 4.54;/*4.54*//*5.5*/ factors[1] = 11.86;/*11.86*//*10.86*/ factors[2] = 7.32;/*7.32*//*7.99*/ } } else if (AtomSymbol.equals("S")) { if(ac.getMaximumBondOrder(ac.getAtom(i)) == IBond.Order.SINGLE){ factors[0] = 7.73; factors[1] = 8.16; factors[2] = 1.81; }else { factors[0] = 6.60; factors[1] = 10.32; factors[2] = 3.72; } } else if (AtomSymbol.equals("F")) { factors[0] = 7.34; factors[1] = 13.86; factors[2] = 9.68; } else if (AtomSymbol.equals("Cl")) { factors[0] = 6.50; factors[1] = 11.02; factors[2] = 4.52; } else if (AtomSymbol.equals("Br")) { factors[0] = 5.20; factors[1] = 9.68; factors[2] = 4.48; } else if (AtomSymbol.equals("I")) { factors[0] = 4.95; factors[1] = 8.81; factors[2] = 3.86; } gasteigerFactors[k][STEP_SIZE * i + i] = factors[0]; gasteigerFactors[k][STEP_SIZE * i + i + 1] = factors[1]; gasteigerFactors[k][STEP_SIZE * i + i + 2] = factors[2]; gasteigerFactors[k][STEP_SIZE * i + i + 5] = ac.getAtom(i).getCharge(); if (factors[0] == 0 && factors[1] == 0 && factors[2] == 0) { gasteigerFactors[k][STEP_SIZE * i + i + 3] = 1; } else { gasteigerFactors[k][STEP_SIZE * i + i + 3] = factors[0] + factors[1] + factors[2]; } } } return gasteigerFactors; } /** * Method which stores and assigns the factors a,b,c and CHI+ * *@return Array of doubles [a1,b1,c1,denom1,chi1,q1...an,bn,cn...] 1:Atom 1-n in AtomContainer */ @TestMethod("testAssignrPiMarsilliFactors_IAtomContainerSet") public double[][] assignrPiMarsilliFactors(IAtomContainerSet setAc) { //a,b,c,denom,chi,q double[][] gasteigerFactors = new double[setAc.getAtomContainerCount()][(setAc.getAtomContainer(0).getAtomCount() * (STEP_SIZE+1))]; String AtomSymbol = ""; double[] factors = new double[]{0.0, 0.0, 0.0}; for( int k = 1 ; k < setAc.getAtomContainerCount(); k ++){ IAtomContainer ac = setAc.getAtomContainer(k); for (int i = 0; i < ac.getAtomCount(); i++) { factors[0] = 0.0; factors[1] = 0.0; factors[2] = 0.0; AtomSymbol = ac.getAtom(i).getSymbol(); if (AtomSymbol.equals("H")) { factors[0] = 0.0; factors[1] = 0.0; factors[2] = 0.0; } else if (AtomSymbol.equals("C")) { factors[0] = 5.98;/*5.98-5.60*/ factors[1] = 7.93;/*7.93-8.93*/ factors[2] = 1.94; } else if (AtomSymbol.equals("O")) { if(ac.getMaximumBondOrder(ac.getAtom(i)) != IBond.Order.SINGLE){ factors[0] = 11.2;/*11.2-10.0*/ factors[1] = 13.24;/*13.24-13.86*/ factors[2] = 9.68; }else { factors[0] = 7.91; factors[1] = 14.76; factors[2] = 6.85; } } else if (AtomSymbol.equals("N")) { if(ac.getMaximumBondOrder(ac.getAtom(i)) != IBond.Order.SINGLE){ factors[0] = 8.95;/*7.95*/ factors[1] = 9.73;/*9.73*/ factors[2] = 2.67;/*2.67*/ }else { factors[0] = 4.54; factors[1] = 11.86; factors[2] = 7.32; } } else if (AtomSymbol.equals("P")) {// <--No correct if(ac.getMaximumBondOrder(ac.getAtom(i)) != IBond.Order.SINGLE){ factors[0] = 10.73;// <--No correct factors[1] = 11.16;// <--No correct factors[2] = 6.81;// <--No correct }else { factors[0] = 9.60;// <--No correct factors[1] = 13.32;// <--No correct factors[2] = 2.72;// <--No correct } } else if (AtomSymbol.equals("S")) { if(ac.getMaximumBondOrder(ac.getAtom(i)) != IBond.Order.SINGLE){ factors[0] = 7.73; factors[1] = 8.16; factors[2] = 1.81; }else { factors[0] = 6.60; factors[1] = 10.32; factors[2] = 3.72; } } else if (AtomSymbol.equals("F")) { factors[0] = 7.14/*7.34*/; factors[1] = 13.86; factors[2] = 5.68; } else if (AtomSymbol.equals("Cl")) { factors[0] = 6.51;/*6.50*/ factors[1] = 11.02; factors[2] = 4.52; } else if (AtomSymbol.equals("Br")) { factors[0] = 5.20; factors[1] = 9.68; factors[2] = 4.48; } else if (AtomSymbol.equals("I")) { factors[0] = 4.95; factors[1] = 8.81; factors[2] = 3.86; } gasteigerFactors[k][STEP_SIZE * i + i] = factors[0]; gasteigerFactors[k][STEP_SIZE * i + i + 1] = factors[1]; gasteigerFactors[k][STEP_SIZE * i + i + 2] = factors[2]; gasteigerFactors[k][STEP_SIZE * i + i + 5] = ac.getAtom(i).getCharge(); if (factors[0] == 0 && factors[1] == 0 && factors[2] == 0) { gasteigerFactors[k][STEP_SIZE * i + i + 3] = 1; } else { gasteigerFactors[k][STEP_SIZE * i + i + 3] = factors[0] + factors[1] + factors[2]; } } } return gasteigerFactors; } /** * clean the flags CDKConstants.REACTIVE_CENTER from the molecule * * @param ac */ private void cleanFlagReactiveCenter(IAtomContainer ac){ for(int j = 0 ; j < ac.getAtomCount(); j++) ac.getAtom(j).setFlag(CDKConstants.REACTIVE_CENTER, false); for(int j = 0 ; j < ac.getBondCount(); j++) ac.getBond(j).setFlag(CDKConstants.REACTIVE_CENTER, false); } } cdk-1.2.10/src/main/org/openscience/cdk/charges/IChargeCalculator.java100644 0 0 2306 11570154753 22625 0ustar 0 0 /* $Revision: 10248 $ $Author: egonw $ $Date: 2008-02-26 11:12:38 +0100 (Tue, 26 Feb 2008) $ * * Copyright (C) 2008 Egon Willighagen * * Contact: cdk-devel@list.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. * * 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.charges; /** * Interface for classes that calculate (partial) charges centered * on atom nuclei. * * @author egonw * @cdk.module charges * @cdk.githash */ public interface IChargeCalculator extends IElectronicPropertyCalculator { } cdk-1.2.10/src/main/org/openscience/cdk/charges/IElectronicPropertyCalculator.java100644 0 0 2545 11570154753 25275 0ustar 0 0 /* $Revision: 10248 $ $Author: egonw $ $Date: 2008-02-26 11:12:38 +0100 (Tue, 26 Feb 2008) $ * * Copyright (C) 2008 Egon Willighagen * * Contact: cdk-devel@list.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. * * 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.charges; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtomContainer; /** * Interface for classes that calculate (partial) charges centered * on atom nuclei. * * @author egonw * @cdk.module charges * @cdk.githash */ public interface IElectronicPropertyCalculator { public void calculateCharges(IAtomContainer container) throws CDKException; } cdk-1.2.10/src/main/org/openscience/cdk/charges/InductivePartialCharges.java100644 0 0 34142 11570154753 24100 0ustar 0 0 /* * $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project * * Contact: cdk-devel@list.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. * * 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.charges; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.AtomTypeFactory; import org.openscience.cdk.config.IsotopeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.*; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.manipulator.AtomContainerManipulator; import javax.vecmath.Point3d; import java.io.IOException; /** * The calculation of the inductive partial atomic charges and equalization of * effective electronegativities is based on {@cdk.cite CHE03}. * * @author mfe4 * @cdk.module charges * @cdk.githash * @cdk.created 2004-11-03 * @cdk.keyword partial atomic charges * @cdk.keyword charge distribution * @cdk.keyword electronegativity */ @TestClass("org.openscience.cdk.charges.InductivePartialChargesTest") public class InductivePartialCharges implements IChargeCalculator { private static double[] pauling; private IsotopeFactory ifac = null; private AtomTypeFactory factory = null; private LoggingTool logger; /** * Constructor for the InductivePartialCharges object * *@exception IOException Description of the Exception *@exception ClassNotFoundException Description of the Exception */ public InductivePartialCharges() throws IOException, ClassNotFoundException { if (pauling == null) { // pauling ElEn : // second position is H, last is Ac pauling = new double[]{0, 2.1, 0, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5, 4.0, 0, 0.9, 1.2, 1.5, 1.8, 2.1, 2.5, 3.0, 0, 0.8, 1.0, 1.3, 1.5, 1.6, 1.6, 1.5, 1.8, 1.8, 1.8, 1.9, 1.6, 1.6, 1.8, 2.0, 2.4, 2.8, 0, 0.8, 1.0, 1.3, 1.4, 1.6, 1.8, 1.9, 2.2, 2.2, 2.2, 1.9, 1.7, 1.7, 1.8, 1.9, 2.1, 2.5, 0.7, 0.9, 1.1, 1.3, 1.5, 1.7, 1.9, 2.2, 2.2, 2.2, 2.4, 1.9, 1.8, 1.8, 1.9, 2.0, 2.2, 0, 0.7, 0.9, 1.1}; } logger = new LoggingTool(this); } /** * Main method, set charge as atom properties * *@param ac AtomContainer *@return AtomContainer *@exception Exception Description of the Exception */ @TestMethod("testInductivePartialCharges") public IAtomContainer assignInductivePartialCharges(IAtomContainer ac) throws Exception { if (factory == null) { factory = AtomTypeFactory.getInstance("org/openscience/cdk/config/data/jmol_atomtypes.txt", ac.getBuilder()); } int stepsLimit = 9; IAtom[] atoms = AtomContainerManipulator.getAtomArray(ac); double[] pChInch = new double[atoms.length * (stepsLimit + 1)]; double[] ElEn = new double[atoms.length * (stepsLimit + 1)]; double[] pCh = new double[atoms.length * (stepsLimit + 1)]; double[] startEE = getPaulingElectronegativities(ac, true); for (int e = 0; e < atoms.length; e++) { ElEn[e] = startEE[e]; //logger.debug("INDU: initial EE "+startEE[e]); } //double tmp1 = 0; //double tmp2 = 0; for (int s = 1; s < 10; s++) { for (int a = 0; a < atoms.length; a++) { pChInch[a + (s * atoms.length)] = getAtomicChargeIncrement(ac, a, ElEn, s); pCh[a + (s * atoms.length)] = pChInch[a + (s * atoms.length)] + pCh[a + ((s-1) * atoms.length)]; ElEn[a + (s * atoms.length)] = ElEn[a + ((s - 1) * atoms.length)] + (pChInch[a + (s * atoms.length)] / getAtomicSoftnessCore(ac, a)); if (s == 9) { atoms[a].setProperty("InductivePartialCharge", new Double(pCh[a + (s * atoms.length)])); atoms[a].setProperty("EffectiveAtomicElectronegativity", new Double(ElEn[a + (s * atoms.length)])); } //tmp1 = pCh[a + (s * atoms.length)]; //tmp2 = ElEn[a + (s * atoms.length)]; //logger.debug("DONE step " + s + ", atom " + atoms[a].getSymbol() + ", ch " + tmp1 + ", ee " + tmp2); } } return ac; } @TestMethod("testCalculateCharges_IAtomContainer") public void calculateCharges(IAtomContainer container) throws CDKException { try { this.assignInductivePartialCharges(container); } catch (Exception exception) { throw new CDKException( "Could not calculate inductive partial charges: " + exception.getMessage(), exception ); } } /** * Gets the paulingElectronegativities attribute of the * InductivePartialCharges object * *@param ac AtomContainer *@param modified if true, some values are modified by following the reference *@return The pauling electronegativities *@exception Exception Description of the Exception */ @TestMethod("testGetPaulingElectronegativities") public double[] getPaulingElectronegativities(IAtomContainer ac, boolean modified) throws CDKException { double[] paulingElectronegativities = new double[ac.getAtomCount()]; IElement element = null; String symbol = null; int atomicNumber = 0; try { ifac = IsotopeFactory.getInstance(ac.getBuilder()); for (int i = 0; i < ac.getAtomCount(); i++) { IAtom atom = ac.getAtom(i); symbol = ac.getAtom(i).getSymbol(); element = ifac.getElement(symbol); atomicNumber = element.getAtomicNumber(); if (modified) { if (symbol.equals("Cl")) { paulingElectronegativities[i] = 3.28; } else if (symbol.equals("Br")) { paulingElectronegativities[i] = 3.13; } else if (symbol.equals("I")) { paulingElectronegativities[i] = 2.93; } else if (symbol.equals("H")) { paulingElectronegativities[i] = 2.10; } else if (symbol.equals("C")) { if (ac.getMaximumBondOrder(atom) == IBond.Order.SINGLE) { // Csp3 paulingElectronegativities[i] = 2.20; } else if (ac.getMaximumBondOrder(atom) == IBond.Order.DOUBLE) { paulingElectronegativities[i] = 2.31; } else { paulingElectronegativities[i] = 3.15; } } else if (symbol.equals("O")) { if (ac.getMaximumBondOrder(atom) == IBond.Order.SINGLE) { // Osp3 paulingElectronegativities[i] = 3.20; } else if (ac.getMaximumBondOrder(atom) != IBond.Order.SINGLE) { paulingElectronegativities[i] = 4.34; } } else if (symbol.equals("Si")) { paulingElectronegativities[i] = 1.99; } else if (symbol.equals("S")) { paulingElectronegativities[i] = 2.74; } else if (symbol.equals("N")) { paulingElectronegativities[i] = 2.59; } else { paulingElectronegativities[i] = pauling[atomicNumber]; } } else { paulingElectronegativities[i] = pauling[atomicNumber]; } } return paulingElectronegativities; } catch (Exception ex1) { logger.debug(ex1); throw new CDKException("Problems with IsotopeFactory due to " + ex1.toString(), ex1); } } /** * Gets the atomicSoftnessCore attribute of the InductivePartialCharges object * *@param ac AtomContainer *@param atomPosition position of target atom *@return The atomicSoftnessCore value *@exception CDKException Description of the Exception */ // this method returns the result of the core of the equation of atomic softness // that can be used for qsar descriptors and during the iterative calculation // of effective electronegativity @TestMethod("testGetAtomicSoftness") public double getAtomicSoftnessCore(IAtomContainer ac, int atomPosition) throws CDKException { if (factory == null) { factory = AtomTypeFactory.getInstance("org/openscience/cdk/config/data/jmol_atomtypes.txt", ac.getBuilder()); } IAtom target = null; double core = 0; double radiusTarget = 0; target = ac.getAtom(atomPosition); double partial = 0; double radius = 0; String symbol = null; IAtomType type = null; try { symbol = ac.getAtom(atomPosition).getSymbol(); type = factory.getAtomType(symbol); if (getCovalentRadius(symbol, ac.getMaximumBondOrder(target)) > 0) { radiusTarget = getCovalentRadius(symbol, ac.getMaximumBondOrder(target)); } else { radiusTarget = type.getCovalentRadius(); } } catch (Exception ex1) { logger.debug(ex1); throw new CDKException("Problems with AtomTypeFactory due to " + ex1.getMessage(), ex1 ); } java.util.Iterator atoms = ac.atoms().iterator(); while (atoms.hasNext()) { IAtom atom = (IAtom)atoms.next(); if (!target.equals(atom)) { symbol = atom.getSymbol(); partial = 0; try { type = factory.getAtomType(symbol); } catch (Exception ex1) { logger.debug(ex1); throw new CDKException("Problems with AtomTypeFactory due to " + ex1.getMessage(), ex1); } if (getCovalentRadius(symbol, ac.getMaximumBondOrder(atom)) > 0) { radius = getCovalentRadius(symbol, ac.getMaximumBondOrder(atom)); } else { radius = type.getCovalentRadius(); } partial += radius * radius; partial += (radiusTarget * radiusTarget); partial = partial / (calculateSquaredDistanceBetweenTwoAtoms(target, atom)); core += partial; } } core = 2 * core; core = 0.172 * core; return core; } // this method returns the partial charge increment for a given atom /** * Gets the atomicChargeIncrement attribute of the InductivePartialCharges * object * *@param ac AtomContainer *@param atomPosition position of target atom *@param ElEn electronegativity of target atom *@param as step in iteration *@return The atomic charge increment fot the target atom *@exception CDKException Description of the Exception */ private double getAtomicChargeIncrement(IAtomContainer ac, int atomPosition, double[] ElEn, int as) throws CDKException { IAtom[] allAtoms = null; IAtom target = null; double incrementedCharge = 0; double radiusTarget = 0; target = ac.getAtom(atomPosition); //logger.debug("ATOM "+target.getSymbol()+" AT POSITION "+atomPosition); allAtoms = AtomContainerManipulator.getAtomArray(ac); double tmp = 0; double radius = 0; String symbol = null; IAtomType type = null; try { symbol = target.getSymbol(); type = factory.getAtomType(symbol); if (getCovalentRadius(symbol, ac.getMaximumBondOrder(target)) > 0) { radiusTarget = getCovalentRadius(symbol, ac.getMaximumBondOrder(target)); } else { radiusTarget = type.getCovalentRadius(); } } catch (Exception ex1) { logger.debug(ex1); throw new CDKException("Problems with AtomTypeFactory due to " + ex1.getMessage(), ex1); } for (int a = 0; a < allAtoms.length; a++) { if (!target.equals(allAtoms[a])) { tmp = 0; symbol = allAtoms[a].getSymbol(); try { type = factory.getAtomType(symbol); } catch (Exception ex1) { logger.debug(ex1); throw new CDKException("Problems with AtomTypeFactory due to " + ex1.getMessage(), ex1); } if (getCovalentRadius(symbol, ac.getMaximumBondOrder(allAtoms[a])) > 0) { radius = getCovalentRadius(symbol, ac.getMaximumBondOrder(allAtoms[a])); } else { radius = type.getCovalentRadius(); } tmp = (ElEn[a + ((as - 1) * allAtoms.length)] - ElEn[atomPosition + ((as - 1) * allAtoms.length)]); tmp = tmp * ((radius * radius) + (radiusTarget * radiusTarget)); tmp = tmp / (calculateSquaredDistanceBetweenTwoAtoms(target, allAtoms[a])); incrementedCharge += tmp; //if(actualStep==1) //logger.debug("INDU: particular atom "+symbol+ ", radii: "+ radius+ " - " + radiusTarget+", dist: "+calculateSquaredDistanceBetweenTwoAtoms(target, allAtoms[a])); } } incrementedCharge = 0.172 * incrementedCharge; //logger.debug("Increment: " +incrementedCharge); return incrementedCharge; } /** * Gets the covalentRadius attribute of the InductivePartialCharges object * *@param symbol symbol of the atom *@param maxBondOrder its max bond order *@return The covalentRadius value given by the reference */ private double getCovalentRadius(String symbol, IBond.Order maxBondOrder) { double radiusTarget = 0; if (symbol.equals("F")) { radiusTarget = 0.64; } else if (symbol.equals("Cl")) { radiusTarget = 0.99; } else if (symbol.equals("Br")) { radiusTarget = 1.14; } else if (symbol.equals("I")) { radiusTarget = 1.33; } else if (symbol.equals("H")) { radiusTarget = 0.30; } else if (symbol.equals("C")) { if (maxBondOrder == IBond.Order.SINGLE) { // Csp3 radiusTarget = 0.77; } else if (maxBondOrder == IBond.Order.DOUBLE) { radiusTarget = 0.67; } else { radiusTarget = 0.60; } } else if (symbol.equals("O")) { if (maxBondOrder == IBond.Order.SINGLE) { // Csp3 radiusTarget = 0.66; } else if (maxBondOrder != IBond.Order.SINGLE) { radiusTarget = 0.60; } } else if (symbol.equals("Si")) { radiusTarget = 1.11; } else if (symbol.equals("S")) { radiusTarget = 1.04; } else if (symbol.equals("N")) { radiusTarget = 0.70; } else { radiusTarget = 0; } return radiusTarget; } /** * Evaluate the square of the Euclidean distance between two atoms. * *@param atom1 first atom *@param atom2 second atom *@return squared distance between the 2 atoms */ private double calculateSquaredDistanceBetweenTwoAtoms(IAtom atom1, IAtom atom2) { double distance = 0; double tmp = 0; Point3d firstPoint = atom1.getPoint3d(); Point3d secondPoint = atom2.getPoint3d(); tmp = firstPoint.distance(secondPoint);distance = tmp * tmp; return distance; } } cdk-1.2.10/src/main/org/openscience/cdk/charges/MMFF94PartialCharges.java100644 0 0 12543 11570154753 23051 0ustar 0 0 /* $RCSfile$ * $Revision$ $Author$ $Date$ * * Copyright (C) 2004-2008 The Chemistry Development Kit (CDK) project * * Contact: cdk-devel@list.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. * * 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.charges; import java.util.Map; import java.util.List; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.modeling.builder3d.ForceFieldConfigurator; /** * The calculation of the MMFF94 partial charges. * Charges are stored as atom properties: * for an AtomContainer ac, values are calculated with: *
 *  HydrogenAdder hAdder = new HydrogenAdder();
 *  SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
 *  IAtomContainer ac = sp.parseSmiles("CC");
 *  hAdder.addExplicitHydrogensToSatisfyValency((Molecule)ac);
 *  MMFF94PartialCharges mmff = new MMFF94PartialCharges();
 *  mmff.assignMMFF94PartialCharges(ac);
 *  
* and for each atom, the value is given by: *
 *  ( (Double)atom.getProperty("MMFF94charge") ).doubleValue().
 *  
* * @author mfe4 * @author chhoppe * @cdk.created 2004-11-03 * @cdk.module forcefield * @cdk.githash */ public class MMFF94PartialCharges implements IChargeCalculator { /** * Constructor for the MMFF94PartialCharges object */ public MMFF94PartialCharges() { } /** * Main method which assigns MMFF94 partial charges * *@param ac AtomContainer *@return AtomContainer with MMFF94 partial charges as atom properties *@exception Exception Possible Exceptions */ public IAtomContainer assignMMFF94PartialCharges(IAtomContainer ac) throws Exception { ForceFieldConfigurator ffc = new ForceFieldConfigurator(); ffc.setForceFieldConfigurator("mmff94"); ffc.assignAtomTyps((IMolecule)ac); Map parameterSet = ffc.getParameterSet(); // for this calculation, // we need some values stored in the vector "data" in the // hashtable of these atomTypes: double charge = 0; double formalCharge = 0; double formalChargeNeigh = 0; double theta = 0; double sumOfFormalCharges = 0; double sumOfBondIncrements = 0; IAtom thisAtom = null; List neighboors; Object data = null; Object bondData = null; Object dataNeigh = null; java.util.Iterator atoms = ac.atoms().iterator(); while(atoms.hasNext()) { //logger.debug("ATOM "+i+ " " +atoms[i].getSymbol()); thisAtom = atoms.next(); data = parameterSet.get("data"+thisAtom.getAtomTypeName()); neighboors = ac.getConnectedAtomsList(thisAtom); formalCharge = thisAtom.getCharge(); theta = (Double)((List)data).get(5); charge = formalCharge * (1 - (neighboors.size() * theta)); sumOfFormalCharges = 0; sumOfBondIncrements = 0; for (IAtom neighboor : neighboors) { IAtom neighbour = (IAtom) neighboor; dataNeigh = parameterSet.get("data" + neighbour.getAtomTypeName()); if (parameterSet.containsKey("bond" + thisAtom.getAtomTypeName() + ";" + neighbour.getAtomTypeName())) { bondData = parameterSet.get("bond" + thisAtom.getAtomTypeName() + ";" + neighbour.getAtomTypeName()); sumOfBondIncrements -= (Double) ((List)bondData).get(4); } else if (parameterSet.containsKey("bond" + neighbour.getAtomTypeName() + ";" + thisAtom.getAtomTypeName())) { bondData = parameterSet.get("bond" + neighbour.getAtomTypeName() + ";" + thisAtom.getAtomTypeName()); sumOfBondIncrements += (Double) ((List)bondData).get(4); } else { // Maybe not all bonds have pbci in mmff94.prm, i.e. C-N sumOfBondIncrements += (theta - (Double) ((List)dataNeigh).get(5)); } dataNeigh = parameterSet.get("data" + neighbour.getID()); formalChargeNeigh = neighbour.getCharge(); sumOfFormalCharges += formalChargeNeigh; } charge += sumOfFormalCharges * theta; charge += sumOfBondIncrements; thisAtom.setProperty("MMFF94charge", charge); //logger.debug( "CHARGE :"+thisAtom.getProperty("MMFF94charge") ); } return ac; } public void calculateCharges(IAtomContainer container) throws CDKException { try { assignMMFF94PartialCharges(container); } catch (Exception exception) { throw new CDKException( "Could not calculate MMFF94 partial charges: " + exception.getMessage(), exception ); } } } cdk-1.2.10/src/main/org/openscience/cdk/charges/PiElectronegativity.java100644 0 0 14260 11570154753 23325 0ustar 0 0 /* $Revision: 10199 $ $Author: rajarshi $ $Date: 2008-02-21 19:19:31 +0100 (Thu, 21 Feb 2008) $ * * Copyright (C) 2008 Miguel Rojas * * Contact: cdk-devel@list.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. * * 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.charges; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomContainerSet; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IMolecule; /** * Calculation of the electronegativity of orbitals of a molecule * by the method Gasteiger based on electronegativity is given by X = a + bq + c(q*q). * * @author Miguel Rojas Cherto * @cdk.created 2008-104-31 * @cdk.module charges * @cdk.keyword electronegativity */ @TestClass("org.openscience.cdk.charges.PiElectronegativityTest") public class PiElectronegativity { private GasteigerMarsiliPartialCharges peoe = null; private GasteigerPEPEPartialCharges pepe = null; /**Number of maximum iterations*/ private int maxI = 6; /**Number of maximum resonance structures*/ private int maxRS = 50; private IMolecule molPi; private IAtomContainer acOldP; private double[][] gasteigerFactors; /** * Constructor for the PiElectronegativity object. */ public PiElectronegativity() { this(6, 50); } /** * Constructor for the Electronegativity object. * * @param maxIterations The maximal number of Iteration * @param maxResonStruc The maximal number of Resonance Structures */ public PiElectronegativity( int maxIterations, int maxResonStruc) { peoe = new GasteigerMarsiliPartialCharges(); pepe = new GasteigerPEPEPartialCharges(); maxI = maxIterations; maxRS = maxResonStruc; } /** * calculate the electronegativity of orbitals pi. * * @param ac IAtomContainer * @param atom atom for which effective atom electronegativity should be calculated * * @return piElectronegativity */ @TestMethod("testCalculatePiElectronegativity_IAtomContainer_IAtom") public double calculatePiElectronegativity(IAtomContainer ac, IAtom atom){ return calculatePiElectronegativity(ac, atom, maxI, maxRS); } /** * calculate the electronegativity of orbitals pi. * * @param ac IAtomContainer * @param atom atom for which effective atom electronegativity should be calculated * @param maxIterations The maximal number of Iteration * @param maxResonStruc The maximal number of Resonance Structures * * @return piElectronegativity */ @TestMethod("testCalculatePiElectronegativity_IAtomContainer_IAtom_Int_Int") public double calculatePiElectronegativity(IAtomContainer ac, IAtom atom, int maxIterations, int maxResonStruc) { maxI = maxIterations; maxRS = maxResonStruc; double electronegativity = 0; try { if(!ac.equals(acOldP)){ molPi = ac.getBuilder().newMolecule(ac); peoe = new GasteigerMarsiliPartialCharges(); peoe.assignGasteigerMarsiliSigmaPartialCharges(molPi, true); IAtomContainerSet iSet = ac.getBuilder().newAtomContainerSet(); iSet.addAtomContainer(molPi); iSet.addAtomContainer(molPi); gasteigerFactors = pepe.assignrPiMarsilliFactors(iSet); acOldP = ac; } IAtom atomi = molPi.getAtom(ac.getAtomNumber(atom)); int atomPosition = molPi.getAtomNumber(atomi); int stepSize = pepe.getStepSize(); int start = (stepSize * (atomPosition) + atomPosition); double q = atomi.getCharge(); if(molPi.getConnectedLonePairsCount(molPi.getAtom(atomPosition)) > 0 || molPi.getMaximumBondOrder(atomi) != IBond.Order.SINGLE || atomi.getFormalCharge() != 0){ return ((gasteigerFactors[1][start]) + (q * gasteigerFactors[1][start + 1]) + (gasteigerFactors[1][start + 2] * (q * q))); } } catch (Exception e) { e.printStackTrace(); } return electronegativity; } /** * set the maximal number of Iterations. * * @param maxIterations The number maximal of iterations */ @TestMethod("testSetMaxIterations_Int") public void setMaxIterations(int maxIterations){ maxI = maxIterations; } /** * set the maximal number of resonance structures. * * @param maxResonStruc The number maximal of resonance structures */ @TestMethod("testSetMaxResonStruc_Int") public void setMaxResonStruc(int maxResonStruc){ maxRS = maxResonStruc; } /** * get the maximal number of Iterations. * * @return The number maximal of iterations */ @TestMethod("testGetMaxIterations") public int getMaxIterations(){ return maxI; } /** * get the maximal number of resonance structures. * * @return The number maximal of resonance structures */ @TestMethod("testGetMaxResonStruc") public int getMaxResonStruc(){ return maxRS; } } cdk-1.2.10/src/main/org/openscience/cdk/charges/Polarizability.java100644 0 0 33007 11570154753 22331 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Christian Hoppe * * Contact: cdk-devel@list.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. * * 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.charges; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.Molecule; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.atomtype.CDKAtomTypeMatcher; import org.openscience.cdk.graph.PathTools; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.tools.CDKHydrogenAdder; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.manipulator.AtomContainerManipulator; import org.openscience.cdk.tools.manipulator.AtomTypeManipulator; /** * Calculation of the polarizability of a molecule by the method of Kang and * Jhon and Gasteiger based on {@cdk.cite KJ81} and {@cdk.cite GH82} * Limitations in parameterization of atoms: * H, Csp3, Csp2, Csp2arom, Csp3, Nsp3, Nsp2, Nsp3, * P, Osp3 and Osp2. Aromaticity must be calculated beforehand. * * @author chhoppe * @cdk.githash * @cdk.created 2004-11-03 * @cdk.keyword polarizability * @cdk.module charges */ @TestClass("org.openscience.cdk.charges.PolarizabilityTest") public class Polarizability { private LoggingTool logger; /** * Constructor for the Polarizability object */ public Polarizability() { logger = new LoggingTool(this); } private void addExplicitHydrogens(IAtomContainer container) { try { CDKAtomTypeMatcher matcher = CDKAtomTypeMatcher.getInstance(container.getBuilder()); Iterator atoms = container.atoms().iterator(); while (atoms.hasNext()) { IAtom atom = atoms.next(); IAtomType type = matcher.findMatchingAtomType(container, atom); AtomTypeManipulator.configure(atom, type); } CDKHydrogenAdder hAdder = CDKHydrogenAdder.getInstance(container.getBuilder()); hAdder.addImplicitHydrogens(container); AtomContainerManipulator.convertImplicitToExplicitHydrogens(container); } catch (Exception ex1) { logger.debug("Error in hydrogen addition"); } } /** * Gets the polarizabilitiyFactorForAtom * *@param atomContainer AtomContainer *@param atom atom for which the factor should become known *@return The polarizabilitiyFactorForAtom value */ @TestMethod("testGetPolarizabilitiyFactorForAtom_IAtomContainer_IAtom") public double getPolarizabilitiyFactorForAtom(IAtomContainer atomContainer, IAtom atom) { IAtomContainer acH = atomContainer.getBuilder().newAtomContainer(atomContainer); addExplicitHydrogens(acH); return getKJPolarizabilityFactor(acH, atom); } /** * calculates the mean molecular polarizability as described in paper of Kang and Jhorn * *@param atomContainer AtomContainer *@return polarizabilitiy */ @TestMethod("testCalculateKJMeanMolecularPolarizability") public double calculateKJMeanMolecularPolarizability(IAtomContainer atomContainer) { double polarizabilitiy = 0; Molecule acH = new Molecule(atomContainer); addExplicitHydrogens(acH); for (int i = 0; i < acH.getAtomCount(); i++) { polarizabilitiy += getKJPolarizabilityFactor(acH, acH.getAtom(i)); } return polarizabilitiy; } /** * calculate effective atom polarizability * * @param atomContainer IAtomContainer * @param atom atom for which effective atom polarizability should be calculated * @param influenceSphereCutOff cut off for spheres which should taken into account for calculation * @param addExplicitH if set to true, then explicit H's will be added, otherwise it assumes that they have * been added to the molecule before being called * @return polarizabilitiy */ @TestMethod("testCalculateGHEffectiveAtomPolarizability_IAtomContainer_IAtom_Int_Boolean") public double calculateGHEffectiveAtomPolarizability(IAtomContainer atomContainer,IAtom atom, int influenceSphereCutOff, boolean addExplicitH) { double polarizabilitiy = 0; Molecule acH; if (addExplicitH) { acH = new Molecule(atomContainer); addExplicitHydrogens(acH); } else { acH = (Molecule) atomContainer; } List startAtom = new ArrayList(1); startAtom.add(0, atom); double bond; polarizabilitiy += getKJPolarizabilityFactor(acH, atom); for (int i = 0; i < acH.getAtomCount(); i++) { if (acH.getAtom(i) != atom) { bond = PathTools.breadthFirstTargetSearch(acH, startAtom, acH.getAtom(i), 0, influenceSphereCutOff); if (bond == 1) { polarizabilitiy += getKJPolarizabilityFactor(acH, acH.getAtom(i)); } else { polarizabilitiy += (Math.pow(0.5, bond - 1) * getKJPolarizabilityFactor(acH, acH.getAtom(i))); }//if bond==0 }//if !=atom }//for return polarizabilitiy; } /** * calculate effective atom polarizability * * @param atomContainer IAtomContainer * @param atom atom for which effective atom polarizability should be calculated * @param addExplicitH if set to true, then explicit H's will be added, otherwise it assumes that they have * been added to the molecule before being called * @param distanceMatrix an n x n matrix of topological distances between all the atoms in the molecule. * if this argument is non-null, then BFS will not be used and instead path lengths will be looked up. This * form of the method is useful, if it is being called for multiple atoms in the same molecule * @return polarizabilitiy */ @TestMethod("testCalculateGHEffectiveAtomPolarizability_IAtomContainer_IAtom_Boolean_IntInt") public double calculateGHEffectiveAtomPolarizability(IAtomContainer atomContainer,IAtom atom, boolean addExplicitH, int[][] distanceMatrix) { double polarizabilitiy = 0; Molecule acH; if (addExplicitH) { acH = new Molecule(atomContainer); addExplicitHydrogens(acH); } else { acH = (Molecule) atomContainer; } List startAtom = new ArrayList(1); startAtom.add(0, atom); double bond; polarizabilitiy += getKJPolarizabilityFactor(acH, atom); for (int i = 0; i < acH.getAtomCount(); i++) { if (acH.getAtom(i) != atom) { int atomIndex = atomContainer.getAtomNumber(atom); bond = distanceMatrix[atomIndex][i]; if (bond == 1) { polarizabilitiy += getKJPolarizabilityFactor(acH, acH.getAtom(i)); } else { polarizabilitiy += (Math.pow(0.5, bond - 1) * getKJPolarizabilityFactor(acH, acH.getAtom(i))); }//if bond==0 }//if !=atom }//for return polarizabilitiy; } /** * calculate bond polarizability * *@param atomContainer AtomContainer *@param bond Bond bond for which the polarizabilitiy should be calculated *@return polarizabilitiy */ @TestMethod("testCalculateBondPolarizability_IAtomContainer_IBond") public double calculateBondPolarizability(IAtomContainer atomContainer, IBond bond) { double polarizabilitiy = 0; Molecule acH = new Molecule(atomContainer); addExplicitHydrogens(acH); if (bond.getAtomCount() == 2) { polarizabilitiy += getKJPolarizabilityFactor(acH, bond.getAtom(0)); polarizabilitiy += getKJPolarizabilityFactor(acH, bond.getAtom(1)); } return (polarizabilitiy / 2); } /** * Method which assigns the polarizabilitiyFactors * *@param atomContainer AtomContainer *@param atom Atom *@return double polarizabilitiyFactor */ private double getKJPolarizabilityFactor(IAtomContainer atomContainer, IAtom atom) { double polarizabilitiyFactor = 0; String AtomSymbol; AtomSymbol = atom.getSymbol(); if (AtomSymbol.equals("H")) { polarizabilitiyFactor = 0.387; } else if (AtomSymbol.equals("C")) { if (atom.getFlag(CDKConstants.ISAROMATIC)) { polarizabilitiyFactor = 1.230; } else if (atomContainer.getMaximumBondOrder(atom) == IBond.Order.SINGLE) { polarizabilitiyFactor = 1.064;/*1.064*/ } else if (atomContainer.getMaximumBondOrder(atom) == IBond.Order.DOUBLE) { if (getNumberOfHydrogen(atomContainer, atom) == 0) { polarizabilitiyFactor = 1.382; } else { polarizabilitiyFactor = 1.37; } } else if (atomContainer.getMaximumBondOrder(atom) == IBond.Order.TRIPLE || atomContainer.getMaximumBondOrder(atom) == IBond.Order.QUADRUPLE) { polarizabilitiyFactor = 1.279; } } else if (AtomSymbol.equals("N")) { if (atom.getCharge() != CDKConstants.UNSET && atom.getCharge() < 0) { polarizabilitiyFactor = 1.090; } else if (atomContainer.getMaximumBondOrder(atom) == IBond.Order.SINGLE) { polarizabilitiyFactor = 1.094; } else if (atomContainer.getMaximumBondOrder(atom) == IBond.Order.DOUBLE) { polarizabilitiyFactor = 1.030; } else { polarizabilitiyFactor = 0.852; } } else if (AtomSymbol.equals("O")) { if (atom.getCharge() != CDKConstants.UNSET && atom.getCharge() == -1) { polarizabilitiyFactor = 1.791; } else if (atom.getCharge() != CDKConstants.UNSET && atom.getCharge() == 1) { polarizabilitiyFactor = 0.422; } else if (atomContainer.getMaximumBondOrder(atom) == IBond.Order.SINGLE) { polarizabilitiyFactor = 0.664; } else if (atomContainer.getMaximumBondOrder(atom) == IBond.Order.DOUBLE) { polarizabilitiyFactor = 0.460; } } else if (AtomSymbol.equals("P")) { if (atomContainer.getConnectedBondsCount(atom) == 4 && atomContainer.getMaximumBondOrder(atom) == IBond.Order.DOUBLE) { polarizabilitiyFactor = 0; } } else if (AtomSymbol.equals("S")) { if (atom.getFlag(CDKConstants.ISAROMATIC)) { polarizabilitiyFactor = 3.38; } else if (atomContainer.getMaximumBondOrder(atom) == IBond.Order.SINGLE) { polarizabilitiyFactor = 3.20;/*3.19*/ } else if (atomContainer.getMaximumBondOrder(atom) == IBond.Order.DOUBLE) { if (getNumberOfHydrogen(atomContainer, atom) == 0) { polarizabilitiyFactor = 3.51; } else { polarizabilitiyFactor = 3.50; } } else { polarizabilitiyFactor = 3.42; } }else if (AtomSymbol.equals("F")) { polarizabilitiyFactor = 0.296; }else if (AtomSymbol.equals("Cl")) { polarizabilitiyFactor = 2.343; } else if (AtomSymbol.equals("Br")) { polarizabilitiyFactor = 3.5; } else if (AtomSymbol.equals("I")) { polarizabilitiyFactor = 5.79; } return polarizabilitiyFactor; } /** * Gets the numberOfHydrogen attribute of the Polarizability object * *@param atomContainer Description of the Parameter *@param atom Description of the Parameter *@return The numberOfHydrogen value */ private int getNumberOfHydrogen(IAtomContainer atomContainer, IAtom atom) { java.util.List bonds = atomContainer.getConnectedBondsList(atom); IAtom connectedAtom; int hCounter = 0; for (IBond bond : bonds) { connectedAtom = bond.getConnectedAtom(atom); if (connectedAtom.getSymbol().equals("H")) { hCounter += 1; } } return hCounter; } } cdk-1.2.10/src/main/org/openscience/cdk/charges/StabilizationCharges.java100644 0 0 13525 11570154753 23447 0ustar 0 0 /* $Revision: 10199 $ $Author: rajarshi $ $Date: 2008-02-21 19:19:31 +0100 (Thu, 21 Feb 2008) $ * * Copyright (C) 2008 Miguel Rojas * * Contact: cdk-devel@list.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. * * 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.charges; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org._3pq.jgrapht.Edge; import org._3pq.jgrapht.graph.SimpleGraph; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.graph.BFSShortestPath; import org.openscience.cdk.graph.MoleculeGraphs; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomContainerSet; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.reaction.IReactionProcess; import org.openscience.cdk.reaction.type.HyperconjugationReaction; import org.openscience.cdk.tools.StructureResonanceGenerator; /** * The stabilization of the positive and the negative charge * obtained (e.g in the polar breaking of a bond) is calculated from the sigma- and * lone pair-electronegativity values of the atoms that are in conjugation to the atoms * obtaining the charges. Based on H. Saller Dissertation @cdk.cite{SallerH1895}. * * @author Miguel Rojas Cherto * @cdk.created 2008-104-31 * @cdk.module charges * @cdk.keyword stabilization charge */ @TestClass("org.openscience.cdk.charges.StabilizationChargesTest") public class StabilizationCharges { /** * Constructor for the StabilizationCharges object. */ public StabilizationCharges() { } /** * calculate the stabilization of orbitals when they contain deficiency of charge. * * @param atomContainer IAtomContainer * @param atom IAtom for which effective atom StabilizationCharges * factor should be calculated * * @return stabilizationValue */ @TestMethod("testCalculatePositive_IAtomContainer_IAtom") public double calculatePositive(IAtomContainer atomContainer, IAtom atom){ /*restrictions*/ // if(atomContainer.getConnectedSingleElectronsCount(atom) > 0 || atom.getFormalCharge() != 1){ if(atom.getFormalCharge() != 1){ return 0.0; } // only must be generated all structures which stabilize the atom in question. StructureResonanceGenerator gRI = new StructureResonanceGenerator(); try { List reactionList = gRI.getReactions(); reactionList.add(new HyperconjugationReaction()); gRI.setReactions(reactionList); } catch (CDKException e) { e.printStackTrace(); } IAtomContainerSet resonanceS = gRI.getStructures((IMolecule) atomContainer); IAtomContainerSet containerS = gRI.getContainers((IMolecule) atomContainer); if(resonanceS.getAtomContainerCount() < 2)// meaning it was not find any resonance structure return 0.0; int positionStart = atomContainer.getAtomNumber(atom); List result1 = new ArrayList(); List distance1 = new ArrayList(); resonanceS.removeAtomContainer(0);// the first is the initial structure for(Iterator itA = resonanceS.atomContainers().iterator(); itA.hasNext();){ IAtomContainer resonance = itA.next(); if(resonance.getAtomCount() < 2) // resonance with only one atom donnot have resonance continue; /*search positive charge*/ PiElectronegativity electronegativity = new PiElectronegativity(); for(Iterator itAtoms = resonance.atoms().iterator(); itAtoms.hasNext();){ IAtom atomP = itAtoms.next(); IAtom atomR = atomContainer.getAtom(resonance.getAtomNumber(atomP)); if(containerS.getAtomContainer(0).contains(atomR)){ electronegativity.setMaxIterations(6); double result = electronegativity.calculatePiElectronegativity(resonance, atomP); result1.add(result); int dis = calculateBondsToAtom(resonance.getAtom(positionStart),atomP, resonance); distance1.add(dis); } } } /*logarithm*/ double value = 0.0; double sum = 0.0; Iterator itDist = distance1.iterator(); for(Iterator itElec = result1.iterator(); itElec.hasNext();){ double suM = itElec.next(); if(suM < 0) suM = -1*suM; sum += suM*Math.pow(0.67,itDist.next().intValue()); } value = sum; return value; } /** * Calculate the distance in bonds far from a atom. * * @param startAtom The atom as reference * @param focusAtom The atom as focus * @param container The IAtomContainer to study * @return The distance */ private int calculateBondsToAtom(IAtom startAtom, IAtom focusAtom, IAtomContainer container) { SimpleGraph mygraph = MoleculeGraphs.getMoleculeGraph((IMolecule)container); List mylist = BFSShortestPath.findPathBetween(mygraph,startAtom,focusAtom); return mylist.size(); } } cdk-1.2.10/src/main/org/openscience/cdk/config/AtomTypeFactory.java100644 0 0 36622 11570154753 22264 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2001-2007 Christoph Steinbeck * * 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. * * 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.config; import java.io.File; import java.io.FileInputStream; import java.io.InputStream; import java.util.ArrayList; import java.util.Hashtable; import java.util.List; import java.util.Map; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.exception.NoSuchAtomTypeException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IPseudoAtom; import org.openscience.cdk.tools.LoggingTool; /** * General class for defining AtomTypes. This class itself does not define the * items types; for this classes implementing the AtomTypeConfiguration * interface are used. * *

To see which AtomTypeConfigurator's CDK provides, one should check the * AtomTypeConfigurator API. * *

The AtomTypeFactory is a singleton class, which means that there exists * only one instance of the class. Well, almost. For each atom type table, * there is one AtomTypeFactory instance. An instance of this class is * obtained with: *

 *  AtomTypeFactory factory = AtomTypeFactory.getInstance(someChemObjectBuilder);
 *  
* For each atom type list a separate AtomTypeFactory is instantiated. * *

To get all the atom types of an element from a specific list, this * code can be used: *

 *  AtomTypeFactory factory = AtomTypeFactory.getInstance(
 *    "org/openscience/cdk/config/data/jmol_atomtypes.txt",
      someChemObjectBuilder
 *  );
 *  AtomType[] types = factory.getAtomTypes("C");
 *  
* * @cdk.module core * @cdk.githash * * @author steinbeck * @cdk.created 2001-08-29 * @cdk.keyword atom, type * @see IAtomTypeConfigurator */ @TestClass("org.openscience.cdk.config.AtomTypeFactoryTest") public class AtomTypeFactory { /** * Used as an ID to describe the atom type. */ public final static String ATOMTYPE_ID_STRUCTGEN = "structgen"; /** * Used as an ID to describe the atom type. */ public final static String ATOMTYPE_ID_MODELING = "modeling"; // these are not available /** * Used as an ID to describe the atom type. */ public final static String ATOMTYPE_ID_JMOL = "jmol"; private final static String TXT_EXTENSION = "txt"; private final static String XML_EXTENSION = "xml"; private final static String OWL_EXTENSION = "owl"; private static LoggingTool logger; private static Map tables = null; private List atomTypes = null; /** * Private constructor for the AtomTypeFactory singleton. * * */ private AtomTypeFactory(String configFile, IChemObjectBuilder builder) { if (logger == null) { logger = new LoggingTool(this); } atomTypes = new ArrayList(100); readConfiguration(configFile, builder); } /** * Private constructor for the AtomTypeFactory singleton. * */ private AtomTypeFactory(InputStream ins, String format, IChemObjectBuilder builder) { if (logger == null) { logger = new LoggingTool(this); } atomTypes = new ArrayList(100); readConfiguration(ins, format, builder); } /** * Method to create a default AtomTypeFactory, using the given InputStream. * An AtomType of this kind is not cached. * * @see #getInstance(String, IChemObjectBuilder) * @param ins InputStream containing the data * @param format String representing the possible formats ('xml' and 'txt') * @param builder IChemObjectBuilder used to make IChemObject instances * @return The AtomTypeFactory for the given data file */ @TestMethod("testGetInstance_InputStream_String_IChemObjectBuilder") public static AtomTypeFactory getInstance(InputStream ins, String format, IChemObjectBuilder builder) { return new AtomTypeFactory(ins, format, builder); } /** * Method to create a default AtomTypeFactory, using the structgen atom type list. * * @see #getInstance(String, IChemObjectBuilder) * @param builder IChemObjectBuilder used to make IChemObject instances * @return The AtomTypeFactory for the given data file */ @TestMethod("testGetInstance_IChemObjectBuilder") public static AtomTypeFactory getInstance(IChemObjectBuilder builder) { return getInstance("org/openscience/cdk/config/data/structgen_atomtypes.xml", builder); } /** * Method to create a specialized AtomTypeFactory. Available lists in CDK are: *
    *
  • org/openscience/cdk/config/data/jmol_atomtypes.txt *
  • org/openscience/cdk/config/data/mol2_atomtypes.xml *
  • org/openscience/cdk/config/data/structgen_atomtypes.xml *
  • org/openscience/cdk/config/data/mm2_atomtypes.xml *
  • org/openscience/cdk/config/data/mmff94_atomtypes.xml *
  • org/openscience/cdk/dict/data/cdk-atom-types.owl *
  • org/openscience/cdk/dict/data/sybyl-atom-types.owl *
* * @param configFile String the name of the data file * @param builder IChemObjectBuilder used to make IChemObject instances * @return The AtomTypeFactory for the given data file */ @TestMethod("testGetInstance_String_IChemObjectBuilder") public static AtomTypeFactory getInstance(String configFile, IChemObjectBuilder builder) { if (tables == null) { tables = new Hashtable(); } if (!(tables.containsKey(configFile))) { tables.put(configFile, new AtomTypeFactory(configFile, builder)); } return tables.get(configFile); } /** * Read the config from a text file. * * @param fileName name of the config file * @param builder IChemObjectBuilder used to make IChemObject instances */ private void readConfiguration(String fileName, IChemObjectBuilder builder) { logger.info("Reading config file from ", fileName); InputStream ins; { //try to see if this is a resource ins = this.getClass().getClassLoader().getResourceAsStream(fileName); if(ins==null){ // try to see if this configFile is an actual file File file = new File(fileName); if (file.exists()) { logger.debug("configFile is a File"); // what's next? try { ins = new FileInputStream(file); } catch (Exception exception) { logger.error(exception.getMessage()); logger.debug(exception); } } else { logger.error("no stream and no file"); } } } String format = XML_EXTENSION; if (fileName.endsWith(TXT_EXTENSION)) { format = TXT_EXTENSION; } else if (fileName.endsWith(XML_EXTENSION)) { format = XML_EXTENSION; } else if (fileName.endsWith(OWL_EXTENSION)) { format = OWL_EXTENSION; } readConfiguration(ins, format, builder); } private IAtomTypeConfigurator constructConfigurator(String format) { try { if (format.equals(TXT_EXTENSION)) { return (IAtomTypeConfigurator) this.getClass().getClassLoader(). loadClass("org.openscience.cdk.config.TXTBasedAtomTypeConfigurator"). newInstance(); } else if (format.equals(XML_EXTENSION)) { return (IAtomTypeConfigurator) this.getClass().getClassLoader(). loadClass("org.openscience.cdk.config.CDKBasedAtomTypeConfigurator"). newInstance(); } else if (format.equals(OWL_EXTENSION)) { return (IAtomTypeConfigurator) this.getClass().getClassLoader(). loadClass("org.openscience.cdk.config.OWLBasedAtomTypeConfigurator"). newInstance(); } } catch (Exception exc) { logger.error("Could not get instance of AtomTypeConfigurator for format ", format); logger.debug(exc); } return null; } private void readConfiguration(InputStream ins, String format, IChemObjectBuilder builder) { IAtomTypeConfigurator atc = constructConfigurator(format); if (atc != null) { atc.setInputStream(ins); try { atomTypes = atc.readAtomTypes(builder); } catch (Exception exc) { logger.error("Could not read AtomType's from file due to: ", exc.getMessage()); logger.debug(exc); } } else { logger.debug("AtomTypeConfigurator was null!"); atomTypes = new ArrayList(); } } /** * Returns the number of atom types in this list. * * @return The number of atom types */ @TestMethod("testGetSize") public int getSize() { return atomTypes.size(); } /** * Get an AtomType with the given ID. * * @param identifier an ID for a particular atom type (like C$) * @return The AtomType for this id * @exception NoSuchAtomTypeException Thrown if the atom type does not exist. */ @TestMethod("testGetAtomType_String,testGetAtomTypeFromJmol,testGetAtomTypeFromMM2,testGetAtomTypeFromPDB") public IAtomType getAtomType(String identifier) throws NoSuchAtomTypeException { for (IAtomType atomType : atomTypes) { if (atomType.getAtomTypeName().equals(identifier)) { return atomType; } } throw new NoSuchAtomTypeException("The AtomType " + identifier + " could not be found"); } /** * Get an array of all atomTypes known to the AtomTypeFactory for the given * element symbol and atomtype class. * * @param symbol An element symbol to search for * @return An array of atomtypes that matches the given element symbol * and atomtype class */ @TestMethod("testGetAtomTypes_String") public IAtomType[] getAtomTypes(String symbol) { logger.debug("Request for atomtype for symbol ", symbol); List atomList = new ArrayList(); for (IAtomType atomType : atomTypes) { // logger.debug(" does symbol match for: ", atomType); if (atomType.getSymbol().equals(symbol)) { // logger.debug("Atom type found for symbol: ", atomType); IAtomType clone; try { clone = (IAtomType) atomType.clone(); atomList.add(clone); } catch (CloneNotSupportedException e) { logger.error("Could not clone IAtomType: ", e.getMessage()); logger.debug(e); } } } IAtomType[] atomTypes = (IAtomType[])atomList.toArray(new IAtomType[atomList.size()]); if (atomTypes.length > 0) logger.debug("Atomtype for symbol ", symbol, " has this number of types: " + atomTypes.length); else logger.debug("No atomtype for symbol ", symbol); return atomTypes; } /** * Gets the allAtomTypes attribute of the AtomTypeFactory object. * * @return The allAtomTypes value */ @TestMethod("testGetAllAtomTypes") public IAtomType[] getAllAtomTypes() { logger.debug("Returning list of size: ", getSize()); List atomtypeList = new ArrayList(); for (IAtomType atomType : atomTypes) { IAtomType clone; try { clone = (IAtomType) atomType.clone(); atomtypeList.add(clone); } catch (CloneNotSupportedException e) { logger.error("Could not clone IAtomType: ", e.getMessage()); logger.debug(e); } } return (IAtomType[])atomtypeList.toArray(new IAtomType[atomtypeList.size()]); } /** * Configures an atom. Finds the correct element type by looking at the Atom's * atom type name, and if that fails, picks the first atom type matching * the Atom's element symbol.. * * @param atom The atom to be configured * @return The configured atom * @throws CDKException when it could not recognize and configure the * IAtom */ @TestMethod("testConfigure_IAtom") public IAtom configure(IAtom atom) throws CDKException { if (atom instanceof IPseudoAtom) { // do not try to configure PseudoAtom's return atom; } try { IAtomType atomType; String atomTypeName = atom.getAtomTypeName(); if (atomTypeName == null || atomTypeName.length() == 0) { logger.debug("Using atom symbol because atom type name is empty..."); IAtomType[] types = getAtomTypes(atom.getSymbol()); if (types.length > 0) { logger.warn("Taking first atom type, but other may exist"); atomType = types[0]; } else { String message = "Could not configure atom with unknown ID: " + atom.toString() + " + (id=" + atom.getAtomTypeName() + ")"; logger.warn(message); throw new CDKException(message); } } else { atomType = getAtomType(atom.getAtomTypeName()); } logger.debug("Configuring with atomtype: ", atomType); atom.setSymbol(atomType.getSymbol()); atom.setMaxBondOrder(atomType.getMaxBondOrder()); atom.setBondOrderSum(atomType.getBondOrderSum()); atom.setCovalentRadius(atomType.getCovalentRadius()); atom.setHybridization(atomType.getHybridization()); Object color = atomType.getProperty("org.openscience.cdk.renderer.color"); if (color != null) { atom.setProperty("org.openscience.cdk.renderer.color", color); } atom.setAtomicNumber(atomType.getAtomicNumber()); atom.setExactMass(atomType.getExactMass()); } catch (Exception exception) { logger.warn("Could not configure atom with unknown ID: ", atom, " + (id=", atom.getAtomTypeName(), ")"); logger.debug(exception); throw new CDKException(exception.toString(), exception); } logger.debug("Configured: ", atom); return atom; } } cdk-1.2.10/src/main/org/openscience/cdk/config/CDKBasedAtomTypeConfigurator.java100644 0 0 7750 11570154753 24560 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 Egon Willighagen * * 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. * * 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.config; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.atomtypes.AtomTypeReader; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.tools.LoggingTool; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; /** * AtomType resource that reads the atom type configuration from an XML file. * The format is required to be in the STMML format {@cdk.cite PMR2002}; examples * can be found in CVS in the src/org/openscience/cdk/config/data directory. * * @cdk.module core * @cdk.githash */ @TestClass("org.openscience.cdk.config.CDKBasedAtomTypeConfiguratorTest") public class CDKBasedAtomTypeConfigurator implements IAtomTypeConfigurator { private String configFile = "org.openscience.cdk.config.data.structgen_atomtypes.xml"; private InputStream ins = null; private LoggingTool logger; public CDKBasedAtomTypeConfigurator() { logger = new LoggingTool(this); } @TestMethod("testSetInputStream_InputStream") public void setInputStream(InputStream ins) { this.ins = ins; } /** * Reads the atom types from the CDK based atom type list. * * @param builder IChemObjectBuilder used to construct the IAtomType's. * @throws IOException when a problem occured with reading from the InputStream * @return A List with read IAtomType's. */ @TestMethod("testReadAtomTypes_IChemObjectBuilder") public List readAtomTypes(IChemObjectBuilder builder) throws IOException { List atomTypes; if (ins == null) { try { ins = this.getClass().getClassLoader().getResourceAsStream(configFile); } catch(Exception exc) { logger.error(exc.getMessage()); logger.debug(exc); throw new IOException("There was a problem getting a stream for " + configFile + " with getClass.getClassLoader.getResourceAsStream"); } if (ins == null) { try { ins = this.getClass().getResourceAsStream(configFile); } catch(Exception exc) { logger.error(exc.getMessage()); logger.debug(exc); throw new IOException("There was a problem getting a stream for " + configFile + " with getClass.getResourceAsStream"); } } } if (ins == null) throw new IOException("There was a problem getting an input stream"); AtomTypeReader reader = new AtomTypeReader(new InputStreamReader(ins)); atomTypes = reader.readAtomTypes(builder); for (IAtomType atomType : atomTypes) { if (atomType == null) { logger.debug("Expecting an object but found null!"); } } return atomTypes; } } cdk-1.2.10/src/main/org/openscience/cdk/config/ElementPTFactory.java100644 0 0 25212 11570154753 22350 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2005-2007 Miguel Rojas * * 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. * * 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.config; import org.openscience.cdk.PeriodicTableElement; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.elements.ElementPTReader; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IElement; import org.openscience.cdk.tools.LoggingTool; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; /** * Used to store and return data of a particular chemicalElement. As this class is a * singleton class, one gets an instance with: *
 *   ElementPTFactory efac = ElementPTFactory.getInstance();
 * 
* * @author Miguel Rojas * @cdk.created May 8, 2005 * @cdk.module extra * @cdk.githash */ @TestClass("org.openscience.cdk.config.ElementPTFactoryTest") public class ElementPTFactory { private static ElementPTFactory efac = null; private List elements = null; private boolean debug = false; private LoggingTool logger; /** * Private constructor for the ElementPTFactory object. * *@exception IOException A problem with reading the chemicalElements.xml file */ private ElementPTFactory() throws IOException { logger = new LoggingTool(this); logger.info("Creating new ElementPTFactory"); InputStream ins = null; String errorMessage = "There was a problem getting org.openscience.cdk." + "config.chemicalElements.xml as a stream"; try { String configFile = "org/openscience/cdk/config/data/chemicalElements.xml"; if (debug) logger.debug("Getting stream for ", configFile); ins = this.getClass().getClassLoader().getResourceAsStream(configFile); } catch (Exception exception) { logger.error(errorMessage); logger.debug(exception); throw new IOException(errorMessage); } if (ins == null) { logger.error(errorMessage); throw new IOException(errorMessage); } ElementPTReader reader = new ElementPTReader(new InputStreamReader(ins)); elements = reader.readElements(); if (debug) logger.debug("Found #elements in file: ", elements.size()); } /** * Returns an ElementPTFactory instance. * *@return The instance value *@exception IOException Description of the Exception */ @TestMethod("testGetInstance") public static ElementPTFactory getInstance() throws IOException { if (efac == null) { efac = new ElementPTFactory(); } return efac; } /** * Returns the number of elements defined by this class. * *@return The size value */ @TestMethod("testGetSize") public int getSize() { return elements.size(); } /** * Get all the elements loaded by the factory. * * @return A Vector of PeriodicTableElement objects * @see org.openscience.cdk.PeriodicTableElement */ @TestMethod("testGetElements") public List getElements() { return elements; } /** * Returns an Element with a given element symbol. * *@param symbol An element symbol to search for *@return An array of element that matches the given element symbol */ @TestMethod("testGetElement_String") public PeriodicTableElement getElement(String symbol) { for (PeriodicTableElement element : elements) { if (element.getSymbol().equals(symbol)) { try { return (PeriodicTableElement) element.clone(); } catch (CloneNotSupportedException e) { logger.error("Could not clone PeriodicTableElement: ", e.getMessage()); logger.debug(e); } } } return null; } /** * Configures a PeriodicTableElement. Finds the correct element type * by looking at the element symbol. * *@param element The PeriodicTableElement to be configure *@return The configured PeriodicTableElement * @throws org.openscience.cdk.exception.CDKException if there is an error during configuration * (such as invalid IUPAC group number) */ @TestMethod("testConfigure_PeriodicTableElement") public PeriodicTableElement configure(PeriodicTableElement element) throws CDKException { PeriodicTableElement elementInt = getElement(element.getSymbol()); element.setSymbol(elementInt.getSymbol()); element.setAtomicNumber(elementInt.getAtomicNumber()); element.setName(elementInt.getName()); element.setChemicalSerie(elementInt.getChemicalSerie()); element.setPeriod(elementInt.getPeriod()); if(elementInt.getGroup()!=null) element.setGroup(elementInt.getGroup()); element.setPhase(elementInt.getPhase()); element.setCASid(elementInt.getCASid()); element.setPaulingEneg(elementInt.getPaulingEneg()); return element; } /** * Configures a IElement given a PeridicTableElement. * *@param elementPT The element of the Periodic Table to be configure *@return element The configured element */ @TestMethod("testConfigureE_PeriodicTableElement") public IElement configureE(PeriodicTableElement elementPT) { IElement element = elementPT.getBuilder().newElement(elementPT.getSymbol()); element.setSymbol(elementPT.getSymbol()); element.setAtomicNumber(elementPT.getAtomicNumber()); return element; } /** * Gets the atomic number of this element in the periodic table. * * @param element The PeriodicTableElement object * @return The atomic number value */ @TestMethod("testGetAtomicNumber_PeriodicTableElement") public double getAtomicNumber(PeriodicTableElement element){ PeriodicTableElement elementInt = getElement(element.getSymbol()); return elementInt.getAtomicNumber(); } /** * Gets the name of this element in the periodic table. * * @param element The PeriodicTableElement object * @return The name value of this element */ @TestMethod("testGetName_PeriodicTableElement") public String getName(PeriodicTableElement element){ PeriodicTableElement elementInt = getElement(element.getSymbol()); return elementInt.getName(); } /** * Gets the chemical serie of this element in the periodic table. * * @param element The PeriodicTableElement object * @return The chemical serie value of this element */ @TestMethod("testGetChemicalSerie_PeriodicTableElement") public String getChemicalSerie(PeriodicTableElement element){ PeriodicTableElement elementInt = getElement(element.getSymbol()); return elementInt.getChemicalSerie(); } /** * Gets the period of this element in the periodic table. * * @param element The PeriodicTableElement object * @return The period value of this element */ @TestMethod("testGetPeriod_PeriodicTableElement") public int getPeriod(PeriodicTableElement element){ PeriodicTableElement elementInt = getElement(element.getSymbol()); return elementInt.getPeriod(); } /** * Gets the group of this element in the periodic table. * * @param element The PeriodicTableElement object * @return The group value of this element */ @TestMethod("testGetGroup_PeriodicTableElement") public int getGroup(PeriodicTableElement element){ PeriodicTableElement elementInt = getElement(element.getSymbol()); return elementInt.getGroup(); } /** * Gets the phase of this element in the periodic table. * * @param element The PeriodicTableElement object * @return The phase value of this element */ @TestMethod("testGetPhase_PeriodicTableElement") public String getPhase(PeriodicTableElement element){ PeriodicTableElement elementInt = getElement(element.getSymbol()); return elementInt.getPhase(); } /** * Gets the CAS id of this element in the periodic table. * * @param element The PeriodicTableElement object * @return The CASE id value of this element */ @TestMethod("testGetCASid_PeriodicTableElement") public String getCASid(PeriodicTableElement element){ PeriodicTableElement elementInt = getElement(element.getSymbol()); return elementInt.getCASid(); } /** * Gets the Vdw radios of this element in the periodic table. * * @param element The PeriodicTableElement object * @return The Vdw radio value of this element */ @TestMethod("testGetVdwRadius_PeriodicTableElement") public double getVdwRadius(PeriodicTableElement element){ PeriodicTableElement elementInt = getElement(element.getSymbol()); return elementInt.getVdwRadius(); } /** * Gets the covalent radios of this element in the periodic table. * * @param element The PeriodicTableElement object * @return The covalent radio value of this element */ @TestMethod("testGetCovalentRadius_PeriodicTableElement") public double getCovalentRadius(PeriodicTableElement element){ PeriodicTableElement elementInt = getElement(element.getSymbol()); return elementInt.getCovalentRadius(); } /** * Gets the Pauling Electronegativity radios of this element in the periodic table. * * @param element The PeriodicTableElement object * @return The Pauling Electronegativity value of this element */ @TestMethod("testGetPaulingEneg_PeriodicTableElement") public double getPaulingEneg(PeriodicTableElement element){ PeriodicTableElement elementInt = getElement(element.getSymbol()); return elementInt.getPaulingEneg(); } } cdk-1.2.10/src/main/org/openscience/cdk/config/Elements.java100644 0 0 26434 11570154753 20746 0ustar 0 0 /* $RCSfile: $ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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 org.openscience.cdk.config; import org.openscience.cdk.Element; import org.openscience.cdk.interfaces.IElement; /** * List of elements. Data is taken from the Blue Obelisk Data Repository, * version 3. * * @author egonw * @cdk.module extra * @cdk.githash */ public class Elements { public final static IElement DUMMY = new Element(Symbols.byAtomicNumber[0], 0); public final static IElement HYDROGEN = new Element(Symbols.byAtomicNumber[1], 1); public final static IElement HELIUM = new Element(Symbols.byAtomicNumber[2], 2); public final static IElement LITHIUM = new Element(Symbols.byAtomicNumber[3], 3); public final static IElement BERYLLIUM = new Element(Symbols.byAtomicNumber[4], 4); public final static IElement BORON = new Element(Symbols.byAtomicNumber[5], 5); public final static IElement CARBON = new Element(Symbols.byAtomicNumber[6], 6); public final static IElement NITROGEN = new Element(Symbols.byAtomicNumber[7], 7); public final static IElement OXYGEN = new Element(Symbols.byAtomicNumber[8], 8); public final static IElement FLUORINE = new Element(Symbols.byAtomicNumber[9], 9); public final static IElement NEON = new Element(Symbols.byAtomicNumber[10], 10); public final static IElement SODIUM = new Element(Symbols.byAtomicNumber[11], 11); public final static IElement MAGNESIUM = new Element(Symbols.byAtomicNumber[12], 12); public final static IElement ALUMINIUM = new Element(Symbols.byAtomicNumber[13], 13); public final static IElement SILICON = new Element(Symbols.byAtomicNumber[14], 14); public final static IElement PHOSPHORUS = new Element(Symbols.byAtomicNumber[15], 15); public final static IElement SULFUR = new Element(Symbols.byAtomicNumber[16], 16); public final static IElement CHLORINE = new Element(Symbols.byAtomicNumber[17], 17); public final static IElement ARGON = new Element(Symbols.byAtomicNumber[18], 18); public final static IElement POTASSIUM = new Element(Symbols.byAtomicNumber[19], 19); public final static IElement CALCIUM = new Element(Symbols.byAtomicNumber[20], 20); public final static IElement SCANDIUM = new Element(Symbols.byAtomicNumber[21], 21); public final static IElement TITANIUM = new Element(Symbols.byAtomicNumber[22], 22); public final static IElement VANADIUM = new Element(Symbols.byAtomicNumber[23], 23); public final static IElement CHROMIUM = new Element(Symbols.byAtomicNumber[24], 24); public final static IElement MANGANESE = new Element(Symbols.byAtomicNumber[25], 25); public final static IElement IRON = new Element(Symbols.byAtomicNumber[26], 26); public final static IElement COBALT = new Element(Symbols.byAtomicNumber[27], 27); public final static IElement NICKEL = new Element(Symbols.byAtomicNumber[28], 28); public final static IElement COPPER = new Element(Symbols.byAtomicNumber[29], 29); public final static IElement ZINC = new Element(Symbols.byAtomicNumber[30], 30); public final static IElement GALLIUM = new Element(Symbols.byAtomicNumber[31], 31); public final static IElement GERMANIUM = new Element(Symbols.byAtomicNumber[32], 32); public final static IElement ARSENIC = new Element(Symbols.byAtomicNumber[33], 33); public final static IElement SELENIUM = new Element(Symbols.byAtomicNumber[34], 34); public final static IElement BROMINE = new Element(Symbols.byAtomicNumber[35], 35); public final static IElement KRYPTON = new Element(Symbols.byAtomicNumber[36], 36); public final static IElement RUBIDIUM = new Element(Symbols.byAtomicNumber[37], 37); public final static IElement STRONTIUM = new Element(Symbols.byAtomicNumber[38], 38); public final static IElement YTTRIUM = new Element(Symbols.byAtomicNumber[39], 39); public final static IElement ZIRCONIUM = new Element(Symbols.byAtomicNumber[40], 40); public final static IElement NIOBIUM = new Element(Symbols.byAtomicNumber[41], 41); public final static IElement MOLYBDENUM = new Element(Symbols.byAtomicNumber[42], 42); public final static IElement TECHNETIUM = new Element(Symbols.byAtomicNumber[43], 43); public final static IElement RUTHENIUM = new Element(Symbols.byAtomicNumber[44], 44); public final static IElement RHODIUM = new Element(Symbols.byAtomicNumber[45], 45); public final static IElement PALLADIUM = new Element(Symbols.byAtomicNumber[46], 46); public final static IElement SILVER = new Element(Symbols.byAtomicNumber[47], 47); public final static IElement CADMIUM = new Element(Symbols.byAtomicNumber[48], 48); public final static IElement INDIUM = new Element(Symbols.byAtomicNumber[49], 49); public final static IElement TIN = new Element(Symbols.byAtomicNumber[50], 50); public final static IElement ANTIMONY = new Element(Symbols.byAtomicNumber[51], 51); public final static IElement TELLURIUM = new Element(Symbols.byAtomicNumber[52], 52); public final static IElement IODINE = new Element(Symbols.byAtomicNumber[53], 53); public final static IElement XENON = new Element(Symbols.byAtomicNumber[54], 54); public final static IElement CAESIUM = new Element(Symbols.byAtomicNumber[55], 55); public final static IElement BARIUM = new Element(Symbols.byAtomicNumber[56], 56); public final static IElement LANTHANUM = new Element(Symbols.byAtomicNumber[57], 57); public final static IElement CERIUM = new Element(Symbols.byAtomicNumber[58], 58); public final static IElement PRASEODYMIUM = new Element(Symbols.byAtomicNumber[59], 59); public final static IElement NEODYMIUM = new Element(Symbols.byAtomicNumber[60], 60); public final static IElement PROMETHIUM = new Element(Symbols.byAtomicNumber[61], 61); public final static IElement SAMARIUM = new Element(Symbols.byAtomicNumber[62], 62); public final static IElement EUROPIUM = new Element(Symbols.byAtomicNumber[63], 63); public final static IElement GADOLINIUM = new Element(Symbols.byAtomicNumber[64], 64); public final static IElement TERBIUM = new Element(Symbols.byAtomicNumber[65], 65); public final static IElement DYSPROSIUM = new Element(Symbols.byAtomicNumber[66], 66); public final static IElement HOLMIUM = new Element(Symbols.byAtomicNumber[67], 67); public final static IElement ERBIUM = new Element(Symbols.byAtomicNumber[68], 68); public final static IElement THULIUM = new Element(Symbols.byAtomicNumber[69], 69); public final static IElement YTTERBIUM = new Element(Symbols.byAtomicNumber[70], 70); public final static IElement LUTETIUM = new Element(Symbols.byAtomicNumber[71], 71); public final static IElement HAFNIUM = new Element(Symbols.byAtomicNumber[72], 72); public final static IElement TANTALUM = new Element(Symbols.byAtomicNumber[73], 73); public final static IElement TUNGSTEN = new Element(Symbols.byAtomicNumber[74], 74); public final static IElement RHENIUM = new Element(Symbols.byAtomicNumber[75], 75); public final static IElement OSMIUM = new Element(Symbols.byAtomicNumber[76], 76); public final static IElement IRIDIUM = new Element(Symbols.byAtomicNumber[77], 77); public final static IElement PLATINUM = new Element(Symbols.byAtomicNumber[78], 78); public final static IElement GOLD = new Element(Symbols.byAtomicNumber[79], 79); public final static IElement MERCURY = new Element(Symbols.byAtomicNumber[80], 80); public final static IElement THALLIUM = new Element(Symbols.byAtomicNumber[81], 81); public final static IElement LEAD = new Element(Symbols.byAtomicNumber[82], 82); public final static IElement BISMUTH = new Element(Symbols.byAtomicNumber[83], 83); public final static IElement POLONIUM = new Element(Symbols.byAtomicNumber[84], 84); public final static IElement ASTATINE = new Element(Symbols.byAtomicNumber[85], 85); public final static IElement RADON = new Element(Symbols.byAtomicNumber[86], 86); public final static IElement FRANCIUM = new Element(Symbols.byAtomicNumber[87], 87); public final static IElement RADIUM = new Element(Symbols.byAtomicNumber[88], 88); public final static IElement ACTINIUM = new Element(Symbols.byAtomicNumber[89], 89); public final static IElement THORIUM = new Element(Symbols.byAtomicNumber[90], 90); public final static IElement PROTACTINIUM = new Element(Symbols.byAtomicNumber[91], 91); public final static IElement URANIUM = new Element(Symbols.byAtomicNumber[92], 92); public final static IElement NEPTUNIUM = new Element(Symbols.byAtomicNumber[93], 93); public final static IElement PLUTONIUM = new Element(Symbols.byAtomicNumber[94], 94); public final static IElement AMERICIUM = new Element(Symbols.byAtomicNumber[95], 95); public final static IElement CURIUM = new Element(Symbols.byAtomicNumber[96], 96); public final static IElement BERKELIUM = new Element(Symbols.byAtomicNumber[97], 97); public final static IElement CALIFORNIUM = new Element(Symbols.byAtomicNumber[98], 98); public final static IElement EINSTEINIUM = new Element(Symbols.byAtomicNumber[99], 99); public final static IElement FERMIUM = new Element(Symbols.byAtomicNumber[100], 100); public final static IElement MENDELEVIUM = new Element(Symbols.byAtomicNumber[101], 101); public final static IElement NOBELIUM = new Element(Symbols.byAtomicNumber[102], 102); public final static IElement LAWRENCIUM = new Element(Symbols.byAtomicNumber[103], 103); public final static IElement RUTHERFORDIUM = new Element(Symbols.byAtomicNumber[104], 104); public final static IElement DUBNIUM = new Element(Symbols.byAtomicNumber[105], 105); public final static IElement SEABORGIUM = new Element(Symbols.byAtomicNumber[106], 106); public final static IElement BOHRIUM = new Element(Symbols.byAtomicNumber[107], 107); public final static IElement HASSIUM = new Element(Symbols.byAtomicNumber[108], 108); public final static IElement MEITNERIUM = new Element(Symbols.byAtomicNumber[109], 109); public final static IElement DARMSTADTIUM = new Element(Symbols.byAtomicNumber[110], 110); public final static IElement ROENTGENIUM = new Element(Symbols.byAtomicNumber[111], 111); public final static IElement UNUNBIUM = new Element(Symbols.byAtomicNumber[112], 112); public final static IElement UNUNTRIUM = new Element(Symbols.byAtomicNumber[113], 113); public final static IElement UNUNQUADIUM = new Element(Symbols.byAtomicNumber[114], 114); public final static IElement UNUNPENTIUM = new Element(Symbols.byAtomicNumber[115], 115); public final static IElement UNUNHEXIUM = new Element(Symbols.byAtomicNumber[116], 116); } cdk-1.2.10/src/main/org/openscience/cdk/config/IAtomTypeConfigurator.java100644 0 0 3611 11570154753 23400 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 Egon Willighagen * * 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. * * 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.config; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IChemObjectBuilder; import java.io.IOException; import java.io.InputStream; import java.util.List; /** * Interface that allows reading atom type configuration data from some * source. * * @cdk.module core * @cdk.githash */ public interface IAtomTypeConfigurator { /** * Sets the file containing the config data. * * @param ins InputStream from which the atom type definitions are to be read */ public void setInputStream(InputStream ins); /** * Reads a set of configured AtomType's into a List. * * @param builder ChemObjectBuilder used to instantiate the AtomType's. * * @return A List containing the AtomTypes extracted from the InputStream * @throws IOException when something went wrong with reading the data */ public List readAtomTypes(IChemObjectBuilder builder) throws IOException; } cdk-1.2.10/src/main/org/openscience/cdk/config/IsotopeFactory.java100644 0 0 30067 11570154753 22141 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2001-2007 Christoph Steinbeck * * 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. * * 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.config; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.isotopes.IsotopeReader; import org.openscience.cdk.interfaces.*; import org.openscience.cdk.tools.LoggingTool; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.HashMap; import java.util.List; /** * Used to store and return data of a particular isotope. As this class is a * singleton class, one gets an instance with: *
 * IsotopeFactory ifac = IsotopFactory.getInstance(new IChemObject().getBuilder());
 * 
* *

Data about the isotopes are read from the file * org.openscience.cdk.config.isotopes.xml in the cdk-standard * module. Part of the data in this file was collected from * the website webelements.org. * *

The use of this class is exemplified as follows. To get information * about the major isotope of hydrogen, one can use this code: *

 *   IsotopeFactory factory = IsotopeFactory.getInstance(DefaultChemObjectBuilder.getInstance());
 *   Isotope major = factory.getMajorIsotope("H");
 * 
* * @cdk.module core * @cdk.githash * * @author steinbeck * @cdk.created 2001-08-29 * @cdk.keyword isotope * @cdk.keyword element */ @TestClass("org.openscience.cdk.config.IsotopeFactoryTest") public class IsotopeFactory { private static IsotopeFactory ifac = null; private List isotopes = null; private HashMap majorIsotopes = null; private boolean debug = false; private LoggingTool logger; /** * Private constructor for the IsotopeFactory object. * *@exception IOException A problem with reading the isotopes.xml * file * @param builder The builder from which we the factory will be generated */ private IsotopeFactory(IChemObjectBuilder builder) throws IOException { logger = new LoggingTool(this); logger.info("Creating new IsotopeFactory"); InputStream ins; // ObjIn in = null; String errorMessage = "There was a problem getting org.openscience.cdk." + "config.isotopes.xml as a stream"; try { String configFile = "org/openscience/cdk/config/data/isotopes.xml"; if (debug) logger.debug("Getting stream for ", configFile); ins = this.getClass().getClassLoader().getResourceAsStream(configFile); } catch (Exception exception) { logger.error(errorMessage); logger.debug(exception); throw new IOException(errorMessage); } if (ins == null) { logger.error(errorMessage); throw new IOException(errorMessage); } IsotopeReader reader = new IsotopeReader(ins, builder); //in = new ObjIn(ins, new Config().aliasID(false)); isotopes = reader.readIsotopes(); if (debug) logger.debug("Found #isotopes in file: ", isotopes.size()); /* for (int f = 0; f < isotopes.size(); f++) { Isotope isotope = (Isotope)isotopes.elementAt(f); } What's this loop for?? */ majorIsotopes = new HashMap(); } /** * Returns an IsotopeFactory instance. * * @param builder ChemObjectBuilder used to construct the Isotope's * @return The instance value * @exception IOException Description of the Exception */ @TestMethod("testGetInstance_IChemObjectBuilder") public static IsotopeFactory getInstance(IChemObjectBuilder builder) throws IOException { if (ifac == null) { ifac = new IsotopeFactory(builder); } return ifac; } /** * Returns the number of isotopes defined by this class. * *@return The size value */ @TestMethod("testGetSize") public int getSize() { return isotopes.size(); } /** * Gets an array of all isotopes known to the IsotopeFactory for the given * element symbol. * *@param symbol An element symbol to search for *@return An array of isotopes that matches the given element symbol */ @TestMethod("testGetIsotopes_String") public IIsotope[] getIsotopes(String symbol) { ArrayList list = new ArrayList(); for (IIsotope isotope : isotopes) { if (isotope.getSymbol().equals(symbol)) { try { IIsotope clone = (IIsotope) isotope.clone(); list.add(clone); } catch (CloneNotSupportedException e) { logger.error("Could not clone IIsotope: ", e.getMessage()); logger.debug(e); } } } return list.toArray(new IIsotope[list.size()]); } /** * Returns the most abundant (major) isotope with a given atomic number. * *

The isotope's abundancy is for atoms with atomic number 60 and smaller * defined as a number that is proportional to the 100 of the most abundant * isotope. For atoms with higher atomic numbers, the abundancy is defined * as a percentage. * * @param atomicNumber The atomicNumber for which an isotope is to be returned * @return The isotope corresponding to the given atomic number * * @see #getMajorIsotope(String symbol) */ @TestMethod("testGetMajorIsotope_int") public IIsotope getMajorIsotope(int atomicNumber) { IIsotope major = null; for (IIsotope isotope : isotopes) { if (isotope.getAtomicNumber() == atomicNumber) { try { if (major == null) { major = (IIsotope) isotope.clone(); } else { if (isotope.getNaturalAbundance() > major.getNaturalAbundance()) { major = (IIsotope) isotope.clone(); } } } catch (CloneNotSupportedException e) { logger.error("Could not clone IIsotope: ", e.getMessage()); logger.debug(e); } } } if (major == null) logger.error("Could not find major isotope for: ", atomicNumber); return major; } /** * Checks whether the given element exists. * * @param elementName The element name to test * @return True is the element exists, false otherwise */ @TestMethod("testIsElement_String") public boolean isElement(String elementName) { return (getElement(elementName) != null); } /** * Returns the most abundant (major) isotope whose symbol equals element. * *@param symbol Description of the Parameter *@return The Major Isotope value */ @TestMethod("testGetMajorIsotope_String") public IIsotope getMajorIsotope(String symbol) { IIsotope major = null; if (majorIsotopes.containsKey(symbol)) { major = majorIsotopes.get(symbol); } else { for (IIsotope isotope : isotopes) { if (isotope.getSymbol().equals(symbol)) { try { if (major == null) { major = (IIsotope) isotope.clone(); } else { if (isotope.getNaturalAbundance() > major.getNaturalAbundance()) { major = (IIsotope) isotope.clone(); } } } catch (CloneNotSupportedException e) { logger.error("Could not clone IIsotope: ", e.getMessage()); logger.debug(e); } } } if (major == null) { logger.error("Could not find major isotope for: ", symbol); } else { majorIsotopes.put(symbol, major); } } return major; } /** * Returns an Element with a given element symbol. * *@param symbol The element symbol for the requested element *@return The configured element */ @TestMethod("testGetElement_String") public IElement getElement(String symbol) { return getMajorIsotope(symbol); } /** * Returns an element according to a given atomic number. * *@param atomicNumber The elements atomic number *@return The Element */ @TestMethod("testGetElement_int") public IElement getElement(int atomicNumber) { return getMajorIsotope(atomicNumber); } /** * Returns the symbol matching the element with the given atomic number. * * @param atomicNumber The elements atomic number * @return The symbol of the Element */ @TestMethod("testGetElementSymbol_int") public String getElementSymbol(int atomicNumber) { IIsotope isotope = getMajorIsotope(atomicNumber); return isotope.getSymbol(); } /** * Configures an atom. Finds the correct element type * by looking at the atoms element symbol. * *@param atom The atom to be configured *@return The configured atom */ @TestMethod("testConfigure_IAtom") public IAtom configure(IAtom atom) { IIsotope isotope = getMajorIsotope(atom.getSymbol()); return configure(atom, isotope); } /** * Configures an atom to have all the data of the * given isotope. * *@param atom The atom to be configure *@param isotope The isotope to read the data from *@return The configured atom */ @TestMethod("testConfigure_IAtom_IIsotope") public IAtom configure(IAtom atom, IIsotope isotope) { atom.setMassNumber(isotope.getMassNumber()); atom.setSymbol(isotope.getSymbol()); atom.setExactMass(isotope.getExactMass()); atom.setAtomicNumber(isotope.getAtomicNumber()); atom.setNaturalAbundance(isotope.getNaturalAbundance()); return atom; } /** * Configures atoms in an AtomContainer to * carry all the correct data according to their element type. * *@param container The AtomContainer to be configured */ @TestMethod("testConfigureAtoms_IAtomContainer") public void configureAtoms(IAtomContainer container) { for (int f = 0; f < container.getAtomCount(); f++) { configure(container.getAtom(f)); } } /** * Gets the natural mass of this element, defined as average of masses of isotopes, * weighted by abundance. * * @param element Description of the Parameter * @return The natural mass value */ @TestMethod("testGetNaturalMass_IElement") public double getNaturalMass(IElement element){ IIsotope[] isotopes = getIsotopes(element.getSymbol()); double summedAbundances = 0; double summedWeightedAbundances = 0; double getNaturalMass = 0; for (int i = 0; i < isotopes.length; i++) { summedAbundances += isotopes[i].getNaturalAbundance(); summedWeightedAbundances += isotopes[i].getNaturalAbundance() * isotopes[i].getExactMass(); getNaturalMass = summedWeightedAbundances / summedAbundances; } return getNaturalMass; } } cdk-1.2.10/src/main/org/openscience/cdk/config/OWLBasedAtomTypeConfigurator.java100644 0 0 5465 11570154753 24621 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2003-2008 Egon Willighagen * * 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. * * 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.config; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.atomtypes.OWLAtomTypeReader; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.tools.LoggingTool; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.List; /** * AtomType resource that reads the atom type configuration from an OWL file. * * @cdk.module core * @cdk.githash */ @TestClass("org.openscience.cdk.config.OWLBasedAtomTypeConfiguratorTest") public class OWLBasedAtomTypeConfigurator implements IAtomTypeConfigurator { private InputStream ins = null; private LoggingTool logger; public OWLBasedAtomTypeConfigurator() { logger = new LoggingTool(this); } @TestMethod("testSetInputStream_InputStream") public void setInputStream(InputStream ins) { this.ins = ins; } /** * Reads the atom types from the OWL based atom type list. * * @param builder IChemObjectBuilder used to construct the IAtomType's. * @throws IOException when a problem occurred with reading from the InputStream * @return A List with read IAtomType's. */ @TestMethod("testReadAtomTypes_IChemObjectBuilder") public List readAtomTypes(IChemObjectBuilder builder) throws IOException { List atomTypes; if (ins == null) throw new IOException("There was a problem getting an input stream"); OWLAtomTypeReader reader = new OWLAtomTypeReader(new InputStreamReader(ins)); atomTypes = reader.readAtomTypes(builder); for (IAtomType atomType : atomTypes) { if (atomType == null) { logger.debug("Expecting an object but found null!"); } } return atomTypes; } } cdk-1.2.10/src/main/org/openscience/cdk/config/Symbols.java100644 0 0 7452 11570154753 20601 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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 org.openscience.cdk.config; import java.util.HashMap; import java.util.Map; /** * List of element symbols. Data is taken from the Blue Obelisk Data Repository, * version 3. * * @author egonw * @cdk.module standard * @cdk.githash */ public class Symbols { public final static String[] byAtomicNumber = { "Xx", // 0 "H", // 1 "He", // 2 "Li", // 3 "Be", // 4 "B", // 5 "C", // 6 "N", // 7 "O", // 8 "F", // 9 "Ne", // 10 "Na", // 11 "Mg", // 12 "Al", // 13 "Si", // 14 "P", // 15 "S", // 16 "Cl", // 17 "Ar", // 18 "K", // 19 "Ca", // 20 "Sc", // 21 "Ti", // 22 "V", // 23 "Cr", // 24 "Mn", // 25 "Fe", // 26 "Co", // 27 "Ni", // 28 "Cu", // 29 "Zn", // 30 "Ga", // 31 "Ge", // 32 "As", // 33 "Se", // 34 "Br", // 35 "Kr", // 36 "Rb", // 37 "Sr", // 38 "Y", // 39 "Zr", // 40 "Nb", // 41 "Mo", // 42 "Tc", // 43 "Ru", // 44 "Rh", // 45 "Pd", // 46 "Ag", // 47 "Cd", // 48 "In", // 49 "Sn", // 50 "Sb", // 51 "Te", // 52 "I", // 53 "Xe", // 54 "Cs", // 55 "Ba", // 56 "La", // 57 "Ce", // 58 "Pr", // 59 "Nd", // 60 "Pm", // 61 "Sm", // 62 "Eu", // 63 "Gd", // 64 "Tb", // 65 "Dy", // 66 "Ho", // 67 "Er", // 68 "Tm", // 69 "Yb", // 70 "Lu", // 71 "Hf", // 72 "Ta", // 73 "W", // 74 "Re", // 75 "Os", // 76 "Ir", // 77 "Pt", // 78 "Au", // 79 "Hg", // 80 "Tl", // 81 "Pb", // 82 "Bi", // 83 "Po", // 84 "At", // 85 "Rn", // 86 "Fr", // 87 "Ra", // 88 "Ac", // 89 "Th", // 90 "Pa", // 91 "U", // 92 "Np", // 93 "Pu", // 94 "Am", // 95 "Cm", // 96 "Bk", // 97 "Cf", // 98 "Es", // 99 "Fm", // 100 "Md", // 101 "No", // 102 "Lr", // 103 "Rf", // 104 "Db", // 105 "Sg", // 106 "Bh", // 107 "Hs", // 108 "Mt", // 109 "Ds", // 110 "Rg", // 111 "Uub", // 112 "Uut", // 113 "Uuq", // 114 "Uup", // 115 "Uuh" // 116 }; public final static int KNOWN_ELEMENTS = 116; private final static Map symbolToAtomicNumberMap = new HashMap(); /** * Returns the atomic number of the element identified by the given symbol. * * @return null, if the symbol is not recognized */ public static Integer getAtomicNumber(String symbol) { if (symbolToAtomicNumberMap.size() == 0) fillSymbolToAtomicNumberMap(); return symbolToAtomicNumberMap.get(symbol); } private static void fillSymbolToAtomicNumberMap() { for (int i=0; i * * Contact: cdk-developers@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. * * 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.config; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IChemObjectBuilder; import java.awt.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; /** * AtomType list configurator that uses the AtomTypes originally * defined in Jmol v5. This class was added to be able to port * Jmol to CDK. The AtomType's themselves seems have a computational * background, but this is not clear. * * @cdk.module core * @cdk.githash * * @author Bradley A. Smith * * @cdk.keyword atom, type */ @TestClass("org.openscience.cdk.config.TXTBasedAtomTypeConfiguratorTest") public class TXTBasedAtomTypeConfigurator implements IAtomTypeConfigurator { private String configFile = "org/openscience/cdk/config/data/jmol_atomtypes.txt"; private InputStream ins = null; public TXTBasedAtomTypeConfigurator() { } /** * Sets the file containing the config data. */ @TestMethod("testSetInputStream_InputStream") public void setInputStream(InputStream ins) { this.ins = ins; } /** * Reads a text based configuration file. * * @param builder IChemObjectBuilder used to construct the IAtomType's. * @throws IOException when a problem occured with reading from the InputStream * @return A List with read IAtomType's. */ @TestMethod("testReadAtomTypes_IChemObjectBuilder") public List readAtomTypes(IChemObjectBuilder builder) throws IOException { List atomTypes = new ArrayList(); if (ins == null) { // trying the default //logger.debug("readAtomTypes getResourceAsStream:" // + configFile); ins = this.getClass().getClassLoader().getResourceAsStream(configFile); } if (ins == null) throw new IOException("There was a problem getting the default stream: " + configFile); // read the contents from file BufferedReader reader = new BufferedReader(new InputStreamReader(ins), 1024); StringTokenizer tokenizer; String string; while (true) { string = reader.readLine(); if (string == null) { break; } if (!string.startsWith("#")) { String name; String rootType; int atomicNumber, colorR, colorG, colorB; double mass, covalent; tokenizer = new StringTokenizer(string, "\t ,;"); int tokenCount = tokenizer.countTokens(); if (tokenCount == 9) { name = tokenizer.nextToken(); rootType = tokenizer.nextToken(); String san = tokenizer.nextToken(); String sam = tokenizer.nextToken(); tokenizer.nextToken(); // skip the vdw radius value String scovalent = tokenizer.nextToken(); String sColorR = tokenizer.nextToken(); String sColorG = tokenizer.nextToken(); String sColorB = tokenizer.nextToken(); try { mass = new Double(sam); covalent = new Double(scovalent); atomicNumber = Integer.parseInt(san); colorR = Integer.parseInt(sColorR); colorG = Integer.parseInt(sColorG); colorB = Integer.parseInt(sColorB); } catch (NumberFormatException nfe) { throw new IOException("AtomTypeTable.ReadAtypes: " + "Malformed Number"); } IAtomType atomType = builder.newAtomType(name, rootType); atomType.setAtomicNumber(atomicNumber); atomType.setExactMass(mass); atomType.setCovalentRadius(covalent); Color color = new Color(colorR, colorG, colorB); atomType.setProperty("org.openscience.cdk.renderer.color", color); atomTypes.add(atomType); } else { throw new IOException("AtomTypeTable.ReadAtypes: " + "Wrong Number of fields"); } } } // end while ins.close(); return atomTypes; } } cdk-1.2.10/src/main/org/openscience/cdk/config/atomtypes/AtomTypeHandler.java100644 0 0 27424 11570154753 24257 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 Egon Willighagen * * Contact: cdk-devel@lists.sf.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.config.atomtypes; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IAtomType.Hybridization; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.tools.LoggingTool; import org.xml.sax.Attributes; import org.xml.sax.helpers.DefaultHandler; import java.util.ArrayList; import java.util.List; /** * SAX Handler for the AtomTypeReader. * * @see AtomTypeReader * * @cdk.module core * @cdk.githash */ @TestClass("org.openscience.cdk.config.atomtypes.AtomTypeHandlerTest") public class AtomTypeHandler extends DefaultHandler { private final int SCALAR_UNSET = 0; private final int SCALAR_MAXBONDORDER = 1; private final int SCALAR_BONDORDERSUM = 2; private final int SCALAR_HYBRIDIZATION = 3; private final int SCALAR_FORMALNEIGHBOURCOUNT = 4; private final int SCALAR_VALENCY = 5; private final int SCALAR_DA = 6; private final int SCALAR_SPHERICALMATCHER = 7; private final int SCALAR_CHEMICALGROUPCONSTANT = 8; private final int SCALAR_RINGSIZE = 9; private final int SCALAR_ISAROMATIC = 10; private final int SCALAR_FORMALCHARGE=11; private final int SCALAR_VANDERWAALSRADIUS=12; private final int SCALAR_PIBONDCOUNT=13; private final int SCALAR_LONEPAIRCOUNT=14; private LoggingTool logger; private String currentChars; private List atomTypes; private int scalarType; private IAtomType atomType; private static IChemObjectBuilder builder; /** * Constructs a new AtomTypeHandler and will create IAtomType * implementations using the given IChemObjectBuilder. * * @param build The IChemObjectBuilder used to create the IAtomType's. */ public AtomTypeHandler(IChemObjectBuilder build) { logger = new LoggingTool(this); builder = build; } /** * Returns a List with read IAtomType's. * * @return The read IAtomType's. */ @TestMethod("testGetAtomTypes") public List getAtomTypes() { return atomTypes; } // SAX Parser methods /* public void doctypeDecl(String name, String publicId, String systemId) { logger.info("DocType root element: " + name); logger.info("DocType root PUBLIC: " + publicId); logger.info("DocType root SYSTEM: " + systemId); } */ @TestMethod("testStartDocument") public void startDocument() { atomTypes = new ArrayList(); scalarType = SCALAR_UNSET; atomType = null; } @TestMethod("testEndElement_String_String_String") public void endElement(String uri, String local, String raw) { //NOPMD logger.debug("END Element: ", raw); logger.debug(" uri: ", uri); logger.debug(" local: ", local); logger.debug(" raw: ", raw); logger.debug(" chars: ", currentChars.trim()); if ("atomType".equals(local)) { atomTypes.add(atomType); } else if ("scalar".equals(local)) { currentChars.trim(); try { if (scalarType == SCALAR_BONDORDERSUM) { atomType.setBondOrderSum(Double.parseDouble(currentChars)); } else if (scalarType == SCALAR_MAXBONDORDER) { double scalarValue = Double.parseDouble(currentChars); if (scalarValue == 1.0) { atomType.setMaxBondOrder(IBond.Order.SINGLE); } else if (scalarValue == 2.0) { atomType.setMaxBondOrder(IBond.Order.DOUBLE); } else if (scalarValue == 3.0) { atomType.setMaxBondOrder(IBond.Order.TRIPLE); } else if (scalarValue == 4.0) { atomType.setMaxBondOrder(IBond.Order.QUADRUPLE); } } else if (scalarType == SCALAR_FORMALNEIGHBOURCOUNT) { atomType.setFormalNeighbourCount(Integer.parseInt(currentChars)); }else if (scalarType == SCALAR_VALENCY) { atomType.setValency(Integer.parseInt(currentChars)); }else if (scalarType == SCALAR_FORMALCHARGE) { atomType.setFormalCharge(Integer.parseInt(currentChars)); } else if (scalarType == SCALAR_HYBRIDIZATION) { if ("sp1".equals(currentChars)) { atomType.setHybridization(Hybridization.SP1); } else if ("sp2".equals(currentChars)) { atomType.setHybridization(Hybridization.SP2); } else if ("sp3".equals(currentChars)) { atomType.setHybridization(Hybridization.SP3); } else if ("planar".equals(currentChars)) { atomType.setHybridization(Hybridization.PLANAR3); }else { logger.warn("Unrecognized hybridization in config file: ", currentChars); } } else if (scalarType == SCALAR_DA){ if ("A".equals(currentChars)) { atomType.setFlag(CDKConstants.IS_HYDROGENBOND_ACCEPTOR, true); } else if ("D".equals(currentChars)){ atomType.setFlag(CDKConstants.IS_HYDROGENBOND_DONOR, true); } else { logger.warn("Unrecognized H-bond donor/acceptor pattern in config file: ", currentChars); } } else if (scalarType == SCALAR_SPHERICALMATCHER){ atomType.setProperty(CDKConstants.SPHERICAL_MATCHER, currentChars); } else if (scalarType == SCALAR_RINGSIZE){ atomType.setProperty(CDKConstants.PART_OF_RING_OF_SIZE, Integer.valueOf(currentChars)); } else if (scalarType == SCALAR_CHEMICALGROUPCONSTANT){ atomType.setProperty(CDKConstants.CHEMICAL_GROUP_CONSTANT, Integer.valueOf(currentChars)); } else if (scalarType == SCALAR_ISAROMATIC){ atomType.setFlag(CDKConstants.ISAROMATIC, true); } else if (scalarType == SCALAR_PIBONDCOUNT){ atomType.setProperty(CDKConstants.PI_BOND_COUNT, Integer.valueOf(currentChars)); } else if (scalarType == SCALAR_LONEPAIRCOUNT){ atomType.setProperty(CDKConstants.LONE_PAIR_COUNT, Integer.valueOf(currentChars)); } } catch (Exception exception) { logger.error("Value (", currentChars, ") is not off the expected type: ", exception.getMessage()); logger.debug(exception); } scalarType = SCALAR_UNSET; } currentChars = ""; } @TestMethod("testStartElement_String_String_String_Attributes") public void startElement(String uri, String local, //NOPMD String raw, Attributes atts) { currentChars = ""; logger.debug("START Element: ", raw); logger.debug(" uri: ", uri); logger.debug(" local: ", local); logger.debug(" raw: ", raw); if ("atomType".equals(local)) { atomType = builder.newAtomType("R"); for (int i = 0; i < atts.getLength(); i++) { if ("id".equals(atts.getQName(i))) { atomType.setAtomTypeName(atts.getValue(i)); } } } else if ("atom".equals(local)) { for (int i = 0; i < atts.getLength(); i++) { if ("elementType".equals(atts.getQName(i))) { atomType.setSymbol(atts.getValue(i)); } else if ("formalCharge".equals(atts.getQName(i))) { try { atomType.setFormalCharge(Integer.parseInt(atts.getValue(i))); } catch (NumberFormatException exception) { logger.error("Value of @", atts.getQName(i), " is not an integer: ", atts.getValue(i)); logger.debug(exception); } } } } else if ("label".equals(local)) { // assume xpath atomType/label for (int i = 0; i < atts.getLength(); i++) { if ("value".equals(atts.getQName(i))) { if (atomType.getAtomTypeName() != null) { atomType.setID(atomType.getAtomTypeName()); } atomType.setAtomTypeName(atts.getValue(i)); } } } else if ("scalar".equals(local)) { for (int i = 0; i < atts.getLength(); i++) { if ("dictRef".equals(atts.getQName(i))) { if ("cdk:maxBondOrder".equals(atts.getValue(i))) { scalarType = SCALAR_MAXBONDORDER; } else if ("cdk:bondOrderSum".equals(atts.getValue(i))) { scalarType = SCALAR_BONDORDERSUM; } else if ("cdk:hybridization".equals(atts.getValue(i))) { scalarType = SCALAR_HYBRIDIZATION; } else if ("cdk:formalNeighbourCount".equals(atts.getValue(i))) { scalarType = SCALAR_FORMALNEIGHBOURCOUNT; } else if ("cdk:valency".equals(atts.getValue(i))) { scalarType = SCALAR_VALENCY; } else if ("cdk:formalCharge".equals(atts.getValue(i))) { scalarType = SCALAR_FORMALCHARGE; } else if ("cdk:DA".equals(atts.getValue(i))) { scalarType = SCALAR_DA; } else if ("cdk:sphericalMatcher".equals(atts.getValue(i))) { scalarType = SCALAR_SPHERICALMATCHER; } else if ("cdk:ringSize".equals(atts.getValue(i))) { scalarType = SCALAR_RINGSIZE; } else if ("cdk:ringConstant".equals(atts.getValue(i))) { scalarType = SCALAR_CHEMICALGROUPCONSTANT; } else if ("cdk:aromaticAtom".equals(atts.getValue(i))) { scalarType = SCALAR_ISAROMATIC; } else if ("emboss:vdwrad".equals(atts.getValue(i))) { scalarType = SCALAR_VANDERWAALSRADIUS; } else if ("cdk:piBondCount".equals(atts.getValue(i))) { scalarType = SCALAR_PIBONDCOUNT; } else if ("cdk:lonePairCount".equals(atts.getValue(i))) { scalarType = SCALAR_LONEPAIRCOUNT; } } } } } @TestMethod("testCharacters_arraychar_int_int") public void characters(char chars[], int start, int length) { logger.debug("character data"); currentChars += new String(chars, start, length); } } cdk-1.2.10/src/main/org/openscience/cdk/config/atomtypes/AtomTypeReader.java100644 0 0 12662 11570154753 24102 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2002-2007 Egon Willighagen * * 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 org.openscience.cdk.config.atomtypes; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.tools.LoggingTool; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import java.io.IOException; import java.io.Reader; import java.util.ArrayList; import java.util.List; /** * XML Reader for the CDKBasedAtomTypeConfigurator. * * @see org.openscience.cdk.config.CDKBasedAtomTypeConfigurator * * @cdk.module core * @cdk.githash */ @TestClass("org.openscience.cdk.config.atomtypes.AtomTypeReaderTest") public class AtomTypeReader { private XMLReader parser; private Reader input; private LoggingTool logger; /** * Instantiates the XML based AtomTypeReader. * * @param input The Reader to read the IAtomType's from. */ public AtomTypeReader(Reader input) { this.init(); this.input = input; } private void init() { logger = new LoggingTool(this); boolean success = false; // If JAXP is prefered (comes with Sun JVM 1.4.0 and higher) if (!success) { try { javax.xml.parsers.SAXParserFactory spf = javax.xml.parsers.SAXParserFactory.newInstance(); spf.setNamespaceAware(true); javax.xml.parsers.SAXParser saxParser = spf.newSAXParser(); parser = saxParser.getXMLReader(); logger.info("Using JAXP/SAX XML parser."); success = true; } catch (Exception exception) { logger.warn("Could not instantiate JAXP/SAX XML reader!"); logger.debug(exception); } } // Aelfred is first alternative. if (!success) { try { parser = (XMLReader)this.getClass().getClassLoader(). loadClass("gnu.xml.aelfred2.XmlReader"). newInstance(); logger.info("Using Aelfred2 XML parser."); success = true; } catch (Exception exception) { logger.warn("Could not instantiate Aelfred2 XML reader!"); logger.debug(exception); } } // Xerces is second alternative if (!success) { try { parser = (XMLReader)this.getClass().getClassLoader(). loadClass("org.apache.xerces.parsers.SAXParser"). newInstance(); logger.info("Using Xerces XML parser."); success = true; } catch (Exception exception) { logger.warn("Could not instantiate Xerces XML reader!"); logger.debug(exception); } } if (!success) { logger.error("Could not instantiate any XML parser!"); } } /** * Reads the atom types from the data file. * * @param builder The IChemObjectBuilder used to create new IAtomType's. * @return a List with atom types. Is empty if some reading error occured. */ @TestMethod("testReadAtomTypes2,testReadAtomTypes_CDK,testReadAtomTypes_FF,testReadAtomTypes_IChemObjectBuilder") public List readAtomTypes(IChemObjectBuilder builder) { List isotopes = new ArrayList(); try { parser.setFeature("http://xml.org/sax/features/validation", false); logger.info("Deactivated validation"); } catch (SAXException exception) { logger.warn("Cannot deactivate validation: ", exception.getMessage()); logger.debug(exception); } AtomTypeHandler handler = new AtomTypeHandler(builder); parser.setContentHandler(handler); try { parser.parse(new InputSource(input)); isotopes = handler.getAtomTypes(); } catch (IOException exception) { logger.error("IOException: ",exception.getMessage()); logger.debug(exception); } catch (SAXException saxe) { logger.error("SAXException: ", saxe.getMessage()); logger.debug(saxe); } return isotopes; } } cdk-1.2.10/src/main/org/openscience/cdk/config/atomtypes/OWLAtomTypeHandler.java100644 0 0 13567 11570154753 24644 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2003-2008 Egon Willighagen * * Contact: cdk-devel@lists.sf.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.config.atomtypes; import java.util.ArrayList; import java.util.List; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.tools.LoggingTool; import org.xml.sax.Attributes; import org.xml.sax.helpers.DefaultHandler; /** * SAX Handler for the {@link OWLAtomTypeReader}. * * @cdk.module core * @cdk.githash */ @TestClass("org.openscience.cdk.config.atomtypes.OWLAtomTypeHandlerTest") public class OWLAtomTypeHandler extends DefaultHandler { private final String NS_ATOMTYPE = "http://cdk.sf.net/ontologies/atomtypes#"; private LoggingTool logger; private String currentChars; private List atomTypes; private IAtomType currentAtomType; private static IChemObjectBuilder builder; /** * Constructs a new AtomTypeHandler and will create IAtomType * implementations using the given IChemObjectBuilder. * * @param build The IChemObjectBuilder used to create the IAtomType's. */ public OWLAtomTypeHandler(IChemObjectBuilder build) { logger = new LoggingTool(this); builder = build; } /** * Returns a List with read IAtomType's. * * @return The read IAtomType's. */ @TestMethod("testGetAtomTypes") public List getAtomTypes() { return atomTypes; } // SAX Parser methods @TestMethod("testStartDocument") public void startDocument() { atomTypes = new ArrayList(); currentAtomType = null; } @TestMethod("testedByOtherClass") public void endElement(String uri, String local, String raw) { if (NS_ATOMTYPE.equals(uri)) { endAtomTypeElement(local); } // ignore other namespaces currentChars = ""; } private void endAtomTypeElement(String local) { if ("AtomType".equals(local)) { atomTypes.add(currentAtomType); } else if ("formalCharge".equals(local)) { if (currentChars.charAt(0) == '+') { currentChars = currentChars.substring(1); } currentAtomType.setFormalCharge(Integer.parseInt(currentChars)); } else if ("formalNeighbourCount".equals(local)) { currentAtomType.setFormalNeighbourCount(Integer.parseInt(currentChars)); } else if ("lonePairCount".equals(local)) { currentAtomType.setProperty(CDKConstants.LONE_PAIR_COUNT, Integer.parseInt(currentChars)); } else if ("piBondCount".equals(local)) { currentAtomType.setProperty(CDKConstants.PI_BOND_COUNT, Integer.parseInt(currentChars)); } } @TestMethod("testedByOtherClass") public void startElement(String uri, String local, String raw, Attributes atts) { currentChars = ""; if (NS_ATOMTYPE.equals(uri)) { startAtomTypeElement(local, atts); } // ignore other namespaces } private void startAtomTypeElement(String local, Attributes atts) { if ("AtomType".equals(local)) { currentAtomType = builder.newAtomType("H"); currentAtomType.setAtomTypeName(atts.getValue("rdf:ID")); } else if ("hasElement".equals(local)) { String attrValue = atts.getValue("rdf:resource"); currentAtomType.setSymbol(attrValue.substring(attrValue.indexOf("#")+1)); } else if ("hybridization".equals(local)) { String attrValue = atts.getValue("rdf:resource"); String hybridization = attrValue.substring(attrValue.indexOf("#")+1); if ("sp3".equals(hybridization)) { currentAtomType.setHybridization(IAtomType.Hybridization.SP3); } else if ("sp2".equals(hybridization)) { currentAtomType.setHybridization(IAtomType.Hybridization.SP2); } else if ("sp1".equals(hybridization)) { currentAtomType.setHybridization(IAtomType.Hybridization.SP1); } else if ("s".equals(hybridization)) { currentAtomType.setHybridization(IAtomType.Hybridization.S); } else if ("planar".equals(hybridization)) { currentAtomType.setHybridization(IAtomType.Hybridization.PLANAR3); } else if ("sp3d1".equals(hybridization)) { currentAtomType.setHybridization(IAtomType.Hybridization.SP3D1); } else if ("sp3d2".equals(hybridization)) { currentAtomType.setHybridization(IAtomType.Hybridization.SP3D2); } else if ("sp3d3".equals(hybridization)) { currentAtomType.setHybridization(IAtomType.Hybridization.SP3D3); } else if ("sp3d4".equals(hybridization)) { currentAtomType.setHybridization(IAtomType.Hybridization.SP3D4); } else if ("sp3d5".equals(hybridization)) { currentAtomType.setHybridization(IAtomType.Hybridization.SP3D5); } } } @TestMethod("testedByOtherClass") public void characters(char chars[], int start, int length) { logger.debug("character data"); currentChars += new String(chars, start, length); } } cdk-1.2.10/src/main/org/openscience/cdk/config/atomtypes/OWLAtomTypeMappingHandler.java100644 0 0 7023 11570154753 26126 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2003-2008 Egon Willighagen * * Contact: cdk-devel@lists.sf.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.config.atomtypes; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.xml.sax.Attributes; import org.xml.sax.helpers.DefaultHandler; import java.util.Hashtable; import java.util.Map; /** * SAX Handler for the {@link OWLAtomTypeMappingReader}. * * @cdk.module atomtype * @cdk.githash */ @TestClass("org.openscience.cdk.config.atomtypes.OWLAtomTypeMappingHandlerTest") public class OWLAtomTypeMappingHandler extends DefaultHandler { private final String NS_ATOMTYPE_MAPPING = "http://cdk.sf.net/ontologies/atomtypemappings#"; private final String NS_OWL = "http://www.w3.org/2002/07/owl#"; private Map atomTypeMappings; private String fromType; private String toType; /** * Constructs a new OWLAtomTypeMappingHandler. */ public OWLAtomTypeMappingHandler() {} /** * Returns a {@link Map} with atom type mappings. */ @TestMethod("testGetAtomTypeMappings") public Map getAtomTypeMappings() { return atomTypeMappings; } // SAX Parser methods @TestMethod("testStartDocument") public void startDocument() { atomTypeMappings = new Hashtable(); } @TestMethod("testEndElement_String_String_String") public void endElement(String uri, String local, String raw) { if (NS_OWL.equals(uri)) { endAtomTypeElement(local); } // ignore other namespaces } private void endAtomTypeElement(String local) { if ("Thing".equals(local) && toType != null && fromType != null) { atomTypeMappings.put(fromType, toType); } } @TestMethod("testStartElement_String_String_String_Attributes") public void startElement(String uri, String local, String raw, Attributes atts) { if (NS_OWL.equals(uri)) { startOWLElement(local, atts); } else if (NS_ATOMTYPE_MAPPING.equals(uri)) { startAtomTypeMappingElement(local, atts); } // ignore other namespaces } private void startOWLElement(String local, Attributes atts) { if ("Thing".equals(local)) { toType = null; fromType = atts.getValue("rdf:about"); fromType = fromType.substring(fromType.indexOf('#')+1); } } private void startAtomTypeMappingElement(String local, Attributes atts) { if ("mapsToType".equals(local) || "equivalentAsType".equals(local)) { toType = atts.getValue("rdf:resource"); toType = toType.substring(toType.indexOf('#')+1); } } @TestMethod("testCharacters_arraychar_int_int") public void characters(char chars[], int start, int length) {} } cdk-1.2.10/src/main/org/openscience/cdk/config/atomtypes/OWLAtomTypeMappingReader.java100644 0 0 11455 11570154753 25777 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2002-2008 Egon Willighagen * * 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 org.openscience.cdk.config.atomtypes; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.OWLBasedAtomTypeConfigurator; import org.openscience.cdk.tools.LoggingTool; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import java.io.IOException; import java.io.Reader; import java.util.HashMap; import java.util.Map; /** * XML Reader for the {@link OWLBasedAtomTypeConfigurator}. * * @cdk.module atomtype * @cdk.githash */ @TestClass("org.openscience.cdk.config.atomtypes.OWLAtomTypeMappingReaderTest") public class OWLAtomTypeMappingReader { private XMLReader parser; private Reader input; private LoggingTool logger; /** * Instantiates the XML based AtomTypeReader. * * @param input The Reader to read the IAtomType's from. */ @TestMethod("testOWLAtomTypeMappingReader_Reader") public OWLAtomTypeMappingReader(Reader input) { this.init(); this.input = input; } private void init() { logger = new LoggingTool(this); boolean success = false; // If JAXP is preferred (comes with Sun JVM 1.4.0 and higher) if (!success) { try { javax.xml.parsers.SAXParserFactory spf = javax.xml.parsers.SAXParserFactory.newInstance(); spf.setNamespaceAware(true); javax.xml.parsers.SAXParser saxParser = spf.newSAXParser(); parser = saxParser.getXMLReader(); logger.info("Using JAXP/SAX XML parser."); success = true; } catch (Exception exception) { logger.warn("Could not instantiate JAXP/SAX XML reader!"); logger.debug(exception); } } // Xerces is an alternative if (!success) { try { parser = (XMLReader)this.getClass().getClassLoader(). loadClass("org.apache.xerces.parsers.SAXParser"). newInstance(); logger.info("Using Xerces XML parser."); success = true; } catch (Exception exception) { logger.warn("Could not instantiate Xerces XML reader!"); logger.debug(exception); } } if (!success) { logger.error("Could not instantiate any XML parser!"); } } /** * Reads the atom type mappings from the data file. * * @return a Map with atom type mappings. Null, if some reading error occurred. */ @TestMethod("testReadAtomTypeMappings,testReadAtomTypes_CDK2Sybyl") public Map readAtomTypeMappings() { Map mappings = null; try { parser.setFeature("http://xml.org/sax/features/validation", false); logger.info("Deactivated validation"); } catch (SAXException exception) { logger.warn("Cannot deactivate validation: ", exception.getMessage()); logger.debug(exception); } OWLAtomTypeMappingHandler handler = new OWLAtomTypeMappingHandler(); parser.setContentHandler(handler); try { parser.parse(new InputSource(input)); mappings = handler.getAtomTypeMappings(); } catch (IOException exception) { logger.error("IOException: ",exception.getMessage()); logger.debug(exception); } catch (SAXException saxe) { logger.error("SAXException: ", saxe.getMessage()); logger.debug(saxe); } return mappings == null ? new HashMap() : mappings; } } cdk-1.2.10/src/main/org/openscience/cdk/config/atomtypes/OWLAtomTypeReader.java100644 0 0 11565 11570154753 24465 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2002-2008 Egon Willighagen * * 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 org.openscience.cdk.config.atomtypes; import java.io.IOException; import java.io.Reader; import java.util.ArrayList; import java.util.List; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.OWLBasedAtomTypeConfigurator; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.tools.LoggingTool; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; /** * XML Reader for the {@link OWLBasedAtomTypeConfigurator}. * * @cdk.module core * @cdk.githash */ @TestClass("org.openscience.cdk.config.atomtypes.OWLAtomTypeReaderTest") public class OWLAtomTypeReader { private XMLReader parser; private Reader input; private LoggingTool logger; /** * Instantiates the XML based AtomTypeReader. * * @param input The Reader to read the IAtomType's from. */ public OWLAtomTypeReader(Reader input) { this.init(); this.input = input; } private void init() { logger = new LoggingTool(this); boolean success = false; // If JAXP is preferred (comes with Sun JVM 1.4.0 and higher) if (!success) { try { javax.xml.parsers.SAXParserFactory spf = javax.xml.parsers.SAXParserFactory.newInstance(); spf.setNamespaceAware(true); javax.xml.parsers.SAXParser saxParser = spf.newSAXParser(); parser = saxParser.getXMLReader(); logger.info("Using JAXP/SAX XML parser."); success = true; } catch (Exception exception) { logger.warn("Could not instantiate JAXP/SAX XML reader!"); logger.debug(exception); } } // Xerces is an alternative if (!success) { try { parser = (XMLReader)this.getClass().getClassLoader(). loadClass("org.apache.xerces.parsers.SAXParser"). newInstance(); logger.info("Using Xerces XML parser."); success = true; } catch (Exception exception) { logger.warn("Could not instantiate Xerces XML reader!"); logger.debug(exception); } } if (!success) { logger.error("Could not instantiate any XML parser!"); } } /** * Reads the atom types from the data file. * * @param builder The IChemObjectBuilder used to create new IAtomType's. * @return a List with atom types. Is empty if some reading error occured. */ @TestMethod("testReadAtomTypes_CDK,testReadAtomTypes_IChemObjectBuilder") public List readAtomTypes(IChemObjectBuilder builder) { List isotopes = new ArrayList(); try { parser.setFeature("http://xml.org/sax/features/validation", false); logger.info("Deactivated validation"); } catch (SAXException exception) { logger.warn("Cannot deactivate validation: ", exception.getMessage()); logger.debug(exception); } OWLAtomTypeHandler handler = new OWLAtomTypeHandler(builder); parser.setContentHandler(handler); try { parser.parse(new InputSource(input)); isotopes = handler.getAtomTypes(); } catch (IOException exception) { logger.error("IOException: ",exception.getMessage()); logger.debug(exception); } catch (SAXException saxe) { logger.error("SAXException: ", saxe.getMessage()); logger.debug(saxe); } return isotopes; } } cdk-1.2.10/src/main/org/openscience/cdk/config/data/chemicalElements.xml100644 0 0 245373 11570154753 23251 0ustar 0 0 Pseudoatom 0 1 1 Hydrogen 1 Nonmetals Gas 0.37 1.2 2.20 18 1 Helium 2 Noble Gasses Gas 0.32 1.4 1 2 Lithium 3 Alkali Metals Solid 0.32 2.2 0.98 2 2 Beryllium 4 Alkali Earth Metals Solid 0.90 1.9 1.57 13 2 Boron 5 Metalloids Solid 0.82 1.8 2.04 14 2 Carbon 6 Nonmetals Solid 0.77 1.7 2.55 15 2 Nitrogen 7 Nonmetals Gas 0.77 1.6 3.04 16 2 Oxygen 8 Nonmetals Gas 0.73 1.55 3.44 17 2 Fluorine 9 Halogens Gas 0.73 1.5 3.98 18 2 Neon 10 Noble Gasses Gas 0.69 1.54 1 3 Sodium 11 Alkali Metals Solid 1.54 2.4 0.93 2 3 Magnesium 12 Alkali Earth Metals Solid 1.30 2.2 1.31 13 3 Aluminum 13 Metals Solid 1.18 2.1 1.61 14 3 Silicon 14 Metalloids Solid 1.11 2.1 1.90 15 3 Phosphorus 15 Nonmetals Solid 1.06 1.95 2.19 16 3 Sulfur 16 Nonmetals Solid 1.02 1.8 2.58 17 3 Chlorine 17 Halogens Gas 0.99 1.8 3.16 18 3 Argon 18 Noble Gasses Gas 0.97 1.8 1 4 Potassium 19 Alkali Metals Solid 1.96 2.8 0.82 2 4 Calcium 20 Alkali Earth Metals Solid 1.74 2.4 1.00 13 4 Gallium 31 Metals Solid 2.1 1.81 14 4 Germanium 32 Metalloids Solid 1.22 2.1 2.01 15 4 Arsenic 33 Metalloids Solid 1.19 2.05 2.18 16 4 Selenium 34 Nonmetals Solid 1.16 1.9 2.55 17 4 Bromine 35 Halogens Liquid 1.14 1.9 2.96 18 4 Krypton 36 Noble Gasses Gas 1.10 2.02 3.00 1 5 Rubidium 37 Alkali Metals Solid 2.11 2.9 0.82 2 5 Strontium 38 Alkali Earth Metals Solid 1.92 2.55 0.95 13 5 Indium 49 Metals Solid 2.25 14 5 Tin 50 Metals Solid 1.41 2.25 15 5 Antimony 51 Metalloids Solid 1.38 2.2 16 5 Tellurium 52 Metalloids Solid 1.35 2.1 17 5 Iodine 53 Halogens Solid 1.33 2.1 18 5 Xenon 54 Noble Gasses Gas 1.30 2.16 1 6 Cesium 55 Alkali Metals Solid 2.25 3 2 6 Barium 56 Alkali Earth Metals Solid 1.98 2.7 13 6 Thallium 81 Metals Solid 1.49 2.2 14 6 Lead 82 Metals Solid 1.48 2.3 15 6 Bismuth 83 Metals Solid 1.47 2.3 16 6 Polonium 84 Metalloids Solid 1.46 2 17 6 Astatine 85 Halogens Solid 2 18 6 Radon 86 Noble Gasses Gas 1.45 2 1 7 Francium 87 Alkali Metals Solid 2 2 7 Radium 88 Alkali Earth Metals Solid 2 3 4 Scandium 21 Transition metals Solid 1.44 2.3 1.36 4 4 Titanium 22 Transition metals Solid 1.44 2.15 1.54 5 4 Vanadium 23 Transition metals Solid 1.25 2.05 1.63 6 4 Chromium 24 Transition metals Solid 1.27 2.05 1.66 7 4 Manganese 25 Transition metals Solid 1.39 2.05 1.55 8 4 Iron 26 Transition metals Solid 1.25 2.05 1.83 9 4 Cobalt 27 Transition metals Solid 1.26 2 1.88 10 4 Nickel 28 Transition metals Solid 1.21 2 1.91 11 4 Copper 29 Transition metals Solid 1.38 2 1.90 12 4 Zinc 30 Transition metals Solid 1.31 2.1 1.65 3 5 Yttrium 39 Transition metals Solid 4 5 Zirconium 40 Transition metals Solid 1.48 2.3 5 5 Niobium 41 Transition metals Solid 1.37 2.15 6 5 Molybdenum 42 Transition metals Solid 1.45 2.1 7 5 Technetium 43 Transition metals Synthetic 1.56 2.05 8 5 Ruthenium 44 Transition metals Solid 1.26 2.05 9 5 Rhodium 45 Transition metals Solid 1.35 2 10 5 Palladium 46 Transition metals Solid 1.31 2.05 11 5 Silver 47 Transition metals Solid 1.53 2.1 12 5 Cadmium 48 Transition metals Solid 1.48 2.2 3 6 Lanthanum 57 Lanthanides Solid 1.69 2.5 4 6 Hafnium 72 Transition metals Solid 1.50 2.25 5 6 Tantalum 73 Transition metals Solid 1.38 2.2 6 6 Tungsten 74 Transition metals Solid 1.46 2.1 7 6 Rhenium 75 Transition metals Solid 1.59 2.05 8 6 Osmium 76 Transition metals Solid 1.28 2 9 6 Iridium 77 Transition metals Solid 1.37 2 10 6 Platinum 78 Transition metals Solid 1.28 2.05 11 6 Gold 79 Transition metals Solid 1.44 2.1 12 6 Mercury 80 Transition metals Liquid 1.49 2.05 3 7 Actinium 89 Actinides Synthetic 2 4 7 Rutherfordium 104 Transition metals Synthetic 5 7 Dubnium 105 Transition metals Synthetic 6 7 Seaborgium 106 Transition metals Synthetic 7 7 Bohrium 107 Transition metals Synthetic 8 7 Hassium 108 Transition metals Synthetic 9 7 Meitnerium 109 Transition metals Synthetic 9 7 Darmstadtium 110 Transition metals Synthetic 11 7 Roentgenium 111 Transition metals Synthetic 12 7 Ununbium 112 Transition metals Synthetic 6 Cerium 58 Lanthanides Solid 2.48 6 Praseodymium 59 Lanthanides Solid 2.47 6 Neodymium 60 Lanthanides Solid 2.47 6 Promethium 61 Lanthanides Synthetic 2.43 6 Samarium 62 Lanthanides Solid 2.43 6 Europium 63 Lanthanides Solid 2.4 6 Gadolinium 64 Lanthanides Solid 2.38 6 Terbium 65 Lanthanides Solid 2.37 6 Dysprosium 66 Lanthanides Solid 2.35 6 Holmium 67 Lanthanides Solid 2.33 6 Erbium 68 Lanthanides Solid 2.32 6 Thulium 69 Lanthanides Solid 2.3 6 Ytterbium 70 Lanthanides Solid 2.28 6 Lutetium 71 Lanthanides Solid 1.60 2.27 7 Thorium 90 Actinides Solid 2.3 7 Protactinium 91 Actinides Solid 2 7 Uranium 92 Actinides Solid 2.3 7 Neptunium 93 Actinides Synthetic 2 7 Plutonium 94 Actinides Synthetic 2 7 Americium 95 Actinides Synthetic 2 7 Curium 96 Actinides Synthetic 2 7 Berkelium 97 Actinides Synthetic 2 7 Californium 98 Actinides Synthetic 2 7 Einsteinium 99 Actinides Synthetic 2 7 Fermium 100 Actinides Synthetic 2 7 Mendelevium 101 Actinides Synthetic 2 7 Nobelium 102 Actinides Synthetic 2 7 Lawrencium 103 Actinides Synthetic 2 cdk-1.2.10/src/main/org/openscience/cdk/config/data/conversion_table.xml100644 0 0 1210 11570154753 23257 0ustar 0 0 cdk-1.2.10/src/main/org/openscience/cdk/config/data/electroneg-pauling.txt100644 0 0 1642 11570154753 23537 0ustar 0 0 # Pauling electronegativity # Columns represent the atomic number and the electronegativity (Pauling scale) # Missing values are omitted # # Sources: see electronic-pauling.bibxml # License: The MIT License 1 2.20 3 0.98 4 1.57 5 2.04 6 2.55 7 3.04 8 3.44 9 3.98 11 0.93 12 1.31 13 1.61 14 1.90 15 2.19 16 2.58 17 3.16 19 0.82 20 1.00 21 1.36 22 1.54 23 1.63 24 1.66 25 1.55 26 1.83 27 1.88 28 1.91 29 1.90 30 1.65 31 1.81 32 2.01 33 2.18 34 2.55 35 2.96 36 3.00 37 0.82 38 0.95 39 1.22 40 1.33 41 1.6 42 2.16 43 1.9 44 2.2 45 2.28 46 2.20 47 1.93 48 1.69 49 1.78 50 1.96 51 2.05 52 2.1 53 2.66 54 2.6 55 0.79 56 0.89 57 1.10 58 1.12 59 1.13 60 1.14 62 1.17 64 1.20 66 1.22 67 1.23 68 1.24 69 1.25 71 1.27 72 1.3 73 1.5 74 2.36 75 1.9 76 2.2 77 2.20 78 2.28 79 2.54 80 2.00 81 1.62 82 2.33 83 2.02 84 2.0 85 2.2 87 0.7 88 0.9 89 1.1 90 1.3 91 1.5 92 1.38 93 1.36 94 1.28 95 1.3 96 1.3 97 1.3 98 1.3 99 1.3 100 1.3 101 1.3 102 1.3 cdk-1.2.10/src/main/org/openscience/cdk/config/data/html.xsl100644 0 0 4770 11570154753 20713 0ustar 0 0 <xsl:value-of select="cml:atomTypeList/@title"/>

Atom Types

identifier element formal charge hybridization neighbours pi bonds lone pairs unpaired electron
yes cdk-1.2.10/src/main/org/openscience/cdk/config/data/isotopes.xml100644 0 0 3053747 11570154753 21701 0ustar 0 0 99.9885 1.007825032 1/2+ +2.792846 -1 1 0.0115 2.014101778 1+ +0.857438 -1 1 3.016049278 1/2+ +2.978960 3.88839e+08 0.01861 100.0 1 4.02781 1 5.03531 1 6.04494 1 7.05275 1 0.000137 3.016029319 1/2+ -2.127624 -1 2 99.999863 4.002603254 0+ -1 2 5.01222 2 6.0188891 0.8067 2 7.028021 2 8.033922 0.119 2 9.04395 2 10.0524 2 3.03078 3 4.02719 3 5.01254 3 7.59 6.015122795 1+ +0.822056 -1 3 92.41 7.01600455 3/2- +3.25644 -1 3 8.02248736 0.838 3 9.0267895 0.1783 3 10.035481 3 11.043798 0.0085 3 12.05378 3 5.04079 4 6.019726 4 7.01692983 3/2- 4.58957e+06 0.862 100.0 4 8.0053051 4 100 9.0121822 3/2- -1.1776 -1 4 10.0135338 0+ 4.76194e+13 0.555 100.0 4 11.021658 13.81 4 12.026921 0.0236 4 13.03569 4 14.04289 0.00435 4 15.05346 4 16.06192 4 6.04681 5 7.02992 5 8.0246072 0.77 5 9.0133288 5 19.9 10.012937 3+ +1.80065 -1 5 80.1 11.0093054 3/2- +2.688637 -1 5 12.0143521 0.0202 5 13.0177802 0.01736 5 14.025404 0.0138 5 15.031103 0.0105 5 16.03981 5 17.04699 0.00508 5 18.05617 5 19.06373 5 8.037675 6 9.0310367 0.126 6 10.0168532 19.255 6 11.0114336 3/2- 1223.4 0.96 100.0 6 98.93 12 0+ -1 6 1.07 13.00335484 1/2- +0.702411 -1 6 14.00324199 1.80701e+11 0.15648 100.0 6 15.0105993 2.449 6 16.014701 0.747 6 17.022586 0.193 6 18.02676 0.095 6 19.03481 0.046 6 20.04032 0.014 6 21.04934 6 22.0572 6 10.04165 7 11.02609 7 12.0186132 0.011 7 13.00573861 597.9 7 99.632 14.003074 1+ +0.403761 -1 7 0.368 15.0001089 1/2- -0.283189 -1 7 16.0061017 7.13 7 17.00845 4.173 7 18.014079 0.624 7 19.017029 0.304 7 20.02337 0.1 7 21.02711 0.085 7 22.03439 0.024 7 23.04122 7 24.05104 7 25.06066 7 12.034405 8 13.024812 0.00858 8 14.00859625 70.606 8 15.0030656 122.24 8 99.757 15.99491462 0+ -1 8 0.038 16.9991317 5/2+ -1.89379 -1 8 0.205 17.999161 0+ -1 8 19.00358 26.91 8 20.0040767 13.51 8 21.008656 3.42 8 22.00997 2.25 8 23.01569 0.082 8 24.02047 0.061 8 25.02946 8 26.03834 8 27.04826 8 28.05781 8 14.03506 9 15.01801 -1 9 16.011466 9 17.00209524 64.49 9 18.000938 1+ 6586.2 0.64 97.0 3.0 9 100 18.99840322 1/2+ +2.628866 -1 9 19.99998132 11 9 20.999949 4.158 9 22.002999 4.23 9 23.00357 2.23 9 24.00812 0.34 9 25.0121 0.059 9 26.01962 9 27.02676 9 28.03567 9 29.04326 9 30.0525 9 31.06043 9 16.025761 10 17.017672 0.1092 10 18.0057082 1.672 10 19.0018802 17.22 10 90.48 19.99244018 0+ -1 10 0.27 20.99384668 3/2 -0.661796 -1 10 9.25 21.99138511 0+ -1 10 22.9944669 37.24 10 23.9936108 202.8 10 24.997737 0.602 10 26.000461 0.197 10 27.00759 0.032 10 28.01207 0.017 10 29.01939 0.2 10 30.0248 10 31.03311 10 32.04002 10 33.04938 10 34.05703 10 18.02597 11 19.013877 11 20.007351 0.4479 11 20.9976552 22.49 11 21.9944364 3+ +1.746 8.20535e+07 2.842 100.0 100.0 11 100 22.98976928 3/2+ -2.217520 -1 11 23.99096278 4+ +1.6903 14.959 5.514 100.0 11 24.989954 59.1 11 25.992633 1.072 11 26.994077 0.301 11 27.998938 0.0305 11 29.002861 0.0449 11 30.008976 0.048 11 31.01359 0.017 11 32.02047 0.0132 11 33.02672 0.0082 11 34.03517 0.0055 11 35.04249 0.0015 11 36.05148 11 37.05934 11 19.03547 12 20.018863 0.095 12 21.011713 0.122 12 21.9995738 3.857 12 22.9941237 11.317 12 78.99 23.9850417 0+ -1 12 10.00 24.98583692 5/2+ -0.85545 -1 12 11.01 25.98259293 0+ -1 12 26.98434059 567.48 12 27.9838768 75276 12 28.9886 1.3 12 29.990434 0.335 12 30.996546 0.23 12 31.998975 0.12 12 33.005254 0.09 12 34.00946 0.02 12 35.01734 12 36.023 12 37.0314 12 38.03757 12 39.04677 12 40.05393 12 21.02804 13 22.01952 0.07 13 23.007267 0.47 13 23.9999389 2.053 13 24.9904281 7.183 13 25.98689169 5+ 740000 4.003 82 18 13 100 26.98153863 5/2+ +3.641504 -1 13 27.98191031 134.484 13 28.980445 393.6 13 29.98296 3.6 13 30.983947 0.644 13 31.98812 0.033 13 32.99084 13 33.99685 13 34.99986 13 36.00621 13 37.01068 13 38.01723 13 39.02297 13 40.03145 13 41.03833 13 42.04689 13 22.03453 0.006 14 23.02552 14 24.011546 0.102 14 25.004106 0.22 14 25.99233 2.234 14 26.98670491 4.16 14 92.2297 27.97692653 0+ -1 14 4.6832 28.9764947 1/2+ -0.55529 -1 14 3.0872 29.97377017 0+ -1 14 30.97536323 9438 14 31.97414808 4.7304e+09 14 32.978 6.18 14 33.978576 2.77 14 34.98458 0.78 14 35.9866 0.45 14 36.99294 14 37.99563 14 39.00207 14 40.00587 14 41.01456 14 42.01979 14 43.02866 14 44.03526 14 24.03435 15 25.02026 15 26.01178 0.02 15 26.99923 0.26 15 27.992315 0.2703 15 28.9818006 4.14 15 29.9783138 149.88 15 100 30.97376163 1/2+ +1.13160 -1 15 31.97390727 1+ -0.2524 1.23224e+06 1.710 100.0 15 32.9717255 2.18938e+06 15 33.973636 12.43 15 34.9733141 47.3 15 35.97826 5.6 15 36.97961 2.31 15 37.98416 0.64 15 38.98618 0.16 15 39.9913 0.26 15 40.99434 0.12 15 42.00101 0.11 15 43.00619 0.033 15 44.01299 15 45.01922 15 46.02738 15 26.02788 16 27.01883 0.021 16 28.00437 0.125 16 28.99661 0.187 16 29.984903 1.178 16 30.9795547 2.572 16 94.93 31.972071 0+ -1 16 0.76 32.97145876 3/2+ +0.643821 -1 16 4.29 33.9678669 0+ -1 16 34.96903216 3/2+ +1 7.54445e+06 0.1674 100.0 16 0.02 35.96708076 0+ -1 16 36.97112557 303 16 37.971163 10218 16 38.97513 11.5 16 39.97545 8.8 16 40.97958 16 41.98102 0.56 16 42.98715 0.22 16 43.99021 0.123 16 44.99651 0.082 16 46.00075 16 47.00859 16 48.01417 16 49.02362 16 28.02851 17 29.01411 17 30.00477 17 30.99241 0.15 17 31.98569 0.298 17 32.9774519 2.511 17 33.97376282 1.5264 17 75.78 34.96885268 3/2+ +0.82187 -1 17 35.96830698 17 24.22 36.96590259 3/2+ +0.68412 -1 17 37.96801043 2234.4 17 38.9680082 3336 17 39.97042 81 17 40.97068 38.4 17 41.97325 6.8 17 42.97405 3.3 17 43.97828 0.434 17 44.98029 0.4 17 45.98421 0.223 17 46.98871 17 47.99495 17 49.00032 17 50.00784 17 51.01449 17 30.02156 2e-08 18 31.01212 0.0151 18 31.997638 0.098 18 32.9899257 0.173 18 33.9802712 0.8445 18 34.9752576 1.775 18 0.3365 35.96754511 0+ -1 18 36.96677632 3.02746e+06 18 0.0632 37.9627324 0+ -1 18 38.964313 8.48318e+09 18 99.6003 39.96238312 0+ -1 18 40.9645006 6560.4 18 41.963046 1.03753e+09 18 42.965636 322.2 18 43.964924 712.2 18 44.96804 21.48 18 45.96809 8.4 18 46.97219 0.7 18 47.97454 18 48.98052 18 49.98443 18 50.99163 18 51.99678 18 53.00494 18 32.02192 19 33.00726 19 33.99841 19 34.98801 0.19 19 35.981292 0.342 19 36.97337589 1.226 19 37.9690812 458.16 19 93.2581 38.96370668 3/2+ +0.391466 -1 19 0.0117 39.96399848 4- -1.298099 1277000000 1.32 89.33 10.67 19 6.7302 40.96182576 3/2+ +0.2148699 -1 19 41.96240281 44496 19 42.960716 80280 19 43.96156 1327.8 19 44.960699 1038 19 45.961977 105 19 46.961678 17.5 19 47.965514 6.8 19 48.96745 1.26 19 49.97278 0.472 19 50.97638 0.365 19 51.98261 0.105 19 52.98712 0.03 19 53.9942 0.01 19 54.99971 19 34.01412 20 35.00494 0.05 20 35.99309 0.102 20 36.98587 0.1811 20 37.976318 0.44 20 38.9707197 0.8596 20 96.941 39.96259098 0+ -1 20 40.96227806 20 0.647 41.95861801 0+ -1 20 0.135 42.9587666 7/2- +1.31725 -1 20 2.086 43.9554818 0+ -1 20 44.9561866 7/2- 1.40495e+07 20 0.004 45.9536926 -1 0.257 100.0 20 46.954546 391910 20 0.187 47.952534 0+ 20 48.955674 523.08 20 49.957519 13.9 20 50.9615 10 20 51.9651 4.6 20 52.97005 0.09 20 53.97435 20 54.98055 20 55.98557 20 56.99236 20 36.01492 21 37.00305 21 37.9947 21 38.98479 21 39.977967 0.1823 21 40.96925113 0.5963 21 41.96551643 0.6813 21 42.9611507 14007.6 21 43.9594028 14137.2 21 100 44.9559119 7/2- +4.756483 -1 21 45.9551719 4+ 7.23946e+06 2.367 100.0 21 46.9524075 7/2- 289371 0.601 100.0 21 47.952231 6+ 157212 4.0 100.0 21 48.950024 3432 21 49.952188 102.5 21 50.953603 12.4 21 51.95668 8.2 21 52.95961 21 53.96326 21 54.96824 21 55.97287 21 56.97779 21 57.98371 21 58.98922 21 59.99571 21 38.00977 22 39.00161 0.026 22 39.9905 0.05 22 40.98315 0.08 22 41.973031 0.199 22 42.968522 0.509 22 43.9596901 1.98677e+09 22 44.9581256 11088 22 8.25 45.9526316 0+ -1 22 7.44 46.9517631 5/2- -0.78848 -1 22 73.72 47.9479463 0+ -1 22 5.41 48.94787 7/2- -1.10417 -1 22 5.18 49.9447912 0+ -1 22 50.946615 345.6 22 51.946897 102 22 52.94973 32.7 22 53.95105 22 54.95527 0.32 22 55.9582 0.16 22 56.96399 0.18 22 57.96697 22 58.97293 22 59.97676 22 60.9832 22 61.98749 22 62.99442 22 40.01109 23 40.99978 23 41.99123 23 42.98065 0.8 23 43.97411 0.09 23 44.965776 0.547 23 45.9602005 0.42237 23 46.9549089 1956 23 47.9522537 1.38011e+06 23 48.9485161 2.8512e+07 23 0.250 49.9471585 6+ +3.34745 140000000000000000 17.0 83 23 99.750 50.9439595 7/2- +5.1574 -1 23 51.9447755 224.58 23 52.944338 96.6 23 53.94644 49.8 23 54.94723 6.54 23 55.95053 0.23 23 56.95256 0.32 23 57.95683 0.2 23 58.96021 0.13 23 59.96503 0.2 23 60.96848 23 61.97378 23 62.97755 23 63.98347 23 64.98792 23 42.00643 24 42.99771 0.021 24 43.98555 0.053 24 44.97964 0.05 24 45.968359 0.26 24 46.9629 0.5 24 47.954032 77616 24 48.9513357 2538 24 4.345 49.9460442 0+ 24 50.9447674 2.3935e+06 24 83.789 51.9405075 0+ -1 24 9.501 52.9406494 3/2- -0.47454 -1 24 2.365 53.9388804 0+ -1 24 54.9408397 209.82 24 55.9406531 356.4 24 56.943613 21.1 24 57.94435 7 24 58.94859 0.74 24 59.95008 0.57 24 60.95472 0.27 24 61.95661 0.19 24 62.96186 0.11 24 63.96441 24 64.97016 24 65.97338 24 66.97955 24 44.00687 25 44.99451 25 45.98672 0.041 25 46.9761 0.1 25 47.96852 0.1581 25 48.959618 0.382 25 49.9542382 0.28388 25 50.9482108 2772 25 51.9455655 483062 25 52.9412901 25 53.9403589 3+ +3.2818 2.69827e+07 1.377 100.0 25 100 54.9380451 5/2- +3.4687 -1 25 55.9389049 9282.6 25 56.9382854 85.4 25 57.93998 3 25 58.94044 4.6 25 59.94291 51 25 60.94465 0.71 25 61.94843 0.88 25 62.95024 0.25 25 63.95425 0.14 25 64.95634 0.11 25 65.96108 0.09 25 66.96414 25 67.9693 25 68.97284 25 45.01458 26 46.00081 0.02 26 46.99289 0.027 26 47.9805 0.044 26 48.97361 0.07 26 49.96299 0.15 26 50.95682 0.305 26 51.948114 29790 26 52.9453079 510.6 26 5.845 53.9396105 0+ -1 26 54.9382934 8.60933e+07 26 91.754 55.9349375 0+ -1 26 2.119 56.935394 1/2- +0.09044 -1 26 0.282 57.9332756 0+ -1 26 58.9348755 3.84506e+06 26 59.934072 26 60.936745 358.8 26 61.936767 68 26 62.94037 6.1 26 63.9412 26 64.94538 0.4 26 65.94678 0.44 26 66.95095 0.47 26 67.9537 0.1 26 68.95878 0.17 26 69.96146 26 70.96672 26 71.96962 26 47.01149 27 48.00176 27 48.98972 27 49.98154 0.044 27 50.97072 27 51.96359 0.018 27 52.954219 0.24 27 53.9484596 0.19323 27 54.941999 63108 27 55.9398393 4+ 6.67613e+06 4.566 100.0 100.0 27 56.9362914 7/2- 2.34827e+07 0.836 100.0 27 57.9357528 2+ 6.1223e+06 2.3 100.0 100.0 27 100 58.933195 7/2- +4.627 -1 27 59.9338171 5+ +3.799 1.66239e+08 2.824 100.0 27 60.9324758 5940 27 61.934051 90 27 62.933612 27.4 27 63.93581 0.3 27 64.936478 1.2 27 65.93976 0.233 27 66.94089 0.42 27 67.94487 0.18 27 68.94632 0.27 27 69.951 0.15 27 70.9529 0.21 27 71.95781 0.09 27 72.96024 27 73.96538 27 74.96833 27 48.01975 28 49.00966 28 49.99593 28 50.98772 28 51.97568 0.038 28 52.96847 0.045 28 53.95791 28 54.95133 0.2121 28 55.942132 525053 28 56.9397935 128160 28 68.0769 57.9353429 0+ -1 28 58.9343467 3/2- 75000 1.072 100.0 28 26.2231 59.9307864 0+ -1 28 1.1399 60.931056 3/2- -0.75002 -1 28 3.6345 61.9283451 0+ -1 28 62.9296694 1/2- 3.15675e+09 0.065 100.0 28 0.9256 63.927966 0+ -1 28 64.9300843 9061.92 28 65.9291393 196560 28 66.931569 21 28 67.931869 19 28 68.93561 11.4 28 69.9365 28 70.94074 1.86 28 71.94209 2.1 28 72.94647 0.7 28 73.94807 0.54 28 74.95287 0.6 28 75.95533 0.24 28 76.96055 28 77.96318 28 51.99718 29 52.98555 29 53.97671 29 54.96605 29 55.95856 29 56.949211 0.1994 29 57.9445385 3.204 29 58.939498 81.5 29 59.937365 1422 29 60.9334578 11998.8 29 61.932584 584.4 29 69.17 62.9295975 3/2- +2.2233 -1 29 63.9297642 1+ -0.217 45720 1.7 19.0 0.578 39.0 1.675 41.0 29 30.83 64.9277895 3/2- +2.3817 -1 29 65.9288688 307.2 29 66.9277303 222588 29 67.9296109 31.1 29 68.9294293 171 29 69.9323923 4.5 29 70.9326768 19.5 29 71.9358203 6.6 29 72.936675 3.9 29 73.939875 1.594 29 74.9419 1.224 29 75.945275 0.641 29 76.94785 0.469 29 77.95196 0.342 29 78.95456 0.188 29 79.96087 29 53.99295 30 54.98398 30 55.97238 30 56.96479 0.04 30 57.95459 0.065 30 58.94926 0.182 30 59.941827 142.8 30 60.939511 89.1 30 61.93433 33069.6 30 62.9332116 2308.2 30 48.63 63.9291422 0+ -1 30 64.929241 5/2- +0.7690 2.11041e+07 1.352 98.0 1.5 30 27.90 65.9260334 0+ -1 30 4.10 66.9271273 5/2- +0.87515 -1 30 18.75 67.9248442 0+ -1 30 68.9265503 3384 30 0.62 69.9253193 0+ 30 70.927722 147 30 71.926858 167400 30 72.92978 23.5 30 73.92946 95.6 30 74.93294 10.2 30 75.93329 5.7 30 76.93696 2.08 30 77.93844 1.47 30 78.94265 0.995 30 79.94434 0.545 30 80.95048 0.29 30 81.95442 30 82.96103 30 55.99491 31 56.98293 31 57.97425 31 58.96337 31 59.95706 31 60.94945 0.15 31 61.944175 0.11612 31 62.9392942 32.4 31 63.9368387 157.62 31 64.9327348 912 31 65.931589 34164 31 66.9282017 281768 31 67.9279801 4057.74 31 60.108 68.9255736 3/2- +2.01659 -1 31 69.926022 1268.4 31 39.892 70.9247013 3/2- 2.56227 -1 31 71.9263663 50760 31 72.9251747 17496 31 73.926946 487.2 31 74.9265002 126 31 75.9288276 32.6 31 76.9291543 13.2 31 77.9316082 5.09 31 78.93289 2.847 31 79.93652 1.697 31 80.93775 1.217 31 81.94299 0.599 31 82.94698 0.31 31 83.95265 0.085 31 84.957 31 85.96312 31 57.99101 32 58.98175 32 59.97019 32 60.96379 0.04 32 61.95465 32 62.94964 0.095 32 63.94165 63.7 32 64.93944 30.9 32 65.93384 8136 32 66.932734 1134 32 67.928094 2.33971e+07 32 68.9279645 140580 32 20.84 69.9242474 0+ -1 32 70.924951 987552 32 27.54 71.9220758 0+ -1 32 7.73 72.9234589 9/2+ -0.879467 -1 32 36.28 73.9211778 0+ -1 32 74.9228589 4966.8 32 7.61 75.9214026 0+ -1 32 76.9235486 40680 32 77.922853 5280 32 78.9254 18.98 32 79.92537 29.5 32 80.92882 7.6 32 81.92955 4.6 32 82.93462 1.85 32 83.93747 32 84.94303 32 85.94649 32 86.95251 32 87.95691 32 88.96383 32 59.99313 33 60.98062 33 61.9732 33 62.96369 33 63.95757 33 64.94956 0.19 33 65.94471 0.09577 33 66.93919 42.5 33 67.93677 151.6 33 68.93227 912 33 69.93092 3156 33 70.927112 235008 33 71.926752 93600 33 72.923825 6.93792e+06 33 73.9239287 1.53533e+06 33 100 74.9215965 3/2- +1.43947 -1 33 75.922394 2- -0.906 93121.9 2.97 100.0 33 76.9206473 139788 33 77.921827 5442 33 78.920948 540.6 33 79.922534 15.2 33 80.922132 33.3 33 81.9245 19.1 33 82.92498 13.4 33 83.92906 4.5 33 84.93202 2.021 33 85.9365 0.945 33 86.9399 0.48 33 87.94494 33 88.94939 33 89.9555 33 90.96043 33 91.9668 33 64.96466 34 65.95521 34 66.95009 0.06 34 67.9418 35.5 34 68.93956 27.4 34 69.93339 2466 34 70.93224 284.4 34 71.927112 725760 34 72.926765 25740 34 0.89 73.9224764 0+ -1 34 74.9225234 1.03489e+07 34 9.37 75.9192136 0+ -1 34 7.63 76.919914 1/2- +0.535506 -1 34 23.77 77.9173091 0+ -1 34 78.9184991 34 49.61 79.9165213 0+ -1 34 80.9179925 1107 34 8.73 81.9166994 0+ 34 82.919118 1338 34 83.918462 186 34 84.92225 31.7 34 85.924272 15.3 34 86.92852 5.29 34 87.93142 1.53 34 88.93645 0.41 34 89.93996 34 90.94596 0.27 34 91.94992 34 92.95629 34 93.96049 34 66.96479 35 67.95852 35 68.95011 35 69.94479 0.0791 35 70.93874 21.4 35 71.93664 78.6 35 72.93169 204 35 73.929891 1524 35 74.925776 5802 35 75.924541 58320 35 76.921379 205330 35 77.921146 387.6 35 50.69 78.9183371 3/2- +2.1064 -1 35 79.9185293 1060.8 35 49.31 80.9162906 3/2- +2.2706 -1 35 81.9168041 127080 35 82.91518 8640 35 83.916479 1908 35 84.915608 174 35 85.918798 55.1 35 86.920711 55.6 35 87.92407 16.34 35 88.92639 4.348 35 89.93063 1.91 35 90.93397 0.541 35 91.93926 0.343 35 92.94305 0.102 35 93.94868 0.07 35 94.95287 35 95.95853 35 96.9628 35 68.96518 36 69.95526 36 70.94963 0.064 36 71.942092 17.2 36 72.939289 27 36 73.9330844 690 36 74.930946 258 36 75.92591 53280 36 76.92467 4464 36 0.35 77.9203648 0+ -1 36 78.920082 126144 36 2.28 79.916379 0+ -1 36 80.916592 36 11.58 81.9134836 0+ -1 36 11.49 82.914136 9/2+ -0.970669 -1 36 57.00 83.911507 0+ -1 36 84.9125273 3.39201e+08 36 17.30 85.91061073 0+ -1 36 86.91335486 4578 36 87.914447 10224 36 88.91763 189 36 89.919517 32.32 36 90.92345 8.57 36 91.926156 1.84 36 92.93127 1.286 36 93.93436 0.2 36 94.93984 0.78 36 95.94307 36 96.94856 36 97.95191 36 98.9576 36 99.96114 36 70.96532 37 71.95908 37 72.95056 37 73.944265 0.0649 37 74.93857 19 37 75.9350722 36.5 37 76.930408 226.2 37 77.928141 1059.6 37 78.923989 1374 37 79.922519 34 37 80.918996 16473.6 37 81.9182086 76.38 37 82.91511 7.44768e+06 37 83.914385 2.83133e+06 37 72.17 84.91178974 5/2- +1.3530 -1 37 85.91116742 -1.6920 1.60972e+06 1.774 99.99 0.0052 37 27.83 86.90918053 3/2- +2.75124 47500000000 37 87.91131559 1066.8 37 88.912278 909 37 89.914802 158 37 90.916537 58.4 37 91.919729 4.492 37 92.922042 5.84 37 93.926405 2.702 37 94.929303 0.3775 37 95.93427 0.199 37 96.93735 0.1699 37 97.94179 0.114 37 98.94538 0.0503 37 99.94987 0.051 37 100.9532 0.032 37 101.95887 0.037 37 72.96597 38 73.95631 38 74.94995 0.071 38 75.94177 8.9 38 76.937945 9 38 77.93218 150 38 78.929708 135 38 79.924521 6378 38 80.923212 1338 38 81.918402 2.20752e+06 38 82.917557 116676 38 0.56 83.913425 0+ -1 38 84.912933 9/2+ 5.60218e+06 1.08 100 38 9.86 85.9092602 0+ -1 38 7.00 86.9088771 9/2+ -1.093 -1 38 82.58 87.9056121 0+ -1 38 88.9074507 4.36579e+06 38 89.907738 9.07921e+08 38 90.910203 34668 38 91.911038 9756 38 92.914026 445.38 38 93.915361 75.3 38 94.919359 23.9 38 95.921697 1.07 38 96.926153 0.426 38 97.928453 0.653 38 98.93324 0.269 38 99.93535 0.202 38 100.94052 0.118 38 101.94302 38 102.94895 38 103.95233 38 104.95858 38 75.95845 39 76.94965 39 77.94361 39 78.93735 14.8 39 79.93428 35 39 80.92913 70.4 39 81.92679 9.5 39 82.92235 424.8 39 83.92039 4.6 39 84.916433 9648 39 85.914886 53064 39 86.9108757 287280 39 87.9095011 9.21456e+06 39 100 88.9058483 1/2- -0.1374153 -1 39 89.9071519 2- -1.630 230400 2.283 100.0 39 90.907305 5.05526e+06 39 91.908949 12744 39 92.909583 36648 39 93.911595 1122 39 94.912821 618 39 95.915891 5.34 39 96.918134 3.75 39 97.922203 39 98.924636 39 99.92776 39 100.93031 39 101.93356 39 102.93673 39 103.94105 39 104.94487 39 105.94979 39 106.95414 39 107.95948 39 77.95523 40 78.94916 40 79.9404 40 80.93721 15 40 81.93109 32 40 82.92865 44 40 83.92325 1554 40 84.92147 471.6 40 85.91647 59400 40 86.914816 6048 40 87.910227 7.20576e+06 40 88.90889 282276 40 51.45 89.9047044 0+ -1 40 11.22 90.9056458 5/2+ -1.30362 -1 40 17.15 91.9050408 0+ -1 40 92.906476 5/2+ 1530000 0.09 100.0 40 17.38 93.9063152 0+ -1 40 94.9080426 5/2+ 5.53133e+06 1.121 100.0 40 2.80 95.9082734 0+ 40 96.9109531 60876 40 97.912735 30.7 40 98.916512 2.1 40 99.91776 7.1 40 100.92114 2.3 40 101.92298 2.9 40 102.9266 1.3 40 103.92878 1.2 40 104.93305 40 105.93591 40 106.94075 40 107.94396 40 108.94924 40 109.95287 40 80.94903 41 81.94313 41 82.93671 4.1 41 83.93357 12 41 84.92791 20.9 41 85.92504 88 41 86.92036 156 41 87.91833 870 41 88.913418 6840 41 89.911265 52560 41 90.906996 2.14445e+10 41 91.907194 41 100 92.9063781 9/2+ -1 41 93.9072839 41 94.9068358 9/2+ +6.123 3.02184e+06 0.925 100.0 41 95.908101 84060 41 96.9080986 4326 41 97.910328 2.86 41 98.911618 15 41 99.914182 41 100.915252 41 101.91804 41 102.91914 41 103.92246 41 104.92394 41 105.92797 41 106.93031 41 107.93484 41 108.93763 41 109.94244 41 110.94565 41 111.95083 41 112.9547 41 82.94874 42 83.94009 42 84.93655 42 85.9307 19.6 42 86.92733 13.4 42 87.921953 480 42 88.91948 122.4 42 89.913937 20016 42 90.91175 929.4 42 14.84 91.906811 0+ -1 42 92.906813 5/2+ 3500 100.0 42 9.25 93.9050883 0+ -1 42 15.92 94.9058421 5/2+ -0.9133 -1 42 16.68 95.9046795 0+ -1 42 9.55 96.9060215 5/2+ -0.9133 -1 42 24.13 97.9054082 0+ -1 42 98.9077119 1/2+ 237384 1.357 100.0 42 9.63 99.907477 0+ -1 42 100.910347 876.6 42 101.910297 678 42 102.91321 67.5 42 103.91376 60 42 104.91697 35.6 42 105.918137 8.4 42 106.92169 3.5 42 107.92345 1.09 42 108.92781 0.53 42 109.92973 0.3 42 110.93441 42 111.93684 42 112.94188 42 113.94492 42 114.95029 42 84.94883 43 85.94288 43 86.93653 43 87.93268 6.4 43 88.92717 12.8 43 89.92356 49.2 43 90.91843 188.4 43 91.91526 253.8 43 92.910249 9900 43 93.909657 17580 43 94.907657 72000 43 95.907871 369792 43 96.906365 9/2+ 2600000 0.32 100.0 43 97.907216 43 98.9062547 9/2+ +5.6847 211100 0.293 100.0 43 99.9076578 15.8 43 100.907315 853.2 43 101.909215 5.28 43 102.909181 54.2 43 103.91145 1098 43 104.91166 456 43 105.914358 43 106.91508 43 107.91846 43 108.91998 43 109.92382 43 110.92569 43 111.92915 43 112.93159 43 113.93588 43 114.93869 43 115.94337 43 116.94648 43 117.95148 43 86.94918 44 87.94026 44 88.93611 44 89.92989 11 44 90.92629 9 44 91.92012 219 44 92.91705 59.7 44 93.91136 3108 44 94.910413 5914.8 44 5.54 95.907598 0+ -1 44 96.907555 5/2+ +0.687 250560 1.2 100.0 44 1.87 97.905287 0+ -1 44 12.76 98.9059393 5/2+ +0.6413 -1 44 12.60 99.9042195 0+ -1 44 17.06 100.9055821 5/2+ -0.7188 -1 44 31.55 101.9043493 0+ -1 44 102.9063238 5/2+ +0.67 3.39206e+06 0.767 100.0 44 18.62 103.905433 0+ -1 44 104.907753 15984 44 105.907329 3.22782e+07 44 106.90991 225 44 107.91017 273 44 108.9132 34.5 44 109.91414 14.6 44 110.9177 2.12 44 111.91897 1.75 44 112.92249 0.8 44 113.92428 0.53 44 114.92869 0.4 44 115.93081 44 116.93558 44 117.93782 44 118.94284 44 119.94531 44 88.94884 45 89.94287 45 90.93655 45 91.93198 45 92.92574 45 93.9217 70.6 45 94.9159 301.2 45 95.914461 594 45 96.91134 1842 45 97.910708 522 45 98.908132 1.39104e+06 45 99.908122 74880 45 100.906164 1.04069e+08 45 101.906843 1.78848e+07 45 100 102.905504 1/2- -0.08840 -1 45 103.906656 42.3 45 104.905694 127296 45 105.907287 29.8 45 106.906748 1302 45 107.90873 16.8 45 108.908737 80 45 109.91114 45 110.91159 45 111.91439 45 112.91553 45 113.91881 45 114.92033 45 115.92406 45 116.92598 45 117.93007 45 118.93211 45 119.93641 45 120.93872 45 121.94321 45 90.94911 46 91.94042 46 92.93591 46 93.92877 46 94.92469 46 95.91816 122 46 96.91648 186 46 97.912721 1062 46 98.911768 1284 46 99.908506 313632 46 100.908289 30492 46 1.02 101.905609 0+ -1 46 102.906087 5/2+ 1.46802e+06 0.56 100.0 46 11.14 103.904036 0+ -1 46 22.33 104.905085 5/2+ -0.642 -1 46 27.33 105.903486 0+ -1 46 106.905133 5/2+ 6500000 0.035 100.0 46 26.46 107.903892 0+ -1 46 108.90595 5/2+ 49324.3 1.116 100.0 46 11.72 109.905153 0+ -1 46 110.907671 1404 46 111.907314 75708 46 112.91015 93 46 113.910363 145.2 46 114.91368 25 46 115.91416 11.8 46 116.91784 4.3 46 117.91898 1.9 46 118.92311 0.92 46 119.92469 0.5 46 120.92887 46 121.93055 46 122.93493 46 123.93688 46 92.94978 47 93.94278 0.01 47 94.93548 47 95.93068 5.1 47 96.92397 19 47 97.92157 46.7 47 98.9176 124 47 99.9161 120.6 47 100.9128 666 47 101.91169 774 47 102.908973 3942 47 103.908629 4152 47 104.906529 1/2- 3.56746e+06 47 105.906669 1+ 1437.6 47 51.839 106.905097 1/2- -0.113570 -1 47 107.905956 1+ 142.2 47 48.161 108.904752 1/2- -0.1306905 -1 47 109.906107 1+ 24.6 47 110.905291 643680 47 111.907005 11268 47 112.906567 19332 47 113.908804 4.6 47 114.90876 1200 47 115.91136 160.8 47 116.91168 72.8 47 117.91458 3.76 47 118.91567 2.1 47 119.91879 1.23 47 120.91985 0.78 47 121.92353 0.48 47 122.9249 0.309 47 123.92864 0.172 47 124.93043 0.166 47 125.9345 0.107 47 126.93677 0.109 47 127.94117 0.058 47 128.94369 47 129.95045 47 94.94987 48 95.93977 48 96.93494 3 48 97.9274 9.2 48 98.92501 16 48 99.92029 49.1 48 100.91868 81.6 48 101.91446 330 48 102.913419 438 48 103.909849 3462 48 104.909468 3330 48 1.25 105.906459 0+ -1 48 106.906618 5/2+ 23400 100.0 48 0.89 107.904184 0+ -1 48 108.904982 5/2+ -0.8270 3.99686e+07 0.16 100.0 48 12.49 109.9030021 0+ -1 48 12.80 110.9041781 1/2+ -0.5943 -1 48 24.13 111.9027578 0+ -1 48 12.22 112.9044017 1/2+ -0.6217 48 28.73 113.9033585 0+ -1 48 114.905431 1/2+ -0.648 192456 48 7.49 115.904756 0+ -1 48 116.907219 8964 48 117.906915 3018 48 118.90992 161.4 48 119.90985 50.8 48 120.91298 13.5 48 121.91333 5.24 48 122.917 2.1 48 123.91765 1.25 48 124.92125 0.65 48 125.92235 0.506 48 126.92644 0.37 48 127.92776 0.34 48 128.93215 0.27 48 129.9339 0.2 48 130.94067 48 131.94555 48 96.94954 49 97.94214 49 98.93422 49 99.93111 7 49 100.92634 15.1 49 101.92409 22 49 102.919914 65 49 103.9183 108 49 104.914674 304.2 49 105.913465 372 49 106.910295 1944 49 107.909698 3480 49 108.907151 15120 49 109.907165 17640 49 110.905103 9/2+ 242326 49 111.905532 1+ 898.2 49 4.29 112.904058 1/2- +5.5229 -1 49 113.904914 5+ 71.9 49 95.71 114.903878 9/2+ +5.534 49 115.90526 1+ 14.1 49 116.904514 2592 49 117.906354 5 49 118.905845 144 49 119.90796 3.08 49 120.907846 23.1 49 121.91028 1.5 49 122.910438 5.98 49 123.91318 3.11 49 124.9136 2.36 49 125.91646 1.6 49 126.91735 1.09 49 127.92017 0.84 49 128.9217 0.61 49 129.92497 0.32 49 130.92685 0.282 49 131.93299 0.201 49 132.93781 0.18 49 133.94415 0.138 49 134.94933 49 98.94933 50 99.93904 0.94 50 100.93606 3 50 101.9303 4.5 50 102.9281 7 50 103.92314 20.8 50 104.92135 31 50 105.91688 115 50 106.91564 174 50 107.911925 618 50 108.911283 1080 50 109.907843 14796 50 110.907734 2118 50 0.97 111.904818 0+ -1 50 112.905171 1/2+ 9.94378e+06 1.02 100.0 50 0.66 113.902779 0+ -1 50 0.34 114.903342 1/2+ -0.91883 -1 50 14.54 115.901741 0+ -1 50 7.68 116.902952 1/2+ 1.00104 -1 50 24.22 117.901603 0+ -1 50 8.59 118.903308 1/2+ -1.04728 -1 50 32.58 119.9021947 0+ -1 50 120.9042355 11/2- 97416 50 4.63 121.903439 0+ -1 50 122.9057208 11/2- 1.11629e+07 50 5.79 123.9052739 0+ -1 50 124.9077841 832896 50 125.907653 -1 50 126.91036 7560 50 127.910537 3544.2 50 128.91348 133.8 50 129.913967 223.2 50 130.917 56 50 131.917816 39.7 50 132.92383 1.45 50 133.92829 1.12 50 134.93473 50 135.93934 50 136.94599 50 102.93969 51 103.93647 51 104.93149 51 105.92879 51 106.92415 51 107.92216 7.4 51 108.918132 17 51 109.91675 23 51 110.91316 75 51 111.912398 51.4 51 112.909372 400.2 51 113.90927 209.4 51 114.906598 1926 51 115.906794 948 51 116.904836 10080 51 117.905529 216 51 118.903942 137484 51 119.905072 1+ 953.4 51 57.21 120.9038157 5/2+ +3.3592 -1 51 121.9051737 2- 235336 51 42.79 122.904214 7/2+ +2.5466 -1 51 123.9059357 3- 5.20128e+06 51 124.9052538 8.69826e+07 51 125.90725 1.07654e+06 51 126.906924 332640 51 127.909169 32436 51 128.909148 15840 51 129.911656 2370 51 130.911982 1381.8 51 131.914467 167.4 51 132.915252 150 51 133.92038 0.78 51 134.92517 1.71 51 135.93035 0.82 51 136.93531 51 137.94079 51 138.94598 51 104.94364 52 105.9375 6e-05 52 106.93501 0.0031 52 107.92944 2.1 52 108.92742 4.6 52 109.92241 18.6 52 110.92111 19.3 52 111.91701 52 112.91589 102 52 113.91209 912 52 114.9119 348 52 115.90846 8964 52 116.908645 3720 52 117.905828 518400 52 118.906404 57708 52 0.09 119.90402 0+ -1 52 120.904936 1/2+ 1.44979e+06 52 2.55 121.9030439 0+ -0.7359 -1 0.052 100.0 52 0.89 122.90427 1/2+ -1 52 4.74 123.9028179 0+ -0.8871 -1 52 7.07 124.9044307 1/2+ -1 52 18.84 125.9033117 0+ -1 0.697 100.0 52 126.9052263 3/2+ 33660 52 31.74 127.9044631 0+ 52 128.9065982 3/2+ 4176 52 34.08 129.9062244 0+ 52 130.9085239 1500 52 131.908553 276826 52 132.910955 750 52 133.911369 2508 52 134.91645 19 52 135.9201 17.5 52 136.92532 2.49 52 137.92922 1.4 52 138.93473 52 139.93885 52 140.94465 52 141.94908 52 107.94348 0.036 53 108.93815 1e-04 53 109.93524 0.65 53 110.93028 2.5 53 111.92797 3.42 53 112.92364 6.6 53 113.92185 2.1 53 114.91805 78 53 115.91681 2.91 53 116.91365 133.2 53 117.913074 822 53 118.91007 1146 53 119.910048 4860 53 120.907367 7632 53 121.907589 217.8 53 122.905589 47772 53 123.9062099 360806 53 124.9046302 5/2+ 5.13285e+06 53 125.905624 2- 1.1327e+06 53 100 126.904473 5/2+ +2.808 -1 53 127.905809 1+ 1499.4 53 128.904988 +2.617 15700000 0.193 100.0 53 129.906674 44496 53 130.9061246 692988 53 131.907997 8262 53 132.907797 74880 53 133.909744 3150 53 134.910048 23652 53 135.91465 83.4 53 136.917871 24.5 53 137.92235 6.49 53 138.9261 2.29 53 139.931 0.86 53 140.93503 0.43 53 141.94018 53 142.94456 53 143.94999 53 109.94428 6e-07 54 110.9416 0.74 54 111.93562 2.7 54 112.93334 2.74 54 113.92798 10 54 114.926294 18 54 115.921581 59 54 116.920359 61 54 117.916179 228 54 118.915411 348 54 119.911784 2400 54 120.911462 2406 54 121.908368 72360 54 122.908482 7488 54 0.09 123.905893 0+ 54 124.9063955 1/2+ 60840 100.0 54 0.09 125.904274 0+ -1 54 126.905184 1/2+ 3.14496e+06 0.44 100.0 54 1.92 127.9035313 0+ -1 54 26.44 128.9047794 1/2+ -0.7768 -1 54 4.08 129.903508 0+ -1 54 21.18 130.9050824 3/2+ +0.691861 -1 54 26.89 131.9041535 0+ -1 54 132.9059107 3/2+ 452995 54 10.44 133.9053945 0+ -1 54 134.907227 3/2+ 32904 54 8.87 135.907219 0+ 54 136.911562 229.08 54 137.91395 844.8 54 138.918793 39.68 54 139.92164 13.6 54 140.92665 1.73 54 141.92971 1.22 54 142.93511 0.3 54 143.93851 1.15 54 144.94407 0.9 54 145.94775 54 146.95356 54 111.9503 55 112.94449 1.7e-05 55 113.94145 0.57 55 114.93591 1.4 55 115.93337 3.84 55 116.92867 8.4 55 117.926559 14 55 118.922377 43 55 119.920677 64 55 120.917229 155 55 121.91611 21 55 122.912996 356.4 55 123.912258 30.8 55 124.909728 2700 55 125.909452 98.4 55 126.907418 22500 55 127.907749 219.6 55 128.906064 115416 55 129.906709 1752.6 55 130.905464 837130 55 131.9064343 559786 55 100 132.9054519 7/2+ +2.579 -1 55 133.9067185 4+ 6.51155e+07 55 134.905977 7/2+ +2.729 2300000 2.05 100.0 55 135.9073116 1.13702e+06 55 136.9070895 9.48288e+08 55 137.911017 2004.6 55 138.913364 556.2 55 139.917282 63.7 55 140.920046 24.94 55 141.924299 1.7 55 142.927352 1.78 55 143.932077 1.01 55 144.935526 0.594 55 145.94029 0.321 55 146.94416 0.225 55 147.94922 0.158 55 148.95293 55 149.95817 55 150.96219 55 113.95068 0.43 56 114.94737 0.4 56 115.94138 0.3 56 116.9385 1.75 56 117.93304 5.5 56 118.93066 5.4 56 119.92604 32 56 120.92405 29.7 56 121.9199 117 56 122.918781 162 56 123.915094 660 56 124.914473 210 56 125.91125 6000 56 126.911094 762 56 127.908318 209952 56 128.908679 8028 56 0.106 129.9063208 0+ -1 56 130.906941 1/2+ 993600 1.16 100.0 56 0.101 131.9050613 0+ -1 56 132.9060075 1/2+ 3.31443e+08 56 2.417 133.9045084 0+ -1 56 6.592 134.9056886 3/2+ +0.8365 -1 56 7.854 135.9045759 0+ -1 56 11.232 136.9058274 3/2+ +0.9357 -1 56 71.698 137.9052472 0+ -1 56 138.9088413 4983.6 56 139.910605 1.10177e+06 56 140.914411 1096.2 56 141.916453 636 56 142.920627 14.33 56 143.922953 11.5 56 144.92763 4.31 56 145.93022 2.22 56 146.93495 0.893 56 147.93772 0.607 56 148.94258 0.344 56 149.94568 0.3 56 150.95081 56 151.95427 56 152.95961 56 116.95007 57 117.94673 57 118.94099 57 119.93807 2.8 57 120.93301 5.3 57 121.93071 8.7 57 122.92624 17 57 123.92457 29 57 124.920816 76 57 125.91951 54 57 126.916375 306 57 127.91559 300 57 128.912693 696 57 129.912369 522 57 130.91007 3540 57 131.9101 17280 57 132.90822 14083.2 57 133.908514 387 57 134.906977 70200 57 135.90764 592.2 57 136.906494 57 0.090 137.907112 5- +3.707 105000000000 1.04 33.6 1.75 66.4 57 99.910 138.9063533 7/2+ +2.778 -1 57 139.9094776 3- +0.73 144988 3.761 100.0 57 140.910962 14112 57 141.914079 5466 57 142.916063 852 57 143.9196 40.8 57 144.92165 24.8 57 145.92579 6.27 57 146.92824 4.015 57 147.93223 1.05 57 148.93473 1.05 57 149.93877 0.86 57 150.94172 57 151.94625 57 152.94962 57 153.9545 57 154.95835 57 118.95276 58 119.94664 58 120.94342 58 121.93791 58 122.9354 3.2 58 123.93041 6 58 124.92844 9 58 125.92397 50 58 126.92273 31 58 127.91891 4.1 58 128.9181 210 58 129.91474 1500 58 130.91442 612 58 131.91146 12636 58 132.911515 5820 58 133.908925 273024 58 134.909151 63720 58 0.185 135.907172 0+ -1 58 136.907806 3/2+ 32400 100.0 100.0 58 0.251 137.905991 0+ -1 58 138.906653 0.9 1.18921e+07 0.27 100.0 58 88.450 139.9054387 0+ -1 58 140.9082763 7/2- 0.97 2.80809e+06 0.581 100.0 58 11.114 141.909244 0+ 58 142.912386 118940 58 143.913647 2.46148e+07 58 144.91723 180.6 58 145.91876 811.2 58 146.92267 56.4 58 147.92443 56 58 148.9284 5.3 58 149.93041 4 58 150.93398 1.02 58 151.93654 1.4 58 152.94058 58 153.94342 58 154.94804 58 155.95126 58 156.95634 58 120.95536 59 121.95181 59 122.94596 59 123.94296 1.2 59 124.93783 3.3 59 125.93531 3.14 59 126.93083 4.2 59 127.92879 3.1 59 128.9251 30 59 129.92359 40 59 130.92026 91.8 59 131.91926 96 59 132.916331 390 59 133.91571 1020 59 134.913112 1440 59 135.912692 786 59 136.910705 4608 59 137.910755 87 59 138.908938 15876 59 139.909076 203.4 59 100 140.9076528 5/2+ +4.3 -1 59 141.9100448 2- 68832 2.160 99.98 0.02 59 142.9108169 1.17245e+06 59 143.913305 1036.8 59 144.914512 21542.4 59 145.91764 1449 59 146.918996 804 59 147.922135 136.2 59 148.92372 135.6 59 149.926673 6.19 59 150.928319 18.9 59 151.9315 3.63 59 152.93384 4.28 59 153.93752 2.3 59 154.94012 59 155.94427 59 156.94743 59 157.95198 59 158.9555 59 123.95223 60 124.94888 60 125.94322 60 126.9405 1.8 60 127.93539 4 60 128.93319 7 60 129.92851 28 60 130.92725 27 60 131.923321 105 60 132.92235 70 60 133.91879 510 60 134.918181 744 60 135.914976 3039 60 136.914567 2310 60 137.91195 18144 60 138.911978 1782 60 139.90955 291168 60 140.90961 8964 60 27.2 141.9077233 0+ -1 60 12.2 142.9098143 7/2- -1.08 -1 60 23.8 143.9100873 0+ 2290000000000000 1.83 100.0 60 8.3 144.9125736 7/2- -0.66 -1 60 17.2 145.9131169 0+ -1 60 146.9161004 5/2- 0.59 948672 0.91 100.0 60 5.7 147.916893 0+ -1 60 148.920149 5/2- 6220.8 1.66 100.0 60 5.6 149.920891 0+ 60 150.923829 746.4 60 151.924682 684 60 152.927698 31.6 60 153.92948 25.9 60 154.93293 8.9 60 155.93502 5.47 60 156.93903 60 157.9416 60 158.94609 60 159.94909 60 160.95388 60 125.95752 61 126.95163 61 127.94842 61 128.94316 61 129.94045 61 130.93587 61 131.93375 6.3 61 132.92978 61 133.92835 5 61 134.92488 45 61 135.92357 47 61 136.920479 144 61 137.919548 10 61 138.916804 249 61 139.91604 9.2 61 140.913555 1254 61 141.912874 40.5 61 142.910933 2.2896e+07 61 143.912591 3.13632e+07 61 144.912749 5.58187e+08 61 145.914696 1.74394e+08 61 146.9151385 +2.7 8.27315e+07 0.224 100.0 61 147.917475 463968 2.46 100.0 61 148.918334 3.3 191088 1.073 100.0 61 149.920984 9648 3.43 100.0 61 150.921207 102240 61 151.923497 247.2 61 152.924117 315 61 153.92646 103.8 61 154.9281 41.5 61 155.93106 26.7 61 156.93304 10.56 61 157.93656 4.8 61 158.93897 61 159.94299 61 160.94586 61 161.95029 61 162.95368 61 127.95808 62 128.95464 62 129.94892 62 130.94611 1.2 62 131.94069 4 62 132.93867 3.7 62 133.93397 10 62 134.93252 10.3 62 135.928276 47 62 136.92697 45 62 137.923244 186 62 138.922297 154.2 62 139.918995 889.2 62 140.918476 612 62 141.915198 4349.4 62 142.914628 529.8 62 3.07 143.911999 0+ -1 62 144.91341 7/2- 2.9376e+07 0.65 100.0 62 145.913041 0+ 103100000 2.55 100.0 62 14.99 146.9148979 7/2- -0.813 106000000000 2.31 100.0 62 11.24 147.9148227 0+ 12000000000000 2.00 100.0 62 13.82 148.9171847 7/2- -0.670 400000000000000 1.9 100.0 62 7.38 149.9172755 0+ -1 62 150.9199324 7/2- 2.83824e+09 0.076 100.0 62 26.75 151.9197324 0+ -1 62 152.9220974 3/2+ 166622 62 22.75 153.9222093 0+ -1 62 154.9246402 1338 62 155.925528 33840 62 156.92836 482 62 157.92999 318 62 158.93321 11.37 62 159.93514 9.6 62 160.93883 62 161.94122 62 162.94536 62 163.94828 62 164.95298 62 129.96357 63 130.95775 63 131.95437 63 132.94924 63 133.94651 0.5 63 134.94182 1.5 63 135.9396 3.3 63 136.93557 11 63 137.93371 12.1 63 138.929792 17.9 63 139.92809 1.51 63 140.924931 40.7 63 141.92343 2.34 63 142.920298 157.8 63 143.918817 10.2 63 144.916265 512352 63 145.917206 398304 63 146.916746 2.08224e+06 63 147.918086 4.7088e+06 63 148.917931 8.04384e+06 63 149.919702 1.16368e+09 63 47.81 150.9198502 5/2+ +3.464 -1 63 151.9217445 3- 4.26903e+08 63 52.19 152.9212303 5/2+ +1.530 -1 63 153.9229792 2.70989e+08 63 154.9228933 1.50146e+08 63 155.924752 1.31242e+06 63 156.925424 54648 63 157.92785 2754 63 158.929089 1086 63 159.93197 38 63 160.93368 26 63 161.93704 10.6 63 162.93921 63 163.94299 63 164.94572 63 165.94997 63 166.95321 63 133.95537 64 134.95257 64 135.94734 64 136.94502 64 137.94012 64 138.93824 4.9 64 139.93367 15.8 64 140.932126 14 64 141.92812 70.2 64 142.92675 39 64 143.92296 270 64 144.921709 1380 64 145.918311 4.17053e+06 64 146.919094 137016 64 147.918115 2.35259e+09 64 148.919341 801792 64 149.918659 64 150.920348 1.07136e+07 64 0.20 151.919791 0+ 108000000000000 2.24 100.0 64 152.9217495 3/2+ 2.07706e+07 64 2.18 153.9208656 0+ -1 64 14.80 154.922622 3/2- -0.27 -1 64 20.47 155.9221227 0+ -1 64 15.65 156.9239601 3/2- -0.36 -1 64 24.84 157.9241039 0+ -1 64 158.9263887 3/2- 66524.4 0.95 100.0 64 21.86 159.9270541 0+ 64 160.9296692 219.6 64 161.930985 504 64 162.93399 68 64 163.93586 45 64 164.93938 64 165.9416 64 166.94557 64 167.94836 64 168.95287 64 135.96138 65 136.95598 65 137.95316 65 138.94829 65 139.94581 2.4 65 140.94145 3.5 65 141.93874 0.597 65 142.93512 12 65 143.93305 -1 65 144.92927 65 145.92725 8 65 146.924045 6120 65 147.924272 3600 65 148.923246 14824.8 65 149.92366 12528 65 150.923103 63392.4 65 151.92407 63000 65 152.923435 202176 65 153.92468 77400 65 154.923505 459648 65 155.924747 462240 65 156.9240246 2.23906e+09 65 157.9254131 5.67648e+09 65 100 158.9253468 3/2+ +1.95 -1 65 159.9271676 3- +1.702 6.24672e+06 1.72 100.0 65 160.9275699 3/2+ 594432 65 161.92949 456 65 162.930648 1170 65 163.93335 180 65 164.93488 126.6 65 165.93799 65 166.94005 65 167.94364 65 168.94622 65 169.95025 65 170.9533 65 137.96249 66 138.95954 66 139.95401 66 140.95135 0.9 66 141.94637 2.3 66 142.94383 4.1 66 143.93925 9.1 66 144.93743 10 66 145.932845 29 66 146.931092 40 66 147.92715 186 66 148.927305 252 66 149.925585 430.2 66 150.926185 1074 66 151.924718 8568 66 152.925765 23040 66 153.924424 66 154.925754 35640 66 0.06 155.924283 0+ -1 66 156.925466 3/2- 29304 66 0.10 157.924409 0+ -1 66 158.9257392 3/2- 1.24762e+07 66 2.34 159.9251975 0+ -1 66 18.91 160.9269334 5/2+ -0.4805 -1 66 25.51 161.9267984 0+ -1 66 24.90 162.9287312 5/2- +0.6726 -1 66 28.18 163.9291748 0+ -1 1.3 100.0 66 164.9317033 8402.4 66 165.9328067 293760 66 166.93566 372 66 167.93713 522 66 168.94031 39 66 169.94239 66 170.9462 66 171.94876 66 172.953 66 139.96854 67 140.9631 67 141.95977 67 142.95461 67 143.95148 0.7 67 144.9472 2.4 67 145.94464 3.6 67 146.94006 5.8 67 147.93772 2.2 67 148.933775 21.1 67 149.933496 72 67 150.931688 35.2 67 151.931714 161.8 67 152.930199 120.6 67 153.930602 705.6 67 154.929103 2880 67 155.92984 3360 67 156.928256 756 67 157.928941 678 67 158.927712 1983 67 159.928729 1536 67 160.927855 8928 67 161.929096 900 67 162.9287339 1.4412e+11 67 163.9302335 1740 67 100 164.9303221 7/2- +4.173 -1 67 165.9322842 0- 96588 1.85 100.0 67 166.933133 11160 67 167.93552 179.4 67 168.936872 282 67 169.93962 165.6 67 170.94147 53 67 171.94482 25 67 172.94729 67 173.95115 67 174.95405 67 142.96634 68 143.96038 68 144.95739 0.9 68 145.952 1.7 68 146.94949 2.5 68 147.94455 4.6 68 148.94231 4 68 149.937914 18.5 68 150.937449 23.5 68 151.93505 10.3 68 152.935063 37.1 68 153.932783 223.8 68 154.933209 318 68 155.931065 1170 68 156.93192 1119 68 157.929893 8244 68 158.930684 2160 68 159.929083 102888 68 160.929995 11556 68 0.14 161.928778 0+ -1 68 162.930033 5/2- 4500 68 1.61 163.9292 0+ -1 68 164.930726 5/2- 37296 68 33.61 165.9302931 0+ -1 68 22.93 166.9320482 7/2+ -0.5665 -1 68 26.78 167.9323702 0+ -1 68 168.9345904 1/2- 812160 68 14.93 169.9354643 0+ -1 68 170.9380298 27057.6 68 171.939356 177480 68 172.9424 84 68 173.94423 198 68 174.94777 72 68 175.95008 68 176.95405 68 144.97007 69 145.96643 0.235 69 146.96096 0.56 69 147.95784 0.7 69 148.95272 0.9 69 149.94996 2.2 69 150.945483 4.17 69 151.94442 8 69 152.942012 1.48 69 153.941568 8.1 69 154.939199 21.6 69 155.93898 83.8 69 156.93697 217.8 69 157.93698 238.8 69 158.93498 547.8 69 159.93526 564 69 160.93355 1980 69 161.933995 1302 69 162.932651 6516 69 163.93356 69 164.932435 108216 69 165.933554 27720 69 166.9328516 799200 69 167.934173 8.04384e+06 69 100 168.9342133 1/2+ -0.2316 -1 69 169.9358014 1- 1.1111e+07 69 170.9364294 1/2+ 6.05491e+07 69 171.9384 228960 69 172.939604 29664 69 173.94217 324 69 174.94384 912 69 175.94699 114 69 176.94904 85 69 177.95264 69 178.95534 69 147.96742 70 148.96404 70 149.95842 70 150.9554 1.6 70 151.95029 3.04 70 152.94948 4.2 70 153.946394 0.409 70 154.945782 1.8 70 155.942818 26.1 70 156.942628 38.6 70 157.939866 89.4 70 158.94005 94.8 70 159.937552 288 70 160.937902 252 70 161.935768 1132.2 70 162.936334 663 70 163.934489 4548 70 164.93528 594 70 165.933882 204120 70 166.93495 1050 70 0.13 167.933897 0+ -1 70 168.93519 7/2+ 2.76705e+06 70 3.04 169.9347618 0+ -1 70 14.28 170.9363258 1/2- +0.4919 -1 70 21.83 171.9363815 0+ -1 70 16.13 172.9382108 5/2- -0.6776 -1 70 31.83 173.9388621 0+ -1 70 174.9412765 7/2- 0.3 361584 0.467 100.0 70 12.76 175.9425717 0+ -1 70 176.9452608 6879.6 70 177.946647 4440 70 178.95017 480 70 179.95233 144 70 180.95615 70 149.97323 0.035 71 150.96758 0.088 71 151.96412 0.7 71 152.95877 0.9 71 153.95752 71 154.954316 0.14 71 155.95303 0.198 71 156.950098 6.8 71 157.949313 10.6 71 158.94663 12.1 71 159.94603 36.1 71 160.94357 77 71 161.94328 82.2 71 162.94118 238 71 163.94134 188.4 71 164.939407 644.4 71 165.93986 159 71 166.93827 3090 71 167.93874 330 71 168.937651 122616 71 169.938475 173837 71 170.9379131 711936 71 171.939086 578880 71 172.9389306 4.32043e+07 71 173.9403375 1.04384e+08 71 97.41 174.9407718 7/2+ +2.2327 -1 71 2.59 175.9426863 1- 3.19 71 176.9437581 +2.239 581818 71 177.945955 1704 71 178.947327 16524 71 179.94988 342 71 180.95197 210 71 181.95504 71 182.95757 58 71 183.96091 20 71 152.97069 72 153.96486 72 154.96339 0.89 72 155.95936 0.025 72 156.9584 0.11 72 157.954799 2.85 72 158.953995 5.6 72 159.950684 13.6 72 160.950275 16.8 72 161.94721 37.6 72 162.94709 40 72 163.944367 111 72 164.94457 76 72 165.94218 406.2 72 166.9426 123 72 167.94057 1557 72 168.94126 194.4 72 169.93961 57636 72 170.94049 43560 72 171.939448 5.89723e+07 72 172.94051 84960 72 0.16 173.940046 0+ 2000000000000000 2.55 100.0 72 174.941509 5/2- 0.70 6.048e+06 0.59 100.0 72 5.26 175.9414086 0+ -1 72 18.60 176.9432207 7/2- +0.7935 -1 72 27.28 177.9436988 0+ -1 72 13.62 178.9458161 9/2+ -0.6409 -1 72 35.08 179.94655 0+ -1 72 180.9491012 3.6625e+06 72 181.950554 72 182.95353 3841.2 72 183.95545 14832 72 184.95882 210 72 185.96089 72 186.96459 72 187.96685 72 154.97459 73 155.9723 0.144 73 156.96819 0.0101 73 157.9667 0.0365 73 158.963018 0.57 73 159.96149 1.55 73 160.95842 2.7 73 161.95729 3.52 73 162.95433 10.6 73 163.95353 14.2 73 164.950773 31 73 165.95051 34.4 73 166.94809 84 73 167.94805 73 168.94601 294 73 169.94618 405.6 73 170.94448 1398 73 171.9449 2208 73 172.94375 11304 73 173.94445 3780 73 174.94374 37800 73 175.94486 29124 73 176.944472 203616 73 177.945778 558.6 73 178.9459295 5.73955e+07 73 0.012 179.9474648 1- 29347.2 14.0 86.0 73 99.988 180.9479958 7/2+ +2.370 -1 73 181.9501518 3- 2.6 9.88675e+06 1.811 100.0 73 182.9513726 440640 73 183.954008 31320 73 184.955559 2964 73 185.95855 630 73 186.96053 73 187.9637 73 188.96583 73 189.96923 73 157.97456 0.0009 74 158.97292 0.0073 74 159.96848 0.091 74 160.96736 0.41 74 161.963497 1.39 74 162.96252 2.75 74 163.958954 6 74 164.95828 5.1 74 165.955027 18.8 74 166.954816 19.9 74 167.951808 53 74 168.951779 76 74 169.949228 145.2 74 170.94945 142.8 74 171.94729 396 74 172.94769 456 74 173.94608 1860 74 174.94672 2112 74 175.94563 9000 74 176.94664 8100 74 177.945876 1.86624e+06 74 178.94707 2223 74 0.12 179.946704 0+ -1 74 180.948197 9/2+ 1.04717e+07 0.19 100.0 74 26.50 181.9482042 0+ 0+ -1 74 14.31 182.950223 1/2- +0.1177847 74 30.64 183.9509312 0+ 74 184.9534193 6.48864e+06 0.432 100.0 74 28.43 185.9543641 3/2- -1 74 186.9571605 0.688 85392 1.321 100.0 74 187.958489 5.99616e+06 74 188.96191 690 74 189.96318 1800 74 190.9666 74 191.96817 74 159.98212 0.00079 75 160.97759 0.00037 75 161.976 0.107 75 162.972081 0.26 75 163.97032 0.38 75 164.967089 2.4 75 165.96581 2.8 75 166.9626 6.1 75 167.96157 4.4 75 168.95879 75 169.95822 9.2 75 170.95572 15.2 75 171.95542 15 75 172.95324 118.8 75 173.95312 144 75 174.95138 353.4 75 175.95162 318 75 176.95033 840 75 177.95099 792 75 178.949988 1170 75 179.950789 146.4 75 180.950068 71640 75 181.95121 230400 75 182.95082 6.048e+06 75 183.952521 3.2832e+06 75 37.40 184.952955 5/2+ +3.172 -1 75 185.9549861 1- +1.739 321261 1.071 93.1 6.9 75 62.60 186.9557531 5/2+ +3.2197 43500000000 0.00251 100.0 75 187.9581144 1- +1.788 61218 2.12 100.0 75 188.959229 87480 75 189.96182 186 75 190.963125 588 75 191.96596 16 75 192.96747 75 193.97042 75 161.98443 0.0019 76 162.98269 76 163.97804 0.021 76 164.97676 0.071 76 165.972691 0.181 76 166.97155 0.83 76 167.967804 2.1 76 168.967019 3.4 76 169.963577 7.3 76 170.963185 8 76 171.960023 19.2 76 172.959808 16 76 173.957062 44 76 174.956946 84 76 175.95481 216 76 176.954965 168 76 177.953251 300 76 178.953816 390 76 179.952379 1290 76 180.95324 6300 76 181.95211 79560 76 182.95313 46800 76 0.02 183.9524891 0+ 76 184.9540423 1/2- 8.08704e+06 0.98 100.0 76 1.59 185.9538382 0+ 2000000000000000 100.0 76 1.96 186.9557505 1/2- +0.06465 -1 76 13.24 187.9558382 0+ -1 76 16.15 188.9581475 3/2- +0.659933 -1 76 26.26 189.958447 0+ -1 76 190.9609297 9/2- 1.33056e+06 0.313 100.0 76 40.78 191.9614807 0+ -1 76 192.9641516 108396 76 193.9651821 1.89216e+08 76 194.96813 390 76 195.96964 2094 76 163.9922 77 164.98752 0.0003 77 165.98582 0.0105 77 166.981665 0.005 77 167.97988 0.161 77 168.976295 0.4 77 169.97497 1.05 77 170.97163 1.5 77 171.97046 4.4 77 172.967502 9 77 173.966861 9 77 174.964113 9 77 175.963649 8 77 176.961302 30 77 177.961082 12 77 178.959122 79 77 179.959229 90 77 180.957625 294 77 181.958076 900 77 182.956846 3480 77 183.95748 11124 77 184.9567 51840 77 185.957946 59904 77 186.957363 37800 77 187.958853 149400 77 188.958719 1.14048e+06 77 189.960546 1.01779e+06 77 37.3 190.960594 3/2+ +0.1461 -1 77 191.962605 4- +1.880 6.379e+06 1.2 4.6 1.454 95.4 4.6 77 62.7 192.9629264 3/2+ +0.1591 -1 77 193.9650784 1- 69408 77 194.9659796 9000 77 195.9684 52 77 196.969653 348 77 197.97228 8 77 198.9738 77 165.99486 78 166.99298 78 167.98815 78 168.98672 0.005 78 169.982495 0.006 78 170.98124 0.025 78 171.977347 0.096 78 172.97644 0.342 78 173.972819 0.9 78 174.972421 2.52 78 175.968945 6.33 78 176.968469 11 78 177.965649 21.1 78 178.965363 21.2 78 179.963031 52 78 180.963097 51 78 181.961171 180 78 182.961597 390 78 183.959922 1038 78 184.96062 4254 78 185.959351 7920 78 186.96059 8460 78 187.959395 881280 78 188.960834 39132 78 0.014 189.959932 0+ 650000000000 3.18 100.0 78 190.961677 3/2- 242093 78 0.782 191.961038 0+ -1 2.6 100.0 78 192.9629874 1.5768e+09 78 32.967 193.9626803 0+ -1 78 33.832 194.9647911 1/2- +0.60949 -1 78 25.242 195.9649515 0+ -1 78 196.9673402 1/2- -0.51 71609.4 0.75 100.0 78 7.163 197.967893 0+ -1 78 198.970593 1848 78 199.971441 45000 78 200.97451 150 78 201.97574 158400 78 168.99808 79 169.99612 79 170.991879 79 171.99004 0.0063 79 172.986237 0.059 79 173.98476 0.12 79 174.98127 0.2 79 175.9801 1.08 79 176.976865 1.18 79 177.97603 2.6 79 178.973213 7.1 79 179.972521 8.1 79 180.970079 11.4 79 181.969618 15.6 79 182.967593 42 79 183.967452 53 79 184.965789 255 79 185.965953 642 79 186.964568 504 79 187.965324 530.4 79 188.963948 1722 79 189.9647 2568 79 190.9637 11448 79 191.964813 17784 79 192.96415 63540 79 193.965365 136872 79 194.9650346 0.148 1.60782e+07 0.230 100.0 79 195.96657 534211 79 100 196.9665687 3/2+ +0.1457 -1 79 197.9682423 2- +0.5934 232863 1.372 100.0 79 198.9687652 3/2+ +0.2715 271210 0.453 100.0 79 199.97073 2904 79 200.971657 1560 79 201.97381 28.8 79 202.975155 53 79 203.97772 39.8 79 204.97987 31 79 171.00376 80 171.99883 80 172.99724 80 173.992864 80 174.99142 0.02 80 175.987355 0.018 80 176.98628 0.13 80 177.982483 0.266 80 178.981834 1.09 80 179.978266 2.8 80 180.977819 3.6 80 181.97469 10.83 80 182.97445 9.4 80 183.971713 30.9 80 184.971899 49.1 80 185.969362 82.8 80 186.969814 144 80 187.967577 195 80 188.96819 456 80 189.966322 1200 80 190.967157 2940 80 191.965634 17460 80 192.966665 13680 80 193.965439 1.4002e+10 80 194.96672 35640 80 0.15 195.965833 0+ -1 80 196.967213 1/2- +0.5274 230904 0.42 100.0 80 9.97 197.966769 0+ -1 80 16.87 198.9682799 1/2- +0.5058851 -1 80 23.10 199.968326 0+ -1 80 13.18 200.9703023 3/2- -0.560225 -1 80 29.86 201.970643 0+ -1 80 202.9728725 5/2- +0.8489 4.02728e+06 0.492 100.0 80 6.87 203.9734939 0+ -1 80 204.976073 312 80 205.977514 489 80 206.98259 174 80 207.98594 2520 80 208.99104 80 209.99451 80 176.00059 81 176.996427 81 177.9949 81 178.99109 0.16 81 179.98991 0.7 81 180.986257 81 181.98567 3.1 81 182.982193 81 183.98187 11 81 184.97879 19.5 81 185.97833 27.5 81 186.975906 51 81 187.97601 71 81 188.973588 138 81 189.97388 156 81 190.971786 81 191.97223 576 81 192.97067 1296 81 193.9712 1980 81 194.969774 4176 81 195.970481 6624 81 196.969575 10224 81 197.97048 19080 81 198.96988 26712 81 199.970963 93960 81 200.970819 262483 81 201.972106 1.05667e+06 81 29.524 202.9723442 1/2+ +1.622257 -1 81 203.9738635 2- -0.06 1.19206e+08 0.763 97.43 0.345 2.57 81 70.476 204.9744275 1/2+ +1.6382134 -1 81 205.9761103 0- 251.94 81 206.977419 286.2 81 207.9820187 183.18 81 208.985359 132 81 209.990074 78 81 210.99348 81 211.99823 81 178.00383 82 179.00215 82 179.997918 82 180.99662 0.045 82 181.992672 0.055 82 182.99187 0.3 82 183.988142 0.55 82 184.98761 4.1 82 185.984239 4.83 82 186.983918 18.3 82 187.980874 24 82 188.98081 51 82 189.978082 72 82 190.97827 79.8 82 191.975785 210 82 192.97617 82 193.974012 720 82 194.974542 900 82 195.972774 2220 82 196.973431 480 82 197.972034 8640 82 198.972917 5400 82 199.971827 77400 82 200.972885 33588 82 201.972159 82 202.973391 186743 82 1.4 203.9730436 0+ 82 204.9744818 5/2- 82 24.1 205.9744653 0+ -1 82 22.1 206.9758969 1/2- +0.5926 -1 82 52.4 207.9766521 0+ -1 82 208.9810901 9/2+ 11710.8 82 209.9841885 7.03253e+08 82 210.988737 2166 82 211.9918975 38304 82 212.996581 612 82 213.9998054 1608 82 215.00481 36 82 184.00112 83 184.99763 4.4e-05 83 185.9966 0.015 83 186.993158 0.035 83 187.99227 0.21 83 188.9892 0.68 83 189.9883 6.3 83 190.985786 12 83 191.98546 37 83 192.98296 67 83 193.98283 95 83 194.980651 183 83 195.980667 308 83 196.978864 559.8 83 197.97921 618 83 198.977672 1620 83 199.978132 2184 83 200.977009 6480 83 201.977742 6192 83 202.976876 42336 83 203.977813 40392 83 204.977389 1.32278e+06 83 205.978499 539395 83 206.9784707 9.94961e+08 83 207.9797422 83 100 208.9803987 9/2- +4.11 83 209.9841204 1- -0.044 433123 5.04 100.0 1.16 100.0 83 210.987269 9/2- 128.4 83 211.9912857 3633 83 212.994385 2735.4 83 213.998712 1194 83 215.00177 456 83 216.006306 216 83 217.00947 97 83 218.01432 83 187.999422 84 188.998481 84 189.995101 84 190.994574 0.0155 84 191.991335 0.0332 84 192.99103 0.42 84 193.988186 0.392 84 194.98811 4.64 84 195.985535 5.8 84 196.98566 53.6 84 197.983389 106.2 84 198.983666 328.8 84 199.981799 690 84 200.98226 918 84 201.980758 2682 84 202.98142 2202 84 203.980318 12708 84 204.981203 5976 84 205.980481 760320 84 206.981593 20880 84 207.9812457 9.13913e+07 84 208.9824304 +0.77 3.21667e+09 4.976 99.74 0.26 84 209.9828737 0+ 1.19557e+07 5.407 100.0 84 210.9866532 9/2+ 0.516 7.594 100.0 84 211.988868 0+ 2.99e-07 100.0 84 212.992857 4.2e-06 84 213.9952014 0+ 0.0001643 84 214.99942 9/2+ 0.001781 99.9998 0.0002 84 216.001915 0.145 6.906 100.0 84 217.006335 10 84 218.008973 186 6.114 99.98 0.02 84 219.01374 84 220.0166 84 192.99984 0.04 85 193.99873 0.04 85 194.996268 0.63 85 195.99579 0.253 85 196.99319 0.35 85 197.99284 4.2 85 198.99053 7.2 85 199.990351 43 85 200.988417 89 85 201.98863 184 85 202.986942 444 85 203.987251 552 85 204.986074 1572 85 205.986667 1800 85 206.985784 6480 85 207.98659 5868 85 208.986173 9/2+ 19476 85 209.987148 5+ 29160 5.63 0.18 3.98 99.82 85 210.9874963 9/2- 25970.4 5.981 41.7 0.784 58.3 85 211.990745 0.314 85 212.992937 1.25e-07 85 213.996372 5.58e-07 85 214.998653 0.0001 100.0 85 216.002423 0.0003 100 85 217.004719 0.0323 85 218.008694 1.5 99.99 0.01 85 219.011162 56 99.9 0.1 85 220.01541 222.6 85 221.01805 138 85 222.02233 54 85 223.02519 50 85 195.00544 86 196.002115 0.003 86 197.00158 0.065 86 197.998679 0.064 86 198.99837 0.62 86 199.995699 0.96 86 200.99563 7 86 201.993263 10 86 202.993387 45 86 203.991429 74.4 86 204.99172 168 86 205.990214 340.2 86 206.990734 555 86 207.989642 1461 86 208.990415 1710 86 209.989696 8640 86 210.990601 52560 86 211.990704 1434 86 212.993883 0.025 86 213.995363 2.7e-07 86 214.998745 2.3e-06 86 216.000274 4.5e-05 86 217.003928 0.00054 86 218.0056013 0.035 86 219.0094802 3.96 86 220.011394 0+ 55.6 86 221.015537 1500 86 222.0175777 0+ 330350 86 223.02179 1392 86 224.02409 6420 86 225.02844 270 86 226.03089 444 86 227.03541 22.5 86 228.03799 65 86 199.00726 87 200.00657 0.019 87 201.00386 0.048 87 202.00337 0.34 87 203.000925 0.55 87 204.000653 1.7 87 204.998594 3.85 87 205.99867 15.9 87 206.99695 14.8 87 207.99714 59.1 87 208.995954 50 87 209.996408 190.8 87 210.995537 186 87 211.996202 1200 87 212.996189 34.6 87 213.998971 0.005 87 215.000341 8.6e-08 87 216.003198 7e-07 87 217.004632 2.2e-05 87 218.007578 -1 87 219.009252 0.02 87 220.012327 27.4 87 221.014255 294 87 222.017552 852 87 223.0197359 3/2+ 1308 87 224.02325 199.8 87 225.02557 240 87 226.02939 49 87 227.03184 148.2 87 228.03573 38 87 229.03845 50 87 230.04251 19.1 87 231.04544 17.5 87 232.04977 5 87 202.00989 0.0007 88 203.00927 -1 88 204.0065 0.059 88 205.00627 0.21 88 206.003827 0.24 88 207.0038 1.3 88 208.00184 1.3 88 209.00199 4.6 88 210.000495 3.7 88 211.000898 13 88 211.999794 13 88 213.000384 164.4 88 214.000108 2.46 88 215.00272 0.00159 88 216.003533 1.82e-07 88 217.00632 1.6e-06 88 218.00714 2.56e-05 88 219.010085 0.01 88 220.011028 0.018 88 221.013917 28 88 222.015375 38 88 223.0185022 1/2+ 987984 88 224.0202118 0+ 316224 88 225.023612 1.28736e+06 88 226.0254098 0+ 5.04576e+10 88 227.0291778 2532 88 228.0310703 0+ 1.81332e+08 88 229.034958 240 88 230.037056 5580 88 231.04122 103 88 232.04364 250 88 233.04806 30 88 234.0507 30 88 206.0145 0.022 89 207.01195 0.022 89 208.01155 0.095 89 209.00949 0.1 89 210.00944 0.35 89 211.00773 0.25 89 212.00781 0.93 89 213.00661 0.8 89 214.006902 8.2 89 215.006454 0.17 89 216.00872 0.00033 89 217.009347 6.9e-08 89 218.01164 1.08e-06 89 219.01242 1.18e-05 89 220.014763 0.0264 89 221.01559 0.052 89 222.017844 5 89 223.019137 126 89 224.021723 10008 89 225.02323 864000 89 226.026098 105732 89 227.0277521 3/2+ 6.86633e+08 89 228.0310211 22140 89 229.03302 3762 89 230.03629 122 89 231.03856 450 89 232.04203 119 89 233.04455 145 89 234.04842 44 89 235.05123 89 236.0553 89 209.01772 90 210.015075 0.009 90 211.01493 0.037 90 212.01298 0.03 90 213.01301 0.14 90 214.0115 0.1 90 215.01173 1.2 90 216.011062 0.028 90 217.013114 0.000252 90 218.013284 1.09e-07 90 219.01554 1.05e-06 90 220.015748 9.7e-06 90 221.018184 0.00168 90 222.018468 0.0028 90 223.020811 0.6 90 224.021467 1.05 90 225.023951 523.2 90 226.024903 1834.2 90 227.0277041 3/2+ 1.61741e+06 6.145 100.0 90 228.0287411 0+ 6.02842e+07 5.52 100.0 90 229.031762 +0.46 2.31474e+11 5.17 100.0 90 230.0331338 0+ 75380 4.77 100.0 90 231.0363043 5/2+ 91872 0.389 100.0 90 100 232.0380553 0+ 14000000000 4.081 100.0 90 233.0415818 1338 90 234.043601 0+ 2.08224e+06 0.27 100.0 90 235.04751 426 90 236.04987 2250 90 237.05389 300 90 238.0565 90 212.0232 0.0051 91 213.02111 0.0053 91 214.02092 0.017 91 215.01919 0.014 91 216.01911 0.2 91 217.01832 0.0049 91 218.020042 0.00012 91 219.01988 5.3e-08 91 220.02188 7.8e-07 91 221.02188 5.9e-06 91 222.02374 0.0029 91 223.02396 0.0065 91 224.025626 0.79 91 225.02613 1.7 91 226.027948 108 91 227.028805 2298 91 228.031051 79200 91 229.0320968 129600 91 230.034541 1.50336e+06 91 100 231.035884 3/2- 2.01 1.03312e+12 5.148 100.0 91 232.038592 +3.5 113184 1.34 100.0 91 233.0402473 +3.5 2.32995e+06 0.572 100.0 91 234.043308 4+ 24120 91 235.04544 1470 91 236.04868 546 91 237.05115 522 91 238.0545 138 91 239.05726 91 240.06098 91 217.02437 92 218.02354 0.0015 92 219.02492 4.2e-05 92 220.02472 92 221.0264 92 222.02609 -1 92 223.02774 1.8e-05 92 224.027605 0.0009 92 225.029391 0.095 92 226.029339 0.35 92 227.031156 66 92 228.031374 546 92 229.033506 3480 92 230.03394 1.79712e+06 92 231.036294 362880 92 232.0371562 2.17283e+09 5.41 100.0 92 233.0396352 +0.55 159200 4.91 100.0 92 0.0055 234.0409521 0+ 245000 4.856 100.0 92 0.7200 235.0439299 7/2- -0.35 703800000 4.6793 100.0 92 236.045568 23415000 4.569 100.0 92 237.0487302 583200 0.52 100.0 92 99.2745 238.0507882 0+ 4468000000 4.039 100.0 92 239.0542933 1407 92 240.056592 50760 0.5 100.0 92 241.06033 92 242.06293 1008 92 225.03391 0.006 93 226.03515 0.035 93 227.03496 0.51 93 228.03618 61.4 93 229.03626 240 93 230.03783 276 93 231.03825 2928 93 232.04011 882 93 233.04074 2172 93 234.042895 380160 93 235.0440633 3.4223e+07 93 236.04657 93 237.0481734 5/2+ 2140000 4.96 100.0 93 238.0509464 182909 1.29 100.0 93 239.052939 203602 0.72 100.0 93 240.056162 3714 93 241.05825 834 93 242.06164 330 93 243.06428 108 93 244.06785 137.4 93 228.03874 0.004 94 229.04015 94 230.03965 94 231.041101 94 232.041187 2046 94 233.043 1254 94 234.043317 31680 94 235.045286 1518 94 236.046058 9.01299e+07 5.87 100.0 94 237.0484097 3.90528e+06 0.004 0.22 99.996 94 238.0495599 2.76571e+09 5.59 100.0 94 239.0521634 1/2+ +0.203 7.60333e+11 5.24 100.0 94 240.0538135 0+ 2.06971e+11 5.26 100.0 94 241.0568515 -0.683 4.52542e+08 0.02 100.0 94 242.0587426 0+ 373300 4.983 100.0 94 243.062003 17841.6 94 244.064204 94 245.067747 37800 94 246.070205 936576 94 247.07407 196128 94 231.04556 95 232.04659 79 95 233.04635 95 234.04781 139.2 95 235.04795 900 95 236.04958 95 237.05 4380 95 238.05198 5880 95 239.0530245 42840 95 240.0553 182880 95 241.0568291 5/2- +1.61 1.36299e+10 5.637 100.0 95 242.0595492 57672 0.67 82.7 0.73 17.3 95 243.0613811 5/2- 2.3242e+11 5.439 100.0 95 244.0642848 36360 95 245.066452 7380 95 246.069775 2340 95 247.07209 1380 95 248.07575 95 249.07848 95 233.05077 96 234.05016 96 235.05143 96 236.05141 96 237.0529 96 238.05303 8640 96 239.05496 10440 96 240.0555295 2.3328e+06 96 241.057653 2.83392e+06 96 242.0588358 1.40659e+07 96 243.0613891 9.17698e+08 96 244.0627526 5.70802e+08 96 245.0654912 7/2+ 2.68056e+11 96 246.0672237 0+ 1.49165e+11 96 247.070354 96 248.072349 0+ 96 249.075953 3849 96 250.078357 2.83824e+11 96 251.082285 1008 96 252.08487 96 235.05658 97 236.05733 97 237.057 97 238.05828 144 97 239.05828 97 240.05976 288 97 241.06023 97 242.06198 420 97 243.063008 16200 97 244.065181 15660 97 245.0663616 426816 97 246.06867 155520 97 247.070307 4.35197e+10 97 248.07309 2.83824e+08 97 249.0749867 7/2+ 2.7648e+07 97 250.078317 11581.2 97 251.08076 3336 97 252.08431 97 253.08688 97 254.0906 97 237.06207 2.1 98 238.06141 0.021 98 239.06242 39 98 240.0623 63.6 98 241.06373 226.8 98 242.0637 209.4 98 243.06543 642 98 244.066001 1164 98 245.068049 2700 98 246.0688053 128520 98 247.071001 11196 98 248.072185 2.88144e+07 98 249.0748535 9/2- 1.10691e+10 98 250.0764061 0+ 4.12491e+08 98 251.079587 1/2+ 2.83193e+10 98 252.081626 0+ 8.34127e+07 98 253.085133 1.53878e+06 98 254.087323 5.2272e+06 98 255.09105 5100 98 256.09344 738 98 240.06892 99 241.06854 9 99 242.06975 40 99 243.06955 21 99 244.07088 37 99 245.07132 66 99 246.0729 462 99 247.07366 273 99 248.07547 1620 99 249.07641 6132 99 250.07861 30960 99 251.079992 118800 99 252.08298 4.07549e+07 99 253.0848247 7/2+ 1.76861e+06 99 254.088022 2.38205e+07 99 255.090273 3.43872e+06 99 256.0936 1524 99 257.09598 99 258.09952 99 242.07343 0.0008 100 243.07435 0.18 100 244.07408 0.0033 100 245.07539 4.2 100 246.0753 1.1 100 247.07685 35 100 248.077195 36 100 249.07903 156 100 250.079521 1800 100 251.081575 19080 100 252.082467 0+ 91404 100 253.085185 259200 100 254.0868542 11664 100 255.089962 72252 100 256.091773 9456 100 257.095105 8.6832e+06 100 258.09708 0.00037 100 259.1006 1.5 100 260.10268 100 245.08083 0.35 101 246.08189 -1 101 247.08164 1.12 101 248.08282 7 101 249.08301 24 101 250.08442 52 101 251.08484 240 101 252.08656 138 101 253.08728 360 101 254.08966 600 101 255.091083 1620 101 256.09406 4686 101 257.095541 19872 101 258.098431 4.4496e+06 101 259.10051 5760 101 260.10365 2.74752e+06 101 261.10572 101 262.10887 101 248.0866 102 249.08783 102 250.08751 0.00025 102 251.08901 0.8 102 252.088977 2.3 102 253.09068 102 102 254.090955 55 102 255.093241 186 102 256.094283 2.91 102 257.096877 25 102 258.09821 0.0012 102 259.10103 3480 102 260.10264 0.106 102 261.10575 102 262.1073 0.005 102 263.11055 102 264.11235 102 251.09436 103 252.09537 103 253.09521 1.3 103 254.09645 13 103 255.09668 22 103 256.09863 28 103 257.09956 0.646 103 258.10181 3.9 103 259.1029 6.3 103 260.1055 180 103 261.10688 2340 103 262.10963 12960 103 263.11129 103 264.11404 103 265.11584 103 266.11931 103 253.10069 1.8 104 254.10018 0.0005 104 255.10134 1.5 104 256.101166 0.0067 104 257.10299 4.7 104 258.10349 0.012 104 259.10564 3.1 104 260.10644 0.0201 104 261.10877 65 104 262.10993 2.1 104 263.11255 104 264.11399 104 265.1167 104 266.11796 104 267.12153 104 268.12364 104 255.1074 1.6 105 256.10813 2.6 105 257.10772 1.3 105 258.10923 4.4 105 259.10961 105 260.1113 1.52 105 261.11206 1.8 105 262.11408 34 105 263.11499 27 105 264.1174 105 265.1186 105 266.12103 105 267.12238 105 268.12545 105 269.12746 105 270.13071 105 258.11317 0.0029 106 259.1145 0.48 106 260.11442 0.0036 106 261.11612 0.23 106 262.1164 106 263.11832 0.8 106 264.11893 106 265.12111 10 106 266.12207 21 106 267.12443 106 268.12561 106 269.12876 106 270.13033 106 271.13347 106 272.13516 106 273.13822 106 260.12197 107 261.12166 0.0118 107 262.12289 0.102 107 263.12304 107 264.1246 0.44 107 265.12515 0.94 107 266.12694 107 267.12765 107 268.12976 107 269.13069 107 270.13362 107 271.13518 107 272.13803 107 273.13962 107 274.14244 107 275.14425 107 263.12856 108 264.12839 0.00085 108 265.13009 0.0009 108 266.1301 108 267.13179 0.026 108 268.13216 108 269.13406 9 108 270.13465 108 271.13766 108 272.13905 108 273.14199 108 274.14313 108 275.14595 108 276.14721 108 277.14984 108 265.13615 109 266.1373 0.0008 109 267.13731 109 268.13873 0.07 109 269.13906 109 270.14066 109 271.14114 109 272.14374 109 273.14491 109 274.14749 109 275.14865 109 276.15116 109 277.15242 109 278.15481 109 279.15619 109 267.14434 3e-06 110 268.1438 110 269.14512 0.00017 110 270.14472 110 271.14606 0.06 110 272.14632 110 273.14886 0.00018 110 274.14949 110 275.15218 110 276.15303 110 277.15565 110 278.15647 110 279.15886 110 280.1598 110 281.16206 110 272.15362 0.0015 111 273.15368 111 274.15571 111 275.15614 111 276.15849 111 277.15952 111 278.1616 111 279.16247 111 280.16447 111 281.16537 111 282.16749 111 283.16842 111 277.16394 0.00024 112 278.16431 112 279.16655 112 280.16704 112 281.16929 112 282.16977 112 283.17179 112 284.17238 112 285.17411 112 283.17645 113 284.17808 113 285.17873 113 286.18048 113 287.18105 113 285.1837 0.00058 114 286.18386 0.1 114 287.1856 5 114 288.18569 6 114 289.18728 21 114 287.19119 115 288.19249 115 289.19272 115 290.19414 115 291.19438 115 cdk-1.2.10/src/main/org/openscience/cdk/config/data/jmol_atomtypes.txt100644 0 0 17713 11570154753 23047 0ustar 0 0 #Type Base Number Mass vdWR covR Red Green Blue # X is a fall-back element type that should always exist X X 0 0.0 1.0 0.0 255 20 147 # The elements: H H 1 1.008 1.20 0.32 250 235 215 He He 2 4.003 1.40 0.93 255 192 203 Li Li 3 6.941 1.82 1.23 178 34 34 Be Be 4 9.0122 1.3725 0.90 34 139 34 B B 5 10.811 0.795 0.82 0 255 0 C C 6 12.011 1.70 0.77 112 128 144 N N 7 14.007 1.55 0.75 0 191 255 O O 8 15.999 1.52 0.73 255 0 0 F F 9 18.998 1.47 0.72 218 165 32 Ne Ne 10 20.18 1.54 0.71 255 105 180 Na Na 11 22.99 2.27 1.54 0 0 255 Mg Mg 12 24.312 1.73 1.36 34 139 34 Al Al 13 26.982 1.7 1.18 190 190 190 Si Si 14 28.086 2.10 1.11 218 165 32 P P 15 30.974 1.80 1.06 255 165 0 S S 16 32.06 1.80 1.02 255 255 0 Cl Cl 17 35.453 1.75 0.99 0 255 0 Ar Ar 18 39.948 1.88 0.98 255 192 203 K K 19 39.098 2.75 2.03 255 20 147 Ca Ca 20 40.078 2.45 1.74 128 128 128 Sc Sc 21 44.956 1.37 1.44 190 190 190 Ti Ti 22 47.9 1.37 1.32 190 190 190 V V 23 50.941 1.37 1.22 190 190 190 Cr Cr 24 51.996 1.37 1.18 190 190 190 Mn Mn 25 54.938 1.37 1.17 190 190 190 Fe Fe 26 55.847 1.456 1.17 255 165 0 Co Co 27 58.933 0.88 1.16 165 42 42 Ni Ni 28 58.71 0.69 1.15 165 42 42 Cu Cu 29 63.54 0.72 1.17 165 42 42 Zn Zn 30 65.37 0.74 1.25 165 42 42 Ga Ga 31 69.72 1.37 1.26 165 42 42 Ge Ge 32 72.59 1.95 1.22 85 107 47 As As 33 74.9216 1.85 1.20 253 245 230 Se Se 34 78.96 1.90 1.16 152 251 152 Br Br 35 79.904 1.85 1.14 165 42 42 Kr Kr 36 83.80 2.02 1.12 50 205 50 Rb Rb 37 85.47 1.58 2.16 165 42 42 Sr Sr 38 87.62 2.151 1.91 190 190 190 Y Y 39 88.9059 1.801 1.62 190 190 190 Zr Zr 40 91.224 1.602 1.45 190 190 190 Nb Nb 41 92.9064 1.468 1.34 190 190 190 Mo Mo 42 95.94 1.526 1.30 255 127 80 Tc Tc 43 98.0 1.360 1.27 190 190 190 Ru Ru 44 101.07 1.339 1.25 190 190 190 Rh Rh 45 102.906 1.345 1.25 190 190 190 Pd Pd 46 106.42 1.376 1.28 190 190 190 Ag Ag 47 107.87 1.27 1.34 190 190 190 Cd Cd 48 112.41 1.424 1.48 255 140 0 In In 49 114.82 1.663 1.44 190 190 190 Sn Sn 50 118.71 2.10 1.41 190 190 190 Sb Sb 51 121.75 2.05 1.40 190 190 190 Te Te 52 127.60 2.06 1.36 190 190 190 I I 53 129.905 1.98 1.33 160 32 240 Xe Xe 54 131.29 2.00 1.31 255 105 180 Cs Cs 55 132.905 1.84 2.35 165 42 42 Ba Ba 56 137.33 2.243 1.98 190 190 190 La La 57 138.906 1.877 1.69 190 190 190 Lu Lu 71 174.967 2.17 1.60 190 190 190 Hf Hf 72 178.49 1.580 1.44 190 190 190 Ta Ta 73 180.948 1.467 1.34 190 190 190 W W 74 183.85 1.534 1.30 64 224 208 Re Re 75 186.207 1.375 1.28 190 190 190 Os Os 76 190.2 1.353 1.26 190 190 190 Ir Ir 77 192.22 1.357 1.27 190 190 190 Pt Pt 78 195.08 1.75 1.30 190 190 190 Au Au 79 196.967 1.66 1.34 255 215 0 Hg Hg 80 200.59 1.55 1.49 190 190 190 Tl Tl 81 204.383 1.96 1.48 190 190 190 Pb Pb 82 207.2 2.02 1.47 190 190 190 Bi Bi 83 208.98 2.15 1.46 255 181 197 # Derived types. LP X 0 0.0 1.0 0.0 255 20 147 PD X 0 0.0 0.0 0.0 0 0 0 DM X 0 0.0 0.0 0.0 0 0 0 1 H 1 1.008 1.20 0.32 250 235 215 H3 H 1 1.008 1.25 0.32 250 235 215 HALI H 1 1.008 1.25 0.32 250 235 215 HARO H 1 1.008 1.25 0.32 250 235 215 HC H 1 1.008 1.25 0.32 250 235 215 HHBN H 1 1.008 1.25 0.32 250 235 215 HN H 1 1.008 1.25 0.32 250 235 215 HO H 1 1.008 1.25 0.32 250 235 215 HS H 1 1.008 1.25 0.32 250 235 215 HE He 2 4.003 1.40 0.93 255 192 203 3 Li 3 6.941 1.82 1.23 178 34 34 LI Li 3 6.941 1.82 1.23 178 34 34 5 B 5 10.811 0.795 0.82 0 255 0 6 C 6 12.011 1.70 0.77 112 128 144 C1 C 6 12.011 1.5 0.77 112 128 144 C2 C 6 12.011 1.5 0.77 112 128 144 C3 C 6 12.011 1.65 0.77 112 128 144 CA C 6 12.011 1.5 0.77 112 128 144 CAR C 6 12.011 1.5 0.77 112 128 144 CARO C 6 12.011 1.5 0.77 112 128 144 CB C 6 12.011 1.5 0.77 112 128 144 CD C 6 12.011 1.5 0.77 112 128 144 CD1 C 6 12.011 1.5 0.77 112 128 144 CD2 C 6 12.011 1.5 0.77 112 128 144 CE C 6 12.011 1.5 0.77 112 128 144 CE1 C 6 12.011 1.5 0.77 112 128 144 CE2 C 6 12.011 1.5 0.77 112 128 144 CG C 6 12.011 1.5 0.77 112 128 144 CG1 C 6 12.011 1.5 0.77 112 128 144 CG2 C 6 12.011 1.5 0.77 112 128 144 CZ C 6 12.011 1.5 0.77 112 128 144 CH2AL C 6 14.027 1.65 0.77 112 128 144 CH2OL C 6 14.027 1.65 0.77 112 128 144 CH3AL C 6 15.035 1.77 0.77 112 128 144 CHAL C 6 13.019 1.67 0.77 112 128 144 CHAR C 6 13.019 1.58 0.77 112 128 144 CHOL C 6 13.019 1.67 0.77 112 128 144 CSP C 6 12.011 1.5 0.77 112 128 144 CSP2 C 6 12.011 1.5 0.77 112 128 144 CSP3 C 6 12.011 1.65 0.77 112 128 144 CT C 6 15.035 1.77 0.77 112 128 144 7 N 7 14.007 1.55 0.75 0 191 255 NE N 7 14.007 1.35 0.75 0 191 255 ND2 N 7 14.007 1.35 0.75 0 191 255 NH1 N 7 14.007 1.35 0.75 0 191 255 NH2 N 7 14.007 1.35 0.75 0 191 255 N1 N 7 14.007 1.35 0.75 0 191 255 N2 N 7 14.007 1.35 0.75 0 191 255 N3 N 7 14.007 1.5 0.75 0 191 255 N3+ N 7 14.007 1.5 0.75 0 191 255 NAM N 7 14.007 1.35 0.75 0 191 255 NAR N 7 14.007 1.35 0.75 0 191 255 NARO N 7 14.007 1.35 0.75 0 191 255 NPL3 N 7 14.007 1.35 0.75 0 191 255 NSP N 7 14.007 1.35 0.75 0 191 255 NSP2 N 7 14.007 1.35 0.75 0 191 255 NSP3 N 7 14.007 1.5 0.75 0 191 255 NSP3+ N 7 14.007 1.5 0.75 0 191 255 8 O 8 15.999 1.52 0.73 255 0 0 O2 O 8 15.999 1.35 0.73 255 0 0 O3 O 8 15.999 1.35 0.73 255 0 0 OH O 8 15.999 1.35 0.73 255 0 0 OD1 O 8 15.999 1.35 0.73 255 0 0 OE1 O 8 15.999 1.35 0.73 255 0 0 OE2 O 8 15.999 1.35 0.73 255 0 0 OG O 8 15.999 1.35 0.73 255 0 0 OG1 O 8 15.999 1.35 0.73 255 0 0 OXT O 8 15.999 1.35 0.73 255 0 0 OSP2 O 8 15.999 1.35 0.73 255 0 0 OSP3 O 8 15.999 1.35 0.73 255 0 0 OSP3- O 8 15.999 1.35 0.73 255 0 0 9 F 9 18.998 1.47 0.72 218 165 32 NE Ne 10 20.18 1.54 0.71 255 105 180 11 Na 11 22.99 2.27 1.54 0 0 255 NA Na 11 22.99 2.27 1.54 0 0 255 12 Mg 12 24.312 1.73 1.36 34 139 34 MG Mg 12 24.312 1.73 1.36 34 139 34 13 Al 13 26.982 1.7 1.18 190 190 190 AL Al 13 26.982 1.7 1.18 190 190 190 14 Si 14 28.086 2.10 1.11 218 165 32 SI Si 14 28.086 2.10 1.11 218 165 32 15 P 15 30.974 1.80 1.06 255 165 0 P(C) P 15 30.974 1.75 1.06 255 165 0 P(N) P 15 30.974 1.75 1.06 255 165 0 P(O) P 15 30.974 1.75 1.06 255 165 0 P(S) P 15 30.974 1.75 1.06 255 165 0 16 S 16 32.06 1.80 1.02 255 255 0 S2 S 16 32.06 1.85 1.02 255 255 0 S3 S 16 32.06 1.85 1.02 255 255 0 SG S 16 32.06 1.85 1.02 255 255 0 SDIV S 16 32.06 1.85 1.02 255 255 0 STET S 16 32.06 1.85 1.02 255 255 0 STRI S 16 32.06 1.85 1.02 255 255 0 Sh S 16 32.06 1.85 1.02 255 255 0 17 Cl 17 35.453 1.75 0.99 0 255 0 CL Cl 17 35.453 1.75 0.99 0 255 0 AR Ar 18 39.948 1.88 0.98 255 192 203 HV Ar 18 399.48 1.91 0.0 255 192 203 LT Ar 18 39.948 1.91 0.0 255 192 203 DZ Ar 18 39.948 1.91 0.0 255 192 203 19 K 19 39.098 2.75 2.03 255 20 147 20 Ca 20 40.078 2.45 1.74 128 128 128 21 Sc 21 44.956 1.37 1.44 190 190 190 SC Sc 21 44.956 1.37 1.44 190 190 190 22 Ti 22 47.9 1.37 1.32 190 190 190 TI Ti 22 47.9 1.37 1.32 190 190 190 23 V 23 50.941 1.37 1.22 190 190 190 24 Cr 24 51.996 1.37 1.18 190 190 190 CR Cr 24 51.996 1.37 1.18 190 190 190 25 Mn 25 54.938 1.37 1.17 190 190 190 MN Mn 25 54.938 1.37 1.17 190 190 190 26 Fe 26 55.847 1.456 1.17 255 165 0 FE Fe 26 55.847 1.456 1.17 255 165 0 27 Co 27 58.933 0.88 1.16 165 42 42 CO Co 27 58.933 0.88 1.16 165 42 42 28 Ni 28 58.71 0.69 1.15 165 42 42 NI Ni 28 58.71 0.69 1.15 165 42 42 29 Cu 29 63.54 0.72 1.17 165 42 42 CU Cu 29 63.54 0.72 1.17 165 42 42 30 Zn 30 65.37 0.74 1.25 165 42 42 ZN Zn 30 65.37 0.74 1.25 165 42 42 31 Ga 31 69.72 1.37 1.26 165 42 42 GA Ga 31 69.72 1.37 1.26 165 42 42 GE Ge 32 72.59 1.95 1.22 85 107 47 35 Br 35 79.904 1.85 1.14 165 42 42 BR Br 35 79.904 1.85 1.14 165 42 42 37 Rb 37 85.47 1.58 2.16 165 42 42 RB Rb 37 85.47 1.58 2.16 165 42 42 MO Mo 42 95.94 1.526 1.30 255 127 80 47 Ag 47 107.87 1.27 1.34 190 190 190 AG Ag 47 107.87 1.27 1.34 190 190 190 53 I 53 129.905 1.98 1.33 160 32 240 55 Cs 55 132.905 1.84 2.35 165 42 42 CS Cs 55 132.905 1.84 2.35 165 42 42 79 Au 79 196.967 1.66 1.34 255 215 0 AU Au 79 196.967 1.66 1.34 255 215 0 # Some oddball types derived from X: XX X 0 0.0 1.0 0.0 255 20 147 + X 0 0.0 1.0 1.38 255 20 147 ++ X 0 0.0 1.0 0.9 255 20 147 - X 0 0.0 1.0 2.0 255 20 147 -- X 0 0.0 1.0 2.0 255 20 147 DUMMY X 0 0.0 1.0 0.0 255 20 147 RESERV X 0 0.0 1.0 0.0 255 20 147 BOGUS X 0 0.0 1.0 0.0 255 20 147 DU X 0 0.0 1.0 0.0 255 20 147 Tv X 0 0.0 1.0 0.0 255 20 147 TV X 0 0.0 1.0 0.0 255 20 147 BQ X 0 0.0 1.0 0.0 255 20 147 GB X 0 760.09 1.0 0.0 255 20 147 GBDP X 0 760.09 10.0 0.0 255 20 147 cdk-1.2.10/src/main/org/openscience/cdk/config/data/log4j.properties100644 0 0 467 11570154753 22333 0ustar 0 0 log4j.rootCategory=DEBUG, file log4j.category.org.openscience.cdk=DEBUG log4j.appender.file=org.apache.log4j.FileAppender log4j.appender.file.File=cdk.log log4j.appender.file.layout=org.apache.log4j.PatternLayout log4j.appender.file.layout.ConversionPattern=%d [%t] %-5p %c - %m%n log4j.category.joelib=WARN cdk-1.2.10/src/main/org/openscience/cdk/config/data/mm2_atomtypes.xml100644 0 0 135721 11570154753 22602 0ustar 0 0 1.0 4.0 4 4 sp3 - [CSP]-[0-4][-]?+;[A-Za-z\+\-&&[^=%]]{0,6}[(].*+ 2.0 4.0 3 4 sp2 - [CS]-[0-3];[H]{0,2}+[A-Za-z]*+=[A-Z]{1,2}+.*+ 3.0 4.0 2 4 sp1 - C-[1-2][-]?+;[H]{0,1}+%.*+ 2.0 3.0 3 sp3 - NOT Implemented 1.0 4.0 4 4 sp3 - C-3;CCC..?+&?+[A-Za-z]?+,?+.?+&?+,?+.?+&?+.*+ 3 3 2.0 4.0 3 4 sp2 - C-2;=CC..?+[A-Za-z]?+,?+&?+,?+C?+&?+.*+ 3 3 2.0 4.0 3 4 sp2 - C-2;=CC.*+ 4 3 2.0 4.0 3 4 sp2 - NotImplemented 1.0 1.0 1 1 - H-[0-1];[C].*+ 1.0 1.0 1 1 D H-1;S.*+ 1.0 1.0 1 1 D H-1;[NP][+]?+[(][H]{0,2}+=?+[A-Z]{0,2}+/.*+ 1.0 1.0 1 1 D H-1;O[+-]?+.[PSCN]{0,2}+/.*+ 1.0 1.0 1 1 D H-1;O[+]?+.=?+C/=?+[OCSP]{1,2}+/.*+ 1.0 1.0 1 1 D H-1;N[(]{1}+[CH]{2,2}+/[H]{0,3}+[,]?+=OC.*+ 1.0 1.0 1 1 D H-1;O.C/=CC/.*+ 1.0 2.0 2 6 sp3 A [OS]-[0-2][-]?+;[A-Za-z]{1,4}+[+]?+[(].*+ 2.0 2.0 1 6 sp2 A O-1[-]?+;=?+N.*+ 1.0 1.0 1 6 sp3 A O-3[+];[H]{0,3}+[C]{0,3}+[(].*+ 1.0 1.0 1 6 sp3 A O-1-?+;=?+[CS][(][=0]?+[OCSNH]*+/.*+ 1.0 2.0 2 6 sp2 A O-2;CC.H?+,?+H?+,?+&,&.*+ 3 0 1.0 2.0 2 6 sp2 A O-2;CC.=C.*+&amp;.*+&amp;.*+ 5 4 6 1.0 3.0 3 5 sp3 A N-[0-3][+-]?+;[A-Z &&[^=%]]{1,3}+.*+ 2.0 3.0 2 5 sp2 A N-[1-3][-+]?+;[^%]=?+[ON]?+[+]?+[CH]*+.(=O)?+.*+ 2.0 3.0 2 5 sp2 A N-[1-3];[CH]{1,3}.{1}+[A-Z]{0,3}+[,]?+=OC.*+ 3.0 4.0 2 5 sp1 A N-[1-2][+]?+;%.*+ 2.0 3.0 2 5 sp2 A N-[2-3][+]?+;=?+[NC][+-]?+C?+O[-]?+.*+ 2.0 4.0 3 5 sp2 - N-3[+];=O[A-Z][+-]?+O-?+.*+ 1.0 3.0 3 5 sp3 - N-[2-3];H?+CC.[^(=O)].*+ 5 4 4 1.0 2.0 2 6 sp3 A S-[1-2][-]?+;[HCSON]{1,2}+[(].*+ 2.0 4.0 4 6 sp2 - S-4;=O=O[A-Za-z]++.*+ 1.0 2.0 2 6 sp2 A S-[2];[H]{0,3}+=C.*+ 5 4 8 2.0 5.0 4 5 sp2 - P-[2-4];.* 1.0 3.0 3 5 sp3 A P-[0-3];[A-Za-z]{1,3}[(].*+ 2.0 5.0 4 3 sp2 - B-[2-4];.* 1.0 3.0 3 3 sp3 A B-[0-3];[A-Za-z]{1,3}[(].*+ 1.0 1.0 1 7 sp3 A F-[0-7][+]?+;.*+ 1.0 1.0 1 7 sp3 A Cl-[0-7][+]?+;.*+ 1.0 1.0 1 7 sp3 A Br-[0-7][+]?+;.*+ 1.0 1.0 1 7 sp3 A I.*+ 1.0 4.0 4 4 sp3 - Si.*+ 0 0 0 0 - Ge.*+ 0 0 0 0 - Sn.*+ 0 0 0 0 - Pb.*+ 0 0 0 0 - Se.*+ 0 0 0 0 - Te.*+ 0 0 0 0 - D.*+ 0 0 0 0 - He.*+ 0 0 0 0 - Ne.*+ 0 0 0 0 - Ar.*+ 0 0 0 0 - Kr.*+ 0 0 0 0 - Xe.*+ 0 0 0 0 - - .*+ cdk-1.2.10/src/main/org/openscience/cdk/config/data/mmff94_atomtypes.xml100644 0 0 206607 11570154753 23213 0ustar 0 0 1.0 4.0 4 4 sp3 - C-[0-4][+]?+;[A-Za-z+-]{0,6}[(].*+ 2.0 3.0 3 4 sp2 - [C]-[1-3];[H]{0,2}+[A-Za-z]*+=[C]{1}+.*+ 3.0 4.0 2 4 sp1 - C-[0-2];[H]{0,1}+%.*+ 2.0 4.0 3 sp2 - [C]-[3][-]?+;[A-Za-z]{0,2}+=O=O[A-Za-z]{0,2}+[(].*+ 2.0 4.0 3 4 sp2 - [S]-[3][-]?+;[A-Za-z]{0,2}+=O=O[A-Za-z]{0,2}+[(].*+ 1.0 4.0 4 4 sp3 - C-[0-4];[A-Za-z+-]{1,6}[(].*+ 4 3 1.0 4.0 4 4 sp3 - C-[0-4];[A-Za-z+-]{1,6}[(].*+ 3 3 2.0 4.0 3 4 sp2 - [C]-[0-3];[H]{0,2}+[A-Za-z]*+=[A-Z]{1,2}+.*+ 4 3 2.0 4.0 3 4 sp2 - [C]-[0-3];[H]{0,2}+[A-Za-z]*+=[A-Z]{1,2}+.*+ 4 3 2.0 4.0 3 4 sp2 - C-[2-3];[H]?+[C]{1}+[A-Z&&[^C]]{1}+[(].*+ 5 4 1 2.0 4.0 3 4 sp2 - C-[2-3];[H]?+[C]{2,3}+[(][HC]{0,2}+[,]?+[A-Z&&[^C]]{1}+.*+ 5 4 1 2.0 4.0 3 4 sp2 - NO PATTERN 4 1 1.0 1.0 1 1 - H-[1];[CSi]{1,2}.*+ 1.0 1.0 1 1 D H-[1];O[(].{2,}+.*+ 1.0 1.0 1 1 D H-[0-1];[N][(].*+ 1.0 1.0 1 1 D H-1;O[(]C/[H]{0,1}+=O.*+ 1.0 1.0 1 1 D H-[0-1];N[(][H]{0,2}+=[A-Z[^C]].*+ 1.0 1.0 1 1 D H-[0-1];O[(]C/[H]?+=C.*+ 1.0 1.0 1 1 D H-[0-1];O[(]H[)] 1.0 1.0 1 1 D H-[0-1];O[(][H]{0,2}+=?+S.*+ 1.0 1.0 1 1 D H-[1];[SP].*+ 1.0 2.0 2 6 sp2 A O-[2];[HCSN]{1,2}+[+]?+[(].*+ 2.0 2.0 1 6 sp2 A O-[1];=[A-Za-z&&[^C]]{1,2}+[(].*+ 1.0 1.0 1 6 sp3 A O-[1][-]?+;.*+ 1.0 2.0 2 6 sp2 A O-[1-2];[H]{0,2}.*+ 1.0 2.0 2 6 sp2 A O-2;CC.=C.*+&.*+&.*+ 5 4 6 1.0 3.0 3 5 sp3 A N-[0-3];[A-Za-z &&[^=%]]{1,3}+.*+ 3.0 3.0 1 5 sp A N-[1-2][+]?+;%.*+ 2.0 2.0 1 5 sp A N-1[+-]?+;%?+=?+N[+]?+[(]=?+N[-]?+.*+ 2.0 3.0 2 5 sp2 A N-[2-3][+]?+;=[A-Z&&[^O]]{1,2}+O[-]?+[(].*+ 1.0 3.0 3 5 sp3 A N-[1-3];[H]{0,2}+[A-Za-z&&[^O]]{0,2}+[O][-]?+[(].*+ 2.0 4.0 3 5 sp2 - N-3[+];=OCO-.*+ 1.0 3.0 3 5 sp3 A N-1-2];[CH]{1}+=S[(].*+ 1.0 2.0 2 5 sp3 A N-[1-2][-];[H]{0,1}+S[A-Z]{0,1}+[(][H]{0,4}+=?+O[-]?+.*+ 2.0 3.0 2 5 sp2 A N-[2][-];.*+ 5 4 0 2.0 3.0 2 5 sp2 A N-[2-3];[A-Za-z&&[^ON]]{2}[(].*+ 6 4 12 1.0 3.0 3 5 sp3 - N-[2-3];[H]{0,1}+[A-Za-z&&[^N]]{2,3}+[(].*+ 5 4 4 2.0 3.0 2 5 sp2 A N-[2-3][+]?+;[H]{0,1}+=?+[N,O,S]{0,1}+[+]?+=?+C[+]?+[N,O,S]{0,1}+[(].*+ 5 4 0 2.0 3.0 2 5 sp2 A N-[2,3];[H]{0,1}+=CC[(][H]{0,3}+=?+[A-Z&&[^C]].*+ 5 4 0 2.0 4.0 3 5 sp2 A N-[3][+];[A-Z&&[^ON]]{2}+O[-]?+[(].*+ 6 4 12 1.0 3.0 3 5 sp3 A N-[3][+];[A-Z&&[^ON]]{2}+O[-]?+[(].*+ 5 0 2.0 3.0 2 5 sp2 A N-[1-3];[H]{0,1}+[A-Za-z]++[(].*+ 5 4 0 1.0 2.0 2 6 sp3 A S-[1-2];[HCNO]{1,2}+[+]?+[(].*+ 2.0 4.0 4 6 sp2 - S-[3-4];[H]{0,2}+=[OCN]=[OCN]=?+[OCN]{0,2}+[(].*+ 1.0 1.0 1 6 sp3 A S-[1-2][-]?+;[H]{0,1}+[A-Za-z]{0,2}+[(].*+s 2.0 5.0 3 6 sp2 - S-[3];=OO[-]?+[A-Za-z]{1,2}+[-]?+[(].*+ 1.0 2.0 2 6 sp2 A S-[2];[H]{0,3}+=C.*+ 5 4 8 2.0 5.0 4 5 sp2 - P-[4];.*+ 1.0 3.0 3 5 sp3 A P-[0-3];.*+ 1.0 1.0 1 7 sp3 A F-[0-7][+]?+;.*+ 1.0 1.0 1 7 sp3 A Cl-[0-7][+]?+;.*+ 1.0 1.0 1 7 sp3 A Br-[0-7][+]?+;.*+ 1.0 1.0 1 7 sp3 A I.*+ 1.0 4.0 4 4 sp3 - Si.*+ 2.0 7.0 4 7 A Cl[4];.*+ 0 0 0 7 A F-[0-2][-];.* 0 0 0 7 A Cl-[0-2][-];.*+ 0 0 0 7 A Br-[0-2][-];.*+ - .*+ cdk-1.2.10/src/main/org/openscience/cdk/config/data/mol2_atomtypes.xml100644 0 0 12536 11570154753 22736 0ustar 0 0 sp3 sp2 sp1 sp3 sp2 sp1 sp3 sp2 sp3 sp3 sp3 sp2 tetrahedral octahedral octahedral cdk-1.2.10/src/main/org/openscience/cdk/config/data/pdb_atomtypes.xml100644 0 0 141045 11570154753 22650 0ustar 0 0 1.4 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.7 1.9 1.9 1.7 1.4 1.4 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.7 1.9 1.9 1.9 1.9 1.7 1.7 1.7 1.7 1.7 1.4 1.4 1.2 1.2 1.2 1.2 1.2 1.2 1.7 1.9 1.9 1.7 1.7 1.4 1.4 1.4 1.4 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.7 1.9 1.9 1.7 1.7 1.7 1.4 1.4 1.4 1.2 1.2 1.2 1.2 1.2 1.2 1.7 1.9 1.9 1.7 1.4 1.8 1.4 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.7 1.9 1.9 1.9 1.7 1.7 1.4 1.4 1.4 1.4 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.7 1.9 1.9 1.9 1.9 1.7 1.7 1.4 1.4 1.4 1.2 1.2 1.2 1.2 1.7 1.9 1.7 1.4 1.4 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.7 1.9 1.9 1.9 1.9 1.9 1.7 1.7 1.7 1.4 1.4 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.7 1.9 1.9 1.9 1.9 1.9 1.7 1.4 1.4 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.7 1.9 1.9 1.9 1.9 1.9 1.7 1.4 1.4 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.7 1.9 1.9 1.9 1.9 1.9 1.7 1.7 1.4 1.4 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.7 1.9 1.9 1.9 1.9 1.7 1.4 1.8 1.4 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.7 1.9 1.9 1.9 1.9 1.9 1.9 1.9 1.9 1.7 1.4 1.4 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.7 1.9 1.9 1.9 1.9 1.7 1.4 1.4 1.2 1.2 1.2 1.2 1.2 1.2 1.7 1.9 1.9 1.7 1.4 1.4 1.4 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.7 1.9 1.9 1.9 1.7 1.4 1.4 1.4 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.7 1.9 1.9 1.9 1.9 1.9 1.9 1.9 1.9 1.9 1.9 1.7 1.7 1.4 1.4 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.7 1.9 1.9 1.9 1.9 1.9 1.9 1.9 1.8 1.7 1.4 1.4 1.4 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.7 1.9 1.9 1.9 1.9 1.7 1.4 1.4 cdk-1.2.10/src/main/org/openscience/cdk/config/data/radii-covalent.txt100644 0 0 1324 11570154753 22651 0ustar 0 0 # covalent radii # Columns represent the atomic number and the covalent radius (in Angstrom) # # Sources: see elements.bibxml in the BODR # License: The MIT License 1 0.37 2 0.32 3 1.34 4 0.90 5 0.82 6 0.77 7 0.75 8 0.73 9 0.71 10 0.69 11 1.54 12 1.30 13 1.18 14 1.11 15 1.06 16 1.02 17 0.99 18 0.97 19 1.96 20 1.74 21 1.44 22 1.36 23 1.25 24 1.27 25 1.39 26 1.25 27 1.26 28 1.21 29 1.38 30 1.31 31 1.26 32 1.22 33 1.19 34 1.16 35 1.14 36 1.10 37 2.11 38 1.92 39 1.62 40 1.48 41 1.37 42 1.45 43 1.56 44 1.26 45 1.35 46 1.31 47 1.53 48 1.48 49 1.44 50 1.41 51 1.38 52 1.35 53 1.33 54 1.30 55 2.25 56 1.98 57 1.69 71 1.60 72 1.50 73 1.38 74 1.46 75 1.59 76 1.28 77 1.37 78 1.28 79 1.44 80 1.49 81 1.48 82 1.47 83 1.46 86 1.45 cdk-1.2.10/src/main/org/openscience/cdk/config/data/radii-vdw.txt100644 0 0 1664 11570154753 21645 0ustar 0 0 # van der Waals radii # Columns represent the atomic number and the vdW radius (in Angstrom) # Missing values are represented by 2 as a mean value # # Sources: see radii-vdw.bibxml # License: The MIT License 0 0 1 1.2 2 1.4 3 2.2 4 1.9 5 1.8 6 1.7 7 1.6 8 1.55 9 1.5 10 1.54 11 2.4 12 2.2 13 2.1 14 2.1 15 1.95 16 1.8 17 1.8 18 1.88 19 2.8 20 2.4 21 2.3 22 2.15 23 2.05 24 2.05 25 2.05 26 2.05 27 2 28 2 29 2 30 2.1 31 2.1 32 2.1 33 2.05 34 1.9 35 1.9 36 2.02 37 2.9 38 2.55 39 2.4 40 2.3 41 2.15 42 2.1 43 2.05 44 2.05 45 2 46 2.05 47 2.1 48 2.2 49 2.2 50 2.25 51 2.2 52 2.1 53 2.1 54 2.16 55 3 56 2.7 57 2.5 58 2.48 59 2.47 60 2.45 61 2.43 62 2.42 63 2.4 64 2.38 65 2.37 66 2.35 67 2.33 68 2.32 69 2.3 70 2.28 71 2.27 72 2.25 73 2.2 74 2.1 75 2.05 76 2 77 2 78 2.05 79 2.1 80 2.05 81 2.2 82 2.3 83 2.3 84 2 85 2 86 2 87 2 88 2 89 2 90 2.4 91 2 92 2.3 93 2 94 2 95 2 96 2 97 2 98 2 99 2 100 2 101 2 102 2 103 2 104 2 105 2 106 2 107 2 108 2 109 2 cdk-1.2.10/src/main/org/openscience/cdk/config/data/structgen_atomtypes.xml100644 0 0 12266 11570154753 24103 0ustar 0 0 1.0 1.0 1.0 1.0 3.0 4.0 2.0 3.0 3.0 4.0 3.0 3.0 2.0 5.0 2.0 2.0 3.0 3.0 3.0 5.0 2.0 2.0 2.0 4.0 2.0 6.0 2.0 2.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 3.0 cdk-1.2.10/src/main/org/openscience/cdk/config/data/whim_weights.txt100644 0 0 1745 11570154753 22455 0ustar 0 0 Symbol Mass VdWVolume Electronegativity Polarizability H 1.01 6.71 2.59 0.67 B 10.81 17.88 2.28 3.03 C 12.01 22.45 2.75 1.76 N 14.01 15.6 3.19 1.1 O 16 11.49 3.65 0.8 F 19 9.2 4 0.56 Al 26.98 36.51 1.71 6.8 Si 28.09 31.98 2.14 5.38 P 30.97 26.52 2.52 3.63 S 32.07 24.43 2.96 2.9 Cl 35.45 22.45 3.48 2.18 Cr 52 44.6 1.66 11.6 Mn 54.94 43.4 2.2 9.4 Fe 55.85 41.05 2.2 8.4 Co 58.93 35.04 2.56 7.5 Ni 58.69 17.16 1.94 6.8 Cu 63.55 11.49 1.98 6.1 Zn 65.39 11.25 2.23 7.1 Ga 69.72 27.39 2.42 8.12 Ge 72.61 28.73 2.62 6.07 As 74.92 26.52 2.82 4.31 Se 78.96 28.73 3.01 3.77 Br 79.9 31.06 3.22 3.05 Mo 95.94 33.51 1.15 12.8 Ag 107.87 21.31 1.83 7.2 Cd 112.41 16.52 1.98 7.2 In 114.82 30.11 2.14 10.2 Sn 118.71 45.83 2.3 7.7 Sb 121.76 38.79 2.46 6.6 Te 127.6 36.62 2.62 5.5 I 126.9 38.79 2.78 5.35 Gd 157.25 72.78 2 23.5 Pt 195.08 22.45 2.28 6.5 Au 196.97 19.16 2.54 5.8 Hg 200.59 15.6 2.2 5.7 Tl 204.38 31.54 2.25 7.6 Pb 207.2 34.53 2.29 6.8 Bi 208.98 38.79 2.34 7.4 cdk-1.2.10/src/main/org/openscience/cdk/config/elements/ElementPTHandler.java100644 0 0 15361 11570154753 24136 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project * * Contact: cdk-devel@lists.sf.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.config.elements; import org.openscience.cdk.PeriodicTableElement; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.tools.LoggingTool; import org.xml.sax.Attributes; import org.xml.sax.helpers.DefaultHandler; import java.util.ArrayList; import java.util.List; /** * Reads an element list in CML2 format. An example definition is: *
 * 
 *     
 *     1
 *     2
 *     Lithium
 *     3
 *     Alkali Metals
 *     Solid
 * 
 * 
* * @author Miguel Rojas * @cdk.created May 8, 2005 * @cdk.module extra * @cdk.githash */ public class ElementPTHandler extends DefaultHandler { private final int SCALAR_UNSET = 0; private final int LABEL_CAS = 1; private final int SCALAR_NAME = 2; private final int SCALAR_ATOMICNUMBER = 3; private final int SCALAR_CHEMICALSERIE = 4; private final int SCALAR_PERIOD = 5; private final int SCALAR_GROUP = 6; private final int SCALAR_PHASE = 7; private final int SCALAR_RADCOV = 8; private final int SCALAR_RADVDW = 9; private final int SCALAR_PAULE = 10; private int scalarType; private LoggingTool logger; private String currentChars; private List elements; public PeriodicTableElement elementType; public String currentElement; public String dictRef; public ElementPTHandler() { logger = new LoggingTool(this); } /** * Returns the element read from the XML file. * * @return A Vector object with all isotopes */ public List getElements() { return elements; } // SAX Parser methods public void startDocument() { elements = new ArrayList(); scalarType = SCALAR_UNSET; elementType = null; } public void endElement(String uri, String local, String raw) { logger.debug("end element: ", raw); if ("elementType".equals(local)) { elements.add(elementType); } else if ("label".equals(local)) { currentChars.trim(); try { if (scalarType == LABEL_CAS) elementType.setCASid(currentChars); } catch (NumberFormatException exception) { logger.error("The abundance value is incorrect: ", currentChars); logger.debug(exception); } }else if ("scalar".equals(local)) { currentChars.trim(); try { if (scalarType == SCALAR_NAME){ elementType.setName(currentChars); } else if (scalarType == SCALAR_ATOMICNUMBER) { elementType.setAtomicNumber(Integer.parseInt(currentChars)); } else if (scalarType == SCALAR_CHEMICALSERIE) { elementType.setChemicalSerie(currentChars); } else if (scalarType == SCALAR_PERIOD) { elementType.setPeriod(Integer.parseInt(currentChars)); } else if (scalarType == SCALAR_GROUP) { elementType.setGroup(Integer.parseInt(currentChars)); } else if (scalarType == SCALAR_PHASE) { elementType.setPhase(currentChars); }else if (scalarType == SCALAR_RADCOV) { elementType.setCovalentRadius(Double.parseDouble(currentChars)); }else if (scalarType == SCALAR_RADVDW) { elementType.setVdwRadius(Double.parseDouble(currentChars)); } else if (scalarType == SCALAR_PAULE) { elementType.setPaulingEneg(Double.parseDouble(currentChars)); } } catch (NumberFormatException exception) { logger.error("The abundance value is incorrect: ", currentChars); logger.debug(exception); } catch (CDKException e) { logger.error("Invalid IUPAC group number is specified"); } scalarType = SCALAR_UNSET; } currentChars = ""; } public void startElement(String uri, String local, String raw, Attributes atts) { currentChars = ""; dictRef = ""; logger.debug("startElement: ", raw); logger.debug("uri: ", uri); logger.debug("local: ", local); logger.debug("raw: ", raw); if ("elementType".equals(local)) { for (int i = 0; i < atts.getLength(); i++) { if ("id".equals(atts.getQName(i))) { elementType = new PeriodicTableElement(atts.getValue(i)); } } }else if ("label".equals(local)){ for (int i = 0; i < atts.getLength(); i++) { if ("dictRef".equals(atts.getQName(i))) { if ("cas:id".equals(atts.getValue(i))) { scalarType = LABEL_CAS; } } } }else if ("scalar".equals(local)) for (int i = 0; i < atts.getLength(); i++) { if ("dictRef".equals(atts.getQName(i))) { if ("cdk:name".equals(atts.getValue(i))) { scalarType = SCALAR_NAME; } else if ("cdk:atomicNumber".equals(atts.getValue(i))) { scalarType = SCALAR_ATOMICNUMBER; } else if ("cdk:name".equals(atts.getValue(i))) { scalarType = SCALAR_NAME; } else if ("cdk:chemicalSerie".equals(atts.getValue(i))) { scalarType = SCALAR_CHEMICALSERIE; } else if ("cdk:period".equals(atts.getValue(i))) { scalarType = SCALAR_PERIOD; } else if ("cdk:group".equals(atts.getValue(i))) { scalarType = SCALAR_GROUP; } else if ("cdk:phase".equals(atts.getValue(i))) { scalarType = SCALAR_PHASE; } else if ("cdk:radiiCova".equals(atts.getValue(i))) { scalarType = SCALAR_RADCOV; } else if ("cdk:radiiVdw".equals(atts.getValue(i))) { scalarType = SCALAR_RADVDW; } else if ("cdk:paulingE".equals(atts.getValue(i))) { scalarType = SCALAR_PAULE; } } } } public void characters(char chars[], int start, int length) { logger.debug("character data"); currentChars += new String(chars, start, length); } } cdk-1.2.10/src/main/org/openscience/cdk/config/elements/ElementPTReader.java100644 0 0 12663 11570154753 23765 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.config.elements; import java.io.IOException; import java.io.Reader; import java.util.ArrayList; import java.util.List; import org.openscience.cdk.PeriodicTableElement; import org.openscience.cdk.tools.LoggingTool; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; /** * Reader that instantiates an XML parser and customized handler to process * the isotope information in the CML2 isotope data file. The Reader first * tries to instantiate a JAXP XML parser available from Sun JVM 1.4.0 and * later. If not found it tries the Aelfred2 parser, and as last try the * Xerces parser. * * @author Miguel Rojas * @cdk.created May 8, 2005 * @cdk.module extra * @cdk.githash */ public class ElementPTReader { private XMLReader parser; private Reader input; private LoggingTool logger; /** * Instantiates a new reader that parses the XML from the given input. * * @param input Reader with the XML source */ public ElementPTReader(Reader input) { this.init(); this.input = input; } private void init() { logger = new LoggingTool(this); boolean success = false; // If JAXP is prefered (comes with Sun JVM 1.4.0 and higher) if (!success) { try { javax.xml.parsers.SAXParserFactory spf = javax.xml.parsers.SAXParserFactory.newInstance(); spf.setNamespaceAware(true); javax.xml.parsers.SAXParser saxParser = spf.newSAXParser(); parser = saxParser.getXMLReader(); logger.info("Using JAXP/SAX XML parser."); success = true; } catch (Exception exception) { logger.warn("Could not instantiate JAXP/SAX XML reader!"); logger.debug(exception); } } // Aelfred is first alternative. if (!success) { try { parser = (XMLReader)this.getClass().getClassLoader(). loadClass("gnu.xml.aelfred2.XmlReader"). newInstance(); logger.info("Using Aelfred2 XML parser."); success = true; } catch (Exception e) { logger.warn("Could not instantiate Aelfred2 XML reader!"); logger.debug(e); } } // Xerces is second alternative if (!success) { try { parser = (XMLReader)this.getClass().getClassLoader(). loadClass("org.apache.xerces.parsers.SAXParser"). newInstance(); logger.info("Using Xerces XML parser."); success = true; } catch (Exception e) { logger.warn("Could not instantiate Xerces XML reader!"); logger.debug(e); } } if (!success) { logger.error("Could not instantiate any XML parser!"); } } /** * Triggers the XML parsing of the data file and returns the read Isotopes. * It turns of XML validation before parsing. * * @return a Vector of Isotope's. Returns an empty vector is some reading error * occured. */ public List readElements() { List elements = new ArrayList(); try { parser.setFeature("http://xml.org/sax/features/validation", false); logger.info("Deactivated validation"); } catch (SAXException exception) { logger.warn("Cannot deactivate validation: ", exception.getMessage()); logger.debug(exception); } ElementPTHandler handler = new ElementPTHandler(); parser.setContentHandler(handler); try { parser.parse(new InputSource(input)); elements = handler.getElements(); } catch (IOException exception) { logger.error("IOException: ", exception.getMessage()); logger.debug(exception); } catch (SAXException saxe) { logger.error("SAXException: ", saxe.getClass().getName()); logger.error(saxe.getMessage()); logger.debug(saxe); } return elements; } } cdk-1.2.10/src/main/org/openscience/cdk/config/fragments/EStateFragments.java100644 0 0 12772 11570154753 24214 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (c) 2006-2008 Rational Discovery LLC, Greg Landrum, and Julie Penzotti * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above * copyright notice, this list of conditions and the following * disclaimer in the documentation and/or other materials provided * with the distribution. * * Neither the name of Rational Discovery nor the names of its * contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ package org.openscience.cdk.config.fragments; /** * A class representing the 79 E-state atom types in terms of SMARTS. *

* These fragments were originally described in {@cdk.cite HALL1995} and were * converted into SMARTS forms by the RDKit project * * @cdk.module standard * @author Greg Landrum * @cdk.created 2008-07-22 * @cdk.keyword estate * @cdk.keyword fragment */ public class EStateFragments { /** * The names of the fragments. *

* See * here for the corresponding chemical groups */ private static final String[] names = { "sLi", "ssBe", "ssssBe", "ssBH", "sssB", "ssssB", "sCH3", "dCH2", "ssCH2", "tCH", "dsCH", "aaCH", "sssCH", "ddC", "tsC", "dssC", "aasC", "aaaC", "ssssC", "sNH3", "sNH2", "ssNH2", "dNH", "ssNH", "aaNH", "tN", "sssNH", "dsN", "aaN", "sssN", "ddsN", "aasN", "ssssN", "sOH", "dO", "ssO", "aaO", "sF", "sSiH3", "ssSiH2", "sssSiH", "ssssSi", "sPH2", "ssPH", "sssP", "dsssP", "sssssP", "sSH", "dS", "ssS", "aaS", "dssS", "ddssS", "sCl", "sGeH3", "ssGeH2", "sssGeH", "ssssGe", "sAsH2", "ssAsH", "sssAs", "sssdAs", "sssssAs", "sSeH", "dSe", "ssSe", "aaSe", "dssSe", "ddssSe", "sBr", "sSnH3", "ssSnH2", "sssSnH", "ssssSn", "sI", "sPbH3", "ssPbH2", "sssPbH", "ssssPb",}; /** * The SMARTS patterns. */ private static final String[] smarts = { "[LiD1]-*", "[BeD2](-*)-*", "[BeD4](-*)(-*)(-*)-*", "[BD2H](-*)-*", "[BD3](-*)(-*)-*", "[BD4](-*)(-*)(-*)-*", "[CD1H3]-*", "[CD1H2]=*", "[CD2H2](-*)-*", "[CD1H]#*", "[CD2H](=*)-*", "[C,c;D2H](:*):*", "[CD3H](-*)(-*)-*", "[CD2H0](=*)=*", "[CD2H0](#*)-*", "[CD3H0](=*)(-*)-*", "[C,c;D3H0](:*)(:*)-*", "[C,c;D3H0](:*)(:*):*", "[CD4H0](-*)(-*)(-*)-*", "[ND1H3]-*", "[ND1H2]-*", "[ND2H2](-*)-*", "[ND1H]=*", "[ND2H](-*)-*", "[N,nD2H](:*):*", "[ND1H0]#*", "[ND3H](-*)(-*)-*", "[ND2H0](=*)-*", "[N,nD2H0](:*):*", "[ND3H0](-*)(-*)-*", "[ND3H0](~[OD1H0])(~[OD1H0])-,:*", "[N,nD3H0](:*)(:*)-,:*", "[ND4H0](-*)(-*)(-*)-*", "[OD1H]-*", "[OD1H0]=*", "[OD2H0](-*)-*", "[O,oD2H0](:*):*", "[FD1]-*", "[SiD1H3]-*", "[SiD2H2](-*)-*", "[SiD3H1](-*)(-*)-*", "[SiD4H0](-*)(-*)(-*)-*", "[PD1H2]-*", "[PD2H1](-*)-*", "[PD3H0](-*)(-*)-*", "[PD4H0](=*)(-*)(-*)-*", "[PD5H0](-*)(-*)(-*)(-*)-*", "[SD1H1]-*", "[SD1H0]=*", "[SD2H0](-*)-*", "[S,sD2H0](:*):*", "[SD3H0](=*)(-*)-*", "[SD4H0](~[OD1H0])(~[OD1H0])(-*)-*", "[ClD1]-*", "[GeD1H3](-*)", "[GeD2H2](-*)-*", "[GeD3H1](-*)(-*)-*", "[GeD4H0](-*)(-*)(-*)-*", "[AsD1H2]-*", "[AsD2H1](-*)-*", "[AsD3H0](-*)(-*)-*", "[AsD4H0](=*)(-*)(-*)-*", "[AsD5H0](-*)(-*)(-*)(-*)-*", "[SeD1H1]-*", "[SeD1H0]=*", "[SeD2H0](-*)-*", "[SeD2H0](:*):*", "[SeD3H0](=*)(-*)-*", "[SeD4H0](=*)(=*)(-*)-*", "[BrD1]-*", "[SnD1H3]-*", "[SnD2H2](-*)-*", "[SnD3H1](-*)(-*)-*", "[SnD4H0](-*)(-*)(-*)-*", "[ID1]-*", "[PbD1H3]-*", "[PbD2H2](-*)-*", "[PbD3H1](-*)(-*)-*", "[PbD4H0](-*)(-*)(-*)-*",}; /** * Get the fragment names. * * @return a string array of the names */ public static String[] getNames() { return names; } /** * Get the SMARTS patterns. * * @return a string array with the SMARTS patterns */ public static String[] getSmarts() { return smarts; } } cdk-1.2.10/src/main/org/openscience/cdk/config/isotopes/IsotopeHandler.java100644 0 0 14663 11570154753 23760 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 Egon Willighagen * * Contact: cdk-devel@lists.sf.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.config.isotopes; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IIsotope; import org.openscience.cdk.tools.LoggingTool; import org.xml.sax.Attributes; import org.xml.sax.helpers.DefaultHandler; import java.util.ArrayList; import java.util.List; /** * Reads an isotope list in CML2 format. An example definition is: *

 * 
 *   
 *     100.0
 *     1.00782504
 *     1
 *   
 *   
 *     0.015
 *     2.01410179
 *     1
 *   
 * 
 * 
* * @cdk.module core * @cdk.githash */ @TestClass("org.openscience.cdk.config.isotopes.IsotopeHandlerTest") public class IsotopeHandler extends DefaultHandler { private LoggingTool logger; private String currentChars; private List isotopes; private IIsotope workingIsotope; private String currentElement; private String dictRef; private IChemObjectBuilder builder; /** * Constructs an IsotopeHandler used by the IsotopeReader. * * @param builder The IChemObjectBuilder used to create new IIsotope's. */ public IsotopeHandler(IChemObjectBuilder builder) { logger = new LoggingTool(this); this.builder = builder; } /** * Returns the isotopes read from the XML file. * * @return A List object with all isotopes */ @TestMethod("testGetIsotopes") public List getIsotopes() { return isotopes; } // SAX Parser methods @TestMethod("testStartDocument") public void startDocument() { isotopes = new ArrayList(); } @TestMethod("testEndElement_String_String_String") public void endElement(String uri, String local, String raw) { logger.debug("end element: ", raw); if ("isotope".equals(local)) { if (workingIsotope != null) isotopes.add(workingIsotope); workingIsotope = null; } else if ("isotopeList".equals(local)) { currentElement = null; } else if ("scalar".equals(local)) { try { if ("bo:exactMass".equals(dictRef)) { workingIsotope.setExactMass(Double.parseDouble(currentChars)); } else if ("bo:atomicNumber".equals(dictRef)) { workingIsotope.setAtomicNumber(Integer.parseInt(currentChars)); } else if ("bo:relativeAbundance".equals(dictRef)) { workingIsotope.setNaturalAbundance(Double.parseDouble(currentChars)); } } catch (NumberFormatException exception) { logger.error("The ", dictRef, " value is incorrect: ", currentChars); logger.debug(exception); } } } @TestMethod("testEndElement_String_String_String") public void startElement(String uri, String local, String raw, Attributes atts) { currentChars = ""; dictRef = ""; logger.debug("startElement: ", raw); logger.debug("uri: ", uri); logger.debug("local: ", local); logger.debug("raw: ", raw); if ("isotope".equals(local)) { workingIsotope = createIsotopeOfElement(currentElement, atts); } else if ("isotopeList".equals(local)) { currentElement = getElementSymbol(atts); } else if ("scalar".equals(local)) { for (int i = 0; i < atts.getLength(); i++) { if ("dictRef".equals(atts.getQName(i))) { dictRef = atts.getValue(i); } } } } @TestMethod("testCharacters_arraychar_int_int") public void characters(char chars[], int start, int length) { currentChars += new String(chars, start, length); } private IIsotope createIsotopeOfElement(String currentElement, Attributes atts) { IIsotope isotope = builder.newIsotope(currentElement); for (int i = 0; i < atts.getLength(); i++) { try { if ("id".equals(atts.getQName(i))) { isotope.setID(atts.getValue(i)); } else if ("number".equals(atts.getQName(i))) { isotope.setMassNumber(Integer.parseInt(atts.getValue(i))); } else if ("elementType".equals(atts.getQName(i))) { isotope.setSymbol(atts.getValue(i)); } } catch (NumberFormatException exception) { logger.error("Value of isotope@", atts.getQName(i), " is not as expected."); logger.debug(exception); } } // we set the natural abundance to 0, since the default is -1, but // some isotope entries have no entry for this field, so the values // stays at -1 isotope.setNaturalAbundance(0.0); return isotope; } private String getElementSymbol(Attributes atts) { for (int i = 0; i < atts.getLength(); i++) { if ("id".equals(atts.getQName(i))) { return atts.getValue(i); } } return ""; } } cdk-1.2.10/src/main/org/openscience/cdk/config/isotopes/IsotopeReader.java100644 0 0 13501 11570154753 23573 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 Egon Willighagen * * 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 org.openscience.cdk.config.isotopes; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IIsotope; import org.openscience.cdk.tools.LoggingTool; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; /** * Reader that instantiates an XML parser and customized handler to process * the isotope information in the CML2 isotope data file. The Reader first * tries to instantiate a JAXP XML parser available from Sun JVM 1.4.0 and * later. If not found it tries the Aelfred2 parser, and as last try the * Xerces parser. * * @cdk.module core * @cdk.githash * * @author Egon Willighagen */ @TestClass("org.openscience.cdk.config.isotopes.IsotopeReaderTest") public class IsotopeReader { private XMLReader parser; private InputStream input; private LoggingTool logger; private IChemObjectBuilder builder; /** * Instantiates a new reader that parses the XML from the given input. * * @param input InputStream with the XML source * @param builder The IChemObjectBuilder used to create new IIsotope's. */ public IsotopeReader(InputStream input, IChemObjectBuilder builder) { this.init(); this.input = input; this.builder = builder; } private void init() { logger = new LoggingTool(this); boolean success = false; // If JAXP is prefered (comes with Sun JVM 1.4.0 and higher) if (!success) { try { javax.xml.parsers.SAXParserFactory spf = javax.xml.parsers.SAXParserFactory.newInstance(); spf.setNamespaceAware(true); javax.xml.parsers.SAXParser saxParser = spf.newSAXParser(); parser = saxParser.getXMLReader(); logger.info("Using JAXP/SAX XML parser."); success = true; } catch (Exception exception) { logger.warn("Could not instantiate JAXP/SAX XML reader!"); logger.debug(exception); } } // Aelfred is first alternative. if (!success) { try { parser = (XMLReader)this.getClass().getClassLoader(). loadClass("gnu.xml.aelfred2.XmlReader"). newInstance(); logger.info("Using Aelfred2 XML parser."); success = true; } catch (Exception e) { logger.warn("Could not instantiate Aelfred2 XML reader!"); logger.debug(e); } } // Xerces is second alternative if (!success) { try { parser = (XMLReader)this.getClass().getClassLoader(). loadClass("org.apache.xerces.parsers.SAXParser"). newInstance(); logger.info("Using Xerces XML parser."); success = true; } catch (Exception e) { logger.warn("Could not instantiate Xerces XML reader!"); logger.debug(e); } } if (!success) { logger.error("Could not instantiate any XML parser!"); } } /** * Triggers the XML parsing of the data file and returns the read Isotopes. * It turns of XML validation before parsing. * * @return a List of Isotope's. Returns an empty list is some reading error * occured. */ @TestMethod("testReadIsotopes,testReadIsotopes2") public List readIsotopes() { List isotopes = new ArrayList(); try { parser.setFeature("http://xml.org/sax/features/validation", false); logger.info("Deactivated validation"); } catch (SAXException exception) { logger.warn("Cannot deactivate validation: ", exception.getMessage()); logger.debug(exception); } IsotopeHandler handler = new IsotopeHandler(builder); parser.setContentHandler(handler); try { parser.parse(new InputSource(input)); isotopes = handler.getIsotopes(); } catch (IOException exception) { logger.error("IOException: ", exception.getMessage()); logger.debug(exception); } catch (SAXException saxe) { logger.error("SAXException: ", saxe.getClass().getName()); logger.error(saxe.getMessage()); logger.debug(saxe); } return isotopes; } } cdk-1.2.10/src/main/org/openscience/cdk/controller/CDKPopupMenu.java100644 0 0 4101 11570154753 22325 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project * * 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 I ask is that proper credit is given for my 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.controller; import javax.swing.JPopupMenu; import org.openscience.cdk.interfaces.IChemObject; /** * Basically, identical to the JPopupMenu class, except that this menu * can also contain the source for which it was popped up. * *

IMPORTANT: The very nature of this design can lead to race conditions. * It would be better that the Event passed to the popup menu would define * the IChemObject source. * * @author Egon Willighagen * @cdk.created 2003-07-36 * @cdk.require swing * @cdk.module controlold * @cdk.githash */ public class CDKPopupMenu extends JPopupMenu { private static final long serialVersionUID = -235498895062628065L; private IChemObject source; public void setSource(IChemObject object) { this.source = object; } public IChemObject getSource() { return this.source; } } cdk-1.2.10/src/main/org/openscience/cdk/controller/IMouseEventRelay.java100644 0 0 4575 11570154753 23272 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2007 Niels Out * * Contact: cdk-devel@lists.sourceforge.net or nout@science.uva.nl * * 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 I ask is that proper credit is given for my 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.controller; /** * * @cdk.module control */ public interface IMouseEventRelay { /** * * @param screenCoordX * @param screenCoordY */ public abstract void mouseClickedUp(int screenCoordX, int screenCoordY); /** * * @param screenCoordX * @param screenCoordY */ public abstract void mouseClickedDown(int screenCoordX, int screenCoordY); /** * * @param screenCoordX * @param screenCoordY */ public abstract void mouseClickedDouble(int screenCoordX, int screenCoordY); /** * * @param screenCoordX * @param screenCoordY */ public abstract void mouseMove(int screenCoordX, int screenCoordY); /** * * @param screenCoordX * @param screenCoordY */ public abstract void mouseEnter(int screenCoordX, int screenCoordY); /** * * @param screenCoordX * @param screenCoordY */ public abstract void mouseExit(int screenCoordX, int screenCoordY); /** * * @param screenCoordXFrom * @param screenCoordYFrom * @param screenCoordXTo * @param screenCoordYTo */ public abstract void mouseDrag(int screenCoordXFrom, int screenCoordYFrom, int screenCoordXTo, int screenCoordYTo); } cdk-1.2.10/src/main/org/openscience/cdk/controller/IViewEventRelay.java100644 0 0 2507 11570154753 23105 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2007 Egon Willighagen * * 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 I ask is that proper credit is given for my 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.controller; /** * * @cdk.module control */ public interface IViewEventRelay { public abstract void updateView(); } cdk-1.2.10/src/main/org/openscience/cdk/controller/SwingEventRelay.java100644 0 0 3053 11570154753 23146 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2007 Niels Out * * 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 I ask is that proper credit is given for my 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.controller; import javax.swing.JComponent; /** * @cdk.module control */ public class SwingEventRelay implements IViewEventRelay { private JComponent component; public SwingEventRelay(JComponent painter) { component = painter; } public void updateView() { System.out.println("updateView in SwingEventRelay"); component.repaint(); } } cdk-1.2.10/src/main/org/openscience/cdk/controller/SwingMouseEventRelay.java100644 0 0 6271 11570154753 24164 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2007 Niels Out * * Contact: cdk-devel@lists.sourceforge.net or nout@science.uva.nl * * 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 I ask is that proper credit is given for my 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.controller; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.awt.event.MouseMotionListener; /** * @cdk.module control */ public class SwingMouseEventRelay implements MouseMotionListener, MouseListener { private IMouseEventRelay relay; public SwingMouseEventRelay(IMouseEventRelay relay) { this.relay = relay; } public void mouseMoved(MouseEvent event) { relay.mouseMove(event.getX(), event.getY()); } public void updateView() { System.out.println("updating View now in SwingMouseEventRelay"); } public void mouseDragged(MouseEvent event) { //check http://www.leepoint.net/notes-java/examples/mouse/020dragdemo.html for implementation relay.mouseDrag(dragFromX, dragFromY, event.getX(), event.getY()); dragFromX = event.getX(); dragFromY = event.getY(); } /** Position of mouse press for dragging. */ private int dragFromX = 0; private int dragFromY = 0; /** true means mouse was pressed in ball and still in panel.*/ private boolean _canDrag = false; public void mouseClicked(MouseEvent event) { //normal mouseClicked is the same as mousePressed and mouseReleased after that //Double click is a special case if (event.getClickCount() > 1) relay.mouseClickedDouble(event.getX(), event.getY()); System.out.println("mouseClicked at: " + event.getX() + "/" + event.getY() + " event.getClickCount(): " + event.getClickCount()); } public void mouseEntered(MouseEvent event) { relay.mouseEnter(event.getX(), event.getY()); } public void mouseExited(MouseEvent event) { relay.mouseExit(event.getX(), event.getY()); } public void mousePressed(MouseEvent event) { // TODO Auto-generated method stub relay.mouseClickedDown(event.getX(), event.getY()); System.out.println("mousePressed at: " + event.getX() + "/" + event.getY()); dragFromX = event.getX(); dragFromY = event.getY(); } public void mouseReleased(MouseEvent event) { // TODO Auto-generated method stub relay.mouseClickedUp(event.getX(), event.getY()); } } cdk-1.2.10/src/main/org/openscience/cdk/controller/UndoAdapter.java100644 0 0 3746 11570154753 22277 0ustar 0 0 /* $RCSfile$ * $Author: egonw $ * $Date: 2008-09-10 08:13:15 +0200 (Wed, 10 Sep 2008) $ * $Revision: 12257 $ * * Copyright (C) 2005-2007 The Chemistry Development Kit (CDK) project * * 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. * * 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.controller; import javax.swing.event.UndoableEditEvent; import javax.swing.event.UndoableEditListener; import javax.swing.undo.UndoManager; import javax.swing.undo.UndoableEdit; /** * An undo adapter for updating the state of the undo components according to * the new state of the undo history list. Is registered as a listener to the * undoSupport which is receiving the undo/redo events. * * @author tohel * @cdk.module control * @cdk.githash */ public class UndoAdapter implements UndoableEditListener { private UndoManager undoManager; /** * @param undoManager * The undoManager handling the undo/redo history list */ public UndoAdapter(UndoManager undoManager) { this.undoManager = undoManager; } /* * (non-Javadoc) * * @see javax.swing.event.UndoableEditListener#undoableEditHappened(javax.swing.event.UndoableEditEvent) */ public void undoableEditHappened(UndoableEditEvent arg0) { UndoableEdit edit = arg0.getEdit(); undoManager.addEdit(edit); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugAdductFormula.java100644 0 0 7476 11570154753 22501 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2008 Egon Willighagen * * 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. * * 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.debug; import org.openscience.cdk.formula.AdductFormula; import org.openscience.cdk.interfaces.*; import org.openscience.cdk.tools.LoggingTool; import java.util.Iterator; /** * @cdk.module datadebug */ public class DebugAdductFormula extends AdductFormula implements IAdductFormula { private LoggingTool logger = new LoggingTool(DebugAdductFormula.class); public DebugAdductFormula() { super(); } public DebugAdductFormula(IMolecularFormula formula) { super(formula); } public boolean contains(IIsotope isotope) { logger.debug("Contains Isotope?: ", isotope); return super.contains(isotope); } public Integer getCharge() { Integer charge = super.getCharge(); logger.debug("Getting charge: ", charge); return charge; } public int getIsotopeCount(IIsotope isotope) { logger.debug("Getting isotope count for: ", isotope); return super.getIsotopeCount(isotope); } public int getIsotopeCount() { logger.debug("Getting isotope count: ", super.getIsotopeCount()); return super.getIsotopeCount(); } public Iterable isotopes() { logger.debug("Getting isotope iterator.."); return super.isotopes(); } public void setCharge(Integer charge) { logger.debug("Setting the charge to: ", charge); super.setCharge(charge); } public void add(IMolecularFormulaSet formulaSet) { logger.debug("Adding a formula set: ", formulaSet); super.add(formulaSet); } public void addMolecularFormula(IMolecularFormula formula) { logger.debug("Adding formula: ", formula); super.addMolecularFormula(formula); } public boolean contains(IMolecularFormula formula) { logger.debug("Contains formula?: ", formula); return super.contains(formula); } public IMolecularFormula getMolecularFormula(int position) { logger.debug("Getting formula at: ", position); return super.getMolecularFormula(position); } public Iterator iterator() { logger.debug("Getting molecular formula iterator..."); return super.iterator(); } public Iterable molecularFormulas() { logger.debug("Getting molecular formula iterable..."); return super.molecularFormulas(); } public void removeAllMolecularFormulas() { logger.debug("Removing all formulas..."); super.removeAllMolecularFormulas(); } public void removeMolecularFormula(IMolecularFormula formula) { logger.debug("Removing this formula: ", formula); super.removeMolecularFormula(formula); } public void removeMolecularFormula(int position) { logger.debug("Removing the formula at position: ", position); super.removeMolecularFormula(position); } public int size() { logger.debug("Getting the size of this adduct: " + super.size()); return super.size(); } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugAminoAcid.java100644 0 0 40710 11570154753 21577 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import org.openscience.cdk.AminoAcid; import org.openscience.cdk.interfaces.*; import org.openscience.cdk.interfaces.IBond.Order; import org.openscience.cdk.tools.LoggingTool; import java.util.List; import java.util.Map; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugAminoAcid extends AminoAcid implements IAminoAcid { private static final long serialVersionUID = 4092864536013855890L; LoggingTool logger = new LoggingTool(DebugAtomContainer.class); public void addAtomParity(IAtomParity parity) { logger.debug("Adding atom parity: ", parity); super.addAtomParity(parity); } public IAtomParity getAtomParity(IAtom atom) { logger.debug("Getting atom parity: ", atom); return super.getAtomParity(atom); } public void setAtoms(IAtom[] atoms) { logger.debug("Setting atoms: ", atoms.length); super.setAtoms(atoms); } // public void setElectronContainers(IElectronContainer[] electronContainers) { // logger.debug("Setting electron containers: ", electronContainers.length); // super.setElectronContainers(electronContainers); // } public void setAtom(int number, IAtom atom) { logger.debug("Setting atom at: pos=" + number, " atom=" + atom); super.setAtom(number, atom); } public IAtom getAtom(int number) { logger.debug("Getting atom at: ", number); return super.getAtom(number); } public IBond getBond(int number) { logger.debug("Getting bond at: ", number); return super.getBond(number); } public ILonePair getLonePair(int number) { logger.debug("Getting lone pair at: ", number); return super.getLonePair(number); } public ISingleElectron getSingleElectron(int number) { logger.debug("Getting single electron at: ", number); return super.getSingleElectron(number); } // public void setElectronContainer(int number, IElectronContainer electronContainer) { // logger.debug("Setting electron container at: pos=" + number, " electron container=" +electronContainer); // super.setElectronContainer(number, electronContainer); // } // public void setElectronContainerCount(int electronContainerCount) { // logger.debug("Setting electron container count: ", electronContainerCount); // super.setElectronContainerCount(electronContainerCount); // } // public void setAtomCount(int atomCount) { // logger.debug("Settting atom count: ", atomCount); // super.setAtomCount(atomCount); // } public Iterable atoms() { logger.debug("Getting atoms iterator"); return super.atoms(); } public Iterable bonds() { logger.debug("Getting bonds iterator"); return super.bonds(); } public Iterable lonePairs() { logger.debug("Getting lone pairs iterator"); return super.lonePairs(); } public Iterable singleElectrons() { logger.debug("Getting single electrons iterator"); return super.singleElectrons(); } public Iterable electronContainers() { logger.debug("Getting electron containers iterator"); return super.electronContainers(); } public IAtom getFirstAtom() { logger.debug("Getting first atom: ", super.getFirstAtom()); return super.getFirstAtom(); } public IAtom getLastAtom() { logger.debug("Getting last atom: ", super.getLastAtom()); return super.getLastAtom(); } public int getAtomNumber(IAtom atom) { logger.debug("Getting atom number: ", atom); return super.getAtomNumber(atom); } public int getBondNumber(IAtom atom1, IAtom atom2) { logger.debug("Getting bond number: atom1=" + atom1, " atom2=" + atom2); return super.getBondNumber(atom1, atom2); } public int getBondNumber(IBond bond) { logger.debug("Getting bond number: ", bond); return super.getBondNumber(bond); } public int getLonePairNumber(ILonePair bond) { logger.debug("Getting lone pair number: ", bond); return super.getLonePairNumber(bond); } public int getSingleElectronNumber(ISingleElectron bond) { logger.debug("Getting single electron number: ", bond); return super.getSingleElectronNumber(bond); } public IElectronContainer getElectronContainer(int number) { logger.debug("Getting electron container at: ", number); return super.getElectronContainer(number); } public IBond getBond(IAtom atom1, IAtom atom2) { logger.debug("Getting bond for atoms: atom1=" + atom1, " atom2=" + atom2); return super.getBond(atom1, atom2); } public int getAtomCount() { logger.debug("Getting atom count"); return super.getAtomCount(); } public int getBondCount() { logger.debug("Getting bond count"); return super.getBondCount(); } public int getLonePairCount() { logger.debug("Getting lone pair count"); return super.getLonePairCount(); } public int getSingleElectronCount() { logger.debug("Getting single electron count"); return super.getSingleElectronCount(); } public int getElectronContainerCount() { logger.debug("Getting electron container count"); return super.getElectronContainerCount(); } // public IAtom[] getConnectedAtoms(IAtom atom) { // logger.debug("Getting connected atoms for atom: ", atom); // return super.getConnectedAtoms(atom); // } public List getConnectedAtomsList(IAtom atom) { logger.debug("Getting connecting atoms vector for atom: ", atom); return super.getConnectedAtomsList(atom); } // public IBond[] getConnectedBonds(IAtom atom) { // logger.debug("Getting connected bonds for atom: ", atom); // return super.getConnectedBonds(atom); // } public List getConnectedBondsList(IAtom atom) { logger.debug("Getting connected bonds vector for atom: ", atom); return super.getConnectedBondsList(atom); } public List getConnectedLonePairsList(IAtom atom) { logger.debug("Getting lone pairs at atom: atom=" + atom, " lone pairs=" + super.getConnectedLonePairsCount(atom)); return super.getConnectedLonePairsList(atom); } public List getConnectedSingleElectronsList(IAtom atom) { logger.debug("Getting single electrons at atom: atom=" + atom, " single electrons=" + super.getConnectedSingleElectronsCount(atom)); return super.getConnectedSingleElectronsList(atom); } public java.util.List getConnectedElectronContainersList(IAtom atom) { logger.debug("Getting connected electron containers for atom: ", atom); return super.getConnectedElectronContainersList(atom); } public int getConnectedAtomsCount(IAtom atom) { logger.debug("Getting connected atoms count for atom: ", atom); return super.getConnectedAtomsCount(atom); } public int getConnectedBondsCount(IAtom atom) { logger.debug("Getting connected bonds count for atom: ", atom); return super.getConnectedBondsCount(atom); } public int getConnectedLonePairsCount(IAtom atom) { logger.debug("Getting connected lone pairs count for atom: ", atom); return super.getConnectedLonePairsCount(atom); } public int getConnectedSingleElectronsCount(IAtom atom) { logger.debug("Getting connected single electrons count for atom: ", atom); return super.getConnectedSingleElectronsCount(atom); } public double getBondOrderSum(IAtom atom) { logger.debug("Getting bond order sum for atom: ", atom); return super.getBondOrderSum(atom); } public Order getMaximumBondOrder(IAtom atom) { logger.debug("Getting maximum bond order for atom: ", atom); return super.getMaximumBondOrder(atom); } public Order getMinimumBondOrder(IAtom atom) { logger.debug("Getting minimum bond order for atom: ", atom); return super.getMinimumBondOrder(atom); } // public void addElectronContainers(IAtomContainer atomContainer) { // logger.debug("Adding electron containers from atom container: ", atomContainer); // super.addElectronContainers(atomContainer); // } public void add(IAtomContainer atomContainer) { logger.debug("Adding atom container: ", atomContainer); super.add(atomContainer); } public void addAtom(IAtom atom) { logger.debug("Adding atom: ", atom); super.addAtom(atom); } public void addBond(IBond bond) { logger.debug("Adding bond: ", bond); super.addBond(bond); } public void addLonePair(ILonePair ec) { logger.debug("Adding lone pair: ", ec); super.addLonePair(ec); } public void addSingleElectron(ISingleElectron ec) { logger.debug("Adding single electron: ", ec); super.addSingleElectron(ec); } public void addElectronContainer(IElectronContainer electronContainer) { logger.debug("Adding electron container: ", electronContainer); super.addElectronContainer(electronContainer); } public void remove(IAtomContainer atomContainer) { logger.debug("Removing atom container: ", atomContainer); super.remove(atomContainer); } public IElectronContainer removeElectronContainer(int position) { logger.debug("Removing electronContainer: ", position); return super.removeElectronContainer(position); } public void removeElectronContainer(IElectronContainer electronContainer) { logger.debug("Removing electron container: ", electronContainer); super.removeElectronContainer(electronContainer); } public void removeAtom(int position) { logger.debug("Removing atom: ", position); super.removeAtom(position); } public void removeAtom(IAtom atom) { logger.debug("Removing atom: ", atom); super.removeAtom(atom); } public IBond removeBond(int pos) { logger.debug("Removing bond at " + pos); return super.removeBond(pos); } public IBond removeBond(IAtom atom1, IAtom atom2) { logger.debug("Removing bond: atom1=" + atom1 + " atom2=" + atom2); return super.removeBond(atom1, atom2); } public void removeBond(IBond bond) { logger.debug("Removing bond=" + bond); super.removeBond(bond); } public ILonePair removeLonePair(int pos) { logger.debug("Removing bond at " + pos); return super.removeLonePair(pos); } public void removeLonePair(ILonePair ec) { logger.debug("Removing bond=" + ec); super.removeLonePair(ec); } public ISingleElectron removeSingleElectron(int pos) { logger.debug("Removing bond at " + pos); return super.removeSingleElectron(pos); } public void removeSingleElectron(ISingleElectron ec) { logger.debug("Removing bond=" + ec); super.removeSingleElectron(ec); } public void removeAtomAndConnectedElectronContainers(IAtom atom) { logger.debug("Removing atom and connected electron containers: ", atom); super.removeAtomAndConnectedElectronContainers(atom); } public void removeAllElements() { logger.debug("Removing all elements"); super.removeAllElements(); } public void removeAllElectronContainers() { logger.debug("Removing all electron containers"); super.removeAllElectronContainers(); } public void removeAllBonds() { logger.debug("Removing all bonds"); super.removeAllBonds(); } public void addBond(int atom1, int atom2, IBond.Order order, int stereo) { logger.debug("Adding bond: atom1=" + atom1 + " atom2=" + atom2, " order=" + order + " stereo=" + stereo); super.addBond(atom1, atom2, order, stereo); } public void addBond(int atom1, int atom2, IBond.Order order) { logger.debug("Adding bond: atom1=" + atom1 + " atom2=" + atom2, " order=" + order); super.addBond(atom1, atom2, order); } public void addLonePair(int atomID) { logger.debug("Adding lone pair: ", atomID); super.addLonePair(atomID); } public void addSingleElectron(int atomID) { logger.debug("Adding single electron: ", atomID); super.addSingleElectron(atomID); } public boolean contains(IAtom atom) { logger.debug("Contains atom: ", atom); return super.contains(atom); } public boolean contains(IBond bond) { logger.debug("Contains bond: ", bond); return super.contains(bond); } public boolean contains(ILonePair ec) { logger.debug("Contains lone pair: ", ec); return super.contains(ec); } public boolean contains(ISingleElectron ec) { logger.debug("Contains single electron: ", ec); return super.contains(ec); } public boolean contains(IElectronContainer electronContainer) { logger.debug("Contains electron container: ", electronContainer); return super.contains(electronContainer); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public String getMonomerName() { logger.debug("Getting monomer name: ", super.getMonomerName()); return super.getMonomerName(); } public String getMonomerType() { logger.debug("Getting monomer type: ", super.getMonomerType()); return super.getMonomerType(); } public void setMonomerName(String cMonomerName) { logger.debug("Setting monomer type to: ", cMonomerName); super.setMonomerName(cMonomerName); } public void setMonomerType(String cMonomerType) { logger.debug("Setting monomer type to: ", cMonomerType); super.setMonomerType(cMonomerType); } public void stateChanged(IChemObjectChangeEvent event) { logger.debug("Received state changed event: ", event); super.stateChanged(event); } public IAtom getNTerminus() { logger.debug("Getting N-terminus: ", super.getNTerminus()); return super.getNTerminus(); } public void addNTerminus(IAtom atom) { logger.debug("Adding N-terminus: ", atom); super.addNTerminus(atom); } public IAtom getCTerminus() { logger.debug("Getting C-terminus: ", super.getCTerminus()); return super.getCTerminus(); } public void addCTerminus(IAtom atom) { logger.debug("Adding C-terminus: ", atom); super.addCTerminus(atom); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugAtom.java100644 0 0 25346 11570154753 20663 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Map; import javax.vecmath.Point2d; import javax.vecmath.Point3d; import org.openscience.cdk.Atom; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IElement; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugAtom extends Atom implements IAtom { private static final long serialVersionUID = 188945429187084868L; LoggingTool logger = new LoggingTool(DebugAtom.class); public DebugAtom() { super(); } public DebugAtom(String symbol) { super(symbol); logger.debug("Instantiated a DebugAtom: symbol= ", symbol); } public DebugAtom(String symbol, Point2d point2d) { super(symbol, point2d); logger.debug("Instantiated a DebugAtom: symbol= ", symbol + " point2d=" + point2d); } public DebugAtom(String symbol, Point3d point3d) { super(symbol, point3d); logger.debug("Instantiated a DebugAtom: symbol= ", symbol + " point3d=" + point3d); } public DebugAtom(IElement element) { super(element); logger.debug("Instantiated a DebugAtom: element= ", element); } public void setCharge(Double charge) { logger.debug("Setting charge: ", charge); super.setCharge(charge); } public Double getCharge() { logger.debug("Setting charge: ", super.getCharge()); return super.getCharge(); } public void setHydrogenCount(Integer hydrogenCount) { logger.debug("Setting hydrogen count: ", hydrogenCount); super.setHydrogenCount(hydrogenCount); } public Integer getHydrogenCount() { logger.debug("Getting hydrogen count: ", super.getHydrogenCount()); return super.getHydrogenCount(); } public void setPoint2d(Point2d point2d) { logger.debug("Setting point2d: x=" + point2d.x + ", y=" + point2d.y); super.setPoint2d(point2d); } public void setPoint3d(Point3d point3d) { logger.debug("Setting point3d: x=" + point3d.x + ", y=" + point3d.y, ", z=" + point3d.z); super.setPoint3d(point3d); } public void setFractionalPoint3d(Point3d point3d) { logger.debug("Setting fractional point3d: x=" + point3d.x + ", y=" + point3d.y, ", z=" + point3d.z); super.setFractionalPoint3d(point3d); } public void setStereoParity(Integer stereoParity) { logger.debug("Setting stereoParity: ", stereoParity); super.setStereoParity(stereoParity); } public Point2d getPoint2d() { Point2d point2d = super.getPoint2d(); if (point2d == null) { logger.debug("Getting point2d: null"); } else { logger.debug("Getting point2d: x=" + point2d.x + ", y=" + point2d.y); } return point2d; } public Point3d getPoint3d() { Point3d point3d = super.getPoint3d(); if (point3d == null) { logger.debug("Getting point3d: null"); } else { logger.debug("Getting point3d: x=" + point3d.x + ", y=" + point3d.y, ", z=" + point3d.z); } return point3d; } public Point3d getFractionalPoint3d() { Point3d point3d = super.getFractionalPoint3d(); if (point3d == null) { logger.debug("Getting fractional point3d: null"); } else { logger.debug("Getting fractional point3d: x=" + point3d.x + ", y=" + point3d.y, ", z=" + point3d.z); } return point3d; } public Integer getStereoParity() { logger.debug("Getting stereo parity: ", super.getStereoParity()); return super.getStereoParity(); } public void setAtomTypeName(String identifier) { logger.debug("Setting atom type name: ", identifier); super.setAtomTypeName(identifier); } public void setMaxBondOrder(IBond.Order maxBondOrder) { logger.debug("Setting max bond order: ", maxBondOrder); super.setMaxBondOrder(maxBondOrder); } public void setBondOrderSum(Double bondOrderSum) { logger.debug("Setting bond order sum: ", bondOrderSum); super.setBondOrderSum(bondOrderSum); } public String getAtomTypeName() { logger.debug("Getting atom type name: ", super.getAtomTypeName()); return super.getAtomTypeName(); } public IBond.Order getMaxBondOrder() { logger.debug("Getting max bond order: ", super.getMaxBondOrder()); return super.getMaxBondOrder(); } public Double getBondOrderSum() { logger.debug("Getting bond order sum: ", super.getBondOrderSum()); return super.getBondOrderSum(); } public void setFormalCharge(Integer charge) { logger.debug("Setting formal charge: ", charge); super.setFormalCharge(charge); } public Integer getFormalCharge() { logger.debug("Getting formal charge: ", super.getFormalCharge()); return super.getFormalCharge(); } public void setFormalNeighbourCount(Integer count) { logger.debug("Setting forml neighbour count: ", count); super.setFormalNeighbourCount(count); } public Integer getFormalNeighbourCount() { logger.debug("Getting formal neighbour count: ", super.getFormalNeighbourCount()); return super.getFormalNeighbourCount(); } public void setHybridization(IAtomType.Hybridization hybridization) { logger.debug("Setting hybridization: ", hybridization); super.setHybridization(hybridization); } public IAtomType.Hybridization getHybridization() { logger.debug("Getting hybridization: ", super.getHybridization()); return super.getHybridization(); } public void setCovalentRadius(Double radius) { logger.debug("Setting covalent radius: ", radius); super.setCovalentRadius(radius); } public Double getCovalentRadius() { logger.debug("Getting covalent radius: ", super.getCovalentRadius()); return super.getCovalentRadius(); } public void setValency(Integer valency) { logger.debug("Setting valency: ", valency); super.setValency(valency); } public Integer getValency() { logger.debug("Getting valency: ", super.getValency()); return super.getValency(); } public void setNaturalAbundance(Double naturalAbundance) { logger.debug("Setting natural abundance: ", naturalAbundance); super.setNaturalAbundance(naturalAbundance); } public void setExactMass(Double exactMass) { logger.debug("Setting exact mass: ", exactMass); super.setExactMass(exactMass); } public Double getNaturalAbundance() { logger.debug("Getting natural abundance: ", super.getNaturalAbundance()); return super.getNaturalAbundance(); } public Double getExactMass() { logger.debug("Getting exact mass: ", super.getExactMass()); return super.getExactMass(); } public Integer getMassNumber() { logger.debug("Getting mass number: ", super.getMassNumber()); return super.getMassNumber(); } public void setMassNumber(Integer massNumber) { logger.debug("Setting mass number: ", massNumber); super.setMassNumber(massNumber); } public Integer getAtomicNumber() { logger.debug("Getting atomic number: ", super.getAtomicNumber()); return super.getAtomicNumber(); } public void setAtomicNumber(Integer atomicNumber) { logger.debug("Setting atomic number: ", atomicNumber); super.setAtomicNumber(atomicNumber); } public String getSymbol() { logger.debug("Getting symbol: ", super.getSymbol()); return super.getSymbol(); } public void setSymbol(String symbol) { logger.debug("Setting symbol: ", symbol); super.setSymbol(symbol); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugAtomContainer.java100644 0 0 40057 11570154753 22522 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.List; import java.util.Map; import org.openscience.cdk.AtomContainer; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomParity; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IElectronContainer; import org.openscience.cdk.interfaces.ILonePair; import org.openscience.cdk.interfaces.ISingleElectron; import org.openscience.cdk.interfaces.IBond.Order; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugAtomContainer extends AtomContainer implements IAtomContainer { private static final long serialVersionUID = 7584711255625778345L; LoggingTool logger = new LoggingTool(DebugAtomContainer.class); public DebugAtomContainer() { super(); } public DebugAtomContainer(int atomCount, int bondCount, int lonePairCount, int singleElectronCount) { super(atomCount, bondCount, lonePairCount, singleElectronCount); } public DebugAtomContainer(IAtomContainer container) { super(container); } public void addAtomParity(IAtomParity parity) { logger.debug("Adding atom parity: ", parity); super.addAtomParity(parity); } public IAtomParity getAtomParity(IAtom atom) { logger.debug("Getting atom parity: ", atom); return super.getAtomParity(atom); } public void setAtoms(IAtom[] atoms) { logger.debug("Setting atoms: ", atoms.length); super.setAtoms(atoms); } // public void setElectronContainers(IElectronContainer[] electronContainers) { // logger.debug("Setting electron containers: ", electronContainers.length); // super.setElectronContainers(electronContainers); // } public void setAtom(int number, IAtom atom) { logger.debug("Setting atom at: pos=" + number, " atom=" + atom); super.setAtom(number, atom); } public IAtom getAtom(int number) { logger.debug("Getting atom at: ", number); return super.getAtom(number); } public IBond getBond(int number) { logger.debug("Getting bond at: ", number); return super.getBond(number); } public ILonePair getLonePair(int number) { logger.debug("Getting lone pair at: ", number); return super.getLonePair(number); } public ISingleElectron getSingleElectron(int number) { logger.debug("Getting single electron at: ", number); return super.getSingleElectron(number); } // public void setElectronContainer(int number, IElectronContainer electronContainer) { // logger.debug("Setting electron container at: pos=" + number, " electron container=" +electronContainer); // super.setElectronContainer(number, electronContainer); // } // public void setElectronContainerCount(int electronContainerCount) { // logger.debug("Setting electron container count: ", electronContainerCount); // super.setElectronContainerCount(electronContainerCount); // } // public void setAtomCount(int atomCount) { // logger.debug("Settting atom count: ", atomCount); // super.setAtomCount(atomCount); // } public Iterable atoms() { logger.debug("Getting atoms iterator"); return super.atoms(); } public Iterable bonds() { logger.debug("Getting bonds iterator"); return super.bonds(); } public Iterable lonePairs() { logger.debug("Getting lone pairs iterator"); return super.lonePairs(); } public Iterable singleElectrons() { logger.debug("Getting single electrons iterator"); return super.singleElectrons(); } public Iterable electronContainers() { logger.debug("Getting electron containers iterator"); return super.electronContainers(); } public IAtom getFirstAtom() { logger.debug("Getting first atom: ", super.getFirstAtom()); return super.getFirstAtom(); } public IAtom getLastAtom() { logger.debug("Getting last atom: ", super.getLastAtom()); return super.getLastAtom(); } public int getAtomNumber(IAtom atom) { logger.debug("Getting atom number: ", atom); return super.getAtomNumber(atom); } public int getBondNumber(IAtom atom1, IAtom atom2) { logger.debug("Getting bond number: atom1=" + atom1, " atom2=" + atom2); return super.getBondNumber(atom1, atom2); } public int getBondNumber(IBond bond) { logger.debug("Getting bond number: ", bond); return super.getBondNumber(bond); } public int getLonePairNumber(ILonePair lp) { logger.debug("Getting lone pair number: ", lp); return super.getLonePairNumber(lp); } public int getSingleElectronNumber(ISingleElectron se) { logger.debug("Getting single electron number: ", se); return super.getSingleElectronNumber(se); } public IElectronContainer getElectronContainer(int number) { logger.debug("Getting electron container at: ", number); return super.getElectronContainer(number); } public IBond getBond(IAtom atom1, IAtom atom2) { logger.debug("Getting bond for atoms: atom1=" + atom1, " atom2=" + atom2); return super.getBond(atom1, atom2); } public int getAtomCount() { logger.debug("Getting atom count"); return super.getAtomCount(); } public int getBondCount() { logger.debug("Getting bond count"); return super.getBondCount(); } public int getLonePairCount() { logger.debug("Getting lone pair count"); return super.getLonePairCount(); } public int getSingleElectronCount() { logger.debug("Getting single electron count"); return super.getSingleElectronCount(); } public int getElectronContainerCount() { logger.debug("Getting electron container count"); return super.getElectronContainerCount(); } // public IAtom[] getConnectedAtoms(IAtom atom) { // logger.debug("Getting connected atoms for atom: ", atom); // return super.getConnectedAtoms(atom); // } public List getConnectedAtomsList(IAtom atom) { logger.debug("Getting connecting atoms list for atom: ", atom); return super.getConnectedAtomsList(atom); } // public IBond[] getConnectedBonds(IAtom atom) { // logger.debug("Getting connected bonds for atom: ", atom); // return super.getConnectedBonds(atom); // } public List getConnectedBondsList(IAtom atom) { logger.debug("Getting connected bonds list for atom: ", atom); return super.getConnectedBondsList(atom); } public List getConnectedLonePairsList(IAtom atom) { logger.debug("Getting lone pairs at atom: atom=" + atom, " lone pairs=" + super.getConnectedLonePairsCount(atom)); return super.getConnectedLonePairsList(atom); } public List getConnectedSingleElectronsList(IAtom atom) { logger.debug("Getting single electrons at atom: atom=" + atom, " single electrons=" + super.getConnectedSingleElectronsCount(atom)); return super.getConnectedSingleElectronsList(atom); } public java.util.List getConnectedElectronContainersList(IAtom atom) { logger.debug("Getting connected electron containers for atom: ", atom); return super.getConnectedElectronContainersList(atom); } public int getConnectedAtomsCount(IAtom atom) { logger.debug("Getting connected atoms count for atom: ", atom); return super.getConnectedAtomsCount(atom); } public int getConnectedBondsCount(IAtom atom) { logger.debug("Getting connected bonds count for atom: ", atom); return super.getConnectedBondsCount(atom); } public int getConnectedLonePairsCount(IAtom atom) { logger.debug("Getting connected lone pairs count for atom: ", atom); return super.getConnectedLonePairsCount(atom); } public int getConnectedSingleElectronsCount(IAtom atom) { logger.debug("Getting connected single electrons count for atom: ", atom); return super.getConnectedSingleElectronsCount(atom); } public double getBondOrderSum(IAtom atom) { logger.debug("Getting bond order sum for atom: ", atom); return super.getBondOrderSum(atom); } public Order getMaximumBondOrder(IAtom atom) { logger.debug("Getting maximum bond order for atom: ", atom); return super.getMaximumBondOrder(atom); } public Order getMinimumBondOrder(IAtom atom) { logger.debug("Getting minimum bond order for atom: ", atom); return super.getMinimumBondOrder(atom); } // public void addElectronContainers(IAtomContainer atomContainer) { // logger.debug("Adding electron containers from atom container: ", atomContainer); // super.addElectronContainers(atomContainer); // } public void add(IAtomContainer atomContainer) { logger.debug("Adding atom container: ", atomContainer); super.add(atomContainer); } public void addAtom(IAtom atom) { logger.debug("Adding atom: ", atom); super.addAtom(atom); } public void addBond(IBond bond) { logger.debug("Adding bond: ", bond); super.addBond(bond); } public void addLonePair(ILonePair ec) { logger.debug("Adding lone pair: ", ec); super.addLonePair(ec); } public void addSingleElectron(ISingleElectron ec) { logger.debug("Adding single electron: ", ec); super.addSingleElectron(ec); } public void addElectronContainer(IElectronContainer electronContainer) { logger.debug("Adding electron container: ", electronContainer); super.addElectronContainer(electronContainer); } public void remove(IAtomContainer atomContainer) { logger.debug("Removing atom container: ", atomContainer); super.remove(atomContainer); } public IElectronContainer removeElectronContainer(int position) { logger.debug("Removing electronContainer: ", position); return super.removeElectronContainer(position); } public void removeElectronContainer(IElectronContainer electronContainer) { logger.debug("Removing electron container: ", electronContainer); super.removeElectronContainer(electronContainer); } public void removeAtom(int position) { logger.debug("Removing atom: ", position); super.removeAtom(position); } public void removeAtom(IAtom atom) { logger.debug("Removing atom: ", atom); super.removeAtom(atom); } public IBond removeBond(int pos) { logger.debug("Removing bond at " + pos); return super.removeBond(pos); } public IBond removeBond(IAtom atom1, IAtom atom2) { logger.debug("Removing bond: atom1=" + atom1 + " atom2=" + atom2); return super.removeBond(atom1, atom2); } public void removeBond(IBond bond) { logger.debug("Removing bond=" + bond); super.removeBond(bond); } public ILonePair removeLonePair(int pos) { logger.debug("Removing bond at " + pos); return super.removeLonePair(pos); } public void removeLonePair(ILonePair ec) { logger.debug("Removing bond=" + ec); super.removeLonePair(ec); } public ISingleElectron removeSingleElectron(int pos) { logger.debug("Removing bond at " + pos); return super.removeSingleElectron(pos); } public void removeSingleElectron(ISingleElectron ec) { logger.debug("Removing bond=" + ec); super.removeSingleElectron(ec); } public void removeAtomAndConnectedElectronContainers(IAtom atom) { logger.debug("Removing atom and connected electron containers: ", atom); super.removeAtomAndConnectedElectronContainers(atom); } public void removeAllElements() { logger.debug("Removing all elements"); super.removeAllElements(); } public void removeAllElectronContainers() { logger.debug("Removing all electron containers"); super.removeAllElectronContainers(); } public void removeAllBonds() { logger.debug("Removing all bonds"); super.removeAllBonds(); } public void addBond(int atom1, int atom2, IBond.Order order, int stereo) { logger.debug("Adding bond: atom1=" + atom1 + " atom2=" + atom2, " order=" + order + " stereo=" + stereo); super.addBond(atom1, atom2, order, stereo); } public void addBond(int atom1, int atom2, IBond.Order order) { logger.debug("Adding bond: atom1=" + atom1 + " atom2=" + atom2, " order=" + order); super.addBond(atom1, atom2, order); } public void addLonePair(int atomID) { logger.debug("Adding lone pair: ", atomID); super.addLonePair(atomID); } public void addSingleElectron(int atomID) { logger.debug("Adding single electron: ", atomID); super.addSingleElectron(atomID); } public boolean contains(IAtom atom) { logger.debug("Contains atom: ", atom); return super.contains(atom); } public boolean contains(IBond bond) { logger.debug("Contains bond: ", bond); return super.contains(bond); } public boolean contains(ILonePair ec) { logger.debug("Contains lone pair: ", ec); return super.contains(ec); } public boolean contains(ISingleElectron ec) { logger.debug("Contains single electron: ", ec); return super.contains(ec); } public boolean contains(IElectronContainer electronContainer) { logger.debug("Contains electron container: ", electronContainer); return super.contains(electronContainer); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtomContainer: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugAtomContainerSet.java100644 0 0 15533 11570154753 23177 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Map; import org.openscience.cdk.AtomContainerSet; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomContainerSet; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugAtomContainerSet extends AtomContainerSet implements IAtomContainerSet { private static final long serialVersionUID = -8358480615782437454L; LoggingTool logger = new LoggingTool(DebugAtomContainerSet.class); public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public void addAtomContainer(IAtomContainer atomContainer) { logger.debug("Adding atom container: ", atomContainer); super.addAtomContainer(atomContainer); } public void removeAtomContainer(IAtomContainer atomContainer) { logger.debug("Removing atom container: ", atomContainer); super.removeAtomContainer(atomContainer); } public void removeAllAtomContainers() { logger.debug("Removing all atom containers"); super.removeAllAtomContainers(); } public void removeAtomContainer(int pos) { logger.debug("Removing atom container at pos: ", pos); super.removeAtomContainer(pos); } public void replaceAtomContainer(int position, IAtomContainer container) { logger.debug("Replacing atom container at pos: ", position); super.replaceAtomContainer(position, container); } public boolean setMultiplier(IAtomContainer container, Double multiplier) { logger.debug("Setting multiplier for atomcontainer: ", container, ""+multiplier); return super.setMultiplier(container, multiplier); } public void setMultiplier(int position, Double multiplier) { logger.debug("Setting multiplier for atomcontainer at pos: ", ""+position, ""+multiplier); super.setMultiplier(position, multiplier); } public Double[] getMultipliers() { logger.debug("Getting multipliers array: ", super.getMultipliers().length); return super.getMultipliers(); } public boolean setMultipliers(Double[] newMultipliers) { logger.debug("Setting multipliers array: ", newMultipliers.length); return super.setMultipliers(newMultipliers); } public void addAtomContainer(IAtomContainer atomContainer, double multiplier) { logger.debug("Adding atom container with multiplier: ", ""+multiplier, atomContainer); super.addAtomContainer(atomContainer, multiplier); } public void add(IAtomContainerSet atomContainerSet) { logger.debug("Adding set of atom containers: ", atomContainerSet); super.add(atomContainerSet); } public Iterable atomContainers() { logger.debug("Getting AtomContainer iterator"); return super.atomContainers(); } public IAtomContainer getAtomContainer(int number) { logger.debug("Getting atom container at: ", number); return super.getAtomContainer(number); } public Double getMultiplier(int number) { logger.debug("Getting multiplier at: ", number); return super.getMultiplier(number); } public Double getMultiplier(IAtomContainer container) { logger.debug("Getting multiplier for atom container: ", container); return super.getMultiplier(container); } public int getAtomContainerCount() { logger.debug("Getting atom container count: ", super.getAtomContainerCount()); return super.getAtomContainerCount(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugAtomParity.java100644 0 0 3705 11570154753 22027 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import org.openscience.cdk.AtomParity; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomParity; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugAtomParity extends AtomParity implements IAtomParity { private static final long serialVersionUID = 6305428844566539948L; public DebugAtomParity(IAtom centralAtom, IAtom first, IAtom second, IAtom third, IAtom fourth, int parity) { super(centralAtom, first, second, third, fourth, parity); } LoggingTool logger = new LoggingTool(DebugAtomParity.class); public IAtom getAtom() { logger.debug("Getting atom: ", super.getAtom()); return super.getAtom(); } public IAtom[] getSurroundingAtoms() { logger.debug("Getting surrounding atoms: ", super.getSurroundingAtoms().length); return super.getSurroundingAtoms(); } public int getParity() { logger.debug("Getting atom parity: ", super.getParity()); return super.getParity(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugAtomType.java100644 0 0 20733 11570154753 21520 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Map; import org.openscience.cdk.AtomType; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IElement; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugAtomType extends AtomType implements IAtomType { private static final long serialVersionUID = 1427549696666679540L; LoggingTool logger = new LoggingTool(DebugAtomType.class); public DebugAtomType(String elementSymbol) { super(elementSymbol); logger.debug("Instantiated a DebugAtomType: symbol= ", elementSymbol); } public DebugAtomType(String identifier, String elementSymbol) { super(elementSymbol); // cannot use super(identifier, elementSymbol); that gives a NPE logger.debug("Instantiated a DebugAtomType: identifier= " + identifier + " symbol= ", elementSymbol); this.setSymbol(elementSymbol); this.setAtomTypeName(identifier); } public DebugAtomType(IElement element) { super(element); logger.debug("Instantiated a DebugAtomType: element= ", element); } public Integer getAtomicNumber() { logger.debug("Getting atomic number: ", super.getAtomicNumber()); return super.getAtomicNumber(); } public void setAtomicNumber(Integer atomicNumber) { logger.debug("Setting atomic number: ", atomicNumber); super.setAtomicNumber(atomicNumber); } public String getSymbol() { logger.debug("Getting symbol: ", super.getSymbol()); return super.getSymbol(); } public void setSymbol(String symbol) { logger.debug("Setting symbol: ", symbol); super.setSymbol(symbol); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public void setNaturalAbundance(Double naturalAbundance) { logger.debug("Setting natural abundance: ", naturalAbundance); super.setNaturalAbundance(naturalAbundance); } public void setExactMass(Double exactMass) { logger.debug("Setting exact mass: ", exactMass); super.setExactMass(exactMass); } public Double getNaturalAbundance() { logger.debug("Getting natural abundance: ", super.getNaturalAbundance()); return super.getNaturalAbundance(); } public Double getExactMass() { logger.debug("Getting exact mass: ", super.getExactMass()); return super.getExactMass(); } public Integer getMassNumber() { logger.debug("Getting mass number: ", super.getMassNumber()); return super.getMassNumber(); } public void setMassNumber(Integer massNumber) { logger.debug("Setting mass number: ", massNumber); super.setMassNumber(massNumber); } public void setAtomTypeName(String identifier) { logger.debug("Setting atom type name: ", identifier); super.setAtomTypeName(identifier); } public void setMaxBondOrder(IBond.Order maxBondOrder) { logger.debug("Setting max bond order: ", maxBondOrder); super.setMaxBondOrder(maxBondOrder); } public void setBondOrderSum(Double bondOrderSum) { logger.debug("Setting bond order sum: ", bondOrderSum); super.setBondOrderSum(bondOrderSum); } public String getAtomTypeName() { logger.debug("Getting atom type name: ", super.getAtomTypeName()); return super.getAtomTypeName(); } public IBond.Order getMaxBondOrder() { logger.debug("Getting max bond order: ", super.getMaxBondOrder()); return super.getMaxBondOrder(); } public Double getBondOrderSum() { logger.debug("Getting bond order sum: ", super.getBondOrderSum()); return super.getBondOrderSum(); } public void setFormalCharge(Integer charge) { logger.debug("Setting formal charge: ", charge); super.setFormalCharge(charge); } public Integer getFormalCharge() { logger.debug("Getting formal charge: ", super.getFormalCharge()); return super.getFormalCharge(); } public void setFormalNeighbourCount(Integer count) { logger.debug("Setting forml neighbour count: ", count); super.setFormalNeighbourCount(count); } public Integer getFormalNeighbourCount() { logger.debug("Getting formal neighbour count: ", super.getFormalNeighbourCount()); return super.getFormalNeighbourCount(); } public void setHybridization(IAtomType.Hybridization hybridization) { logger.debug("Setting hybridization: ", hybridization); super.setHybridization(hybridization); } public IAtomType.Hybridization getHybridization() { logger.debug("Getting hybridization: ", super.getHybridization()); return super.getHybridization(); } public void setCovalentRadius(Double radius) { logger.debug("Setting covalent radius: ", radius); super.setCovalentRadius(radius); } public Double getCovalentRadius() { logger.debug("Getting covalent radius: ", super.getCovalentRadius()); return super.getCovalentRadius(); } public void setValency(Integer valency) { logger.debug("Setting valency: ", valency); super.setValency(valency); } public Integer getValency() { logger.debug("Getting valency: ", super.getValency()); return super.getValency(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugBioPolymer.java100644 0 0 43576 11570154753 22051 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Collection; import java.util.List; import java.util.Map; import org.openscience.cdk.BioPolymer; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomParity; import org.openscience.cdk.interfaces.IBioPolymer; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IElectronContainer; import org.openscience.cdk.interfaces.ILonePair; import org.openscience.cdk.interfaces.IMonomer; import org.openscience.cdk.interfaces.ISingleElectron; import org.openscience.cdk.interfaces.IStrand; import org.openscience.cdk.interfaces.IBond.Order; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugBioPolymer extends BioPolymer implements IBioPolymer { private static final long serialVersionUID = 5349870327516864575L; LoggingTool logger = new LoggingTool(DebugAtomContainer.class); public void addAtomParity(IAtomParity parity) { logger.debug("Adding atom parity: ", parity); super.addAtomParity(parity); } public IAtomParity getAtomParity(IAtom atom) { logger.debug("Getting atom parity: ", atom); return super.getAtomParity(atom); } public void setAtoms(IAtom[] atoms) { logger.debug("Setting atoms: ", atoms.length); super.setAtoms(atoms); } // public void setElectronContainers(IElectronContainer[] electronContainers) { // logger.debug("Setting electron containers: ", electronContainers.length); // super.setElectronContainers(electronContainers); // } public void setAtom(int number, IAtom atom) { logger.debug("Setting atom at: pos=" + number, " atom=" + atom); super.setAtom(number, atom); } public IAtom getAtom(int number) { logger.debug("Getting atom at: ", number); return super.getAtom(number); } public IBond getBond(int number) { logger.debug("Getting bond at: ", number); return super.getBond(number); } public ILonePair getLonePair(int number) { logger.debug("Getting lone pair at: ", number); return super.getLonePair(number); } public ISingleElectron getSingleElectron(int number) { logger.debug("Getting single electron at: ", number); return super.getSingleElectron(number); } // public void setElectronContainer(int number, IElectronContainer electronContainer) { // logger.debug("Setting electron container at: pos=" + number, " electron container=" +electronContainer); // super.setElectronContainer(number, electronContainer); // } // public void setElectronContainerCount(int electronContainerCount) { // logger.debug("Setting electron container count: ", electronContainerCount); // super.setElectronContainerCount(electronContainerCount); // } // public void setAtomCount(int atomCount) { // logger.debug("Settting atom count: ", atomCount); // super.setAtomCount(atomCount); // } public Iterable atoms() { logger.debug("Getting atoms iterator"); return super.atoms(); } public Iterable bonds() { logger.debug("Getting bonds iterator"); return super.bonds(); } public Iterable lonePairs() { logger.debug("Getting lone pairs iterator"); return super.lonePairs(); } public Iterable singleElectrons() { logger.debug("Getting single electrons iterator"); return super.singleElectrons(); } public Iterable electronContainers() { logger.debug("Getting electron containers iterator"); return super.electronContainers(); } public IAtom getFirstAtom() { logger.debug("Getting first atom: ", super.getFirstAtom()); return super.getFirstAtom(); } public IAtom getLastAtom() { logger.debug("Getting last atom: ", super.getLastAtom()); return super.getLastAtom(); } public int getAtomNumber(IAtom atom) { logger.debug("Getting atom number: ", atom); return super.getAtomNumber(atom); } public int getBondNumber(IAtom atom1, IAtom atom2) { logger.debug("Getting bond number: atom1=" + atom1, " atom2=" + atom2); return super.getBondNumber(atom1, atom2); } public int getBondNumber(IBond bond) { logger.debug("Getting bond number: ", bond); return super.getBondNumber(bond); } public int getLonePairNumber(ILonePair bond) { logger.debug("Getting lone pair number: ", bond); return super.getLonePairNumber(bond); } public int getSingleElectronNumber(ISingleElectron bond) { logger.debug("Getting single electron number: ", bond); return super.getSingleElectronNumber(bond); } public IElectronContainer getElectronContainer(int number) { logger.debug("Getting electron container at: ", number); return super.getElectronContainer(number); } public IBond getBond(IAtom atom1, IAtom atom2) { logger.debug("Getting bond for atoms: atom1=" + atom1, " atom2=" + atom2); return super.getBond(atom1, atom2); } public int getAtomCount() { logger.debug("Getting atom count"); return super.getAtomCount(); } public int getBondCount() { logger.debug("Getting bond count"); return super.getBondCount(); } public int getLonePairCount() { logger.debug("Getting lone pair count"); return super.getLonePairCount(); } public int getSingleElectronCount() { logger.debug("Getting single electron count"); return super.getSingleElectronCount(); } public int getElectronContainerCount() { logger.debug("Getting electron container count"); return super.getElectronContainerCount(); } // public IAtom[] getConnectedAtoms(IAtom atom) { // logger.debug("Getting connected atoms for atom: ", atom); // return super.getConnectedAtoms(atom); // } public List getConnectedAtomsList(IAtom atom) { logger.debug("Getting connecting atoms vector for atom: ", atom); return super.getConnectedAtomsList(atom); } // public IBond[] getConnectedBonds(IAtom atom) { // logger.debug("Getting connected bonds for atom: ", atom); // return super.getConnectedBonds(atom); // } public List getConnectedBondsList(IAtom atom) { logger.debug("Getting connected bonds vector for atom: ", atom); return super.getConnectedBondsList(atom); } public List getConnectedLonePairsList(IAtom atom) { logger.debug("Getting lone pairs at atom: atom=" + atom, " lone pairs=" + super.getConnectedLonePairsCount(atom)); return super.getConnectedLonePairsList(atom); } public List getConnectedSingleElectronsList(IAtom atom) { logger.debug("Getting single electrons at atom: atom=" + atom, " single electrons=" + super.getConnectedSingleElectronsCount(atom)); return super.getConnectedSingleElectronsList(atom); } public java.util.List getConnectedElectronContainersList(IAtom atom) { logger.debug("Getting connected electron containers for atom: ", atom); return super.getConnectedElectronContainersList(atom); } public int getConnectedAtomsCount(IAtom atom) { logger.debug("Getting connected atoms count for atom: ", atom); return super.getConnectedAtomsCount(atom); } public int getConnectedBondsCount(IAtom atom) { logger.debug("Getting connected bonds count for atom: ", atom); return super.getConnectedBondsCount(atom); } public int getConnectedLonePairsCount(IAtom atom) { logger.debug("Getting connected lone pairs count for atom: ", atom); return super.getConnectedLonePairsCount(atom); } public int getConnectedSingleElectronsCount(IAtom atom) { logger.debug("Getting connected single electrons count for atom: ", atom); return super.getConnectedSingleElectronsCount(atom); } public double getBondOrderSum(IAtom atom) { logger.debug("Getting bond order sum for atom: ", atom); return super.getBondOrderSum(atom); } public Order getMaximumBondOrder(IAtom atom) { logger.debug("Getting maximum bond order for atom: ", atom); return super.getMaximumBondOrder(atom); } public Order getMinimumBondOrder(IAtom atom) { logger.debug("Getting minimum bond order for atom: ", atom); return super.getMinimumBondOrder(atom); } // public void addElectronContainers(IAtomContainer atomContainer) { // logger.debug("Adding electron containers from atom container: ", atomContainer); // super.addElectronContainers(atomContainer); // } public void add(IAtomContainer atomContainer) { logger.debug("Adding atom container: ", atomContainer); super.add(atomContainer); } public void addAtom(IAtom atom) { logger.debug("Adding atom: ", atom); super.addAtom(atom); } public void addBond(IBond bond) { logger.debug("Adding bond: ", bond); super.addBond(bond); } public void addLonePair(ILonePair ec) { logger.debug("Adding lone pair: ", ec); super.addLonePair(ec); } public void addSingleElectron(ISingleElectron ec) { logger.debug("Adding single electron: ", ec); super.addSingleElectron(ec); } public void addElectronContainer(IElectronContainer electronContainer) { logger.debug("Adding electron container: ", electronContainer); super.addElectronContainer(electronContainer); } public void remove(IAtomContainer atomContainer) { logger.debug("Removing atom container: ", atomContainer); super.remove(atomContainer); } public IElectronContainer removeElectronContainer(int position) { logger.debug("Removing electronContainer: ", position); return super.removeElectronContainer(position); } public void removeElectronContainer(IElectronContainer electronContainer) { logger.debug("Removing electron container: ", electronContainer); super.removeElectronContainer(electronContainer); } public void removeAtom(int position) { logger.debug("Removing atom: ", position); super.removeAtom(position); } public void removeAtom(IAtom atom) { logger.debug("Removing atom: ", atom); super.removeAtom(atom); } public IBond removeBond(int pos) { logger.debug("Removing bond at " + pos); return super.removeBond(pos); } public IBond removeBond(IAtom atom1, IAtom atom2) { logger.debug("Removing bond: atom1=" + atom1 + " atom2=" + atom2); return super.removeBond(atom1, atom2); } public void removeBond(IBond bond) { logger.debug("Removing bond=" + bond); super.removeBond(bond); } public ILonePair removeLonePair(int pos) { logger.debug("Removing bond at " + pos); return super.removeLonePair(pos); } public void removeLonePair(ILonePair ec) { logger.debug("Removing bond=" + ec); super.removeLonePair(ec); } public ISingleElectron removeSingleElectron(int pos) { logger.debug("Removing bond at " + pos); return super.removeSingleElectron(pos); } public void removeSingleElectron(ISingleElectron ec) { logger.debug("Removing bond=" + ec); super.removeSingleElectron(ec); } public void removeAtomAndConnectedElectronContainers(IAtom atom) { logger.debug("Removing atom and connected electron containers: ", atom); super.removeAtomAndConnectedElectronContainers(atom); } public void removeAllElements() { logger.debug("Removing all elements"); super.removeAllElements(); } public void removeAllElectronContainers() { logger.debug("Removing all electron containers"); super.removeAllElectronContainers(); } public void removeAllBonds() { logger.debug("Removing all bonds"); super.removeAllBonds(); } public void addBond(int atom1, int atom2, IBond.Order order, int stereo) { logger.debug("Adding bond: atom1=" + atom1 + " atom2=" + atom2, " order=" + order + " stereo=" + stereo); super.addBond(atom1, atom2, order, stereo); } public void addBond(int atom1, int atom2, IBond.Order order) { logger.debug("Adding bond: atom1=" + atom1 + " atom2=" + atom2, " order=" + order); super.addBond(atom1, atom2, order); } public void addLonePair(int atomID) { logger.debug("Adding lone pair: ", atomID); super.addLonePair(atomID); } public void addSingleElectron(int atomID) { logger.debug("Adding single electron: ", atomID); super.addSingleElectron(atomID); } public boolean contains(IAtom atom) { logger.debug("Contains atom: ", atom); return super.contains(atom); } public boolean contains(IBond bond) { logger.debug("Contains bond: ", bond); return super.contains(bond); } public boolean contains(ILonePair ec) { logger.debug("Contains lone pair: ", ec); return super.contains(ec); } public boolean contains(ISingleElectron ec) { logger.debug("Contains single electron: ", ec); return super.contains(ec); } public boolean contains(IElectronContainer electronContainer) { logger.debug("Contains electron container: ", electronContainer); return super.contains(electronContainer); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public void stateChanged(IChemObjectChangeEvent event) { logger.debug("Receiving state changed event: ", event); super.stateChanged(event); } public void addAtom(IAtom oAtom, IMonomer oMonomer) { logger.debug("Adding atom to monomer: ", oAtom, oMonomer); super.addAtom(oAtom, oMonomer); } public int getMonomerCount() { logger.debug("Getting monomer count: ", super.getMonomerCount()); return super.getMonomerCount(); } public IMonomer getMonomer(String cName) { logger.debug("Getting monomer for String: ", cName); return super.getMonomer(cName); } public Collection getMonomerNames() { logger.debug("Getting monomer names"); return super.getMonomerNames(); } public void removeMonomer(String name) { logger.debug("Removing monomer by string: ", name); super.removeMonomer(name); } public void addAtom(IAtom oAtom, IStrand oStrand) { logger.debug("Adding stoms to strand: ", oAtom, oStrand); super.addAtom(oAtom, oStrand); } public void addAtom(IAtom oAtom, IMonomer oMonomer, IStrand oStrand) { logger.debug("Adding stoms to strand/monomer: ", oAtom, oMonomer, oStrand); super.addAtom(oAtom, oMonomer, oStrand); } public IMonomer getMonomer(String monName, String strandName) { logger.debug("Getting monomer from strand: ", monName, strandName); return super.getMonomer(monName, strandName); } public int getStrandCount() { logger.debug("Getting strand count: ", super.getStrandCount()); return super.getStrandCount(); } public IStrand getStrand(String cName) { logger.debug("Getting strand by name: ", cName); return super.getStrand(cName); } public Collection getStrandNames() { logger.debug("Getting strand names: ", super.getStrandNames()); return super.getStrandNames(); } public void removeStrand(String name) { logger.debug("Removing strand by name: ", name); super.removeStrand(name); } public Map getStrands() { logger.debug("Getting strands: ", super.getStrands()); return super.getStrands(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugBond.java100644 0 0 15401 11570154753 20634 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Map; import javax.vecmath.Point2d; import javax.vecmath.Point3d; import org.openscience.cdk.Bond; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugBond extends Bond implements IBond { private static final long serialVersionUID = -2330398179697796261L; LoggingTool logger = new LoggingTool(DebugBond.class); public DebugBond() { super(); } public DebugBond(IAtom atom1, IAtom atom2) { super(atom1, atom2); } public DebugBond(IAtom atom1, IAtom atom2, IBond.Order order) { super(atom1, atom2, order); } public DebugBond(IAtom atom1, IAtom atom2, IBond.Order order, int stereo) { super(atom1, atom2, order, stereo); } public DebugBond(IAtom[] atoms) { super(atoms); } public DebugBond(IAtom[] atoms, IBond.Order order) { super(atoms, order); } public Integer getElectronCount() { logger.debug("Getting electron count: ", super.getElectronCount()); return super.getElectronCount(); } public void setElectronCount(Integer electronCount) { logger.debug("Setting electron count: ", electronCount); super.setElectronCount(electronCount); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public Iterable atoms() { logger.debug("Getting atoms iterable"); return super.atoms(); } public void setAtoms(IAtom[] atoms) { logger.debug("Setting atoms: ", atoms.length); super.setAtoms(atoms); } public int getAtomCount() { logger.debug("Getting atom count: ", super.getAtomCount()); return super.getAtomCount(); } public IAtom getAtom(int position) { logger.debug("Getting atom at position: ", position); return super.getAtom(position); } public IAtom getConnectedAtom(IAtom atom) { logger.debug("Getting connected atom to atom: ", atom); return super.getConnectedAtom(atom); } public boolean contains(IAtom atom) { logger.debug("Contains atom: ", atom); return super.contains(atom); } public void setAtom(IAtom atom, int position) { logger.debug("Setting atom at position: ", atom); super.setAtom(atom, position); } public Order getOrder() { logger.debug("Getting order: ", super.getOrder()); return super.getOrder(); } public void setOrder(Order order) { logger.debug("Setting order: ", order); super.setOrder(order); } public int getStereo() { logger.debug("Getting stereo: ", super.getStereo()); return super.getStereo(); } public void setStereo(int stereo) { logger.debug("Setting stereo: ", stereo); super.setStereo(stereo); } public Point2d get2DCenter() { logger.debug("Getting 2d center: ", super.get2DCenter()); return super.get2DCenter(); } public Point3d get3DCenter() { logger.debug("Getting 3d center: ", super.get3DCenter()); return super.get3DCenter(); } public boolean compare(Object object) { logger.debug("Comparing to object: ", object); return super.compare(object); } public boolean isConnectedTo(IBond bond) { logger.debug("Is connected to bond: ", bond); return super.isConnectedTo(bond); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugChemFile.java100644 0 0 11616 11570154753 21432 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Map; import org.openscience.cdk.ChemFile; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugChemFile extends ChemFile implements IChemFile { private static final long serialVersionUID = -5575043161897814279L; LoggingTool logger = new LoggingTool(DebugChemFile.class); public DebugChemFile() { super(); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public void addChemSequence(IChemSequence chemSequence) { logger.debug("Adding sequence: ", chemSequence); super.addChemSequence(chemSequence); } public void removeChemSequence(int pos) { logger.debug("Removing sequence: ", pos); super.removeChemSequence(pos); } public Iterable chemSequences() { logger.debug("Getting chemSequences"); return super.chemSequences(); } public IChemSequence getChemSequence(int number) { logger.debug("Getting chemSequence at: ", number); return super.getChemSequence(number); } public int getChemSequenceCount() { logger.debug("Getting chemSequence count: ", super.getChemSequenceCount()); return super.getChemSequenceCount(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugChemModel.java100644 0 0 12545 11570154753 21615 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Map; import org.openscience.cdk.ChemModel; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.ICrystal; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.interfaces.IReactionSet; import org.openscience.cdk.interfaces.IRingSet; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugChemModel extends ChemModel implements IChemModel { private static final long serialVersionUID = -920209300005079592L; LoggingTool logger = new LoggingTool(DebugChemModel.class); public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public IMoleculeSet getMoleculeSet() { logger.debug("Getting setOfMolecules: ", super.getMoleculeSet()); return super.getMoleculeSet(); } public void setMoleculeSet(IMoleculeSet setOfMolecules) { logger.debug("Setting setOfMolecules: ", setOfMolecules); super.setMoleculeSet(setOfMolecules); } public IRingSet getRingSet() { logger.debug("Getting ringSet: ", super.getRingSet()); return super.getRingSet(); } public void setRingSet(IRingSet ringSet) { logger.debug("Setting ringSet: ", ringSet); super.setRingSet(ringSet); } public ICrystal getCrystal() { logger.debug("Getting crystal: ", super.getCrystal()); return super.getCrystal(); } public void setCrystal(ICrystal crystal) { logger.debug("Setting crystal: ", crystal); super.setCrystal(crystal); } public IReactionSet getReactionSet() { logger.debug("Getting setOfReactions: ", super.getReactionSet()); return super.getReactionSet(); } public void setReactionSet(IReactionSet sor) { logger.debug("Setting setOfReactions: ", sor); super.setReactionSet(sor); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugChemObject.java100644 0 0 11044 11570154753 21754 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Map; import org.openscience.cdk.ChemObject; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugChemObject extends ChemObject implements IChemObject { private static final long serialVersionUID = -8547443535884526365L; LoggingTool logger = new LoggingTool(DebugChemObject.class); public DebugChemObject(IChemObject object) { super(object); logger.debug("Instantiated DebugChemObject from object: ", object); } public DebugChemObject() { super(); logger.debug("Instantiated DebugChemObject"); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public void setNotification(boolean bool) { logger.debug("Setting use notification: ", bool); super.setNotification(bool); } public boolean getNotification() { return super.getNotification(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugChemObjectBuilder.java100644 0 0 22335 11570154753 23270 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import org.openscience.cdk.interfaces.*; import org.openscience.cdk.interfaces.IBond.Order; import javax.vecmath.Point2d; import javax.vecmath.Point3d; /** * A helper class to instantiate a IChemObject for the debug implementation. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugChemObjectBuilder implements IChemObjectBuilder { private static DebugChemObjectBuilder instance = null; private DebugChemObjectBuilder() {} public static DebugChemObjectBuilder getInstance() { if (instance == null) { instance = new DebugChemObjectBuilder(); } return instance; } public IAminoAcid newAminoAcid() { return new DebugAminoAcid(); } public IAtom newAtom() { return new DebugAtom(); } public IAtom newAtom(String elementSymbol) { return new DebugAtom(elementSymbol); } public IAtom newAtom(String elementSymbol, javax.vecmath.Point2d point2d) { return new DebugAtom(elementSymbol, point2d); } public IAtom newAtom(String elementSymbol, javax.vecmath.Point3d point3d) { return new DebugAtom(elementSymbol, point3d); } public IAtomContainer newAtomContainer() { return new DebugAtomContainer(); } public IAtomContainer newAtomContainer(int atomCount, int electronContainerCount, int lonePairCount, int singleElectronCount) { return new DebugAtomContainer(atomCount, electronContainerCount, lonePairCount, singleElectronCount); } public IAtomContainer newAtomContainer(IAtomContainer container) { return new DebugAtomContainer(container); } public IAtomParity newAtomParity( IAtom centralAtom, IAtom first, IAtom second, IAtom third, IAtom fourth, int parity) { return new DebugAtomParity(centralAtom, first, second, third, fourth, parity); } public IAtomType newAtomType(String elementSymbol) { return new DebugAtomType(elementSymbol); } public IAtomType newAtomType(String identifier, String elementSymbol) { return new DebugAtomType(identifier, elementSymbol); } public IBioPolymer newBioPolymer(){ return new DebugBioPolymer(); } public IPDBAtom newPDBAtom(IElement element) { return new DebugPDBAtom(element); } public IPDBAtom newPDBAtom(String elementSymbol) { return new DebugPDBAtom(elementSymbol); } public IPDBAtom newPDBAtom(String elementSymbol, javax.vecmath.Point3d point3d) { return new DebugPDBAtom(elementSymbol, point3d); } public IPDBStructure newPDBStructure() { return new DebugPDBStructure(); } public IPDBPolymer newPDBPolymer(){ return new DebugPDBPolymer(); } public IPDBMonomer newPDBMonomer(){ return new DebugPDBMonomer(); } public IPDBStructure newStructure(){ return new DebugPDBStructure(); } public IBond newBond() { return new DebugBond(); } public IBond newBond(IAtom atom1, IAtom atom2) { return new DebugBond(atom1, atom2); } public IBond newBond(IAtom atom1, IAtom atom2, Order order) { return new DebugBond(atom1, atom2, order); } public IBond newBond(IAtom atom1, IAtom atom2, Order order, int stereo) { return new DebugBond(atom1, atom2, order, stereo); } public IBond newBond(IAtom[] atoms) { return new DebugBond(atoms); } public IBond newBond(IAtom[] atoms, Order order) { return new DebugBond(atoms, order); } public IChemFile newChemFile() { return new DebugChemFile(); } public IChemModel newChemModel() { return new DebugChemModel(); } public IChemObject newChemObject() { return new DebugChemObject(); } public IChemSequence newChemSequence() { return new DebugChemSequence(); } public ICrystal newCrystal() { return new DebugCrystal(); } public ICrystal newCrystal(IAtomContainer container) { return new DebugCrystal(container); } public IElectronContainer newElectronContainer() { return new DebugElectronContainer(); } public IElement newElement() { return new DebugElement(); } public IElement newElement(String symbol) { return new DebugElement(symbol); } public IElement newElement(String symbol, int atomicNumber) { return new DebugElement(symbol, atomicNumber); } public IIsotope newIsotope(String elementSymbol) { return new DebugIsotope(elementSymbol); } public IIsotope newIsotope(int atomicNumber, String elementSymbol, int massNumber, double exactMass, double abundance) { return new DebugIsotope(atomicNumber, elementSymbol, massNumber, exactMass, abundance); } public IIsotope newIsotope(int atomicNumber, String elementSymbol, double exactMass, double abundance) { return new DebugIsotope(atomicNumber, elementSymbol, exactMass, abundance); } public IIsotope newIsotope(String elementSymbol, int massNumber) { return new DebugIsotope(elementSymbol, massNumber); } public ILonePair newLonePair() { return new DebugLonePair(); } public ILonePair newLonePair(IAtom atom) { return new DebugLonePair(atom); } public IMapping newMapping(IChemObject objectOne, IChemObject objectTwo) { return new DebugMapping(objectOne, objectTwo); } public IMolecule newMolecule() { return new DebugMolecule(); } public IMolecule newMolecule(int atomCount, int electronContainerCount, int lonePairCount, int singleElectronCount) { return new DebugMolecule(atomCount, electronContainerCount, lonePairCount, singleElectronCount); } public IMolecule newMolecule(IAtomContainer container) { return new DebugMolecule(container); } public IMonomer newMonomer () { return new DebugMonomer(); } public IPolymer newPolymer() { return new DebugPolymer(); } public IReaction newReaction() { return new DebugReaction(); } public IRing newRing() { return new DebugRing(); } public IRing newRing(IAtomContainer container) { return new DebugRing(container); } public IRing newRing(int ringSize, String elementSymbol) { return new DebugRing(ringSize, elementSymbol); } public IRing newRing(int ringSize) { return new DebugRing(ringSize); } public IRingSet newRingSet() { return new DebugRingSet(); } public IAtomContainerSet newAtomContainerSet() { return new DebugAtomContainerSet(); } public IMoleculeSet newMoleculeSet() { return new DebugMoleculeSet(); } public IReactionSet newReactionSet() { return new DebugReactionSet(); } public IReactionScheme newReactionScheme() { return new DebugReactionScheme(); } public ISingleElectron newSingleElectron() { return new DebugSingleElectron(); } public ISingleElectron newSingleElectron(IAtom atom) { return new DebugSingleElectron(atom); } public IStrand newStrand() { return new DebugStrand(); } public IPseudoAtom newPseudoAtom() { return new DebugPseudoAtom(); } public IPseudoAtom newPseudoAtom(String label) { return new DebugPseudoAtom(label); } public IPseudoAtom newPseudoAtom(IAtom atom) { return new DebugPseudoAtom(atom); } public IPseudoAtom newPseudoAtom(String label, Point3d point3d) { return new DebugPseudoAtom(label, point3d); } public IPseudoAtom newPseudoAtom(String label, Point2d point2d) { return new DebugPseudoAtom(label, point2d); } public IAtom newAtom(IElement element) { return new DebugAtom(element); } public IAtomType newAtomType(IElement element) { return new DebugAtomType(element); } public IChemObject newChemObject(IChemObject object) { return new DebugChemObject(object); } public IElement newElement(IElement element) { return new DebugElement(element); } public IIsotope newIsotope(IElement element) { return new DebugIsotope(element); } public IPseudoAtom newPseudoAtom(IElement element) { return new DebugPseudoAtom(element); } public IFragmentAtom newFragmentAtom() { return new DebugFragmentAtom(); } public IAdductFormula newAdductFormula() { return new DebugAdductFormula(); } public IAdductFormula newAdductFormula(IMolecularFormula formula) { return new DebugAdductFormula(formula); } public IMolecularFormula newMolecularFormula() { return new DebugMolecularFormula(); } public IMolecularFormulaSet newMolecularFormulaSet() { return new DebugMolecularFormulaSet(); } public IMolecularFormulaSet newMolecularFormulaSet(IMolecularFormula formula) { return new DebugMolecularFormulaSet(formula); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugChemSequence.java100644 0 0 11474 11570154753 22325 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Map; import org.openscience.cdk.ChemSequence; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugChemSequence extends ChemSequence implements IChemSequence { private static final long serialVersionUID = -628120469241907704L; LoggingTool logger = new LoggingTool(DebugChemSequence.class); public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public void addChemModel(IChemModel chemModel) { logger.debug("Adding chemModel: ", chemModel); super.addChemModel(chemModel); } public void removeChemModel(int pos) { logger.debug("Remove chemModel: ", pos); super.removeChemModel(pos); } public Iterable chemModels() { logger.debug("Getting chemModels"); return super.chemModels(); } public IChemModel getChemModel(int number) { logger.debug("Getting chemModel at: ", number); return super.getChemModel(number); } public int getChemModelCount() { logger.debug("Getting ChemModel count: ", super.getChemModelCount()); return super.getChemModelCount(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugCrystal.java100644 0 0 42310 11570154753 21372 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.List; import java.util.Map; import javax.vecmath.Vector3d; import org.openscience.cdk.Crystal; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomParity; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.ICrystal; import org.openscience.cdk.interfaces.IElectronContainer; import org.openscience.cdk.interfaces.ILonePair; import org.openscience.cdk.interfaces.ISingleElectron; import org.openscience.cdk.interfaces.IBond.Order; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugCrystal extends Crystal implements ICrystal { private static final long serialVersionUID = -1749989529794094087L; LoggingTool logger; public DebugCrystal() { super(); logger = new LoggingTool(DebugCrystal.class); } public DebugCrystal(IAtomContainer container) { super(container); logger = new LoggingTool(DebugCrystal.class); } public void addAtomParity(IAtomParity parity) { logger.debug("Adding atom parity: ", parity); super.addAtomParity(parity); } public IAtomParity getAtomParity(IAtom atom) { logger.debug("Getting atom parity: ", atom); return super.getAtomParity(atom); } public void setAtoms(IAtom[] atoms) { logger.debug("Setting atoms: ", atoms.length); super.setAtoms(atoms); } // public void setElectronContainers(IElectronContainer[] electronContainers) { // logger.debug("Setting electron containers: ", electronContainers.length); // super.setElectronContainers(electronContainers); // } public void setAtom(int number, IAtom atom) { logger.debug("Setting atom at: pos=" + number, " atom=" + atom); super.setAtom(number, atom); } public IAtom getAtom(int number) { logger.debug("Getting atom at: ", number); return super.getAtom(number); } public IBond getBond(int number) { logger.debug("Getting bond at: ", number); return super.getBond(number); } public ILonePair getLonePair(int number) { logger.debug("Getting lone pair at: ", number); return super.getLonePair(number); } public ISingleElectron getSingleElectron(int number) { logger.debug("Getting single electron at: ", number); return super.getSingleElectron(number); } // public void setElectronContainer(int number, IElectronContainer electronContainer) { // logger.debug("Setting electron container at: pos=" + number, " electron container=" +electronContainer); // super.setElectronContainer(number, electronContainer); // } // public void setElectronContainerCount(int electronContainerCount) { // logger.debug("Setting electron container count: ", electronContainerCount); // super.setElectronContainerCount(electronContainerCount); // } // public void setAtomCount(int atomCount) { // logger.debug("Settting atom count: ", atomCount); // super.setAtomCount(atomCount); // } public Iterable atoms() { logger.debug("Getting atoms iterator"); return super.atoms(); } public Iterable bonds() { logger.debug("Getting bonds iterator"); return super.bonds(); } public Iterable lonePairs() { logger.debug("Getting lone pairs iterator"); return super.lonePairs(); } public Iterable singleElectrons() { logger.debug("Getting single electrons iterator"); return super.singleElectrons(); } public Iterable electronContainers() { logger.debug("Getting electron containers iterator"); return super.electronContainers(); } public IAtom getFirstAtom() { logger.debug("Getting first atom: ", super.getFirstAtom()); return super.getFirstAtom(); } public IAtom getLastAtom() { logger.debug("Getting last atom: ", super.getLastAtom()); return super.getLastAtom(); } public int getAtomNumber(IAtom atom) { logger.debug("Getting atom number: ", atom); return super.getAtomNumber(atom); } public int getBondNumber(IAtom atom1, IAtom atom2) { logger.debug("Getting bond number: atom1=" + atom1, " atom2=" + atom2); return super.getBondNumber(atom1, atom2); } public int getBondNumber(IBond bond) { logger.debug("Getting bond number: ", bond); return super.getBondNumber(bond); } public int getLonePairNumber(ILonePair bond) { logger.debug("Getting lone pair number: ", bond); return super.getLonePairNumber(bond); } public int getSingleElectronNumber(ISingleElectron bond) { logger.debug("Getting single electron number: ", bond); return super.getSingleElectronNumber(bond); } public IElectronContainer getElectronContainer(int number) { logger.debug("Getting electron container at: ", number); return super.getElectronContainer(number); } public IBond getBond(IAtom atom1, IAtom atom2) { logger.debug("Getting bond for atoms: atom1=" + atom1, " atom2=" + atom2); return super.getBond(atom1, atom2); } public int getAtomCount() { logger.debug("Getting atom count"); return super.getAtomCount(); } public int getBondCount() { logger.debug("Getting bond count"); return super.getBondCount(); } public int getLonePairCount() { logger.debug("Getting lone pair count"); return super.getLonePairCount(); } public int getSingleElectronCount() { logger.debug("Getting single electron count"); return super.getSingleElectronCount(); } public int getElectronContainerCount() { logger.debug("Getting electron container count"); return super.getElectronContainerCount(); } // public IAtom[] getConnectedAtoms(IAtom atom) { // logger.debug("Getting connected atoms for atom: ", atom); // return super.getConnectedAtoms(atom); // } public List getConnectedAtomsList(IAtom atom) { logger.debug("Getting connecting atoms vector for atom: ", atom); return super.getConnectedAtomsList(atom); } // public IBond[] getConnectedBonds(IAtom atom) { // logger.debug("Getting connected bonds for atom: ", atom); // return super.getConnectedBonds(atom); // } public List getConnectedBondsList(IAtom atom) { logger.debug("Getting connected bonds vector for atom: ", atom); return super.getConnectedBondsList(atom); } public List getConnectedLonePairsList(IAtom atom) { logger.debug("Getting lone pairs at atom: atom=" + atom, " lone pairs=" + super.getConnectedLonePairsCount(atom)); return super.getConnectedLonePairsList(atom); } public List getConnectedSingleElectronsList(IAtom atom) { logger.debug("Getting single electrons at atom: atom=" + atom, " single electrons=" + super.getConnectedSingleElectronsCount(atom)); return super.getConnectedSingleElectronsList(atom); } public java.util.List getConnectedElectronContainersList(IAtom atom) { logger.debug("Getting connected electron containers for atom: ", atom); return super.getConnectedElectronContainersList(atom); } public int getConnectedAtomsCount(IAtom atom) { logger.debug("Getting connected atoms count for atom: ", atom); return super.getConnectedAtomsCount(atom); } public int getConnectedBondsCount(IAtom atom) { logger.debug("Getting connected bonds count for atom: ", atom); return super.getConnectedBondsCount(atom); } public int getConnectedLonePairsCount(IAtom atom) { logger.debug("Getting connected lone pairs count for atom: ", atom); return super.getConnectedLonePairsCount(atom); } public int getConnectedSingleElectronsCount(IAtom atom) { logger.debug("Getting connected single electrons count for atom: ", atom); return super.getConnectedSingleElectronsCount(atom); } public double getBondOrderSum(IAtom atom) { logger.debug("Getting bond order sum for atom: ", atom); return super.getBondOrderSum(atom); } public Order getMaximumBondOrder(IAtom atom) { logger.debug("Getting maximum bond order for atom: ", atom); return super.getMaximumBondOrder(atom); } public Order getMinimumBondOrder(IAtom atom) { logger.debug("Getting minimum bond order for atom: ", atom); return super.getMinimumBondOrder(atom); } // public void addElectronContainers(IAtomContainer atomContainer) { // logger.debug("Adding electron containers from atom container: ", atomContainer); // super.addElectronContainers(atomContainer); // } public void add(IAtomContainer atomContainer) { logger.debug("Adding atom container: ", atomContainer); super.add(atomContainer); } public void addAtom(IAtom atom) { logger.debug("Adding atom: ", atom); super.addAtom(atom); } public void addBond(IBond bond) { logger.debug("Adding bond: ", bond); super.addBond(bond); } public void addLonePair(ILonePair ec) { logger.debug("Adding lone pair: ", ec); super.addLonePair(ec); } public void addSingleElectron(ISingleElectron ec) { logger.debug("Adding single electron: ", ec); super.addSingleElectron(ec); } public void addElectronContainer(IElectronContainer electronContainer) { logger.debug("Adding electron container: ", electronContainer); super.addElectronContainer(electronContainer); } public void remove(IAtomContainer atomContainer) { logger.debug("Removing atom container: ", atomContainer); super.remove(atomContainer); } public IElectronContainer removeElectronContainer(int position) { logger.debug("Removing electronContainer: ", position); return super.removeElectronContainer(position); } public void removeElectronContainer(IElectronContainer electronContainer) { logger.debug("Removing electron container: ", electronContainer); super.removeElectronContainer(electronContainer); } public void removeAtom(int position) { logger.debug("Removing atom: ", position); super.removeAtom(position); } public void removeAtom(IAtom atom) { logger.debug("Removing atom: ", atom); super.removeAtom(atom); } public IBond removeBond(int pos) { logger.debug("Removing bond at " + pos); return super.removeBond(pos); } public IBond removeBond(IAtom atom1, IAtom atom2) { logger.debug("Removing bond: atom1=" + atom1 + " atom2=" + atom2); return super.removeBond(atom1, atom2); } public void removeBond(IBond bond) { logger.debug("Removing bond=" + bond); super.removeBond(bond); } public ILonePair removeLonePair(int pos) { logger.debug("Removing bond at " + pos); return super.removeLonePair(pos); } public void removeLonePair(ILonePair ec) { logger.debug("Removing bond=" + ec); super.removeLonePair(ec); } public ISingleElectron removeSingleElectron(int pos) { logger.debug("Removing bond at " + pos); return super.removeSingleElectron(pos); } public void removeSingleElectron(ISingleElectron ec) { logger.debug("Removing bond=" + ec); super.removeSingleElectron(ec); } public void removeAtomAndConnectedElectronContainers(IAtom atom) { logger.debug("Removing atom and connected electron containers: ", atom); super.removeAtomAndConnectedElectronContainers(atom); } public void removeAllElements() { logger.debug("Removing all elements"); super.removeAllElements(); } public void removeAllElectronContainers() { logger.debug("Removing all electron containers"); super.removeAllElectronContainers(); } public void removeAllBonds() { logger.debug("Removing all bonds"); super.removeAllBonds(); } public void addBond(int atom1, int atom2, IBond.Order order, int stereo) { logger.debug("Adding bond: atom1=" + atom1 + " atom2=" + atom2, " order=" + order + " stereo=" + stereo); super.addBond(atom1, atom2, order, stereo); } public void addBond(int atom1, int atom2, IBond.Order order) { logger.debug("Adding bond: atom1=" + atom1 + " atom2=" + atom2, " order=" + order); super.addBond(atom1, atom2, order); } public void addLonePair(int atomID) { logger.debug("Adding lone pair: ", atomID); super.addLonePair(atomID); } public void addSingleElectron(int atomID) { logger.debug("Adding single electron: ", atomID); super.addSingleElectron(atomID); } public boolean contains(IAtom atom) { logger.debug("Contains atom: ", atom); return super.contains(atom); } public boolean contains(IBond bond) { logger.debug("Contains bond: ", bond); return super.contains(bond); } public boolean contains(ILonePair ec) { logger.debug("Contains lone pair: ", ec); return super.contains(ec); } public boolean contains(ISingleElectron ec) { logger.debug("Contains single electron: ", ec); return super.contains(ec); } public boolean contains(IElectronContainer electronContainer) { logger.debug("Contains electron container: ", electronContainer); return super.contains(electronContainer); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public void setA(Vector3d newAxis) { logger.debug("Setting A axis to: ", newAxis); super.setA(newAxis); } public Vector3d getA() { logger.debug("Getting A axis: ", super.getA()); return super.getA(); } public void setB(Vector3d newAxis) { logger.debug("Setting B axis to: ", newAxis); super.setB(newAxis); } public Vector3d getB() { logger.debug("Getting B axis: ", super.getB()); return super.getB(); } public void setC(Vector3d newAxis) { logger.debug("Setting C axis to: ", newAxis); super.setC(newAxis); } public Vector3d getC() { logger.debug("Getting C axis: ", super.getC()); return super.getC(); } public String getSpaceGroup() { logger.debug("Getting space group: ", super.getSpaceGroup()); return super.getSpaceGroup(); } public void setSpaceGroup(String group) { logger.debug("Setting space group to: ", group); super.setSpaceGroup(group); } public Integer getZ() { logger.debug("Getting Z: ", super.getZ()); return super.getZ(); } public void setZ(Integer value) { logger.debug("Settting Z to: ", value); super.setZ(value); } public void stateChanged(IChemObjectChangeEvent event) { logger.debug("Receiving state changed: ", event); super.stateChanged(event); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugElectronContainer.java100644 0 0 10716 11570154753 23374 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Map; import org.openscience.cdk.ElectronContainer; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IElectronContainer; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugElectronContainer extends ElectronContainer implements IElectronContainer{ private static final long serialVersionUID = 5309193617982266230L; LoggingTool logger = new LoggingTool(DebugElectronContainer.class); public Integer getElectronCount() { logger.debug("Getting electron count: ", super.getElectronCount()); return super.getElectronCount(); } public void setElectronCount(Integer electronCount) { logger.debug("Setting electron count: ", electronCount); super.setElectronCount(electronCount); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugElement.java100644 0 0 12207 11570154753 21344 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Map; import org.openscience.cdk.Element; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IElement; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugElement extends Element implements IElement { private static final long serialVersionUID = -8520499563841667066L; LoggingTool logger = new LoggingTool(DebugElement.class); public DebugElement() { super(); logger.debug("Instantiated a DebugElement"); } public DebugElement(String symbol) { super(symbol); logger.debug("Instantiated a DebugElement: symbol= ", symbol); } public DebugElement(String symbol, int atomicNumber) { super(symbol, atomicNumber); logger.debug("Instantiated a DebugElement: symbol= ", symbol + " atomic number= " + atomicNumber); } public DebugElement(IElement element) { super(element); logger.debug("Instantiated a DebugElement: element= ", element); } public Integer getAtomicNumber() { logger.debug("Getting atomic number: ", super.getAtomicNumber()); return super.getAtomicNumber(); } public void setAtomicNumber(Integer atomicNumber) { logger.debug("Setting atomic number: ", atomicNumber); super.setAtomicNumber(atomicNumber); } public String getSymbol() { logger.debug("Getting symbol: ", super.getSymbol()); return super.getSymbol(); } public void setSymbol(String symbol) { logger.debug("Setting symbol: ", symbol); super.setSymbol(symbol); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugFragmentAtom.java100644 0 0 26367 11570154753 22353 0ustar 0 0 /* $Revision$ $Author$$Date$ * * Copyright (C) 2006-2008 Egon Willighagen * * 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 org.openscience.cdk.debug; import java.util.Map; import javax.vecmath.Point2d; import javax.vecmath.Point3d; import org.openscience.cdk.FragmentAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.tools.LoggingTool; /** * Class to represent an IPseudoAtom which embeds an IAtomContainer. Very much * like the MDL molfile Group concept. * * @cdk.module datadebug * @cdk.githash * * @author egonw */ public class DebugFragmentAtom extends FragmentAtom { private static final long serialVersionUID = 0L; LoggingTool logger = new LoggingTool(DebugFragmentAtom.class); public DebugFragmentAtom() { super(); logger.debug("Instantiated a DebugFragmentAtom"); } public boolean isExpanded() { logger.debug("Getting isExpanded state..."); return super.isExpanded(); } public void setExpanded(boolean bool) { logger.debug("Setting the isExpanded state: " + bool); super.setExpanded(bool); } public IAtomContainer getFragment() { logger.debug("Getting the fragment..."); return super.getFragment(); } public void setFragment(IAtomContainer fragment) { logger.debug("Setting the fragment: ", fragment); super.setFragment(fragment); } public void setCharge(Double charge) { logger.debug("Setting charge: ", charge); super.setCharge(charge); } public Double getCharge() { logger.debug("Setting charge: ", super.getCharge()); return super.getCharge(); } public void setHydrogenCount(Integer hydrogenCount) { logger.debug("Setting hydrogen count: ", hydrogenCount); super.setHydrogenCount(hydrogenCount); } public Integer getHydrogenCount() { logger.debug("Getting hydrogen count: ", super.getHydrogenCount()); return super.getHydrogenCount(); } public void setPoint2d(Point2d point2d) { logger.debug("Setting point2d: x=" + point2d.x + ", y=" + point2d.y); super.setPoint2d(point2d); } public void setPoint3d(Point3d point3d) { logger.debug("Setting point3d: x=" + point3d.x + ", y=" + point3d.y, ", z=" + point3d.z); super.setPoint3d(point3d); } public void setFractionalPoint3d(Point3d point3d) { logger.debug("Setting fractional point3d: x=" + point3d.x + ", y=" + point3d.y, ", z=" + point3d.z); super.setFractionalPoint3d(point3d); } public void setStereoParity(Integer stereoParity) { logger.debug("Setting stereoParity: ", stereoParity); super.setStereoParity(stereoParity); } public Point2d getPoint2d() { Point2d point2d = super.getPoint2d(); if (point2d == null) { logger.debug("Getting point2d: null"); } else { logger.debug("Getting point2d: x=" + point2d.x + ", y=" + point2d.y); } return point2d; } public Point3d getPoint3d() { Point3d point3d = super.getPoint3d(); if (point3d == null) { logger.debug("Getting point3d: null"); } else { logger.debug("Getting point3d: x=" + point3d.x + ", y=" + point3d.y, ", z=" + point3d.z); } return point3d; } public Point3d getFractionalPoint3d() { Point3d point3d = super.getFractionalPoint3d(); if (point3d == null) { logger.debug("Getting fractional point3d: null"); } else { logger.debug("Getting fractional point3d: x=" + point3d.x + ", y=" + point3d.y, ", z=" + point3d.z); } return point3d; } public Integer getStereoParity() { logger.debug("Getting stereo parity: ", super.getStereoParity()); return super.getStereoParity(); } public void setAtomTypeName(String identifier) { logger.debug("Setting atom type name: ", identifier); super.setAtomTypeName(identifier); } public void setMaxBondOrder(IBond.Order maxBondOrder) { logger.debug("Setting max bond order: ", maxBondOrder); super.setMaxBondOrder(maxBondOrder); } public void setBondOrderSum(Double bondOrderSum) { logger.debug("Setting bond order sum: ", bondOrderSum); super.setBondOrderSum(bondOrderSum); } public String getAtomTypeName() { logger.debug("Getting atom type name: ", super.getAtomTypeName()); return super.getAtomTypeName(); } public IBond.Order getMaxBondOrder() { logger.debug("Getting max bond order: ", super.getMaxBondOrder()); return super.getMaxBondOrder(); } public Double getBondOrderSum() { logger.debug("Getting bond order sum: ", super.getBondOrderSum()); return super.getBondOrderSum(); } public void setFormalCharge(Integer charge) { logger.debug("Setting formal charge: ", charge); super.setFormalCharge(charge); } public Integer getFormalCharge() { logger.debug("Getting formal charge: ", super.getFormalCharge()); return super.getFormalCharge(); } public void setFormalNeighbourCount(Integer count) { logger.debug("Setting forml neighbour count: ", count); super.setFormalNeighbourCount(count); } public Integer getFormalNeighbourCount() { logger.debug("Getting formal neighbour count: ", super.getFormalNeighbourCount()); return super.getFormalNeighbourCount(); } public void setHybridization(IAtomType.Hybridization hybridization) { logger.debug("Setting hybridization: ", hybridization); super.setHybridization(hybridization); } public IAtomType.Hybridization getHybridization() { logger.debug("Getting hybridization: ", super.getHybridization()); return super.getHybridization(); } public void setCovalentRadius(Double radius) { logger.debug("Setting covalent radius: ", radius); super.setCovalentRadius(radius); } public Double getCovalentRadius() { logger.debug("Getting covalent radius: ", super.getCovalentRadius()); return super.getCovalentRadius(); } public void setValency(Integer valency) { logger.debug("Setting valency: ", valency); super.setValency(valency); } public Integer getValency() { logger.debug("Getting valency: ", super.getValency()); return super.getValency(); } public void setNaturalAbundance(Double naturalAbundance) { logger.debug("Setting natural abundance: ", naturalAbundance); super.setNaturalAbundance(naturalAbundance); } public void setExactMass(Double exactMass) { logger.debug("Setting exact mass: ", exactMass); super.setExactMass(exactMass); } public Double getNaturalAbundance() { logger.debug("Getting natural abundance: ", super.getNaturalAbundance()); return super.getNaturalAbundance(); } public Double getExactMass() { logger.debug("Getting exact mass: ", super.getExactMass()); return super.getExactMass(); } public Integer getMassNumber() { logger.debug("Getting mass number: ", super.getMassNumber()); return super.getMassNumber(); } public void setMassNumber(Integer massNumber) { logger.debug("Setting mass number: ", massNumber); super.setMassNumber(massNumber); } public Integer getAtomicNumber() { logger.debug("Getting atomic number: ", super.getAtomicNumber()); return super.getAtomicNumber(); } public void setAtomicNumber(Integer atomicNumber) { logger.debug("Setting atomic number: ", atomicNumber); super.setAtomicNumber(atomicNumber); } public String getSymbol() { logger.debug("Getting symbol: ", super.getSymbol()); return super.getSymbol(); } public void setSymbol(String symbol) { logger.debug("Setting symbol: ", symbol); super.setSymbol(symbol); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public String getLabel() { logger.debug("Getting label: ", super.getLabel()); return super.getLabel(); } public void setLabel(String label) { logger.debug("Setting label: ", label); super.setLabel(label); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugIsotope.java100644 0 0 14550 11570154753 21400 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Map; import org.openscience.cdk.Isotope; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IElement; import org.openscience.cdk.interfaces.IIsotope; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugIsotope extends Isotope implements IIsotope { private static final long serialVersionUID = -2659188100080921299L; LoggingTool logger = new LoggingTool(DebugIsotope.class); public DebugIsotope(String elementSymbol) { super(elementSymbol); logger.debug("Instantiated a DebugIsotope."); } public DebugIsotope(int atomicNumber, String elementSymbol, int massNumber, double exactMass, double abundance) { super(atomicNumber, elementSymbol, massNumber, exactMass, abundance); logger.debug("Instantiated a DebugIsotope."); } public DebugIsotope(int atomicNumber, String elementSymbol, double exactMass, double abundance) { super(atomicNumber, elementSymbol, exactMass, abundance); logger.debug("Instantiated a DebugIsotope."); } public DebugIsotope(String elementSymbol, int massNumber) { super(elementSymbol, massNumber); logger.debug("Instantiated a DebugIsotope."); } public DebugIsotope(IElement element) { super(element); logger.debug("Instantiated a DebugIsotope from element: ", element); } public Integer getAtomicNumber() { logger.debug("Getting atomic number: ", super.getAtomicNumber()); return super.getAtomicNumber(); } public void setAtomicNumber(Integer atomicNumber) { logger.debug("Setting atomic number: ", atomicNumber); super.setAtomicNumber(atomicNumber); } public String getSymbol() { logger.debug("Getting symbol: ", super.getSymbol()); return super.getSymbol(); } public void setSymbol(String symbol) { logger.debug("Setting symbol: ", symbol); super.setSymbol(symbol); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public void setNaturalAbundance(Double naturalAbundance) { logger.debug("Setting natural abundance: ", naturalAbundance); super.setNaturalAbundance(naturalAbundance); } public void setExactMass(Double exactMass) { logger.debug("Setting exact mass: ", exactMass); super.setExactMass(exactMass); } public Double getNaturalAbundance() { logger.debug("Getting natural abundance: ", super.getNaturalAbundance()); return super.getNaturalAbundance(); } public Double getExactMass() { logger.debug("Getting exact mass: ", super.getExactMass()); return super.getExactMass(); } public Integer getMassNumber() { logger.debug("Getting mass number: ", super.getMassNumber()); return super.getMassNumber(); } public void setMassNumber(Integer massNumber) { logger.debug("Setting mass number: ", massNumber); super.setMassNumber(massNumber); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugLonePair.java100644 0 0 11761 11570154753 21470 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Map; import org.openscience.cdk.LonePair; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.ILonePair; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugLonePair extends LonePair implements ILonePair { private static final long serialVersionUID = 5683399496728893341L; LoggingTool logger = new LoggingTool(DebugLonePair.class); public DebugLonePair() { super(); logger.debug("Instantiated an empty LonePair"); } public DebugLonePair(IAtom atom) { super(atom); logger.debug("Instantiated LonePair for atom: ", atom); } public IAtom getAtom() { logger.debug("Getting atom: ", super.getAtom()); return super.getAtom(); } public void setAtom(IAtom atom) { logger.debug("Setting atom: ", atom); super.setAtom(atom); } public boolean contains(IAtom atom) { logger.debug("Contains atom: ", atom); return super.contains(atom); } public Integer getElectronCount() { logger.debug("Getting electron count: ", super.getElectronCount()); return super.getElectronCount(); } public void setElectronCount(Integer electronCount) { logger.debug("Setting electron count: ", electronCount); super.setElectronCount(electronCount); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugMapping.java100644 0 0 11103 11570154753 21340 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Map; import org.openscience.cdk.Mapping; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IMapping; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugMapping extends Mapping implements IMapping { private static final long serialVersionUID = -3785399530153469835L; LoggingTool logger; public DebugMapping(IChemObject objectOne, IChemObject objectTwo) { super(objectOne, objectTwo); logger = new LoggingTool(DebugMapping.class); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugMapping: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public IChemObject getChemObject(int pos) { logger.debug("Getting related ChemObject:", pos); return super.getChemObject(pos); } public Iterable relatedChemObjects() { logger.debug("Getting related ChemObjects"); return super.relatedChemObjects(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugMolecularFormula.java100644 0 0 7366 11570154753 23216 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2008 Egon Willighagen * * 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. * * 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.debug; import java.util.Map; import org.openscience.cdk.formula.MolecularFormula; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IIsotope; import org.openscience.cdk.interfaces.IMolecularFormula; import org.openscience.cdk.tools.LoggingTool; /** * @cdk.module datadebug */ public class DebugMolecularFormula extends MolecularFormula implements IMolecularFormula { private LoggingTool logger = new LoggingTool(DebugMolecularFormula.class); public IMolecularFormula add(IMolecularFormula formula) { logger.debug("Adding formula: ", formula); return super.add(formula); } public IMolecularFormula addIsotope(IIsotope isotope) { logger.debug("Adding isotope: ", isotope); return super.addIsotope(isotope); } public IMolecularFormula addIsotope(IIsotope isotope, int count) { logger.debug("Adding 'count' isotopes: ", isotope); return super.addIsotope(isotope, count); } public boolean contains(IIsotope isotope) { logger.debug("Contains isotope?: ", isotope); return super.contains(isotope); } public Integer getCharge() { Integer charge = super.getCharge(); logger.debug("Getting charge: ", charge); return charge; } public int getIsotopeCount(IIsotope isotope) { logger.debug("Getting isotope count for: ", isotope); return super.getIsotopeCount(); } public int getIsotopeCount() { logger.debug("Getting isotope count: ", super.getIsotopeCount()); return super.getIsotopeCount(); } public Map getProperties() { logger.debug("Getting properties..."); return super.getProperties(); } public Object getProperty(Object description) { logger.debug("Getting property: " + description); return super.getProperty(description); } public Iterable isotopes() { logger.debug("Getting isotope iterator.."); return super.isotopes(); } public void removeAllIsotopes() { logger.debug("Removing all isotopes..."); super.removeAllIsotopes(); } public void removeIsotope(IIsotope isotope) { logger.debug("Removing this isotope: ", isotope); } public void removeProperty(Object description) { logger.debug("Removing property: " + description); super.removeProperty(description); } public void setCharge(Integer charge) { logger.debug("Setting the charge to: ", charge); super.setCharge(charge); } public void setProperties(Map properties) { logger.debug("Setting new properties..."); super.setProperties(properties); } public void setProperty(Object description, Object property) { logger.debug("Setting new property: " + description + " -> " + property); super.setProperty(description, property); } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugMolecularFormulaSet.java100644 0 0 6233 11570154753 23662 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2008 Egon Willighagen * * 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. * * 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.debug; import java.util.Iterator; import org.openscience.cdk.formula.MolecularFormulaSet; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IMolecularFormula; import org.openscience.cdk.interfaces.IMolecularFormulaSet; import org.openscience.cdk.tools.LoggingTool; /** * @cdk.module datadebug */ public class DebugMolecularFormulaSet extends MolecularFormulaSet implements IMolecularFormulaSet { private LoggingTool logger = new LoggingTool(DebugMolecularFormulaSet.class); public DebugMolecularFormulaSet() { super(); } public DebugMolecularFormulaSet(IMolecularFormula formula) { super(formula); } public void add(IMolecularFormulaSet formulaSet) { logger.debug("Adding formula set: ", formulaSet); super.add(formulaSet); } public void addMolecularFormula(IMolecularFormula formula) { logger.debug("Adding formula: ", formula); super.addMolecularFormula(formula); } public boolean contains(IMolecularFormula formula) { logger.debug("Contains formula?: ", formula); return super.contains(formula); } public IMolecularFormula getMolecularFormula(int position) { logger.debug("Getting formula at: ", position); return super.getMolecularFormula(position); } public Iterator iterator() { logger.debug("Getting molecular formula iterator..."); return super.iterator(); } public Iterable molecularFormulas() { logger.debug("Getting molecular formula iterable..."); return super.molecularFormulas(); } public void removeAllMolecularFormulas() { logger.debug("Removing all formulas..."); super.removeAllMolecularFormulas(); } public void removeMolecularFormula(IMolecularFormula formula) { logger.debug("Removing this formula: ", formula); super.removeMolecularFormula(formula); } public void removeMolecularFormula(int position) { logger.debug("Removing the formula at position: ", position); super.removeMolecularFormula(position); } public int size() { logger.debug("Getting the size of this adduct: " + super.size()); return super.size(); } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugMolecule.java100644 0 0 40122 11570154753 21515 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.List; import java.util.Map; import org.openscience.cdk.Molecule; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomParity; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IElectronContainer; import org.openscience.cdk.interfaces.ILonePair; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.ISingleElectron; import org.openscience.cdk.interfaces.IBond.Order; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugMolecule extends Molecule implements IMolecule { private static final long serialVersionUID = -7263404200270132412L; LoggingTool logger = new LoggingTool(DebugMolecule.class); public DebugMolecule() { super(); } public DebugMolecule(int atomCount, int electronContainerCount, int lonePairCount, int singleElectronCount) { super(atomCount, electronContainerCount, lonePairCount, singleElectronCount); } public DebugMolecule(IAtomContainer container) { super(container); } public void addAtomParity(IAtomParity parity) { logger.debug("Adding atom parity: ", parity); super.addAtomParity(parity); } public IAtomParity getAtomParity(IAtom atom) { logger.debug("Getting atom parity: ", atom); return super.getAtomParity(atom); } public void setAtoms(IAtom[] atoms) { logger.debug("Setting atoms: ", atoms.length); super.setAtoms(atoms); } // public void setElectronContainers(IElectronContainer[] electronContainers) { // logger.debug("Setting electron containers: ", electronContainers.length); // super.setElectronContainers(electronContainers); // } public void setAtom(int number, IAtom atom) { logger.debug("Setting atom at: pos=" + number, " atom=" + atom); super.setAtom(number, atom); } public IAtom getAtom(int number) { logger.debug("Getting atom at: ", number); return super.getAtom(number); } public IBond getBond(int number) { logger.debug("Getting bond at: ", number); return super.getBond(number); } public ILonePair getLonePair(int number) { logger.debug("Getting lone pair at: ", number); return super.getLonePair(number); } public ISingleElectron getSingleElectron(int number) { logger.debug("Getting single electron at: ", number); return super.getSingleElectron(number); } // public void setElectronContainer(int number, IElectronContainer electronContainer) { // logger.debug("Setting electron container at: pos=" + number, " electron container=" +electronContainer); // super.setElectronContainer(number, electronContainer); // } // public void setElectronContainerCount(int electronContainerCount) { // logger.debug("Setting electron container count: ", electronContainerCount); // super.setElectronContainerCount(electronContainerCount); // } // public void setAtomCount(int atomCount) { // logger.debug("Settting atom count: ", atomCount); // super.setAtomCount(atomCount); // } public Iterable atoms() { logger.debug("Getting atoms iterator"); return super.atoms(); } public Iterable bonds() { logger.debug("Getting bonds iterator"); return super.bonds(); } public Iterable lonePairs() { logger.debug("Getting lone pairs iterator"); return super.lonePairs(); } public Iterable singleElectrons() { logger.debug("Getting single electrons iterator"); return super.singleElectrons(); } public Iterable electronContainers() { logger.debug("Getting electron containers iterator"); return super.electronContainers(); } public IAtom getFirstAtom() { logger.debug("Getting first atom: ", super.getFirstAtom()); return super.getFirstAtom(); } public IAtom getLastAtom() { logger.debug("Getting last atom: ", super.getLastAtom()); return super.getLastAtom(); } public int getAtomNumber(IAtom atom) { logger.debug("Getting atom number: ", atom); return super.getAtomNumber(atom); } public int getBondNumber(IAtom atom1, IAtom atom2) { logger.debug("Getting bond number: atom1=" + atom1, " atom2=" + atom2); return super.getBondNumber(atom1, atom2); } public int getBondNumber(IBond bond) { logger.debug("Getting bond number: ", bond); return super.getBondNumber(bond); } public int getLonePairNumber(ILonePair bond) { logger.debug("Getting lone pair number: ", bond); return super.getLonePairNumber(bond); } public int getSingleElectronNumber(ISingleElectron bond) { logger.debug("Getting single electron number: ", bond); return super.getSingleElectronNumber(bond); } public IElectronContainer getElectronContainer(int number) { logger.debug("Getting electron container at: ", number); return super.getElectronContainer(number); } public IBond getBond(IAtom atom1, IAtom atom2) { logger.debug("Getting bond for atoms: atom1=" + atom1, " atom2=" + atom2); return super.getBond(atom1, atom2); } public int getAtomCount() { logger.debug("Getting atom count"); return super.getAtomCount(); } public int getBondCount() { logger.debug("Getting bond count"); return super.getBondCount(); } public int getLonePairCount() { logger.debug("Getting lone pair count"); return super.getLonePairCount(); } public int getSingleElectronCount() { logger.debug("Getting single electron count"); return super.getSingleElectronCount(); } public int getElectronContainerCount() { logger.debug("Getting electron container count"); return super.getElectronContainerCount(); } // public IAtom[] getConnectedAtoms(IAtom atom) { // logger.debug("Getting connected atoms for atom: ", atom); // return super.getConnectedAtoms(atom); // } public List getConnectedAtomsList(IAtom atom) { logger.debug("Getting connecting atoms vector for atom: ", atom); return super.getConnectedAtomsList(atom); } // public IBond[] getConnectedBonds(IAtom atom) { // logger.debug("Getting connected bonds for atom: ", atom); // return super.getConnectedBonds(atom); // } public List getConnectedBondsList(IAtom atom) { logger.debug("Getting connected bonds vector for atom: ", atom); return super.getConnectedBondsList(atom); } public List getConnectedLonePairsList(IAtom atom) { logger.debug("Getting lone pairs at atom: atom=" + atom, " lone pairs=" + super.getConnectedLonePairsCount(atom)); return super.getConnectedLonePairsList(atom); } public List getConnectedSingleElectronsList(IAtom atom) { logger.debug("Getting single electrons at atom: atom=" + atom, " single electrons=" + super.getConnectedSingleElectronsCount(atom)); return super.getConnectedSingleElectronsList(atom); } public java.util.List getConnectedElectronContainersList(IAtom atom) { logger.debug("Getting connected electron containers for atom: ", atom); return super.getConnectedElectronContainersList(atom); } public int getConnectedAtomsCount(IAtom atom) { logger.debug("Getting connected atoms count for atom: ", atom); return super.getConnectedAtomsCount(atom); } public int getConnectedBondsCount(IAtom atom) { logger.debug("Getting connected bonds count for atom: ", atom); return super.getConnectedBondsCount(atom); } public int getConnectedLonePairsCount(IAtom atom) { logger.debug("Getting connected lone pairs count for atom: ", atom); return super.getConnectedLonePairsCount(atom); } public int getConnectedSingleElectronsCount(IAtom atom) { logger.debug("Getting connected single electrons count for atom: ", atom); return super.getConnectedSingleElectronsCount(atom); } public double getBondOrderSum(IAtom atom) { logger.debug("Getting bond order sum for atom: ", atom); return super.getBondOrderSum(atom); } public Order getMaximumBondOrder(IAtom atom) { logger.debug("Getting maximum bond order for atom: ", atom); return super.getMaximumBondOrder(atom); } public Order getMinimumBondOrder(IAtom atom) { logger.debug("Getting minimum bond order for atom: ", atom); return super.getMinimumBondOrder(atom); } // public void addElectronContainers(IAtomContainer atomContainer) { // logger.debug("Adding electron containers from atom container: ", atomContainer); // super.addElectronContainers(atomContainer); // } public void add(IAtomContainer atomContainer) { logger.debug("Adding atom container: ", atomContainer); super.add(atomContainer); } public void addAtom(IAtom atom) { logger.debug("Adding atom: ", atom); super.addAtom(atom); } public void addBond(IBond bond) { logger.debug("Adding bond: ", bond); super.addBond(bond); } public void addLonePair(ILonePair ec) { logger.debug("Adding lone pair: ", ec); super.addLonePair(ec); } public void addSingleElectron(ISingleElectron ec) { logger.debug("Adding single electron: ", ec); super.addSingleElectron(ec); } public void addElectronContainer(IElectronContainer electronContainer) { logger.debug("Adding electron container: ", electronContainer); super.addElectronContainer(electronContainer); } public void remove(IAtomContainer atomContainer) { logger.debug("Removing atom container: ", atomContainer); super.remove(atomContainer); } public IElectronContainer removeElectronContainer(int position) { logger.debug("Removing electronContainer: ", position); return super.removeElectronContainer(position); } public void removeElectronContainer(IElectronContainer electronContainer) { logger.debug("Removing electron container: ", electronContainer); super.removeElectronContainer(electronContainer); } public void removeAtom(int position) { logger.debug("Removing atom: ", position); super.removeAtom(position); } public void removeAtom(IAtom atom) { logger.debug("Removing atom: ", atom); super.removeAtom(atom); } public IBond removeBond(int pos) { logger.debug("Removing bond at " + pos); return super.removeBond(pos); } public IBond removeBond(IAtom atom1, IAtom atom2) { logger.debug("Removing bond: atom1=" + atom1 + " atom2=" + atom2); return super.removeBond(atom1, atom2); } public void removeBond(IBond bond) { logger.debug("Removing bond=" + bond); super.removeBond(bond); } public ILonePair removeLonePair(int pos) { logger.debug("Removing bond at " + pos); return super.removeLonePair(pos); } public void removeLonePair(ILonePair ec) { logger.debug("Removing bond=" + ec); super.removeLonePair(ec); } public ISingleElectron removeSingleElectron(int pos) { logger.debug("Removing bond at " + pos); return super.removeSingleElectron(pos); } public void removeSingleElectron(ISingleElectron ec) { logger.debug("Removing bond=" + ec); super.removeSingleElectron(ec); } public void removeAtomAndConnectedElectronContainers(IAtom atom) { logger.debug("Removing atom and connected electron containers: ", atom); super.removeAtomAndConnectedElectronContainers(atom); } public void removeAllElements() { logger.debug("Removing all elements"); super.removeAllElements(); } public void removeAllElectronContainers() { logger.debug("Removing all electron containers"); super.removeAllElectronContainers(); } public void removeAllBonds() { logger.debug("Removing all bonds"); super.removeAllBonds(); } public void addBond(int atom1, int atom2, IBond.Order order, int stereo) { logger.debug("Adding bond: atom1=" + atom1 + " atom2=" + atom2, " order=" + order + " stereo=" + stereo); super.addBond(atom1, atom2, order, stereo); } public void addBond(int atom1, int atom2, IBond.Order order) { logger.debug("Adding bond: atom1=" + atom1 + " atom2=" + atom2, " order=" + order); super.addBond(atom1, atom2, order); } public void addLonePair(int atomID) { logger.debug("Adding lone pair: ", atomID); super.addLonePair(atomID); } public void addSingleElectron(int atomID) { logger.debug("Adding single electron: ", atomID); super.addSingleElectron(atomID); } public boolean contains(IAtom atom) { logger.debug("Contains atom: ", atom); return super.contains(atom); } public boolean contains(IBond bond) { logger.debug("Contains bond: ", bond); return super.contains(bond); } public boolean contains(ILonePair ec) { logger.debug("Contains lone pair: ", ec); return super.contains(ec); } public boolean contains(ISingleElectron ec) { logger.debug("Contains single electron: ", ec); return super.contains(ec); } public boolean contains(IElectronContainer electronContainer) { logger.debug("Contains electron container: ", electronContainer); return super.contains(electronContainer); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugMoleculeSet.java100644 0 0 17322 11570154753 22177 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Map; import org.openscience.cdk.MoleculeSet; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomContainerSet; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugMoleculeSet extends MoleculeSet implements IMoleculeSet { private static final long serialVersionUID = -2925577323304207688L; LoggingTool logger = new LoggingTool(DebugMoleculeSet.class); public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public void addAtomContainer(IAtomContainer atomContainer) { logger.debug("Adding atom container: ", atomContainer); super.addAtomContainer(atomContainer); } public void removeAtomContainer(IAtomContainer atomContainer) { logger.debug("Removing atom container: ", atomContainer); super.removeAtomContainer(atomContainer); } public void removeAllAtomContainers() { logger.debug("Removing all atom containers"); super.removeAllAtomContainers(); } public void removeAtomContainer(int pos) { logger.debug("Removing atom container at pos: ", pos); super.removeAtomContainer(pos); } public void replaceAtomContainer(int position, IAtomContainer container) { logger.debug("Replacing atom container at pos: ", position); super.replaceAtomContainer(position, container); } public boolean setMultiplier(IAtomContainer container, Double multiplier) { logger.debug("Setting multiplier for atomcontainer: ", container, ""+multiplier); return super.setMultiplier(container, multiplier); } public void setMultiplier(int position, Double multiplier) { logger.debug("Setting multiplier for atomcontainer at pos: ", ""+position, ""+multiplier); super.setMultiplier(position, multiplier); } public Double[] getMultipliers() { logger.debug("Getting multipliers array: ", super.getMultipliers().length); return super.getMultipliers(); } public boolean setMultipliers(Double[] newMultipliers) { logger.debug("Setting mulipliers array: ", newMultipliers.length); return super.setMultipliers(newMultipliers); } public void addAtomContainer(IAtomContainer atomContainer, double multiplier) { logger.debug("Adding atom container with multiplier: ", ""+multiplier, atomContainer); super.addAtomContainer(atomContainer, multiplier); } public void add(IAtomContainerSet atomContainerSet) { logger.debug("Adding set of atom containers: ", atomContainerSet); super.add(atomContainerSet); } public Iterable atomContainers() { logger.debug("Getting atom container iterator"); return super.atomContainers(); } public IAtomContainer getAtomContainer(int number) { logger.debug("Getting atom container at: ", number); return super.getAtomContainer(number); } public Double getMultiplier(int number) { logger.debug("Getting multiplier at: ", number); return super.getMultiplier(number); } public Double getMultiplier(IAtomContainer container) { logger.debug("Getting multiplier for atom container: ", container); return super.getMultiplier(container); } public int getAtomContainerCount() { logger.debug("Getting atom container count: ", super.getAtomContainerCount()); return super.getAtomContainerCount(); } public void addMolecule(IMolecule molecule) { logger.debug("Adding molecule: ", molecule); super.addMolecule(molecule); } public void add(IMoleculeSet moleculeSet) { logger.debug("Adding set of molecules: ", moleculeSet); super.add(moleculeSet); } public void setMolecules(IMolecule[] molecules) { logger.debug("Setting molecule array: ", molecules.length); super.setMolecules(molecules); } public Iterable molecules() { logger.debug("Getting molecule iterator"); return super.molecules(); } public IMolecule getMolecule(int number) { logger.debug("Getting molecule at: ", number); return super.getMolecule(number); } public int getMoleculeCount() { logger.debug("Getting molecule count: ", super.getMoleculeCount()); return super.getMoleculeCount(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugMonomer.java100644 0 0 40762 11570154753 21376 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.List; import java.util.Map; import org.openscience.cdk.Monomer; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomParity; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IElectronContainer; import org.openscience.cdk.interfaces.ILonePair; import org.openscience.cdk.interfaces.IMonomer; import org.openscience.cdk.interfaces.ISingleElectron; import org.openscience.cdk.interfaces.IBond.Order; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugMonomer extends Monomer implements IMonomer { private static final long serialVersionUID = -7312839949399572435L; LoggingTool logger = new LoggingTool(DebugAtomContainer.class); public void addAtomParity(IAtomParity parity) { logger.debug("Adding atom parity: ", parity); super.addAtomParity(parity); } public IAtomParity getAtomParity(IAtom atom) { logger.debug("Getting atom parity: ", atom); return super.getAtomParity(atom); } public void setAtoms(IAtom[] atoms) { logger.debug("Setting atoms: ", atoms.length); super.setAtoms(atoms); } // public void setElectronContainers(IElectronContainer[] electronContainers) { // logger.debug("Setting electron containers: ", electronContainers.length); // super.setElectronContainers(electronContainers); // } public void setAtom(int number, IAtom atom) { logger.debug("Setting atom at: pos=" + number, " atom=" + atom); super.setAtom(number, atom); } public IAtom getAtom(int number) { logger.debug("Getting atom at: ", number); return super.getAtom(number); } public IBond getBond(int number) { logger.debug("Getting bond at: ", number); return super.getBond(number); } public ILonePair getLonePair(int number) { logger.debug("Getting lone pair at: ", number); return super.getLonePair(number); } public ISingleElectron getSingleElectron(int number) { logger.debug("Getting single electron at: ", number); return super.getSingleElectron(number); } // public void setElectronContainer(int number, IElectronContainer electronContainer) { // logger.debug("Setting electron container at: pos=" + number, " electron container=" +electronContainer); // super.setElectronContainer(number, electronContainer); // } // public void setElectronContainerCount(int electronContainerCount) { // logger.debug("Setting electron container count: ", electronContainerCount); // super.setElectronContainerCount(electronContainerCount); // } // public void setAtomCount(int atomCount) { // logger.debug("Settting atom count: ", atomCount); // super.setAtomCount(atomCount); // } public Iterable atoms() { logger.debug("Getting atoms iterator"); return super.atoms(); } public Iterable bonds() { logger.debug("Getting bonds iterator"); return super.bonds(); } public Iterable lonePairs() { logger.debug("Getting lone pairs iterator"); return super.lonePairs(); } public Iterable singleElectrons() { logger.debug("Getting single electrons iterator"); return super.singleElectrons(); } public Iterable electronContainers() { logger.debug("Getting electron containers iterator"); return super.electronContainers(); } public IAtom getFirstAtom() { logger.debug("Getting first atom: ", super.getFirstAtom()); return super.getFirstAtom(); } public IAtom getLastAtom() { logger.debug("Getting last atom: ", super.getLastAtom()); return super.getLastAtom(); } public int getAtomNumber(IAtom atom) { logger.debug("Getting atom number: ", atom); return super.getAtomNumber(atom); } public int getBondNumber(IAtom atom1, IAtom atom2) { logger.debug("Getting bond number: atom1=" + atom1, " atom2=" + atom2); return super.getBondNumber(atom1, atom2); } public int getBondNumber(IBond bond) { logger.debug("Getting bond number: ", bond); return super.getBondNumber(bond); } public int getLonePairNumber(ILonePair bond) { logger.debug("Getting lone pair number: ", bond); return super.getLonePairNumber(bond); } public int getSingleElectronNumber(ISingleElectron bond) { logger.debug("Getting single electron number: ", bond); return super.getSingleElectronNumber(bond); } public IElectronContainer getElectronContainer(int number) { logger.debug("Getting electron container at: ", number); return super.getElectronContainer(number); } public IBond getBond(IAtom atom1, IAtom atom2) { logger.debug("Getting bond for atoms: atom1=" + atom1, " atom2=" + atom2); return super.getBond(atom1, atom2); } public int getAtomCount() { logger.debug("Getting atom count"); return super.getAtomCount(); } public int getBondCount() { logger.debug("Getting bond count"); return super.getBondCount(); } public int getLonePairCount() { logger.debug("Getting lone pair count"); return super.getLonePairCount(); } public int getSingleElectronCount() { logger.debug("Getting single electron count"); return super.getSingleElectronCount(); } public int getElectronContainerCount() { logger.debug("Getting electron container count"); return super.getElectronContainerCount(); } // public IAtom[] getConnectedAtoms(IAtom atom) { // logger.debug("Getting connected atoms for atom: ", atom); // return super.getConnectedAtoms(atom); // } public List getConnectedAtomsList(IAtom atom) { logger.debug("Getting connecting atoms vector for atom: ", atom); return super.getConnectedAtomsList(atom); } // public IBond[] getConnectedBonds(IAtom atom) { // logger.debug("Getting connected bonds for atom: ", atom); // return super.getConnectedBonds(atom); // } public List getConnectedBondsList(IAtom atom) { logger.debug("Getting connected bonds vector for atom: ", atom); return super.getConnectedBondsList(atom); } public List getConnectedLonePairsList(IAtom atom) { logger.debug("Getting lone pairs at atom: atom=" + atom, " lone pairs=" + super.getConnectedLonePairsCount(atom)); return super.getConnectedLonePairsList(atom); } public List getConnectedSingleElectronsList(IAtom atom) { logger.debug("Getting single electrons at atom: atom=" + atom, " single electrons=" + super.getConnectedSingleElectronsCount(atom)); return super.getConnectedSingleElectronsList(atom); } public java.util.List getConnectedElectronContainersList(IAtom atom) { logger.debug("Getting connected electron containers for atom: ", atom); return super.getConnectedElectronContainersList(atom); } public int getConnectedAtomsCount(IAtom atom) { logger.debug("Getting connected atoms count for atom: ", atom); return super.getConnectedAtomsCount(atom); } public int getConnectedBondsCount(IAtom atom) { logger.debug("Getting connected bonds count for atom: ", atom); return super.getConnectedBondsCount(atom); } public int getConnectedLonePairsCount(IAtom atom) { logger.debug("Getting connected lone pairs count for atom: ", atom); return super.getConnectedLonePairsCount(atom); } public int getConnectedSingleElectronsCount(IAtom atom) { logger.debug("Getting connected single electrons count for atom: ", atom); return super.getConnectedSingleElectronsCount(atom); } public double getBondOrderSum(IAtom atom) { logger.debug("Getting bond order sum for atom: ", atom); return super.getBondOrderSum(atom); } public Order getMaximumBondOrder(IAtom atom) { logger.debug("Getting maximum bond order for atom: ", atom); return super.getMaximumBondOrder(atom); } public Order getMinimumBondOrder(IAtom atom) { logger.debug("Getting minimum bond order for atom: ", atom); return super.getMinimumBondOrder(atom); } // public void addElectronContainers(IAtomContainer atomContainer) { // logger.debug("Adding electron containers from atom container: ", atomContainer); // super.addElectronContainers(atomContainer); // } public void add(IAtomContainer atomContainer) { logger.debug("Adding atom container: ", atomContainer); super.add(atomContainer); } public void addAtom(IAtom atom) { logger.debug("Adding atom: ", atom); super.addAtom(atom); } public void addBond(IBond bond) { logger.debug("Adding bond: ", bond); super.addBond(bond); } public void addLonePair(ILonePair ec) { logger.debug("Adding lone pair: ", ec); super.addLonePair(ec); } public void addSingleElectron(ISingleElectron ec) { logger.debug("Adding single electron: ", ec); super.addSingleElectron(ec); } public void addElectronContainer(IElectronContainer electronContainer) { logger.debug("Adding electron container: ", electronContainer); super.addElectronContainer(electronContainer); } public void remove(IAtomContainer atomContainer) { logger.debug("Removing atom container: ", atomContainer); super.remove(atomContainer); } public IElectronContainer removeElectronContainer(int position) { logger.debug("Removing electronContainer: ", position); return super.removeElectronContainer(position); } public void removeElectronContainer(IElectronContainer electronContainer) { logger.debug("Removing electron container: ", electronContainer); super.removeElectronContainer(electronContainer); } public void removeAtom(int position) { logger.debug("Removing atom: ", position); super.removeAtom(position); } public void removeAtom(IAtom atom) { logger.debug("Removing atom: ", atom); super.removeAtom(atom); } public IBond removeBond(int pos) { logger.debug("Removing bond at " + pos); return super.removeBond(pos); } public IBond removeBond(IAtom atom1, IAtom atom2) { logger.debug("Removing bond: atom1=" + atom1 + " atom2=" + atom2); return super.removeBond(atom1, atom2); } public void removeBond(IBond bond) { logger.debug("Removing bond=" + bond); super.removeBond(bond); } public ILonePair removeLonePair(int pos) { logger.debug("Removing bond at " + pos); return super.removeLonePair(pos); } public void removeLonePair(ILonePair ec) { logger.debug("Removing bond=" + ec); super.removeLonePair(ec); } public ISingleElectron removeSingleElectron(int pos) { logger.debug("Removing bond at " + pos); return super.removeSingleElectron(pos); } public void removeSingleElectron(ISingleElectron ec) { logger.debug("Removing bond=" + ec); super.removeSingleElectron(ec); } public void removeAtomAndConnectedElectronContainers(IAtom atom) { logger.debug("Removing atom and connected electron containers: ", atom); super.removeAtomAndConnectedElectronContainers(atom); } public void removeAllElements() { logger.debug("Removing all elements"); super.removeAllElements(); } public void removeAllElectronContainers() { logger.debug("Removing all electron containers"); super.removeAllElectronContainers(); } public void removeAllBonds() { logger.debug("Removing all bonds"); super.removeAllBonds(); } public void addBond(int atom1, int atom2, IBond.Order order, int stereo) { logger.debug("Adding bond: atom1=" + atom1 + " atom2=" + atom2, " order=" + order + " stereo=" + stereo); super.addBond(atom1, atom2, order, stereo); } public void addBond(int atom1, int atom2, IBond.Order order) { logger.debug("Adding bond: atom1=" + atom1 + " atom2=" + atom2, " order=" + order); super.addBond(atom1, atom2, order); } public void addLonePair(int atomID) { logger.debug("Adding lone pair: ", atomID); super.addLonePair(atomID); } public void addSingleElectron(int atomID) { logger.debug("Adding single electron: ", atomID); super.addSingleElectron(atomID); } public boolean contains(IAtom atom) { logger.debug("Contains atom: ", atom); return super.contains(atom); } public boolean contains(IBond bond) { logger.debug("Contains bond: ", bond); return super.contains(bond); } public boolean contains(ILonePair ec) { logger.debug("Contains lone pair: ", ec); return super.contains(ec); } public boolean contains(ISingleElectron ec) { logger.debug("Contains single electron: ", ec); return super.contains(ec); } public boolean contains(IElectronContainer electronContainer) { logger.debug("Contains electron container: ", electronContainer); return super.contains(electronContainer); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public String getMonomerName() { logger.debug("Getting monomer name: ", super.getMonomerName()); return super.getMonomerName(); } public String getMonomerType() { logger.debug("Getting monomer type: ", super.getMonomerType()); return super.getMonomerType(); } public void setMonomerName(String cMonomerName) { logger.debug("Setting monomer type to: ", cMonomerName); super.setMonomerName(cMonomerName); } public void setMonomerType(String cMonomerType) { logger.debug("Setting monomer type to: ", cMonomerType); super.setMonomerType(cMonomerType); } public void stateChanged(IChemObjectChangeEvent event) { logger.debug("Received state changed event: ", event); super.stateChanged(event); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugPDBAtom.java100644 0 0 12056 11570154753 21203 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2004-2007 Miguel Rojas * * 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. * * 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.debug; import javax.vecmath.Point3d; import org.openscience.cdk.interfaces.IElement; import org.openscience.cdk.interfaces.IPDBAtom; import org.openscience.cdk.protein.data.PDBAtom; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author Miguel Rojas * @cdk.module datadebug * @cdk.githash */ public class DebugPDBAtom extends PDBAtom implements IPDBAtom { private static final long serialVersionUID = -2432127382224382452L; LoggingTool logger = new LoggingTool(DebugPDBAtom.class); public DebugPDBAtom(IElement element) { super(element); logger.debug("Instantiated a DebugPDBAtom: element= ", element); } public DebugPDBAtom(String symbol) { super(symbol); logger.debug("Instantiated a DebugPDBAtom: symbol= ", symbol); } public DebugPDBAtom(String symbol, Point3d point3d) { super(symbol, point3d); logger.debug("Instantiated a DebugAtom: symbol= ", symbol + " point3d=" + point3d); } public String getRecord() { logger.debug("Getting Record: ", super.getRecord()); return super.getRecord(); } public void setRecord(String newRecord) { logger.debug("Setting Record: ", newRecord); super.setRecord(newRecord); } public Double getTempFactor() { logger.debug("Getting Temp Factor: ", super.getTempFactor()); return super.getTempFactor(); } public void setTempFactor(Double newTempFactor) { logger.debug("Setting Temp Factor: ", newTempFactor); super.setTempFactor(newTempFactor); } public void setResName(String newResName) { logger.debug("Setting Res Name: ", newResName); super.setResName(newResName); } public String getResName() { logger.debug("Getting Res Name: ", super.getResName()); return super.getResName(); } public void setICode(String newICode) { logger.debug("Setting I Code: ", newICode); super.setICode(newICode); } public String getICode() { logger.debug("Getting I Code: ", super.getICode()); return super.getICode(); } public void setName(String newName) { logger.debug("Setting Name: ", newName); super.setName(newName); } public String getName() { logger.debug("Getting Name: ", super.getName()); return super.getName(); } public void setChainID(String newChainID) { logger.debug("Setting Chain ID: ", newChainID); super.setChainID(newChainID); } public String getChainID() { logger.debug("Getting Chain ID: ", super.getChainID()); return super.getChainID(); } public void setAltLoc(String newAltLoc) { logger.debug("Setting Alt Loc: ", newAltLoc); super.setAltLoc(newAltLoc); } public String getAltLoc() { logger.debug("Getting Alt Loc: ", super.getAltLoc()); return super.getAltLoc(); } public void setSegID(String newSegID) { logger.debug("Setting SegID: ", newSegID); super.setSegID(newSegID); } public String getSegID() { logger.debug("Getting Seg ID: ", super.getSegID()); return super.getSegID(); } public void setSerial(Integer newSerial) { logger.debug("Setting Serial: ", newSerial); super.setSerial(newSerial); } public Integer getSerial() { logger.debug("Getting Serial: ", super.getSerial()); return super.getSerial(); } public void setResSeq(String newResSeq) { logger.debug("Setting Res Seq: ", newResSeq); super.setResSeq(newResSeq); } public String getResSeq() { logger.debug("Getting Res Seq: ", super.getResSeq()); return super.getResSeq(); } public void setOxt(Boolean newOxt) { logger.debug("Setting Oxt: ", newOxt); super.setOxt(newOxt); } public Boolean getOxt() { logger.debug("Getting Oxt: ", super.getOxt()); return super.getOxt(); } public void setHetAtom(Boolean newHetAtom) { logger.debug("Setting Het Atom: ", newHetAtom); super.setHetAtom(newHetAtom); } public Boolean getHetAtom() { logger.debug("Getting Het Atom: ", super.getHetAtom()); return super.getHetAtom(); } public void setOccupancy(Double newOccupancy) { logger.debug("Setting Occupancy: ", newOccupancy); super.setOccupancy(newOccupancy); } public Double getOccupancy() { logger.debug("Getting Occupancy: ", super.getOccupancy()); return super.getOccupancy(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugPDBMonomer.java100644 0 0 3604 11570154753 21676 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2004-2007 Miguel Rojas * * 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. * * 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.debug; import org.openscience.cdk.interfaces.IPDBMonomer; import org.openscience.cdk.protein.data.PDBMonomer; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author Miguel Rojas * @cdk.module datadebug * @cdk.githash */ public class DebugPDBMonomer extends PDBMonomer implements IPDBMonomer { private static final long serialVersionUID = -5156111560946745699L; LoggingTool logger = new LoggingTool(DebugAtomContainer.class); public void setICode(String newICode) { logger.debug("Setting I Code: ", newICode); super.setICode(newICode); } public String getICode() { logger.debug("Getting I Code: ", super.getICode()); return super.getICode(); } public void setChainID(String newChainID) { logger.debug("Setting ChainID: ", newChainID); super.setChainID(newChainID); } public String getChainID() { logger.debug("Getting ChainID: ", super.getChainID()); return super.getChainID(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugPDBPolymer.java100644 0 0 3363 11570154753 21713 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2004-2007 Miguel Rojas * * 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. * * 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.debug; import java.util.Collection; import org.openscience.cdk.interfaces.IBioPolymer; import org.openscience.cdk.interfaces.IPDBStructure; import org.openscience.cdk.protein.data.PDBPolymer; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author Miguel Rojas * @cdk.module datadebug * @cdk.githash */ public class DebugPDBPolymer extends PDBPolymer implements IBioPolymer { private static final long serialVersionUID = -8485559594520919850L; LoggingTool logger = new LoggingTool(DebugAtomContainer.class); public Collection getStructures() { logger.debug("Getting Structure: ", super.getStructures()); return super.getStructures(); } public void addStructure(IPDBStructure structure) { logger.debug("Adding Structure: ", structure); super.addStructure(structure); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugPDBStructure.java100644 0 0 7257 11570154753 22272 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2004-2007 Miguel Rojas * * 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. * * 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.debug; import org.openscience.cdk.protein.data.PDBStructure; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author Miguel Rojas * @cdk.module datadebug * @cdk.githash */ public class DebugPDBStructure extends PDBStructure { private static final long serialVersionUID = 1934748703085969097L; LoggingTool logger = new LoggingTool(DebugAtomContainer.class); public Character getEndChainID() { logger.debug("Getting End Chain ID: ", super.getEndChainID()); return super.getEndChainID(); } public void setEndChainID(Character endChainID) { logger.debug("Setting End Chain ID: ", endChainID); super.setEndChainID(endChainID); } public Character getEndInsertionCode() { logger.debug("Getting End Insertion Code: ", super.getEndInsertionCode()); return super.getEndInsertionCode(); } public void setEndInsertionCode(Character endInsertionCode) { logger.debug("Setting End Insertion Code: ", endInsertionCode); super.setEndInsertionCode(endInsertionCode); } public Integer getEndSequenceNumber() { logger.debug("Getting End Sequence Number: ", super.getEndSequenceNumber()); return super.getEndSequenceNumber(); } public void setEndSequenceNumber(Integer endSequenceNumber) { logger.debug("Setting End Sequence Number: ", endSequenceNumber); super.setEndSequenceNumber(endSequenceNumber); } public Character getStartChainID() { logger.debug("Getting Start Chain ID: ", super.getStartChainID()); return super.getStartChainID(); } public void setStartChainID(Character startChainID) { logger.debug("Setting Start Chain ID: ", startChainID); super.setStartChainID(startChainID); } public Character getStartInsertionCode() { logger.debug("Getting Start Insertion Code: ", super.getStartInsertionCode()); return super.getStartInsertionCode(); } public void setStartInsertionCode(Character startInsertionCode) { logger.debug("Setting Star tInsertion Code: ", startInsertionCode); super.setStartInsertionCode(startInsertionCode); } public Integer getStartSequenceNumber() { logger.debug("Getting Start Sequence Number: ", super.getStartSequenceNumber()); return super.getStartSequenceNumber(); } public void setStartSequenceNumber(Integer startSequenceNumber) { logger.debug("Setting Start Sequence Number: ", startSequenceNumber); super.setStartSequenceNumber(startSequenceNumber); } public String getStructureType() { logger.debug("Getting Structure Type: ", super.getStructureType()); return super.getStructureType(); } public void setStructureType(String structureType) { logger.debug("Setting Structure Type: ", structureType); super.setStructureType(structureType); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugPolymer.java100644 0 0 41242 11570154753 21403 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Collection; import java.util.List; import java.util.Map; import org.openscience.cdk.Polymer; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomParity; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IElectronContainer; import org.openscience.cdk.interfaces.ILonePair; import org.openscience.cdk.interfaces.IMonomer; import org.openscience.cdk.interfaces.IPolymer; import org.openscience.cdk.interfaces.ISingleElectron; import org.openscience.cdk.interfaces.IBond.Order; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugPolymer extends Polymer implements IPolymer { private static final long serialVersionUID = -1459933635059023539L; LoggingTool logger = new LoggingTool(DebugAtomContainer.class); public void addAtomParity(IAtomParity parity) { logger.debug("Adding atom parity: ", parity); super.addAtomParity(parity); } public IAtomParity getAtomParity(IAtom atom) { logger.debug("Getting atom parity: ", atom); return super.getAtomParity(atom); } public void setAtoms(IAtom[] atoms) { logger.debug("Setting atoms: ", atoms.length); super.setAtoms(atoms); } // public void setElectronContainers(IElectronContainer[] electronContainers) { // logger.debug("Setting electron containers: ", electronContainers.length); // super.setElectronContainers(electronContainers); // } public void setAtom(int number, IAtom atom) { logger.debug("Setting atom at: pos=" + number, " atom=" + atom); super.setAtom(number, atom); } public IAtom getAtom(int number) { logger.debug("Getting atom at: ", number); return super.getAtom(number); } public IBond getBond(int number) { logger.debug("Getting bond at: ", number); return super.getBond(number); } public ILonePair getLonePair(int number) { logger.debug("Getting lone pair at: ", number); return super.getLonePair(number); } public ISingleElectron getSingleElectron(int number) { logger.debug("Getting single electron at: ", number); return super.getSingleElectron(number); } // public void setElectronContainer(int number, IElectronContainer electronContainer) { // logger.debug("Setting electron container at: pos=" + number, " electron container=" +electronContainer); // super.setElectronContainer(number, electronContainer); // } // public void setElectronContainerCount(int electronContainerCount) { // logger.debug("Setting electron container count: ", electronContainerCount); // super.setElectronContainerCount(electronContainerCount); // } // public void setAtomCount(int atomCount) { // logger.debug("Settting atom count: ", atomCount); // super.setAtomCount(atomCount); // } public Iterable atoms() { logger.debug("Getting atoms iterator"); return super.atoms(); } public Iterable bonds() { logger.debug("Getting bonds iterator"); return super.bonds(); } public Iterable lonePairs() { logger.debug("Getting lone pairs iterator"); return super.lonePairs(); } public Iterable singleElectrons() { logger.debug("Getting single electrons iterator"); return super.singleElectrons(); } public Iterable electronContainers() { logger.debug("Getting electron containers iterator"); return super.electronContainers(); } public IAtom getFirstAtom() { logger.debug("Getting first atom: ", super.getFirstAtom()); return super.getFirstAtom(); } public IAtom getLastAtom() { logger.debug("Getting last atom: ", super.getLastAtom()); return super.getLastAtom(); } public int getAtomNumber(IAtom atom) { logger.debug("Getting atom number: ", atom); return super.getAtomNumber(atom); } public int getBondNumber(IAtom atom1, IAtom atom2) { logger.debug("Getting bond number: atom1=" + atom1, " atom2=" + atom2); return super.getBondNumber(atom1, atom2); } public int getBondNumber(IBond bond) { logger.debug("Getting bond number: ", bond); return super.getBondNumber(bond); } public int getLonePairNumber(ILonePair bond) { logger.debug("Getting lone pair number: ", bond); return super.getLonePairNumber(bond); } public int getSingleElectronNumber(ISingleElectron bond) { logger.debug("Getting single electron number: ", bond); return super.getSingleElectronNumber(bond); } public IElectronContainer getElectronContainer(int number) { logger.debug("Getting electron container at: ", number); return super.getElectronContainer(number); } public IBond getBond(IAtom atom1, IAtom atom2) { logger.debug("Getting bond for atoms: atom1=" + atom1, " atom2=" + atom2); return super.getBond(atom1, atom2); } public int getAtomCount() { logger.debug("Getting atom count"); return super.getAtomCount(); } public int getBondCount() { logger.debug("Getting bond count"); return super.getBondCount(); } public int getLonePairCount() { logger.debug("Getting lone pair count"); return super.getLonePairCount(); } public int getSingleElectronCount() { logger.debug("Getting single electron count"); return super.getSingleElectronCount(); } public int getElectronContainerCount() { logger.debug("Getting electron container count"); return super.getElectronContainerCount(); } // public IAtom[] getConnectedAtoms(IAtom atom) { // logger.debug("Getting connected atoms for atom: ", atom); // return super.getConnectedAtoms(atom); // } public List getConnectedAtomsList(IAtom atom) { logger.debug("Getting connecting atoms vector for atom: ", atom); return super.getConnectedAtomsList(atom); } // public IBond[] getConnectedBonds(IAtom atom) { // logger.debug("Getting connected bonds for atom: ", atom); // return super.getConnectedBonds(atom); // } public List getConnectedBondsList(IAtom atom) { logger.debug("Getting connected bonds vector for atom: ", atom); return super.getConnectedBondsList(atom); } public List getConnectedLonePairsList(IAtom atom) { logger.debug("Getting lone pairs at atom: atom=" + atom, " lone pairs=" + super.getConnectedLonePairsCount(atom)); return super.getConnectedLonePairsList(atom); } public List getConnectedSingleElectronsList(IAtom atom) { logger.debug("Getting single electrons at atom: atom=" + atom, " single electrons=" + super.getConnectedSingleElectronsCount(atom)); return super.getConnectedSingleElectronsList(atom); } public java.util.List getConnectedElectronContainersList(IAtom atom) { logger.debug("Getting connected electron containers for atom: ", atom); return super.getConnectedElectronContainersList(atom); } public int getConnectedAtomsCount(IAtom atom) { logger.debug("Getting connected atoms count for atom: ", atom); return super.getConnectedAtomsCount(atom); } public int getConnectedBondsCount(IAtom atom) { logger.debug("Getting connected bonds count for atom: ", atom); return super.getConnectedBondsCount(atom); } public int getConnectedLonePairsCount(IAtom atom) { logger.debug("Getting connected lone pairs count for atom: ", atom); return super.getConnectedLonePairsCount(atom); } public int getConnectedSingleElectronsCount(IAtom atom) { logger.debug("Getting connected single electrons count for atom: ", atom); return super.getConnectedSingleElectronsCount(atom); } public double getBondOrderSum(IAtom atom) { logger.debug("Getting bond order sum for atom: ", atom); return super.getBondOrderSum(atom); } public Order getMaximumBondOrder(IAtom atom) { logger.debug("Getting maximum bond order for atom: ", atom); return super.getMaximumBondOrder(atom); } public Order getMinimumBondOrder(IAtom atom) { logger.debug("Getting minimum bond order for atom: ", atom); return super.getMinimumBondOrder(atom); } // public void addElectronContainers(IAtomContainer atomContainer) { // logger.debug("Adding electron containers from atom container: ", atomContainer); // super.addElectronContainers(atomContainer); // } public void add(IAtomContainer atomContainer) { logger.debug("Adding atom container: ", atomContainer); super.add(atomContainer); } public void addAtom(IAtom atom) { logger.debug("Adding atom: ", atom); super.addAtom(atom); } public void addBond(IBond bond) { logger.debug("Adding bond: ", bond); super.addBond(bond); } public void addLonePair(ILonePair ec) { logger.debug("Adding lone pair: ", ec); super.addLonePair(ec); } public void addSingleElectron(ISingleElectron ec) { logger.debug("Adding single electron: ", ec); super.addSingleElectron(ec); } public void addElectronContainer(IElectronContainer electronContainer) { logger.debug("Adding electron container: ", electronContainer); super.addElectronContainer(electronContainer); } public void remove(IAtomContainer atomContainer) { logger.debug("Removing atom container: ", atomContainer); super.remove(atomContainer); } public IElectronContainer removeElectronContainer(int position) { logger.debug("Removing electronContainer: ", position); return super.removeElectronContainer(position); } public void removeElectronContainer(IElectronContainer electronContainer) { logger.debug("Removing electron container: ", electronContainer); super.removeElectronContainer(electronContainer); } public void removeAtom(int position) { logger.debug("Removing atom: ", position); super.removeAtom(position); } public void removeAtom(IAtom atom) { logger.debug("Removing atom: ", atom); super.removeAtom(atom); } public IBond removeBond(int pos) { logger.debug("Removing bond at " + pos); return super.removeBond(pos); } public IBond removeBond(IAtom atom1, IAtom atom2) { logger.debug("Removing bond: atom1=" + atom1 + " atom2=" + atom2); return super.removeBond(atom1, atom2); } public void removeBond(IBond bond) { logger.debug("Removing bond=" + bond); super.removeBond(bond); } public ILonePair removeLonePair(int pos) { logger.debug("Removing bond at " + pos); return super.removeLonePair(pos); } public void removeLonePair(ILonePair ec) { logger.debug("Removing bond=" + ec); super.removeLonePair(ec); } public ISingleElectron removeSingleElectron(int pos) { logger.debug("Removing bond at " + pos); return super.removeSingleElectron(pos); } public void removeSingleElectron(ISingleElectron ec) { logger.debug("Removing bond=" + ec); super.removeSingleElectron(ec); } public void removeAtomAndConnectedElectronContainers(IAtom atom) { logger.debug("Removing atom and connected electron containers: ", atom); super.removeAtomAndConnectedElectronContainers(atom); } public void removeAllElements() { logger.debug("Removing all elements"); super.removeAllElements(); } public void removeAllElectronContainers() { logger.debug("Removing all electron containers"); super.removeAllElectronContainers(); } public void removeAllBonds() { logger.debug("Removing all bonds"); super.removeAllBonds(); } public void addBond(int atom1, int atom2, IBond.Order order, int stereo) { logger.debug("Adding bond: atom1=" + atom1 + " atom2=" + atom2, " order=" + order + " stereo=" + stereo); super.addBond(atom1, atom2, order, stereo); } public void addBond(int atom1, int atom2, IBond.Order order) { logger.debug("Adding bond: atom1=" + atom1 + " atom2=" + atom2, " order=" + order); super.addBond(atom1, atom2, order); } public void addLonePair(int atomID) { logger.debug("Adding lone pair: ", atomID); super.addLonePair(atomID); } public void addSingleElectron(int atomID) { logger.debug("Adding single electron: ", atomID); super.addSingleElectron(atomID); } public boolean contains(IAtom atom) { logger.debug("Contains atom: ", atom); return super.contains(atom); } public boolean contains(IBond bond) { logger.debug("Contains bond: ", bond); return super.contains(bond); } public boolean contains(ILonePair ec) { logger.debug("Contains lone pair: ", ec); return super.contains(ec); } public boolean contains(ISingleElectron ec) { logger.debug("Contains single electron: ", ec); return super.contains(ec); } public boolean contains(IElectronContainer electronContainer) { logger.debug("Contains electron container: ", electronContainer); return super.contains(electronContainer); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public void stateChanged(IChemObjectChangeEvent event) { logger.debug("Receiving state changed event: ", event); super.stateChanged(event); } public void addAtom(IAtom oAtom, IMonomer oMonomer) { logger.debug("Adding atom to monomer: ", oAtom, oMonomer); super.addAtom(oAtom, oMonomer); } public int getMonomerCount() { logger.debug("Getting monomer count: ", super.getMonomerCount()); return super.getMonomerCount(); } public IMonomer getMonomer(String cName) { logger.debug("Getting monomer for String: ", cName); return super.getMonomer(cName); } public Collection getMonomerNames() { logger.debug("Getting monomer names"); return super.getMonomerNames(); } public void removeMonomer(String name) { logger.debug("Removing monomer by string: ", name); super.removeMonomer(name); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugPseudoAtom.java100644 0 0 26070 11570154753 22036 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Map; import javax.vecmath.Point2d; import javax.vecmath.Point3d; import org.openscience.cdk.PseudoAtom; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IElement; import org.openscience.cdk.interfaces.IPseudoAtom; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugPseudoAtom extends PseudoAtom implements IPseudoAtom { private static final long serialVersionUID = -5935090219383862070L; LoggingTool logger = new LoggingTool(DebugPseudoAtom.class); public DebugPseudoAtom() { super(); logger.debug("Instantiated a DebugAtom"); } public DebugPseudoAtom(IElement element) { super(element); logger.debug("Instantiated a DebugAtom: element= ", element); } public DebugPseudoAtom(String symbol) { super(symbol); logger.debug("Instantiated a DebugAtom: symbol= ", symbol); } public DebugPseudoAtom(String symbol, Point2d point2d) { super(symbol, point2d); logger.debug("Instantiated a DebugAtom: symbol= ", symbol + " point2d=" + point2d); } public DebugPseudoAtom(String symbol, Point3d point3d) { super(symbol, point3d); logger.debug("Instantiated a DebugAtom: symbol= ", symbol + " point3d=" + point3d); } public void setCharge(Double charge) { logger.debug("Setting charge: ", charge); super.setCharge(charge); } public Double getCharge() { logger.debug("Setting charge: ", super.getCharge()); return super.getCharge(); } public void setHydrogenCount(Integer hydrogenCount) { logger.debug("Setting hydrogen count: ", hydrogenCount); super.setHydrogenCount(hydrogenCount); } public Integer getHydrogenCount() { logger.debug("Getting hydrogen count: ", super.getHydrogenCount()); return super.getHydrogenCount(); } public void setPoint2d(Point2d point2d) { logger.debug("Setting point2d: x=" + point2d.x + ", y=" + point2d.y); super.setPoint2d(point2d); } public void setPoint3d(Point3d point3d) { logger.debug("Setting point3d: x=" + point3d.x + ", y=" + point3d.y, ", z=" + point3d.z); super.setPoint3d(point3d); } public void setFractionalPoint3d(Point3d point3d) { logger.debug("Setting fractional point3d: x=" + point3d.x + ", y=" + point3d.y, ", z=" + point3d.z); super.setFractionalPoint3d(point3d); } public void setStereoParity(Integer stereoParity) { logger.debug("Setting stereoParity: ", stereoParity); super.setStereoParity(stereoParity); } public Point2d getPoint2d() { Point2d point2d = super.getPoint2d(); if (point2d == null) { logger.debug("Getting point2d: null"); } else { logger.debug("Getting point2d: x=" + point2d.x + ", y=" + point2d.y); } return point2d; } public Point3d getPoint3d() { Point3d point3d = super.getPoint3d(); if (point3d == null) { logger.debug("Getting point3d: null"); } else { logger.debug("Getting point3d: x=" + point3d.x + ", y=" + point3d.y, ", z=" + point3d.z); } return point3d; } public Point3d getFractionalPoint3d() { Point3d point3d = super.getFractionalPoint3d(); if (point3d == null) { logger.debug("Getting fractional point3d: null"); } else { logger.debug("Getting fractional point3d: x=" + point3d.x + ", y=" + point3d.y, ", z=" + point3d.z); } return point3d; } public Integer getStereoParity() { logger.debug("Getting stereo parity: ", super.getStereoParity()); return super.getStereoParity(); } public void setAtomTypeName(String identifier) { logger.debug("Setting atom type name: ", identifier); super.setAtomTypeName(identifier); } public void setMaxBondOrder(IBond.Order maxBondOrder) { logger.debug("Setting max bond order: ", maxBondOrder); super.setMaxBondOrder(maxBondOrder); } public void setBondOrderSum(Double bondOrderSum) { logger.debug("Setting bond order sum: ", bondOrderSum); super.setBondOrderSum(bondOrderSum); } public String getAtomTypeName() { logger.debug("Getting atom type name: ", super.getAtomTypeName()); return super.getAtomTypeName(); } public IBond.Order getMaxBondOrder() { logger.debug("Getting max bond order: ", super.getMaxBondOrder()); return super.getMaxBondOrder(); } public Double getBondOrderSum() { logger.debug("Getting bond order sum: ", super.getBondOrderSum()); return super.getBondOrderSum(); } public void setFormalCharge(Integer charge) { logger.debug("Setting formal charge: ", charge); super.setFormalCharge(charge); } public Integer getFormalCharge() { logger.debug("Getting formal charge: ", super.getFormalCharge()); return super.getFormalCharge(); } public void setFormalNeighbourCount(Integer count) { logger.debug("Setting forml neighbour count: ", count); super.setFormalNeighbourCount(count); } public Integer getFormalNeighbourCount() { logger.debug("Getting formal neighbour count: ", super.getFormalNeighbourCount()); return super.getFormalNeighbourCount(); } public void setHybridization(IAtomType.Hybridization hybridization) { logger.debug("Setting hybridization: ", hybridization); super.setHybridization(hybridization); } public IAtomType.Hybridization getHybridization() { logger.debug("Getting hybridization: ", super.getHybridization()); return super.getHybridization(); } public void setCovalentRadius(Double radius) { logger.debug("Setting covalent radius: ", radius); super.setCovalentRadius(radius); } public Double getCovalentRadius() { logger.debug("Getting covalent radius: ", super.getCovalentRadius()); return super.getCovalentRadius(); } public void setValency(Integer valency) { logger.debug("Setting valency: ", valency); super.setValency(valency); } public Integer getValency() { logger.debug("Getting valency: ", super.getValency()); return super.getValency(); } public void setNaturalAbundance(Double naturalAbundance) { logger.debug("Setting natural abundance: ", naturalAbundance); super.setNaturalAbundance(naturalAbundance); } public void setExactMass(Double exactMass) { logger.debug("Setting exact mass: ", exactMass); super.setExactMass(exactMass); } public Double getNaturalAbundance() { logger.debug("Getting natural abundance: ", super.getNaturalAbundance()); return super.getNaturalAbundance(); } public Double getExactMass() { logger.debug("Getting exact mass: ", super.getExactMass()); return super.getExactMass(); } public Integer getMassNumber() { logger.debug("Getting mass number: ", super.getMassNumber()); return super.getMassNumber(); } public void setMassNumber(Integer massNumber) { logger.debug("Setting mass number: ", massNumber); super.setMassNumber(massNumber); } public Integer getAtomicNumber() { logger.debug("Getting atomic number: ", super.getAtomicNumber()); return super.getAtomicNumber(); } public void setAtomicNumber(Integer atomicNumber) { logger.debug("Setting atomic number: ", atomicNumber); super.setAtomicNumber(atomicNumber); } public String getSymbol() { logger.debug("Getting symbol: ", super.getSymbol()); return super.getSymbol(); } public void setSymbol(String symbol) { logger.debug("Setting symbol: ", symbol); super.setSymbol(symbol); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public String getLabel() { logger.debug("Getting label: ", super.getLabel()); return super.getLabel(); } public void setLabel(String label) { logger.debug("Setting label: ", label); super.setLabel(label); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugReaction.java100644 0 0 17402 11570154753 21521 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Map; import org.openscience.cdk.Reaction; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.interfaces.IReaction; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugReaction extends Reaction implements IReaction { private static final long serialVersionUID = -8958358842308217875L; LoggingTool logger = new LoggingTool(DebugReaction.class); public DebugReaction() { super(); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public int getReactantCount() { logger.debug("Getting reactant count: ", super.getReactantCount()); return super.getReactantCount(); } public int getProductCount() { logger.debug("Getting product count: ", super.getProductCount()); return super.getProductCount(); } public IMoleculeSet getReactants() { logger.debug("Getting reactants: ", super.getReactants()); return super.getReactants(); } public void setReactants(IMoleculeSet reactants) { logger.debug("Setting reactants: ", reactants); super.setReactants(reactants); } public IMoleculeSet getProducts() { logger.debug("Getting products: ", super.getProducts()); return super.getProducts(); } public void setProducts(IMoleculeSet products) { logger.debug("Setting products: ", products); super.setProducts(products); } public IMoleculeSet getAgents() { logger.debug("Getting agents: ", super.getAgents()); return super.getAgents(); } public void addReactant(IMolecule reactant) { logger.debug("Adding reactant: ", reactant); super.addReactant(reactant); } public void addAgent(IMolecule agent) { logger.debug("Adding agent: ", agent); super.addAgent(agent); } public void addReactant(IMolecule reactant, Double coefficient) { logger.debug("Adding reactant with coefficient: ", reactant, ""+coefficient); super.addReactant(reactant, coefficient); } public void addProduct(IMolecule product) { logger.debug("Adding product: ", product); super.addProduct(product); } public void addProduct(IMolecule product, Double coefficient) { logger.debug("Adding product with coefficient: ", product, ""+coefficient); super.addProduct(product, coefficient); } public Double getReactantCoefficient(IMolecule reactant) { logger.debug("Setting reactant coefficient: ", reactant, ""+ super.getReactantCoefficient(reactant)); return super.getReactantCoefficient(reactant); } public Double getProductCoefficient(IMolecule product) { logger.debug("Setting product coefficient: ", product, ""+ super.getProductCoefficient(product)); return super.getProductCoefficient(product); } public boolean setReactantCoefficient(IMolecule reactant, Double coefficient) { logger.debug("Setting reactant coefficient: ", reactant, ""+coefficient); return super.setReactantCoefficient(reactant, coefficient); } public boolean setProductCoefficient(IMolecule product, Double coefficient) { logger.debug("Setting product coefficient: ", product, ""+coefficient); return super.setProductCoefficient(product, coefficient); } public Double[] getReactantCoefficients() { logger.debug("Getting reactant coefficients: ", super.getReactantCoefficients().length); return super.getReactantCoefficients(); } public Double[] getProductCoefficients() { logger.debug("Getting product coefficients: ", super.getProductCoefficients().length); return super.getProductCoefficients(); } public boolean setReactantCoefficients(Double[] coefficients) { logger.debug("Setting reactant coefficients: ", coefficients.length); return super.setReactantCoefficients(coefficients); } public boolean setProductCoefficients(Double[] coefficients) { logger.debug("Setting product coefficients: ", coefficients.length); return super.setProductCoefficients(coefficients); } public void setDirection(IReaction.Direction direction) { logger.debug("Setting direction: ", direction); super.setDirection(direction); } public IReaction.Direction getDirection() { logger.debug("Getting direction: ", super.getDirection()); return super.getDirection(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugReactionScheme.java100644 0 0 11271 11570154753 22644 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2008 Miguel Rojasch * * 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. * * 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.debug; import java.util.Map; import org.openscience.cdk.ReactionScheme; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IReactionScheme; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author miguelrojasch * @cdk.module datadebug */ public class DebugReactionScheme extends ReactionScheme implements IReactionScheme { private static final long serialVersionUID = 705803374163613819L; LoggingTool logger = new LoggingTool(DebugReactionScheme.class); public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public void add(IReactionScheme scheme) { logger.debug("Adding scheme: ", scheme); super.add(scheme); } public Iterable reactionSchemes() { logger.debug("Getting reactionSchemeIterator"); return super.reactionSchemes(); } public int getReactionSchemeCount() { logger.debug("Getting reactionScheme count: ", super.getReactionSchemeCount()); return super.getReactionSchemeCount(); } public void removeAllReactionSchemes() { logger.debug("Removing all reactionSchemes"); super.removeAllReactionSchemes(); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugReactionSet.java100644 0 0 11662 11570154753 22177 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Map; import org.openscience.cdk.ReactionSet; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IReaction; import org.openscience.cdk.interfaces.IReactionSet; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugReactionSet extends ReactionSet implements IReactionSet { private static final long serialVersionUID = 1620489912540131959L; LoggingTool logger = new LoggingTool(DebugReactionSet.class); public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public void addReaction(IReaction reaction) { logger.debug("Adding reaction: ", reaction); super.addReaction(reaction); } public IReaction getReaction(int number) { logger.debug("Getting reaction at: ", number); return super.getReaction(number); } public Iterable reactions() { logger.debug("Getting reactionIterable"); return super.reactions(); } public int getReactionCount() { logger.debug("Getting reaction count: ", super.getReactionCount()); return super.getReactionCount(); } public void removeAllReactions() { logger.debug("Removing all reactions"); super.removeAllReactions(); } public void removeReaction(IReaction reaction){ logger.debug("Removing reaction "+reaction.getID()); super.removeReaction(reaction); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugRing.java100644 0 0 41671 11570154753 20661 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.List; import java.util.Map; import org.openscience.cdk.Bond; import org.openscience.cdk.Ring; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomParity; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IElectronContainer; import org.openscience.cdk.interfaces.ILonePair; import org.openscience.cdk.interfaces.IRing; import org.openscience.cdk.interfaces.ISingleElectron; import org.openscience.cdk.interfaces.IBond.Order; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugRing extends Ring implements IRing { private static final long serialVersionUID = -6420813246421544803L; LoggingTool logger = new LoggingTool(DebugRing.class); public DebugRing() { super(); } public DebugRing(int ringSize, String elementSymbol) { this(ringSize); super.atomCount = ringSize; super.bondCount = ringSize; atoms[0] = new DebugAtom(elementSymbol); for (int i = 1; i < ringSize; i++) { atoms[i] = new DebugAtom(elementSymbol); super.bonds[i-1] = new Bond(atoms[i - 1], atoms[i], IBond.Order.SINGLE); } super.bonds[ringSize-1] = new Bond(atoms[ringSize - 1], atoms[0], IBond.Order.SINGLE); } public DebugRing(int ringSize) { super(ringSize); } public DebugRing(IAtomContainer container) { super(container); } public void addAtomParity(IAtomParity parity) { logger.debug("Adding atom parity: ", parity); super.addAtomParity(parity); } public IAtomParity getAtomParity(IAtom atom) { logger.debug("Getting atom parity: ", atom); return super.getAtomParity(atom); } public void setAtoms(IAtom[] atoms) { logger.debug("Setting atoms: ", atoms.length); super.setAtoms(atoms); } // public void setElectronContainers(IElectronContainer[] electronContainers) { // logger.debug("Setting electron containers: ", electronContainers.length); // super.setElectronContainers(electronContainers); // } public void setAtom(int number, IAtom atom) { logger.debug("Setting atom at: pos=" + number, " atom=" + atom); super.setAtom(number, atom); } public IAtom getAtom(int number) { logger.debug("Getting atom at: ", number); return super.getAtom(number); } public IBond getBond(int number) { logger.debug("Getting bond at: ", number); return super.getBond(number); } public ILonePair getLonePair(int number) { logger.debug("Getting lone pair at: ", number); return super.getLonePair(number); } public ISingleElectron getSingleElectron(int number) { logger.debug("Getting single electron at: ", number); return super.getSingleElectron(number); } // public void setElectronContainer(int number, IElectronContainer electronContainer) { // logger.debug("Setting electron container at: pos=" + number, " electron container=" +electronContainer); // super.setElectronContainer(number, electronContainer); // } // public void setElectronContainerCount(int electronContainerCount) { // logger.debug("Setting electron container count: ", electronContainerCount); // super.setElectronContainerCount(electronContainerCount); // } // public void setAtomCount(int atomCount) { // logger.debug("Settting atom count: ", atomCount); // super.setAtomCount(atomCount); // } public Iterable atoms() { logger.debug("Getting atoms iterator"); return super.atoms(); } public Iterable bonds() { logger.debug("Getting bonds iterator"); return super.bonds(); } public Iterable lonePairs() { logger.debug("Getting lone pairs iterator"); return super.lonePairs(); } public Iterable singleElectrons() { logger.debug("Getting single electrons iterator"); return super.singleElectrons(); } public Iterable electronContainers() { logger.debug("Getting electron containers iterator"); return super.electronContainers(); } public IAtom getFirstAtom() { logger.debug("Getting first atom: ", super.getFirstAtom()); return super.getFirstAtom(); } public IAtom getLastAtom() { logger.debug("Getting last atom: ", super.getLastAtom()); return super.getLastAtom(); } public int getAtomNumber(IAtom atom) { logger.debug("Getting atom number: ", atom); return super.getAtomNumber(atom); } public int getBondNumber(IAtom atom1, IAtom atom2) { logger.debug("Getting bond number: atom1=" + atom1, " atom2=" + atom2); return super.getBondNumber(atom1, atom2); } public int getBondNumber(IBond bond) { logger.debug("Getting bond number: ", bond); return super.getBondNumber(bond); } public int getLonePairNumber(ILonePair bond) { logger.debug("Getting lone pair number: ", bond); return super.getLonePairNumber(bond); } public int getSingleElectronNumber(ISingleElectron bond) { logger.debug("Getting single electron number: ", bond); return super.getSingleElectronNumber(bond); } public IElectronContainer getElectronContainer(int number) { logger.debug("Getting electron container at: ", number); return super.getElectronContainer(number); } public IBond getBond(IAtom atom1, IAtom atom2) { logger.debug("Getting bond for atoms: atom1=" + atom1, " atom2=" + atom2); return super.getBond(atom1, atom2); } public int getAtomCount() { logger.debug("Getting atom count"); return super.getAtomCount(); } public int getBondCount() { logger.debug("Getting bond count"); return super.getBondCount(); } public int getLonePairCount() { logger.debug("Getting lone pair count"); return super.getLonePairCount(); } public int getSingleElectronCount() { logger.debug("Getting single electron count"); return super.getSingleElectronCount(); } public int getElectronContainerCount() { logger.debug("Getting electron container count"); return super.getElectronContainerCount(); } // public IAtom[] getConnectedAtoms(IAtom atom) { // logger.debug("Getting connected atoms for atom: ", atom); // return super.getConnectedAtoms(atom); // } public List getConnectedAtomsList(IAtom atom) { logger.debug("Getting connecting atoms vector for atom: ", atom); return super.getConnectedAtomsList(atom); } // public IBond[] getConnectedBonds(IAtom atom) { // logger.debug("Getting connected bonds for atom: ", atom); // return super.getConnectedBonds(atom); // } public List getConnectedBondsList(IAtom atom) { logger.debug("Getting connected bonds vector for atom: ", atom); return super.getConnectedBondsList(atom); } public List getConnectedLonePairsList(IAtom atom) { logger.debug("Getting lone pairs at atom: atom=" + atom, " lone pairs=" + super.getConnectedLonePairsCount(atom)); return super.getConnectedLonePairsList(atom); } public List getConnectedSingleElectronsList(IAtom atom) { logger.debug("Getting single electrons at atom: atom=" + atom, " single electrons=" + super.getConnectedSingleElectronsCount(atom)); return super.getConnectedSingleElectronsList(atom); } public java.util.List getConnectedElectronContainersList(IAtom atom) { logger.debug("Getting connected electron containers for atom: ", atom); return super.getConnectedElectronContainersList(atom); } public int getConnectedAtomsCount(IAtom atom) { logger.debug("Getting connected atoms count for atom: ", atom); return super.getConnectedAtomsCount(atom); } public int getConnectedBondsCount(IAtom atom) { logger.debug("Getting connected bonds count for atom: ", atom); return super.getConnectedBondsCount(atom); } public int getConnectedLonePairsCount(IAtom atom) { logger.debug("Getting connected lone pairs count for atom: ", atom); return super.getConnectedLonePairsCount(atom); } public int getConnectedSingleElectronsCount(IAtom atom) { logger.debug("Getting connected single electrons count for atom: ", atom); return super.getConnectedSingleElectronsCount(atom); } public double getBondOrderSum(IAtom atom) { logger.debug("Getting bond order sum for atom: ", atom); return super.getBondOrderSum(atom); } public Order getMaximumBondOrder(IAtom atom) { logger.debug("Getting maximum bond order for atom: ", atom); return super.getMaximumBondOrder(atom); } public Order getMinimumBondOrder(IAtom atom) { logger.debug("Getting minimum bond order for atom: ", atom); return super.getMinimumBondOrder(atom); } // public void addElectronContainers(IAtomContainer atomContainer) { // logger.debug("Adding electron containers from atom container: ", atomContainer); // super.addElectronContainers(atomContainer); // } public void add(IAtomContainer atomContainer) { logger.debug("Adding atom container: ", atomContainer); super.add(atomContainer); } public void addAtom(IAtom atom) { logger.debug("Adding atom: ", atom); super.addAtom(atom); } public void addBond(IBond bond) { logger.debug("Adding bond: ", bond); super.addBond(bond); } public void addLonePair(ILonePair ec) { logger.debug("Adding lone pair: ", ec); super.addLonePair(ec); } public void addSingleElectron(ISingleElectron ec) { logger.debug("Adding single electron: ", ec); super.addSingleElectron(ec); } public void addElectronContainer(IElectronContainer electronContainer) { logger.debug("Adding electron container: ", electronContainer); super.addElectronContainer(electronContainer); } public void remove(IAtomContainer atomContainer) { logger.debug("Removing atom container: ", atomContainer); super.remove(atomContainer); } public IElectronContainer removeElectronContainer(int position) { logger.debug("Removing electronContainer: ", position); return super.removeElectronContainer(position); } public void removeElectronContainer(IElectronContainer electronContainer) { logger.debug("Removing electron container: ", electronContainer); super.removeElectronContainer(electronContainer); } public void removeAtom(int position) { logger.debug("Removing atom: ", position); super.removeAtom(position); } public void removeAtom(IAtom atom) { logger.debug("Removing atom: ", atom); super.removeAtom(atom); } public IBond removeBond(int pos) { logger.debug("Removing bond at " + pos); return super.removeBond(pos); } public IBond removeBond(IAtom atom1, IAtom atom2) { logger.debug("Removing bond: atom1=" + atom1 + " atom2=" + atom2); return super.removeBond(atom1, atom2); } public void removeBond(IBond bond) { logger.debug("Removing bond=" + bond); super.removeBond(bond); } public ILonePair removeLonePair(int pos) { logger.debug("Removing bond at " + pos); return super.removeLonePair(pos); } public void removeLonePair(ILonePair ec) { logger.debug("Removing bond=" + ec); super.removeLonePair(ec); } public ISingleElectron removeSingleElectron(int pos) { logger.debug("Removing bond at " + pos); return super.removeSingleElectron(pos); } public void removeSingleElectron(ISingleElectron ec) { logger.debug("Removing bond=" + ec); super.removeSingleElectron(ec); } public void removeAtomAndConnectedElectronContainers(IAtom atom) { logger.debug("Removing atom and connected electron containers: ", atom); super.removeAtomAndConnectedElectronContainers(atom); } public void removeAllElements() { logger.debug("Removing all elements"); super.removeAllElements(); } public void removeAllElectronContainers() { logger.debug("Removing all electron containers"); super.removeAllElectronContainers(); } public void removeAllBonds() { logger.debug("Removing all bonds"); super.removeAllBonds(); } public void addBond(int atom1, int atom2, IBond.Order order, int stereo) { logger.debug("Adding bond: atom1=" + atom1 + " atom2=" + atom2, " order=" + order + " stereo=" + stereo); super.addBond(atom1, atom2, order, stereo); } public void addBond(int atom1, int atom2, IBond.Order order) { logger.debug("Adding bond: atom1=" + atom1 + " atom2=" + atom2, " order=" + order); super.addBond(atom1, atom2, order); } public void addLonePair(int atomID) { logger.debug("Adding lone pair: ", atomID); super.addLonePair(atomID); } public void addSingleElectron(int atomID) { logger.debug("Adding single electron: ", atomID); super.addSingleElectron(atomID); } public boolean contains(IAtom atom) { logger.debug("Contains atom: ", atom); return super.contains(atom); } public boolean contains(IBond bond) { logger.debug("Contains bond: ", bond); return super.contains(bond); } public boolean contains(ILonePair ec) { logger.debug("Contains lone pair: ", ec); return super.contains(ec); } public boolean contains(ISingleElectron ec) { logger.debug("Contains single electron: ", ec); return super.contains(ec); } public boolean contains(IElectronContainer electronContainer) { logger.debug("Contains electron container: ", electronContainer); return super.contains(electronContainer); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public int getRingSize() { logger.debug("Getting Ring size:", super.getRingSize()); return super.getRingSize(); } public IBond getNextBond(IBond bond, IAtom atom) { logger.debug("Getting next bond: ", super.getNextBond(bond, atom)); return super.getNextBond(bond, atom); } public int getBondOrderSum() { logger.debug("Getting order sum: ", super.getBondOrderSum()); return super.getBondOrderSum(); } public void stateChanged(IChemObjectChangeEvent event) { logger.debug("State changed: ", event); super.stateChanged(event); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugRingSet.java100644 0 0 4211 11570154753 21302 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import org.openscience.cdk.RingSet; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IRing; import org.openscience.cdk.interfaces.IRingSet; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugRingSet extends RingSet implements IRingSet { private static final long serialVersionUID = -4144201128508373352L; LoggingTool logger = new LoggingTool(DebugRingSet.class); public DebugRingSet() { super(); } public IRingSet getRings(IBond bond) { logger.debug("Getting rings for bond: ", bond); return super.getRings(bond); } public IRingSet getRings(IAtom atom) { logger.debug("Getting rings for atom: ", atom); return super.getRings(atom); } public IRingSet getConnectedRings(IRing ring) { logger.debug("Getting connected rings for ring: ", ring); return super.getConnectedRings(ring); } public void add(IRingSet ringSet) { logger.debug("Adding ring set: ", ringSet); super.add(ringSet); } public boolean contains(IAtom atom) { logger.debug("Contains atom: ", super.contains(atom)); return super.contains(atom); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugSingleElectron.java100644 0 0 11666 11570154753 22700 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Map; import org.openscience.cdk.SingleElectron; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.ISingleElectron; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugSingleElectron extends SingleElectron implements ISingleElectron{ private static final long serialVersionUID = -2895377834940311825L; LoggingTool logger = new LoggingTool(DebugSingleElectron.class); public DebugSingleElectron() { super(); } public DebugSingleElectron(IAtom atom) { super(atom); } public Integer getElectronCount() { logger.debug("Getting electron count: ", super.getElectronCount()); return super.getElectronCount(); } public void setElectronCount(Integer electronCount) { logger.debug("Setting electron count: ", electronCount); super.setElectronCount(electronCount); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public IAtom getAtom() { logger.debug("Getting atom: ", super.getAtom()); return super.getAtom(); } public void setAtom(IAtom atom) { logger.debug("Setting atom: ", atom); super.setAtom(atom); } public boolean contains(IAtom atom) { logger.debug("Contains atom?: ", atom); return super.contains(atom); } } cdk-1.2.10/src/main/org/openscience/cdk/debug/DebugStrand.java100644 0 0 42513 11570154753 21211 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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. * * 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.debug; import java.util.Collection; import java.util.List; import java.util.Map; import org.openscience.cdk.Strand; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomParity; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; import org.openscience.cdk.interfaces.IChemObjectListener; import org.openscience.cdk.interfaces.IElectronContainer; import org.openscience.cdk.interfaces.ILonePair; import org.openscience.cdk.interfaces.IMonomer; import org.openscience.cdk.interfaces.ISingleElectron; import org.openscience.cdk.interfaces.IStrand; import org.openscience.cdk.interfaces.IBond.Order; import org.openscience.cdk.tools.LoggingTool; /** * Debugging data class. * * @author egonw * @cdk.module datadebug * @cdk.githash */ public class DebugStrand extends Strand implements IStrand { private static final long serialVersionUID = 1794588804926192427L; LoggingTool logger = new LoggingTool(DebugAtomContainer.class); public void addAtomParity(IAtomParity parity) { logger.debug("Adding atom parity: ", parity); super.addAtomParity(parity); } public IAtomParity getAtomParity(IAtom atom) { logger.debug("Getting atom parity: ", atom); return super.getAtomParity(atom); } public void setAtoms(IAtom[] atoms) { logger.debug("Setting atoms: ", atoms.length); super.setAtoms(atoms); } // public void setElectronContainers(IElectronContainer[] electronContainers) { // logger.debug("Setting electron containers: ", electronContainers.length); // super.setElectronContainers(electronContainers); // } public void setAtom(int number, IAtom atom) { logger.debug("Setting atom at: pos=" + number, " atom=" + atom); super.setAtom(number, atom); } public IAtom getAtom(int number) { logger.debug("Getting atom at: ", number); return super.getAtom(number); } public IBond getBond(int number) { logger.debug("Getting bond at: ", number); return super.getBond(number); } public ILonePair getLonePair(int number) { logger.debug("Getting lone pair at: ", number); return super.getLonePair(number); } public ISingleElectron getSingleElectron(int number) { logger.debug("Getting single electron at: ", number); return super.getSingleElectron(number); } // public void setElectronContainer(int number, IElectronContainer electronContainer) { // logger.debug("Setting electron container at: pos=" + number, " electron container=" +electronContainer); // super.setElectronContainer(number, electronContainer); // } // public void setElectronContainerCount(int electronContainerCount) { // logger.debug("Setting electron container count: ", electronContainerCount); // super.setElectronContainerCount(electronContainerCount); // } // public void setAtomCount(int atomCount) { // logger.debug("Settting atom count: ", atomCount); // super.setAtomCount(atomCount); // } public Iterable atoms() { logger.debug("Getting atoms iterator"); return super.atoms(); } public Iterable bonds() { logger.debug("Getting bonds iterator"); return super.bonds(); } public Iterable lonePairs() { logger.debug("Getting lone pairs iterator"); return super.lonePairs(); } public Iterable singleElectrons() { logger.debug("Getting single electrons iterator"); return super.singleElectrons(); } public Iterable electronContainers() { logger.debug("Getting electron containers iterator"); return super.electronContainers(); } public IAtom getFirstAtom() { logger.debug("Getting first atom: ", super.getFirstAtom()); return super.getFirstAtom(); } public IAtom getLastAtom() { logger.debug("Getting last atom: ", super.getLastAtom()); return super.getLastAtom(); } public int getAtomNumber(IAtom atom) { logger.debug("Getting atom number: ", atom); return super.getAtomNumber(atom); } public int getBondNumber(IAtom atom1, IAtom atom2) { logger.debug("Getting bond number: atom1=" + atom1, " atom2=" + atom2); return super.getBondNumber(atom1, atom2); } public int getBondNumber(IBond bond) { logger.debug("Getting bond number: ", bond); return super.getBondNumber(bond); } public int getLonePairNumber(ILonePair bond) { logger.debug("Getting lone pair number: ", bond); return super.getLonePairNumber(bond); } public int getSingleElectronNumber(ISingleElectron bond) { logger.debug("Getting single electron number: ", bond); return super.getSingleElectronNumber(bond); } public IElectronContainer getElectronContainer(int number) { logger.debug("Getting electron container at: ", number); return super.getElectronContainer(number); } public IBond getBond(IAtom atom1, IAtom atom2) { logger.debug("Getting bond for atoms: atom1=" + atom1, " atom2=" + atom2); return super.getBond(atom1, atom2); } public int getAtomCount() { logger.debug("Getting atom count"); return super.getAtomCount(); } public int getBondCount() { logger.debug("Getting bond count"); return super.getBondCount(); } public int getLonePairCount() { logger.debug("Getting lone pair count"); return super.getLonePairCount(); } public int getSingleElectronCount() { logger.debug("Getting single electron count"); return super.getSingleElectronCount(); } public int getElectronContainerCount() { logger.debug("Getting electron container count"); return super.getElectronContainerCount(); } // public IAtom[] getConnectedAtoms(IAtom atom) { // logger.debug("Getting connected atoms for atom: ", atom); // return super.getConnectedAtoms(atom); // } public List getConnectedAtomsList(IAtom atom) { logger.debug("Getting connecting atoms vector for atom: ", atom); return super.getConnectedAtomsList(atom); } // public IBond[] getConnectedBonds(IAtom atom) { // logger.debug("Getting connected bonds for atom: ", atom); // return super.getConnectedBonds(atom); // } public List getConnectedBondsList(IAtom atom) { logger.debug("Getting connected bonds vector for atom: ", atom); return super.getConnectedBondsList(atom); } public List getConnectedLonePairsList(IAtom atom) { logger.debug("Getting lone pairs at atom: atom=" + atom, " lone pairs=" + super.getConnectedLonePairsCount(atom)); return super.getConnectedLonePairsList(atom); } public List getConnectedSingleElectronsList(IAtom atom) { logger.debug("Getting single electrons at atom: atom=" + atom, " single electrons=" + super.getConnectedSingleElectronsCount(atom)); return super.getConnectedSingleElectronsList(atom); } public java.util.List getConnectedElectronContainersList(IAtom atom) { logger.debug("Getting connected electron containers for atom: ", atom); return super.getConnectedElectronContainersList(atom); } public int getConnectedAtomsCount(IAtom atom) { logger.debug("Getting connected atoms count for atom: ", atom); return super.getConnectedAtomsCount(atom); } public int getConnectedBondsCount(IAtom atom) { logger.debug("Getting connected bonds count for atom: ", atom); return super.getConnectedBondsCount(atom); } public int getConnectedLonePairsCount(IAtom atom) { logger.debug("Getting connected lone pairs count for atom: ", atom); return super.getConnectedLonePairsCount(atom); } public int getConnectedSingleElectronsCount(IAtom atom) { logger.debug("Getting connected single electrons count for atom: ", atom); return super.getConnectedSingleElectronsCount(atom); } public double getBondOrderSum(IAtom atom) { logger.debug("Getting bond order sum for atom: ", atom); return super.getBondOrderSum(atom); } public Order getMaximumBondOrder(IAtom atom) { logger.debug("Getting maximum bond order for atom: ", atom); return super.getMaximumBondOrder(atom); } public Order getMinimumBondOrder(IAtom atom) { logger.debug("Getting minimum bond order for atom: ", atom); return super.getMinimumBondOrder(atom); } // public void addElectronContainers(IAtomContainer atomContainer) { // logger.debug("Adding electron containers from atom container: ", atomContainer); // super.addElectronContainers(atomContainer); // } public void add(IAtomContainer atomContainer) { logger.debug("Adding atom container: ", atomContainer); super.add(atomContainer); } public void addAtom(IAtom atom) { logger.debug("Adding atom: ", atom); super.addAtom(atom); } public void addBond(IBond bond) { logger.debug("Adding bond: ", bond); super.addBond(bond); } public void addLonePair(ILonePair ec) { logger.debug("Adding lone pair: ", ec); super.addLonePair(ec); } public void addSingleElectron(ISingleElectron ec) { logger.debug("Adding single electron: ", ec); super.addSingleElectron(ec); } public void addElectronContainer(IElectronContainer electronContainer) { logger.debug("Adding electron container: ", electronContainer); super.addElectronContainer(electronContainer); } public void remove(IAtomContainer atomContainer) { logger.debug("Removing atom container: ", atomContainer); super.remove(atomContainer); } public IElectronContainer removeElectronContainer(int position) { logger.debug("Removing electronContainer: ", position); return super.removeElectronContainer(position); } public void removeElectronContainer(IElectronContainer electronContainer) { logger.debug("Removing electron container: ", electronContainer); super.removeElectronContainer(electronContainer); } public void removeAtom(int position) { logger.debug("Removing atom: ", position); super.removeAtom(position); } public void removeAtom(IAtom atom) { logger.debug("Removing atom: ", atom); super.removeAtom(atom); } public IBond removeBond(int pos) { logger.debug("Removing bond at " + pos); return super.removeBond(pos); } public IBond removeBond(IAtom atom1, IAtom atom2) { logger.debug("Removing bond: atom1=" + atom1 + " atom2=" + atom2); return super.removeBond(atom1, atom2); } public void removeBond(IBond bond) { logger.debug("Removing bond=" + bond); super.removeBond(bond); } public ILonePair removeLonePair(int pos) { logger.debug("Removing bond at " + pos); return super.removeLonePair(pos); } public void removeLonePair(ILonePair ec) { logger.debug("Removing bond=" + ec); super.removeLonePair(ec); } public ISingleElectron removeSingleElectron(int pos) { logger.debug("Removing bond at " + pos); return super.removeSingleElectron(pos); } public void removeSingleElectron(ISingleElectron ec) { logger.debug("Removing bond=" + ec); super.removeSingleElectron(ec); } public void removeAtomAndConnectedElectronContainers(IAtom atom) { logger.debug("Removing atom and connected electron containers: ", atom); super.removeAtomAndConnectedElectronContainers(atom); } public void removeAllElements() { logger.debug("Removing all elements"); super.removeAllElements(); } public void removeAllElectronContainers() { logger.debug("Removing all electron containers"); super.removeAllElectronContainers(); } public void removeAllBonds() { logger.debug("Removing all bonds"); super.removeAllBonds(); } public void addBond(int atom1, int atom2, IBond.Order order, int stereo) { logger.debug("Adding bond: atom1=" + atom1 + " atom2=" + atom2, " order=" + order + " stereo=" + stereo); super.addBond(atom1, atom2, order, stereo); } public void addBond(int atom1, int atom2, IBond.Order order) { logger.debug("Adding bond: atom1=" + atom1 + " atom2=" + atom2, " order=" + order); super.addBond(atom1, atom2, order); } public void addLonePair(int atomID) { logger.debug("Adding lone pair: ", atomID); super.addLonePair(atomID); } public void addSingleElectron(int atomID) { logger.debug("Adding single electron: ", atomID); super.addSingleElectron(atomID); } public boolean contains(IAtom atom) { logger.debug("Contains atom: ", atom); return super.contains(atom); } public boolean contains(IBond bond) { logger.debug("Contains bond: ", bond); return super.contains(bond); } public boolean contains(ILonePair ec) { logger.debug("Contains lone pair: ", ec); return super.contains(ec); } public boolean contains(ISingleElectron ec) { logger.debug("Contains single electron: ", ec); return super.contains(ec); } public boolean contains(IElectronContainer electronContainer) { logger.debug("Contains electron container: ", electronContainer); return super.contains(electronContainer); } public void addListener(IChemObjectListener col) { logger.debug("Adding listener: ", col); super.addListener(col); } public int getListenerCount() { logger.debug("Getting listener count: ", super.getListenerCount()); return super.getListenerCount(); } public void removeListener(IChemObjectListener col) { logger.debug("Removing listener: ", col); super.removeListener(col); } public void notifyChanged() { logger.debug("Notifying changed"); super.notifyChanged(); } public void notifyChanged(IChemObjectChangeEvent evt) { logger.debug("Notifying changed event: ", evt); super.notifyChanged(evt); } public void setProperty(Object description, Object property) { logger.debug("Setting property: ", description + "=" + property); super.setProperty(description, property); } public void removeProperty(Object description) { logger.debug("Removing property: ", description); super.removeProperty(description); } public Object getProperty(Object description) { logger.debug("Getting property: ", description + "=" + super.getProperty(description)); return super.getProperty(description); } public Map getProperties() { logger.debug("Getting properties"); return super.getProperties(); } public String getID() { logger.debug("Getting ID: ", super.getID()); return super.getID(); } public void setID(String identifier) { logger.debug("Setting ID: ", identifier); super.setID(identifier); } public void setFlag(int flag_type, boolean flag_value) { logger.debug("Setting flag: ", flag_type + "=" + flag_value); super.setFlag(flag_type, flag_value); } public boolean getFlag(int flag_type) { logger.debug("Setting flag: ", flag_type + "=" + super.getFlag(flag_type)); return super.getFlag(flag_type); } public void setProperties(Map properties) { logger.debug("Setting properties: ", properties); super.setProperties(properties); } public void setFlags(boolean[] flagsNew) { logger.debug("Setting flags:", flagsNew.length); super.setFlags(flagsNew); } public boolean[] getFlags() { logger.debug("Getting flags:", super.getFlags().length); return super.getFlags(); } public Object clone() throws CloneNotSupportedException { Object clone = null; try { clone = super.clone(); } catch (Exception exception) { logger.error("Could not clone DebugAtom: " + exception.getMessage(), exception); logger.debug(exception); } return clone; } public IChemObjectBuilder getBuilder() { return DebugChemObjectBuilder.getInstance(); } public String getStrandName() { logger.debug("Getting strand name: ", super.getStrandName()); return super.getStrandName(); } public String getStrandType() { logger.debug("Getting strand type: ", super.getStrandType()); return super.getStrandType(); } public void setStrandName(String cStrandName) { logger.debug("Setting strand name to: ", cStrandName); super.setStrandName(cStrandName); } public void setStrandType(String cStrandType) { logger.debug("Setting strand type to: ", cStrandType); super.setStrandType(cStrandType); } public void addAtom(IAtom oAtom, IMonomer oMonomer) { logger.debug("Adding atom to monomer: ", oAtom, oMonomer); super.addAtom(oAtom, oMonomer); } public int getMonomerCount() { logger.debug("Getting monomer count: ", super.getMonomerCount()); return super.getMonomerCount(); } public IMonomer getMonomer(String cName) { logger.debug("Getting monomer for String: ", cName); return super.getMonomer(cName); } public Collection getMonomerNames() { logger.debug("Getting monomer names"); return super.getMonomerNames(); } public void removeMonomer(String name) { logger.debug("Removing monomer by string: ", name); super.removeMonomer(name); } public Map getMonomers() { logger.debug("Getting monomers as hashtable"); return super.getMonomers(); } public void stateChanged(IChemObjectChangeEvent event) { logger.debug("Receiving state changed event: ", event); super.stateChanged(event); } } cdk-1.2.10/src/main/org/openscience/cdk/dict/CDKDictionaryReferences.java100644 0 0 13112 11570154753 23266 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.dict; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IElement; import org.openscience.cdk.interfaces.IIsotope; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IReaction; /** * This class transforms implicit references to dictionary of CDK * objects into explicit references. * *

The syntax of the property names used is as follows: * org.openscience.cdk.dict:self or * org.openscience.cdk.dict:field:'fieldname', where fieldname * indicates a field for this object. The name may be appended * by :'number' to allow for more than one reference. * * @author Egon Willighagen * @cdk.githash * @cdk.created 2003-08-06 * @cdk.keyword dictionary, implicit CDK references * @cdk.module dict */ public class CDKDictionaryReferences { private static String prefix = DictionaryDatabase.DICTREFPROPERTYNAME; public static void makeReferencesExplicit(IChemObject object) { if (object instanceof IAtom) { makeReferencesExplicitForAtom((IAtom)object); } else if (object instanceof IBond) { makeReferencesExplicitForBond((IBond)object); } else if (object instanceof IChemModel) { makeReferencesExplicitForChemModel((IChemModel)object); } else if (object instanceof IIsotope) { makeReferencesExplicitForIsotope((IIsotope)object); } else if (object instanceof IElement) { makeReferencesExplicitForElement((IElement)object); } else if (object instanceof IMolecule) { makeReferencesExplicitForMolecule((IMolecule)object); } else if (object instanceof IReaction) { makeReferencesExplicitForReaction((IReaction)object); } } private static void makeReferencesExplicitForAtom(IAtom atom) { int selfCounter = 0; atom.setProperty(prefix + ":self:" + selfCounter++, "chemical:atom"); makeReferencesExplicitForElement(atom); } private static void makeReferencesExplicitForBond(IBond bond) { int selfCounter = 0; bond.setProperty(prefix + ":self:" + selfCounter++, "chemical:covalentBond"); bond.setProperty(prefix + ":field:order", "chemical:bondOrder"); } private static void makeReferencesExplicitForChemModel(IChemModel model) { // NOPMD // nothing to do } private static void makeReferencesExplicitForElement(IElement element) { int selfCounter = 0; element.setProperty(prefix + ":field:symbol", "chemical:atomSymbol"); element.setProperty(prefix + ":field:atomicNumber", "chemical:atomicNumber"); if (element.getSymbol().equals("C")) { element.setProperty(prefix + ":self:" + selfCounter++, "element:carbon"); } else if (element.getSymbol().equals("N")) { element.setProperty(prefix + ":self:" + selfCounter++, "element:nitrogen"); } else if (element.getSymbol().equals("O")) { element.setProperty(prefix + ":self:" + selfCounter++, "element:oxygen"); } else if (element.getSymbol().equals("H")) { element.setProperty(prefix + ":self:" + selfCounter++, "element:hydrogen"); } else if (element.getSymbol().equals("S")) { element.setProperty(prefix + ":self:" + selfCounter++, "element:sulphur"); } else if (element.getSymbol().equals("P")) { element.setProperty(prefix + ":self:" + selfCounter++, "element:phosphorus"); } } private static void makeReferencesExplicitForIsotope(IIsotope isotope) { int selfCounter = 0; isotope.setProperty(prefix + ":self:" + selfCounter++, "chemical:isotope"); } private static void makeReferencesExplicitForMolecule(IMolecule molecule) { int selfCounter = 0; molecule.setProperty(prefix + ":self:" + selfCounter++, "chemical:molecularEntity"); /* remark: this is not strictly true... the Compendium includes the ion pair, which normally would not considered a CDK molecule */ } private static void makeReferencesExplicitForReaction(IReaction reaction) { int selfCounter = 0; reaction.setProperty(prefix + ":self:" + selfCounter++, "reaction:reactionStep"); } } cdk-1.2.10/src/main/org/openscience/cdk/dict/DictRef.java100644 0 0 4332 11570154753 20141 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2003-2008 Egon Willighagen * * 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 org.openscience.cdk.dict; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; /** * Object that can be used as key in IChemObject.setProperty(key, value) to * denote that this property is a dictionary reference for this IChemObject. * * @author Egon Willighagen * @cdk.created 2003-08-24 * @cdk.module standard * @cdk.githash */ @TestClass("org.openscience.cdk.dict.DictRefTest") public class DictRef implements java.io.Serializable, Cloneable { private static final long serialVersionUID = -3691244168587563625L; String type; String reference; public DictRef(String type, String dictRef) { this.type = type; this.reference = dictRef; } @TestMethod("testGetDictRef") public String getReference() { return reference; } @TestMethod("testGetType") public String getType() { return type; } @TestMethod("testToString") public String toString() { return "DictRef{T=" + this.type + ", R=" + reference +"}"; } } cdk-1.2.10/src/main/org/openscience/cdk/dict/Dictionary.java100644 0 0 10224 11570154753 20743 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.dict; import org.openscience.cdk.tools.LoggingTool; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.XMLReader; import org.xml.sax.helpers.XMLReaderFactory; import java.io.IOException; import java.io.Reader; import java.util.Enumeration; import java.util.Hashtable; /** * Dictionary with entries. * *

FIXME: this should be replace by a uptodate Dictionary Schema * DOM type thing. * * @author Egon Willighagen * @cdk.githash * @cdk.created 2003-08-23 * @cdk.keyword dictionary * @cdk.module dict */ public class Dictionary { private Hashtable entries; private String ownNS = null; public Dictionary() { entries = new Hashtable(); } public static Dictionary unmarshal(Reader reader) { LoggingTool logger = new LoggingTool(Dictionary.class); DictionaryHandler handler = new DictionaryHandler(); XMLReader parser = null; try { parser = XMLReaderFactory.createXMLReader(); logger.debug("Using "+parser); } catch (Exception e) { logger.error("Could not instantiate any JAXP parser!"); logger.debug(e); } try { if (parser == null) { logger.debug("parser object was null!"); return null; } parser.setFeature("http://xml.org/sax/features/validation", false); logger.debug("Deactivated validation"); } catch (SAXException e) { logger.warn("Cannot deactivate validation."); logger.debug(e); } parser.setContentHandler(handler); Dictionary dict = null; try { parser.parse(new InputSource(reader)); dict = handler.getDictionary(); } catch (IOException e) { logger.error("IOException: " + e.toString()); logger.debug(e); } catch (SAXException saxe) { logger.error("SAXException: " + saxe.getClass().getName()); logger.debug(saxe); } return dict; } public void addEntry(Entry entry) { entries.put(entry.getID().toLowerCase(), entry); } public Entry[] getEntries() { int size = entries.size(); Entry[] entryArray = new Entry[size]; Enumeration elements = entries.elements(); int counter = 0; while (elements.hasMoreElements() && counter < size) { entryArray[counter] = (Entry)elements.nextElement(); counter++; } return entryArray; } public boolean hasEntry(String identifier) { return entries.containsKey(identifier); } public Entry getEntry(String identifier) { return entries.get(identifier); } public int size() { return entries.size(); } public void setNS(String nameSpace) { ownNS = nameSpace; } public String getNS() { return ownNS; } } cdk-1.2.10/src/main/org/openscience/cdk/dict/DictionaryDatabase.java100644 0 0 15434 11570154753 22400 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.dict; import org.openscience.cdk.tools.LoggingTool; import java.io.InputStreamReader; import java.io.Reader; import java.util.Enumeration; import java.util.Hashtable; /** * Database of dictionaries listing entries with compounds, fragments * and entities. * * @author Egon Willighagen * @cdk.githash * @cdk.created 2003-04-06 * @cdk.keyword dictionary * @cdk.depends xom.jar * @cdk.module dict */ public class DictionaryDatabase { public final static String DICTREFPROPERTYNAME = "org.openscience.cdk.dict"; private LoggingTool logger; private String[] dictionaryNames = { "chemical", "elements", "descriptor-algorithms","reaction-processes" }; private String[] dictionaryTypes = { "xml", "owl", "owl", "owl_React" }; private Hashtable dictionaries; public DictionaryDatabase() { logger = new LoggingTool(this); // read dictionaries distributed with CDK dictionaries = new Hashtable(); for (int i=0; i listDictionaries() { return dictionaries.keys(); } /** * Returns true if the given dictionary contains the given * entry. */ public boolean hasEntry(String dictName, String entryID) { if (hasDictionary(dictName)) { Dictionary dictionary = (Dictionary)dictionaries.get(dictName); return dictionary.hasEntry(entryID.toLowerCase()); } else { return false; } } } cdk-1.2.10/src/main/org/openscience/cdk/dict/DictionaryHandler.java100644 0 0 7516 11570154753 22233 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2002-2007 The Chemistry Development Kit (CDK) project * * Contact: cdk-devel@lists.sf.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.dict; import org.xml.sax.Attributes; import org.xml.sax.helpers.DefaultHandler; /** * Class for unmarshalling a dictionary schema file. * * @cdk.module dict */ public class DictionaryHandler extends DefaultHandler { private boolean inEntry = false; private boolean inMetadataList = false; Entry entry; /** Used to store all chars between two tags */ private String currentChars; Dictionary dict; public DictionaryHandler() {} public void doctypeDecl(String name, String publicId, String systemId) throws Exception { } public void startDocument() { dict = new Dictionary(); } public void endElement(String uri, String local, String raw) { if ("entry".equals(local) && !"bibtex:entry".equals(raw) && inEntry) { dict.addEntry(entry); inEntry = false; } else if ("metadataList".equals(local) && inMetadataList) { inMetadataList = false; } } public void startElement(String uri, String local, String raw, Attributes atts) { currentChars = ""; if ("entry".equals(local) && !"bibtex:entry".equals(raw) && !inEntry) { inEntry = true; entry = new Entry(); for (int i = 0; i < atts.getLength(); i++) { if (atts.getQName(i).equals("id")) { entry.setID(atts.getValue(i)); } else if (atts.getQName(i).equals("term")) { entry.setLabel(atts.getValue(i)); } } } if ("metadataList".equals(local) && !inMetadataList) { inMetadataList = true; } // if we're in a metadataList then look at individual // metadata nodes and check for any whose content refers // to QSAR metadata and save that. Currently it does'nt // differentiate between descriptorType or descriptorClass. // Do we need to differentiate? // // RG: I think so and so I save a combination of the dictRef attribute // and the content attribute if ("metadata".equals(local) && inMetadataList) { for (int i = 0; i < atts.getLength()-1; i += 2) { String dictRefValue = ""; if (atts.getQName(i).equals("dictRef")) { dictRefValue = atts.getValue(i); } if (atts.getQName(i+1).equals("content")) { String content = atts.getValue(i+1); if (content.indexOf("qsar-descriptors-metadata:") == 0) { entry.setDescriptorMetadata(dictRefValue+"/"+content); } } } } } public void characters(char character[], int start, int length) { currentChars += new String(character, start, length); } public Dictionary getDictionary() { return dict; } } cdk-1.2.10/src/main/org/openscience/cdk/dict/Entry.java100644 0 0 6701 11570154753 17724 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.dict; import java.util.ArrayList; import java.util.List; /** * Entry in a Dictionary. * * @author Egon Willighagen * @cdk.githash * @cdk.created 2003-08-23 * @cdk.keyword dictionary * @cdk.module dict * * @see Dictionary */ public class Entry { private String className; private String label; private String identifier; private List descriptorInfo; private String definition; private String description; private Object rawContent; public Entry(String identifier, String term) { this.identifier = identifier.toLowerCase(); this.label = term; this.descriptorInfo = new ArrayList(); } public Entry(String identifier) { this(identifier, ""); } public Entry() { this("", ""); } public void setLabel(String term) { this.label = term; } public String getLabel() { return this.label; } public void setID(String identifier) { this.identifier = identifier.toLowerCase(); } public String getID() { return this.identifier; } public String getDefinition() { return this.definition; } public void setDefinition(String definition) { this.definition = definition; } public String getDescription() { return this.description; } public void setDescription(String description) { this.description = description; } public void setDescriptorMetadata(String metadata) { this.descriptorInfo.add( metadata ); } public List getDescriptorMetadata() { return this.descriptorInfo; } public String toString() { return "Entry[" + getID() + "](" + getLabel() + ")"; } /** * @return Returns the rawContent. */ public Object getRawContent() { return rawContent; } /** * @param rawContent The rawContent to set. */ public void setRawContent(Object rawContent) { this.rawContent = rawContent; } /** * @return Returns the className. */ public String getClassName() { return className; } /** * @param className The className to set. */ public void setClassName(String className) { this.className = className; } } cdk-1.2.10/src/main/org/openscience/cdk/dict/EntryReact.java100644 0 0 12215 11570154753 20720 0ustar 0 0 /* $RCSfile$ * $Author: rajarshi $ * $Date: 2007-10-22 02:38:43 +0200 (Mon, 22 Oct 2007) $ * $Revision: 9172 $ * * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.dict; import java.util.ArrayList; import java.util.HashMap; import java.util.List; /** * Entry in a Dictionary for reactions. * * @author Miguel Rojas * @cdk.created 2008-01-01 * @cdk.keyword dictionary * @cdk.module dict * * @see Dictionary */ public class EntryReact extends Entry{ private List reactionInfo; private List representations; private HashMap parameters; private List parametersValue; private List reactionExample; private List> parameterClass; private String mechanism; /** * Constructor of the EntryReact. * * @param identifier The ID value * @param term */ public EntryReact(String identifier, String term) { super(identifier, term); this.representations = new ArrayList(); this.parameters = new HashMap(); this.parametersValue = new ArrayList(); this.reactionExample = new ArrayList(); this.parameterClass = new ArrayList>(); } /** * Constructor of the EntryReact. * * @param identifier The ID value */ public EntryReact(String identifier) { this(identifier, ""); } public void setReactionMetadata(String metadata) { this.reactionInfo.add( metadata ); } public List getReactionMetadata() { return this.reactionInfo; } /** * Set the representation of the reaction. * * @param contentRepr The representation of the reaction as String */ public void setRepresentation(String contentRepr) { this.representations.add(contentRepr); } /** * Get the Representation of the reaction. * * @return A List of String of the reaction representations */ public List getRepresentations() { return this.representations; } /** * Set the parameters of the reaction. * * @param nameParam The parameter names of the reaction as String * @param typeParam The parameter types of the reaction as String * @param value The value default of the parameter */ public void setParameters(String nameParam, String typeParam, String value) { this.parameters.put(nameParam, typeParam); this.parametersValue.add(value); } /** * Get the parameters of the reaction. * * @return A HashMap with the parameters */ public HashMap getParameters() { return this.parameters; } /** * Get the IParameterReact's of the reaction. * * @return A String List with the parameter class */ public List> getParameterClass() { return this.parameterClass; } /** * Add a IParameterReact's of the reaction. * * @param param A String List containing the information about this parameter. */ public void addParameter(List param) { this.parameterClass.add(param); } /** * Get the parameter value of the reaction. * * @return A List with the parameter value */ public List getParameterValue() { return this.parametersValue; } /** * Set the mechanism of this reaction. * * @param mechani The mechanism */ public void setMechanism(String mechani) { this.mechanism = mechani; } /** * Get the mechanism of this reaction. * * @return The mechanism */ public String getMechanism() { return this.mechanism; } /** * add a example for this reaction. * * @param xml A reaction in XML scheme */ public void addExampleReaction(String xml) { this.reactionExample.add(xml); } /** * @return A List of reactions in XML schema. */ public List getExampleReactions() { return this.reactionExample; } } cdk-1.2.10/src/main/org/openscience/cdk/dict/OWLFile.java100644 0 0 11451 11570154753 20102 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.dict; import java.io.IOException; import java.io.Reader; import nu.xom.Attribute; import nu.xom.Builder; import nu.xom.Document; import nu.xom.Element; import nu.xom.Elements; import nu.xom.ParsingException; import org.openscience.cdk.tools.LoggingTool; /** * Dictionary with entries build from an OWL file. * * @author Egon Willighagen * @cdk.githash * @cdk.created 2005-11-18 * @cdk.keyword dictionary * @cdk.module dict * * @cdk.depends xom-1.0.jar */ public class OWLFile extends Dictionary { private static String rdfNS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; private static String rdfsNS = "http://www.w3.org/2000/01/rdf-schema#"; public OWLFile() { super(); } public static Dictionary unmarshal(Reader reader) { LoggingTool logger = new LoggingTool(OWLFile.class); Dictionary dict = new OWLFile(); try { Builder parser = new Builder(); Document doc = parser.build(reader); Element root = doc.getRootElement(); logger.debug("Found root element: ", root.getQualifiedName()); // Extract ownNS from root element // final String ownNS = root.getBaseURI(); final String ownNS = root.getBaseURI(); dict.setNS(ownNS); logger.debug("Found ontology namespace: ", ownNS); // process the defined facts Elements entries = root.getChildElements(); logger.info("Found #elements in OWL dict:", entries.size()); for (int i=0; i * @cdk.created 2008-01-01 * @cdk.keyword dictionary * @cdk.module dict * * @cdk.depends xom-1.0.jar */ public class OWLReact extends Dictionary { private static String rdfNS = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; private static String rdfsNS = "http://www.w3.org/2000/01/rdf-schema#"; /** * Constructor of the OWLReact object. */ public OWLReact() { super(); } /** * * @param reader The Reader * @return The Dictionary */ public static Dictionary unmarshal(Reader reader) { LoggingTool logger = new LoggingTool(OWLReact.class); Dictionary dict = new OWLReact(); try { Builder parser = new Builder(); Document doc = parser.build(reader); Element root = doc.getRootElement(); logger.debug("Found root element: ", root.getQualifiedName()); // Extract ownNS from root element // final String ownNS = root.getBaseURI(); final String ownNS = root.getBaseURI(); dict.setNS(ownNS); logger.debug("Found ontology namespace: ", ownNS); // process the defined facts Elements entries = root.getChildElements(); logger.info("Found #elements in OWL dict:", entries.size()); for (int i=0; i pp = new ArrayList(); pp.add(paramClass); pp.add(needsToSet); pp.add(dataType); pp.add(value); dbEntry.addParameter(pp); } } Elements mechanismDependence = entry.getChildElements("mechanismDependence", ownNS); String mechanism = ""; if (mechanismDependence != null) for(int i = 0 ; i< mechanismDependence.size(); i++){ mechanism = mechanismDependence.get(i).getAttribute(0).getValue(); mechanism = mechanism.substring(mechanism.indexOf("#")+1); logger.debug("mechanism name: ", mechanism); } dbEntry.setMechanism(mechanism); // System.out.println("mechan: "+mechan); Elements exampleReact = entry.getChildElements("example-Reactions", ownNS); if (exampleReact != null) for(int i = 0 ; i< exampleReact.size(); i++){ Elements reaction = exampleReact.get(i).getChildElements("reaction", ownNS); if (reaction != null) for(int j = 0 ; j< reaction.size(); j++){ dbEntry.addExampleReaction(reaction.get(0).toXML()); } } return dbEntry; } } cdk-1.2.10/src/main/org/openscience/cdk/dict/data/atom-type-mappings.owl100644 0 0 3526 11570154753 23151 0ustar 0 0 ]> Atom Type Mapping Ontology $Id$ Maps to Type Equivalent as Type cdk-1.2.10/src/main/org/openscience/cdk/dict/data/atom-types.owl100644 0 0 5661 11570154753 21522 0ustar 0 0 ]> Atom Type Ontology Data Types $Id$ has element cdk-1.2.10/src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl100644 0 0 146735 11570154753 22331 0ustar 0 0 ]> CDK Atom Type Ontology $Id$ A carbon atom type. A SP3 hybridized carbon. 0 0 4 0 0 2 0 2 0 3 0 1 1 3 0 0 1 2 0 1 -1 3 1 0 -1 3 1 0 0 3 0 0 1 0 2 0 1 1 0 1 0 2 1 -1 2 1 1 -1 1 1 2 1 1 0 2 0 2 2 0 0 1 2 0 1 0 1 2 1 0 1 2 1 0 2 2 0 1 2 1 1 1 1 1 1 1 1 1 1 2 1 3 1 0 1 2 1 0 1 -1 1 3 0 -1 1 3 0 -2 0 4 0 0 3 1 0 0 2 1 0 1 0 1 1 1 1 0 2 1 1 0 3 0 2 0 2 0 3 0 3 1 0 0 3 1 0 0 4 0 1 0 3 1 0 0 1 1 2 1 4 0 0 1 3 0 1 1 2 0 1 1 1 3 0 0 1 1 2 0 2 -1 2 2 0 -1 1 2 1 -1 2 2 0 3 0 2 0 1 2 1 0 2 2 0 0 2 0 2 0 2 3 2 1 2 1 1 0 2 2 0 -1 1 3 0 0 4 0 2 2 4 0 0 0 3 0 1 1 3 0 0 0 3 0 3 0 6 0 0 0 4 1 0 0 1 0 0 0 1 0 0 1 0 0 0 -1 0 0 0 0 0 0 0 1 0 1 3 0 0 0 3 0 1 -1 0 4 0 1 2 2 0 1 1 2 1 1 1 2 0 1 0 1 3 0 1 2 2 0 1 1 2 1 -1 0 4 0 0 0 3 0 1 1 1 2 0 1 0 4 0 3 3 4 0 0 0 3 0 2 0 1 3 0 -1 0 4 0 -1 2 3 0 1 1 2 1 0 2 1 1 0 3 0 2 1 2 2 0 0 0 3 0 1 1 1 2 0 1 0 1 3 0 -1 0 4 0 0 0 3 0 1 1 1 2 0 1 1 2 2 0 1 1 2 1 0 0 0 0 3 0 4 0 1 1 4 0 0 0 3 1 0 0 2 1 1 1 0 0 0 0 1 0 0 1 0 0 0 0 0 0 0 0 2 0 0 2 0 0 2 0 0 0 2 0 3 0 0 0 3 0 2 0 0 2 0 0 0 4 0 0 6 0 2 0 0 3 0 0 0 0 0 2 0 0 0 4 0 0 0 4 0 0 1 4 0 0 0 3 1 0 -1 2 0 0 2 0 0 2 0 2 0 0 2 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 0 0 0 0 -3 6 0 0 -3 6 0 0 -3 6 0 0 0 6 0 0 0 4 0 0 -2 4 0 0 -1 4 0 0 0 3 0 0 0 2 2 0 0 2 2 0 3 0 0 0 0 3 0 0 0 4 0 0 cdk-1.2.10/src/main/org/openscience/cdk/dict/data/cdk-sybyl-mappings.owl100644 0 0 41201 11570154753 23143 0ustar 0 0 ]> Atom Type Mapping Ontology $Id$ cdk-1.2.10/src/main/org/openscience/cdk/dict/data/chemical.xml100644 0 0 23717 11570154753 21206 0ustar 0 0 A dictionary of chemical concepts. Many entries refer to the entries in the "IUPAC Compendium of Chemical Terminology" (http://www.iupac.org/publications/compendium/) matching entry@term == 'term in compendium'. Copyright for the descriptions of these entries is given on the IUPAC website. The assembling of separate molecular entities into any aggregate. Smallest particle still characterizing a chemical element. One, two or three letters used to represent the atom in the chemical formulae. Entity that aggregates two atoms or groups of atoms by means of forces acting between them such that they lead to the formation of an aggregate with sufficient stability to make it convenient for the chemist to consider it as an independent 'molecular species'. Theoretical index of the degree of bonding between two atoms relative to that of a single bond. Entity that aggregates two atoms or groups of atoms by means of forces acting between them such that they lead to the formation of an aggregate with sufficient stability to make it convenient for the chemist to consider it as an independent 'molecular species'. A form of association between an electronegative atom and a hydrogen atom attached to a second, relatively electronegative atom. A conceptual bond between two ions. A pair of oppositely charged ions held together by Coulomb attraction without formation of a covalent bond. Isotopes are nuclides with the same specific atomic number but different mass number. The number of protons in the atomic nucleus. An electrically neutral entity consisting of more than one atom (n > 1). Rigorously, a molecule, in which n > 1 must correspond to a depression on the potential energy surface that is deep enough to confine at least on vibrational state. Any constitutionally or isotopically distinct atom, molecule, ion, ion pair, radical, radical ion, complex, conformer etc, identifiable as a separately distinguishable entity. Mass of the atom. The relative or percentual concentration of the isotope in a random, natural sample of the element. The concentration of the subject in a sample quantified by a number that indicates the relative amounts as compared with the other species in the sample. If a sample contains three species, and their relative concentrations are 100, 60, 40, then their percentual concentrations are 50, 30, 20. The concentration of the subject in a sample quantified by a percentage. The sum of the percentages of all specified in the sample sum up to 100%. If a sample contains three species, and their relative concentrations are 100, 60, 40, then their percentual concentrations are 50, 30, 20. cdk-1.2.10/src/main/org/openscience/cdk/dict/data/descriptor-algorithms.owl100644 0 0 321126 11570154753 24002 0ustar 0 0 ]> Descriptor Ontology $Id$ $Date$ $Author$ $Revision$ Add some comment here. A descriptor is an algorithm that operates on a chemical entity (commonly atoms and molecules) and returns a numerical (descriptor) value which described certain information on that entity. Descriptor Value One or more output values calculated by an Implementation of a certain Algorithm for a certain molecule. Is A Instance Of Is Classified As Requires has 2D Coordinates has 3D Coordinates has Fractional Unit Cell Coordinates Coordinates has Partial Atomic Charges Dietz Representation Graph Representation Representation in which atoms are represented by graph nodes and bonds by graph edges. Consequently, bonds are always localized between two atoms. Egon Willighagen Peter Murray-Rust Christian Hoppe Rajarshi Guha Todd Martin Matteo Floris Miguel Rojas Federico Marighetti DescriptorCategories 2005-11-18 Atomic Descriptors 2005-11-18 Molecular Descriptors 2005-11-18 Electronic Descriptors 2005-02-07 Descriptor relating to the electronic distribution in a molecule. Protein Descriptor 2006-11-02 A descriptor specifically designed for characterizing proteins Constitutional Descriptor 2005-02-07 Descriptor reflecting the molecular composition of a compound without connectivity and geometry information. Geometrical Descriptor 2005-02-07 Any descriptor derived from the three-dimensional structure of the molecule. Topological Descriptor 2005-02-07 Descriptor reflecting the molecular connectivity without geometry information. Amino Acid Count 2006-01-15 Returns the number of amino acids found in the system Atomic Polarizabilities 2004-11-26 Descriptor that calculates the sum of the atomic polarizabilities (including implicit hydrogens). Polarizabilities derive from periodic tables. Element Count 2004-11-26 Descriptor based on the number of atoms of a certain element type. Atomic Degree 2004-11-26 Descriptor that calculates the number of not-Hs substituents of an atom. Atomic Hybridization 2004-11-26 Descriptor that returns the hybridization state of an atom. Atomic Hybridization VSEPR 2006-05-08 Descriptor that returns the hybridization state of an atom. The calculation find a SIMPLE WAY the molecular geometry for following from Valence Shell Electron Pair Repulsion or VSEPR model and at the same time its hybridization of atoms in a molecule. Atomic Valence 2004-11-26 Descriptor that calculates the valence of an atom. Aromatic Atoms Count 2004-11-26 Descriptor based on the number of aromatic atoms of a molecule. Aromatic Bonds Count 2004-11-26 Descriptor based on the number of aromatic bonds of a molecule. Inductive atomic hardness 2005-04-21 This class calculates the atomic hardness of a given atom. Inductive atomic hardness of an atom in a polyatomic system can be defined as the resistance to a change of the atomic charge. This descriptor is described by Cherkasov . Inductive atomic softness 2005-04-21 This class calculates the atomic softness of a given atom. Inductive atomic softness of an atom in a polyatomic system can be defined as as charge delocalizing ability. This descriptor is described by Cherkasov . BCUT 2005-01-27 Eigenvalue based descriptor noted for its utility in chemical diversity described by Pearlman et al. . Bond Count 2004-11-26 Descriptor based on the number of bonds of a certain bond order. Bonds to Atom 2004-11-26 Descriptor based on the number of bonds on the shortest path between two atoms. Bond Polarizabilities 2004-11-26 Descriptor that calculates the sum of the absolute value of the difference between atomic polarizabilities of all bonded atoms in the molecule (including implicit hydrogens). Polarizabilities derive from periodic tables. Valence connectivity index (order 1) 2004-11-26 Descriptor that calculates atomic valence connectivity index (order 1). Let v i = ( v i - h i ) ( z i - h i - 1 ) , where p i is the numbers of valence electrons of atom i, h i is the number of hydrogens bonded to atom i, and z i is the atomic number of atom i. Valence connectivity is calculated as the sum of 1 ( v i v j ) 0.5 over all bonds between heavy atoms i and j. Valence carbon connectivity index (order 1) 2004-11-26 Descriptor that calculates carbon valence connectivity index (order 1). Let v i = ( v i - h i ) ( z i - h i - 1 ) , where p i is the numbers of valence electrons of atom i, h i is the number of hydrogens bonded to atom i, and z i is the atomic number of atom i. While the valence connectivity is calculated as the sum of 1 ( v i v j ) 0.5 over all bonds between heavy atoms i and j, the carbon valence connectivity index takes into account only bonds between carbon atoms. Valence connectivity index (order 0) 2004-11-26 Descriptor that calculates atomic valence connectivity index (order 0). Let v i = ( v i - h i ) ( z i - h i - 1 ) , where p i is the numbers of valence electrons of atom i, h i is the number of hydrogens bonded to atom i, and z i is the atomic number of atom i. Valence connectivity is calculated as the sum of 1 ( v i ) 0.5 over all heavy atoms i with v i greather than 0. Valence carbon connectivity index (order 0) 2004-11-26 Descriptor that calculates carbon valence connectivity index (order 0). Let v i = ( v i - h i ) ( z i - h i - 1 ) , where p i is the numbers of valence electrons of atom i, h i is the number of hydrogens bonded to atom i, and z i is the atomic number of atom i. While the atomic valence connectivity is calculated as the sum of 1 ( v i ) 0.5 over all heavy atoms i with v i greather than 0, the carbon valence connectivity index takes into account only carbon atoms with v i greather than 0. Carbon connectivity index (order 0) 2004-11-26 Descriptor that calculates the carbon connectivity index (order 0). While the atomic connectivity is calculated as the sum of 1 d i 0.5 over all heavy atoms i with degree greather than zero, carbon connectivity index takes into account only carbon atoms with degree greather than zero. Carbon connectivity index (order 1) 2004-11-26 Descriptor that calculates carbon connectivity index (order 1). While the atomic connectivity is calculated as the sum of 1 ( d i d j ) 0.5 over all bonds between heavy atoms i and j, the carbon connectivity index takes into account only bonds between carbon atoms. Distance to Atom 2004-11-26 Descriptor that calculates the 3D distance between two atoms. Effective Polarizability 2004-11-26 Descriptor that calculates the effective polarizability of a given heavy atom. Polarizabilities are assigned to the heavy atom by Polarizability class. Gravitational Index 2004-11-24 Descriptor characterizing the mass distribution of the molecule. This descriptor is described by Katritzky et al. . Gravitational Index (Square and Cube Roots) 2004-11-25 Descriptor characterizing the mass distribution of the molecule as the square or cube root of the gravitational index. This descriptor is described by Wessel et al. . Hydrogen Bond Acceptors 2004-11-26 Descriptor that calculates the number of hydrogen bond acceptors. As defined by Daylight website, , a H-bond acceptor is a heteroatom with no positive charge, note that negatively charged oxygen or sulphur are included. Excluded are halogens, including F, heteroaromatic oxygen, sulphur and pyrrole N. Higher oxidation levels of N,P,S are excluded. Note P(III) is currently included. Zeneca's work would imply that (O=S=O) shoud also be excluded. Hydrogen Bond Donors 2004-11-26 Descriptor that calculates the number of hydrogen bond donors. As defined by Daylight website, , a H-bond acceptor must have an N-H bond, an O-H bond, or a F-H bond Proton belonging to an aromatic system 2005-01-27 This Class contains a method that returns 1 if the protons is directly bonded to an aromatic system, it returns 2 if the distance between aromatic system and proton is 2 bonds, and 0 for other positions. Proton belonging to a pi-system 2005-01-27 This Class contains a method that returns true if the protons is directly bonded to a pi system. Kier and Hall kappa molecular shape indices 2004-11-26 Descriptor that calculates Kier and Hall kappa molecular shape indices. Kier and Hall kappa molecular shape indices compare the molecular graph with minimal and maximal molecular graphs. First kappa shape index is given by n ( n - 1 ) 2 m 2 , second kappa shape index is given by ( n - 1 ) ( n - 2 ) 2 p 2 2 and third kappa shape index is given by ( n - 1 ) ( n - 3 ) 2 p 3 2 for odd n and ( n - 3 ) ( n - 2 ) 2 p 3 2 for enev n, where n denotes the number of atoms in the hydrogen suppressed graph, m is the number of bonds in the hydrogen suppressed graph. Also, let p2 denote the number of paths of length 2 and let p3 denote the number of paths of length 3 Largest Chain 2005-02-07 Returns the number of atoms in the largest chain Largest Pi Chain 2005-02-07 Returns the number of atoms in the largest pi chain Lipinski's Rule of Five 2005-01-27 This Class contains a method that returns the number failures of the Lipinski's Rule Of Five. The Rule of 5 got its name from the cutoff values for each of the four parameters that define the potential of a drug candidate for good absorption: all of these values are close to five or a multiple of five. The original definition, given by Christopher A. Lipinski, says that poor absorption (or permeation) is more likely when: the molecule has more than 5 H-bond donors and more than 10 H-bond acceptors; its molecular weight is over 500. its LogP is over 5; Longest Aliphatic Chain 2005-02-07 Returns the number of atoms in the longest aliphatic chain Moments of Inertia 2005-02-07 Descriptor that calculates the principal moments of inertia and ratios of the principal moments. Als calculates the radius of gyration. Partial Pi Charge 2006-05-08 Descriptor that calculates pi partial charges in pi-bonded systems of an heavy atom. Calculation is based on Gasteiger H.Saller (PEPE) . Partial Pi Charge 2006-05-08 Descriptor that calculates sigma partial charges in sigma-bonded systems (PEOE) of an heavy atom. Calculation is based on Gasteiger Marsili (PEOE) . Partial Total Charge (MMFF94) 2006-05-08 Descriptor that calculates total partial charges of an heavy atom. Calculation is based on MMFF94. Period of an atom 2005-02-07 Descriptor that returns the period in the periodic table of an atom belonging to an atom container Petitjean Number 2005-02-07 Descriptor that calculates the Petitjean Number of a molecule. According to the Petitjean definition, the eccentricity of a vertex corresponds to the distance from that vertex to the most remote vertex in the graph. The distance is obtained from the distance matrix as the count of edges between the two vertices. If r i is the largest matrix entry in row i of the distance matrix D, then the radius is defined as the smallest of the r i . The graph diameter D is defined as the largest vertex eccentricity in the graph. Petitjean Number is the value of ( diameter - radius ) diameter . Pi-contact of two atoms 2005-02-07 Descriptor that check if two atoms have pi-contact (this is true when there is one and the same conjugated pi-system which contains both atoms, or directly linked neighboors of the atoms). Pi Electronegativity 2006-05-08 This algorithm contains a method that returns the pi electronegativity for a given atom. Pi electronegativity is given by X = a + b q + c ( q 2 ) , where a, b and c are Gasteiger Marsili parameters, and q is the sigma charge. Proton Total Partial Charge 2005-02-07 Descriptor that calculates partial charges of an heavy atom and its protons. Calculation is based on Gasteiger Marsili (PEOE) RDF Proton Descriptor 2005-01-27 Calculation of RDF proton descriptor based on . A given proton is represented by 5 different descriptors. The first one has the form g H r p i e - B ( r - r i ) 2 where i denotes an atom up to four not rotatable bonds away from the target proton, p is the partial atomic charge of the atom i, B is a smoothing parameter, r i is the 3D distance between proton and atom i, and r is a running variable. The second one is a topological form of the first one, where i is an atom up to the fifth sphere, p i is the partial atomic charge of atom i, and r i is now the sum of bond length on the shortest path between the proton and atom i. The third one has the form g D r 1 r D,i 2 e - B ( r - a D,i ) 2 where i denotes a double bond up to the seventh sphere of nonrotatable bonds centered on the target proton, and r D and a D are geometric variables. The fourth one has the form g S r 1 r S,i 2 e - B ( r - a S,i ) 2 where i denotes a single bond up to the seventh sphere of nonrotatable bonds centered on the target proton, and r S and a S are geometric variables. The last one has the form g 3 r e - B ( r - a 3,i ) 2 where i denotes an atom three nonrotatable bonds away from the target proton and belonging to a six-membered ring, and a 3 is a dihedral angle in radian units. Each values is returned as atom property. Rotatable Bonds Count 2005-02-07 Descriptor that calculates the number of nonrotatable bonds on a molecule. The number of rotatable bonds is given by the SMARTS specified by Daylight on . Sigma Electronegativity 2005-02-07 This Class contains a method that returns the sigma electronegativity for a given atom. Sigma electronegativity is given by X = a + b q + c ( q 2 ) , where a, b and c are Gasteiger Marsili parameters, and q is the sigma charge. Topological Polar Surface Area 2005-01-27 Calculation of topological polar surface area based on fragment contributions . Molecular Weight 2005-01-27 Descriptor based on the weight of atoms of a certain element type. If no element is specified, the returned value is the Molecular Weight WHIM 2005-01-27 Holistic descriptors described by Todeschini et al . Wiener Numbers 2005-01-27 This class calculates Wiener path number and Wiener polarity number. Wiener path number: half the sum of all the distance matrix entries. Wiener polarity number: half the sum of all the distance matrix entries with a value of 3. Vertex adjacency information magnitude 2004-11-26 Descriptor that calculates the vertex adjacency information of a molecule. The values is given by 1 + log 2 * m , where m is the number of heavy-heavy bonds. If m is zero, then zero is returned. Van der Waals radius 2005-01-27 Descriptor that returns the VdW radius of a given atom. XLogP 2005-01-27 Prediction of logP based on the atom-type method called XLogP. For a description of the methodology see . ALogP 2005-01-27 Calculates atom additive logP and molar refractivity values as described by Ghose and Crippen and Zagreb Index 2004-11-26 The sum of the squared atom degrees of all heavy atoms. Covalent Radius 2006-05-08 Descriptor that returns the covalent radius of a given atom. Bond Partial Pi Charge 2006-05-08 Descriptor that calculates bond-pi Partial charge of a bond. Calculation is calculated determining the difference the Partial Pi Charge on atoms A and B of a bond. Based in Gasteiger Charge. Bond Partial Sigma Charge 2006-05-08 Descriptor that calculates bond-sigma Partial charge of a bond. Calculation is calculated determining the difference the Partial Sigma Charge on atoms A and B of a bond. Based in Gasteiger Charge. Bond Partial Total Charge 2006-05-08 Descriptor that calculates bond-total Partial charge of a bond. Calculation is calculated determining the difference the Partial Total Charge on atoms A and B of a bond. Based in Gasteiger Charge. Bond Sigma Electronegativity 2006-05-08 Descriptor that calculates of bond-Polarizability of a bond. Calculation is calculated determining the difference the Sigma electronegativity on atoms A and B of a bond. Petitjean Shape Indices 2006-01-15 The topological and geometric shape indices described Petitjean and Bath et al. respectively. Both measure the anisotropy in a molecule. Eccentric Connectivity Index 2005-03-19 A topological descriptor combining distance and adjacency information. The eccentric connectivity index for a hydrogen supressed molecular graph is given by the expression ξ c = i = 1 n E i V i where E(i) is the eccentricity of the i th atom (path length from the i th atom to the atom farthest from it) and V(i) is the vertex degree of the i th atom. Charged Partial Surface Areas 2005-05-16 A variety of descriptors combining surface area and partial charge information Fragment Complexity 2006-8-22 Class that returns the complexity of a system. The complexity is defined as @cdk.cite{Nilakantan06} Weighted path descriptors 2006-01-15 The weighted path (molecular ID) descriptors described by Randic. They characterize molecular branching. Moreau-Broto Autocorrelation (charge) descriptors 2006-01-15 The Moreau-Broto autocorrelation descriptors using partial charges Moreau-Broto Autocorrelation (polarizability) descriptors 2006-01-15 The Moreau-Broto autocorrelation descriptors using polarizability Moreau-Broto Autocorrelation (mass) descriptors 2006-01-15 The Moreau-Broto autocorrelation descriptors using atomic weight TAE RECON descriptors for amino acid sequences 2006-08-23 The TAE RECON descriptors for amino acid sequences. Uses precalculated quantum mechanical parameters to generate a set of 147 descriptors for a given sequence Molecular Distance Edge 2006-09-18 Evaluate molecular distance edge descriptors for C, N and O For a description of the methodology see . Length Over Breadth 2006-09-26 Calculates the ratio of length to breadth. The descriptor has two values indicating the maximum and minimumn value of LoB. Note that this method does not perform any orientation. Chi Chain Indices 2006-11-12 Evaluates the Kier & Hall Chi chain indices of orders 3,4,5 and 6 Both the simple and valence versions of this descriptor are evaluated Chi Path Indices 2006-11-12 Evaluates the Kier & Hall Chi path indices of orders 0,1,2,3,4,5,6 and 7 Both the simple and valence versions of this descriptor are evaluated Chi Cluster Indices 2006-11-13 Evaluates the Kier & Hall Chi cluster indices of orders 3,4,5,6 and 7 Both the simple and valence versions of this descriptor are evaluated Chi Path-Cluster Indices 2006-11-13 Evaluates the Kier & Hall Chi path cluster indices of orders 4,5 and 6 Both the simple and valence versions of this descriptor are evaluated Carbon Types 2006-09-26 Characterizes the carbon connectivity in terms of hybridization This is a port of the ADAPT CTYPES routine and is a count of carbon atom in different hybridization states and environments Kier & Hall SMARTS 2006-09-26 Counts the number of occurrences of the E-state fragments Traditionally, the E-state indices are obtained by identifying a set of fragments and then evaluating the E-state index from them. However it has been shown by Butina (Molecules, 2004, 9, 1004-1009) that the frequency of occurrence of the fragments can lead to QSAR models that perform as well as those based on the original E-state indices. This descriptor generates counts for 35 fragments. Descriptor names are prefixed with "khs." Ionization Potential 2006-01-15 Descriptor that evaluates the ionization potential. It should be noted that the descriptor values are obtained using a predictive model and are not calculated directly from the structure Bath, P.A. and Poirette, A.R. and Willet, P. and Allen, F.H. The Extent of the Relationship between the Graph-Theoretical and the Geometrical Shape Coefficients of Chemical Compounds Journal of Chemical Information and Computer Science 1995 35 714-716 Cherkasov, A. Inductive Electronegativity Scale. Iterative Calculation of Inductive Partial Charges J. Chem. Inf. Comput. Sci. 2003 43 2039-2047 10.1021/ci034147w Daylight SMILES on-line tutorial http://www.daylight.com/dayhtml_tutorials/languages/smarts/smarts_examples.html Ertl, P. and Rohde, B. and Selzer, P. Fast Calculation of Molecular Polar Surface Area as a Sum of Fragment-Based Contributions and Its Application to the Prediction of Drug Transport Properties J. Med. Chem. 2000 43 20 3714-3717 10.1021/jm000942e Aires-de-Sousa, J. and Hemmer, M.C. and Gasteiger, J. Prediction of 1H NMR Chemical Shifts Using Neural Networks Anal. Chem. 2002 74 1 80-90 10.1021/ac010737m Katritzky, A.R. and Mu, L. and Lobanov, V.S. and Karelson, M. Correlation of Boiling Points With Molecular Structure. 1. A Training Set of 298 Diverse Organics and a Test Set of 9 Simple Inorganics J. Phys. Chem. 1996 100 10400-10407 Liu, S. and Cao, C. and Li, Z. Approach to Estimation and Prediction for Normal Boiling Point (NBP) of Alkanes Based on a Novel Molecular Distance Edge (MDE) Vector, lambda Journal of Chemical Information and Computer Sciences i1998 38 387-394 Gasteiger, J. Marsili, M. Iterative Partial Equalization of Orbital Electronegativity- A Rapid Access to Atomic Charges Tetrahedron 1980 36 3219-3228 Pearlman, R.S. and Smith, K.M. Metric Validation and the Receptor-Relevant Subspace Concept J. Chem. Inf. Comput. Sci. 1999 39 1 28-35 Petitjean, M. Applications of the radius-diameter diagram to the classification of topological and geometrical shapes of chemical compounds Journal of Chemical Information and Computer Science 1992 32 331-337 Randic, M. On molecular identification numbers Journal of Chemical Information and Computer Science 1984 24 164-175 Gasteiger, J. Saller, H. Berechnung der Ladungsverteilung in konjugierten Systemen durch eine Quantifizierung des Mesomeriekonzeptes Angew. Chem. 1985 97 699-701 Todeschini, R. and Gramatica, P. New 3D Molecular Descriptors: The WHIM theory and QAR Applications Persepectives in Drug Discovery and Design 1998 355-380 Trinijastic, N. Chemical Graph Theory CRC Press 1992 0-8493-4256-2 Wang, R., Fu, Y., and Lai, L. A New Atom-Additive Method for Calculating Partition Coefficients Journal of Chemical Information and Computer Sciences 1997 37 615-621 Wessel, M.D. and Jurs, P.C. and Tolan, J.W. and Muskal, S.M. Prediction of Human Intestinal Absorption of Drug Compounds From Molecular Structure Journal of Chemical Information and Computer Sciences 1998 38 726-735 cdk-1.2.10/src/main/org/openscience/cdk/dict/data/elements.owl100644 0 0 44163 11570154753 21254 0ustar 0 0 ]> Chemical Elements Ontology $Id$ Chemical Element hydrogen waterstof hidrógeno helium helium helio lithium lithium litio beryllium boron carbon koolstof carbono nitrogen oxygen zuurstof fluorine fluoride neon neon sodium natrium magnesium magnesium aluminum aluminium silicon silicium phosphorus fosfor sulfur zwavel chlorine chloride argon argon potassium kalium calcium calcium scandium titanium vanadium chromium chroom manganese iron ijzer cobalt nickel nikkel copper koper zinc zink gallium germanium arsenic arseen selenium bromine bromide krypton rubidium strontium yttrium zirconium niobium molybdenum technetium ruthenium rhodium palladium silver zilver cadmium indium tin antimony tellurium iodine xenon cesium barium lanthanum cerium praseodymium neodymium promethium samarium europium gadolinium terbium dysprosium holmium erbium thulium ytterbium lutetium hafnium tantalum tungsten wolfraam rhenium osmium iridium platinum platina gold goud mercury kwik thallium lead lood bismuth polonium astatine radon francium radium actinium thorium protactinium uranium uraan neptunium plutonium americium curium berkelium californium einsteinium fermium mendelevium nobelium lawrencium rutherfordium dubnium seaborgium bohrium hassium meitnerium darmstadtium roentgenium ununbium cdk-1.2.10/src/main/org/openscience/cdk/dict/data/reaction-processes.owl100644 0 0 110651 11570154753 23264 0ustar 0 0 ]> Reaction Ontology $Id: reaction-processes.owl 9612 2008-02-14 21:44:28Z miguelrojasch $ $Date: 2008-02-28 22:44:28 +0100 (Fri, 28 Feb 2008) $ $Author: Miguel Rojas-Cherto $ $Revision: 9612 $ Add some comment here. A process is o reaction or a serial of them that operates on a chemical entity (commonly molecules and agents) and returns a IReaction object which described the products and reactants taking part. Descriptor Value One or more output values calculated by an Implementation of a certain Algorithm for a certain molecule. Is A Instance Of Is Classified As Requires Some processes can require some extra information. Constraints Possible constraints for processes. Smiles Representation Smiles representation of the reaction process. has 3D Coordinates has Active Center search On Library Search of equivalent structures into a Library. predictReactivity Predict the reactivity of a reaction according some descriptor value. Egon Willighagen Miguel Rojas-Cherto DescriptorCategories 2007-02-28 Electron Impact 2007-02-28 Mechanisms 2007-02-28 2007-02-28 2007-02-28 2007-02-28 2007-02-28 2007-02-28 2007-02-28 2007-02-28 2007-02-28 Removing Single Electrons of Non-Bonding 2007-02-28 2007-02-28 2007-02-28 Adduction Proton from Lone Pair Orbitals 2007-02-28 false null 2 1 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null Electron Impact Reaction for Non-Bonding Electrons 2007-02-28 This reaction is the process generated in mass spectrometry when is applied an electron impact technique in non-bonding electrons. The process extract an electron from orbitals which doesn't take part in a bond. The resulting product is the atom with a electron less. It is symbolized with +· meaning that it contains a radical and is deficiency of charge. false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null 2007-02-28 false null cdk-1.2.10/src/main/org/openscience/cdk/dict/data/sybyl-atom-types.owl100644 0 0 32541 11570154753 22677 0ustar 0 0 ]> Sybyl Atom Type Ontology $Id$ 0 0 4 0 3 0 1 3 0 1 2 0 2 3 1 0 2 1 1 1 1 2 2 2 0 1 2 1 4 0 1 1 0 0 3 1 0 1 4 0 0 2 1 1 3 1 0 1 1 2 2 0 1 2 1 cdk-1.2.10/src/main/org/openscience/cdk/event/ChemObjectChangeEvent.java100644 0 0 3532 11570154753 23133 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 Christoph Steinbeck * * 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 org.openscience.cdk.event; import org.openscience.cdk.interfaces.IChemObjectChangeEvent; /** * Event fired by cdk classes to their registered listeners * in case something changes within them. * * @cdk.module data * @cdk.githash */ public class ChemObjectChangeEvent extends java.util.EventObject implements IChemObjectChangeEvent { private static final long serialVersionUID = 5418604788783986725L; /** * Constructs a ChemObjectChangeEvent with a reference * to the object where it originated. * * @param source The reference to the object where this change event originated */ public ChemObjectChangeEvent(Object source) { super(source); } } cdk-1.2.10/src/main/org/openscience/cdk/event/ICDKChangeListener.java100644 0 0 3213 11570154753 22342 0ustar 0 0 /* CDKChangeListener.java * * $RCSfile$ $Author$ $Date$ $Revision$ * * Copyright (C) 1997-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.event; import java.util.EventListener; import java.util.EventObject; /** * A ChangeListener for the CDK, to be independent from the Swing package. * * @cdk.module standard * @cdk.githash */ public interface ICDKChangeListener extends EventListener { /** * Invoked when the target of the listener has changed its state. * * @param event The EventObject */ void stateChanged(EventObject event); } cdk-1.2.10/src/main/org/openscience/cdk/event/ICDKSelectionChangeListener.java100644 0 0 3224 11570154753 24212 0ustar 0 0 /* CDKChangeListener.java * * $RCSfile$ $Author$ $Date$ $Revision$ * * Copyright (C) 1997-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.event; import java.util.EventListener; import java.util.EventObject; /** * A ChangeListener for the CDK, to be independent from the Swing package. * * @cdk.module standard * @cdk.githash */ public interface ICDKSelectionChangeListener extends EventListener { /** * Invoked when the target of the listener has changed its state. * * @param event The EventObject */ void stateChanged(EventObject event); } cdk-1.2.10/src/main/org/openscience/cdk/exception/CDKException.java100644 0 0 4370 11570154753 22156 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 Christoph Steinbeck * * 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 org.openscience.cdk.exception; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; /** * Exception that is thrown by CDK classes when some problem has occured. * * @cdk.module core * @cdk.githash */ @TestClass("org.openscience.cdk.exception.CDKExceptionTest") public class CDKException extends Exception { private static final long serialVersionUID = 8371328769230823678L; /** * Constructs a new CDKException with the given message. * * @param message for the constructed exception */ @TestMethod("testCDKException_String") public CDKException(String message) { super( message ); } /** * Constructs a new CDKException with the given message and the * Exception as cause. * * @param message for the constructed exception * @param cause the Throwable that triggered this CDKException */ @TestMethod("testCDKException_String_Throwable") public CDKException(String message, Throwable cause) { super(message, cause); } } cdk-1.2.10/src/main/org/openscience/cdk/exception/IncorrectUseOfCDKCoreClassError.java100644 0 0 3152 11570154753 25720 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.exception; /** * Error that is thrown by debug implementations of the core CDK classes. * * @author Egon Willighagen * @cdk.githash * @cdk.created 2003-08-07 */ public class IncorrectUseOfCDKCoreClassError extends Error { private static final long serialVersionUID = 5307727155023470782L; public IncorrectUseOfCDKCoreClassError(String message) { super( message ); } } cdk-1.2.10/src/main/org/openscience/cdk/exception/InvalidSmilesException.java100644 0 0 3335 11570154753 24320 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.exception; import org.openscience.cdk.annotations.TestClass; /** * @cdk.module standard * @cdk.githash */ @TestClass("org.openscience.cdk.exception.InvalidSmilesExceptionTest") public class InvalidSmilesException extends CDKException { private static final long serialVersionUID = 1932255464874201495L; public InvalidSmilesException(String message) { super(message); } public InvalidSmilesException(String message, Exception exception) { super(message, exception); } } cdk-1.2.10/src/main/org/openscience/cdk/exception/NoSuchAtomException.java100644 0 0 3673 11570154753 23602 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2001-2007 The Chemistry Development Kit (CKD) project * * 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 I ask is that proper credit is given for my 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.exception; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; /** * Exception that is thrown when an Atom is requested or required that * does not exist in the relevant environment. * * @cdk.module core * @cdk.githash */ @TestClass("org.openscience.cdk.exception.NoSuchAtomExceptionTest") public class NoSuchAtomException extends CDKException { private static final long serialVersionUID = -6367051798808824272L; /** * Constructs a new NoSuchAtomException with the given message. * * @param message for the constructed exception */ @TestMethod("testNoSuchAtomException_String") public NoSuchAtomException(String message) { super( message ); } } cdk-1.2.10/src/main/org/openscience/cdk/exception/NoSuchAtomTypeException.java100644 0 0 3716 11570154753 24442 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 Christoph Steinbeck * * 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 org.openscience.cdk.exception; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; /** * Exception that may be thrown when an atom type is looked up or perceived * but no such atom type was found. * * @cdk.module core * @cdk.githash */ @TestClass("org.openscience.cdk.exception.NoSuchAtomTypeExceptionTest") public class NoSuchAtomTypeException extends CDKException { private static final long serialVersionUID = 2689048410917221667L; /** * Constructs a new NoSuchAtomTypeException. * * @param message Message explaining why the atom type could not be found */ @TestMethod("testNoSuchAtomTypeException_String") public NoSuchAtomTypeException(String message) { super( message ); } } cdk-1.2.10/src/main/org/openscience/cdk/exception/UnsupportedChemObjectException.java100644 0 0 3164 11570154753 26031 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2001-2007 The Chemistry Development Kit (CKD) project * * 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 I ask is that proper credit is given for my 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.exception; import org.openscience.cdk.annotations.TestClass; /** * @cdk.module standard * @cdk.githash */ @TestClass("org.openscience.cdk.exception.UnsupportedChemObjectExceptionTest") public class UnsupportedChemObjectException extends CDKException { private static final long serialVersionUID = -5348883360384907383L; public UnsupportedChemObjectException(String message) { super( message ); } } cdk-1.2.10/src/main/org/openscience/cdk/fingerprint/EStateFingerprinter.java100644 0 0 6603 11570154753 24154 0ustar 0 0 /* $Revision: 11674 $ $Author: rajarshi $ $Date: 2008-07-20 22:05:08 -0400 (Sun, 20 Jul 2008) $ * * Copyright (C) 2008 Rajarshi Guha * * 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 org.openscience.cdk.fingerprint; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.fragments.EStateFragments; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.smiles.smarts.SMARTSQueryTool; import java.util.BitSet; /** * This fingerprinter generates 79 bit fingerprints using the E-State fragments. * *

The E-State fragments are those described in {@cdk.cite HALL1995} and the SMARTS * patterns were taken from RDKit. Note that this * fingerprint simply indicates the presence or occurrence of the fragments. If you need * counts of the fragments take a look at {@link org.openscience.cdk.qsar.descriptors.molecular.KierHallSmartsDescriptor}, * which also lists the substructures corresponding to each bit position. * *

This class assumes that aromaticity perception and atom typing have been performed * prior to generating the fingerprint * * @author Rajarhi Guha * @cdk.created 2008-07-23 * * @cdk.keyword fingerprint * @cdk.keyword similarity * @cdk.keyword estate * * @cdk.module fingerprint * @cdk.githash */ @TestClass("org.openscience.cdk.fingerprint.EStateFingerprinterTest") public class EStateFingerprinter implements IFingerprinter { private static final String[] patterns = EStateFragments.getSmarts(); @TestMethod("testFingerprint,testGetSize") public EStateFingerprinter() { } /** * Calculates the substructure fingerprint for the given AtomContainer. */ @TestMethod("testFingerprint") public BitSet getFingerprint(IAtomContainer atomContainer) throws CDKException { int bitsetLength = patterns.length; BitSet fingerPrint = new BitSet(bitsetLength); SMARTSQueryTool sqt = new SMARTSQueryTool("C"); for (int i = 0; i < patterns.length; i++) { sqt.setSmarts(patterns[i]); boolean status = sqt.matches(atomContainer); if (status) fingerPrint.set(i, true); } return fingerPrint; } @TestMethod("testGetSize") public int getSize() { return patterns.length; } }cdk-1.2.10/src/main/org/openscience/cdk/fingerprint/ExtendedFingerprinter.java100644 0 0 14036 11570154753 24546 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2002-2007 Stefan Kuhn * * 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 org.openscience.cdk.fingerprint; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IRingSet; import org.openscience.cdk.ringsearch.RingPartitioner; import org.openscience.cdk.ringsearch.SSSRFinder; import org.openscience.cdk.tools.manipulator.MolecularFormulaManipulator; import java.util.BitSet; import java.util.List; /** * Generates an extended fingerprint for a given {@link IAtomContainer}, that * extends the {@link Fingerprinter} with additional bits describing ring * features. * * @author shk3 * @cdk.created 2006-01-13 * @cdk.keyword fingerprint * @cdk.keyword similarity * @cdk.module fingerprint * @cdk.githash * * @see org.openscience.cdk.fingerprint.Fingerprinter */ @TestClass("org.openscience.cdk.fingerprint.ExtendedFingerprinterTest") public class ExtendedFingerprinter implements IFingerprinter { private final int RESERVED_BITS = 25; private Fingerprinter fingerprinter = null; /** * Creates a fingerprint generator of length DEFAULT_SIZE * and with a search depth of DEFAULT_SEARCH_DEPTH. */ public ExtendedFingerprinter() { this(Fingerprinter.DEFAULT_SIZE, Fingerprinter.DEFAULT_SEARCH_DEPTH); } public ExtendedFingerprinter(int size) { this(size, Fingerprinter.DEFAULT_SEARCH_DEPTH); } /** * Constructs a fingerprint generator that creates fingerprints of * the given size, using a generation algorithm with the given search * depth. * * @param size The desired size of the fingerprint * @param searchDepth The desired depth of search */ public ExtendedFingerprinter(int size, int searchDepth) { this.fingerprinter = new Fingerprinter(size-RESERVED_BITS, searchDepth); } /** * Generates a fingerprint of the default size for the given AtomContainer, using path and ring metrics * It contains the informations from getFingerprint() and bits which tell if the structure has 0 rings, 1 or less rings, * 2 or less rings ... 10 or less rings (referring to smallest set of smallest rings) and bits which tell if * there is a fused ring system with 1,2...8 or more rings in it * *@param container The AtomContainer for which a Fingerprint is generated */ @TestMethod("testGetFingerprint_IAtomContainer") public BitSet getFingerprint(IAtomContainer container) throws CDKException { return this.getFingerprint(container,null,null); } /** * Generates a fingerprint of the default size for the given AtomContainer, using path and ring metrics * It contains the informations from getFingerprint() and bits which tell if the structure has 0 rings, 1 or less rings, * 2 or less rings ... 10 or less rings and bits which tell if there is a fused ring system with 1,2...8 or more rings in it * The RingSet used is passed via rs parameter. This must be a smallesSetOfSmallestRings. * The List must be a list of all ring systems in the molecule. * *@param atomContainer The AtomContainer for which a Fingerprint is generated *@param ringSet An SSSR RingSet of ac (if not available, use getExtendedFingerprint(AtomContainer ac), which does the calculation) *@param rslist A list of all ring systems in ac *@exception CDKException Description of the Exception * @return a BitSet representing the fingerprint */ @TestMethod("testGetFingerprint_IAtomContainer_IRingSet_List") public BitSet getFingerprint(IAtomContainer atomContainer, IRingSet ringSet, List rslist) throws CDKException { IAtomContainer container; try { container = (IAtomContainer) atomContainer.clone(); } catch (CloneNotSupportedException e) { throw new CDKException("Could not clone input"); } BitSet bitSet = fingerprinter.getFingerprint(container); int size = this.getSize(); double weight = MolecularFormulaManipulator.getTotalNaturalAbundance(MolecularFormulaManipulator.getMolecularFormula(container)); for(int i=1;i<11;i++){ if(weight>(100*i)) bitSet.set(size-26+i); // 26 := RESERVED_BITS+1 } if(ringSet==null){ ringSet=new SSSRFinder(container).findSSSR(); rslist=RingPartitioner.partitionRings(ringSet); } for(int i=0;i<7;i++){ if(ringSet.getAtomContainerCount()>i) bitSet.set(size-15+i); // 15 := RESERVED_BITS+1+10 mass bits } int maximumringsystemsize=0; for(int i=0;imaximumringsystemsize) maximumringsystemsize=((IRingSet)rslist.get(i)).getAtomContainerCount(); } for(int i=0;i * * 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 org.openscience.cdk.fingerprint; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.aromaticity.CDKHueckelAromaticityDetector; import org.openscience.cdk.config.Symbols; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.graph.PathTools; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IPseudoAtom; import org.openscience.cdk.ringsearch.AllRingsFinder; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.manipulator.AtomContainerManipulator; import java.util.*; /** * Generates a fingerprint for a given AtomContainer. Fingerprints are * one-dimensional bit arrays, where bits are set according to a the occurrence * of a particular structural feature (See for example the Daylight inc. theory * manual for more information). Fingerprints allow for a fast screening step to * exclude candidates for a substructure search in a database. They are also a * means for determining the similarity of chemical structures.

* * A fingerprint is generated for an AtomContainer with this code:

 *   Molecule molecule = new Molecule();
 *   BitSet fingerprint = Fingerprinter.getFingerprint(molecule);
 *   fingerprint.size(); // returns 1024 by default
 *   fingerprint.length(); // returns the highest set bit
 * 

* * The FingerPrinter assumes that hydrogens are explicitly given! Furthermore, if * pseudo atoms or atoms with malformed symbols are present, their atomic number is * taken as one more than the last element currently supported in {@link org.openscience.cdk.config.Symbols}. * * Warning: The aromaticity detection for this * FingerPrinter relies on AllRingsFinder, which is known to take very long * for some molecules with many cycles or special cyclic topologies. Thus, the * AllRingsFinder has a built-in timeout of 5 seconds after which it aborts and * throws an Exception. If you want your SMILES generated at any expense, you * need to create your own AllRingsFinder, set the timeout to a higher value, * and assign it to this FingerPrinter. In the vast majority of cases, * however, the defaults will be fine.

* * Another Warning : The daylight manual says: * "Fingerprints are not so definite: if a fingerprint indicates a pattern is * missing then it certainly is, but it can only indicate a pattern's presence * with some probability." In the case of very small molecules, the probability * that you get the same fingerprint for different molecules is high. *

* * @author steinbeck * @cdk.created 2002-02-24 * @cdk.keyword fingerprint * @cdk.keyword similarity * @cdk.module standard * @cdk.githash */ @TestClass("org.openscience.cdk.fingerprint.FingerprinterTest") public class Fingerprinter implements IFingerprinter { /** The default length of created fingerprints. */ public final static int DEFAULT_SIZE = 1024; /** The default search depth used to create the fingerprints. */ public final static int DEFAULT_SEARCH_DEPTH = 8; private int size; private int searchDepth; static int debugCounter = 0; private static LoggingTool logger = new LoggingTool(Fingerprinter.class); private static final Map queryReplace = new HashMap() { private static final long serialVersionUID = 1L; { put("Cl", "X"); put("Br", "Z"); put("Si", "Y"); put("As", "D"); put("Li", "L"); put("Se", "E"); put("Na", "G"); put("Ca", "J"); put("Al", "A"); } }; /** * Creates a fingerprint generator of length DEFAULT_SIZE * and with a search depth of DEFAULT_SEARCH_DEPTH. */ public Fingerprinter() { this(DEFAULT_SIZE, DEFAULT_SEARCH_DEPTH); } public Fingerprinter(int size) { this(size, DEFAULT_SEARCH_DEPTH); } /** * Constructs a fingerprint generator that creates fingerprints of * the given size, using a generation algorithm with the given search * depth. * * @param size The desired size of the fingerprint * @param searchDepth The desired depth of search */ public Fingerprinter(int size, int searchDepth) { this.size = size; this.searchDepth = searchDepth; } /** * Generates a fingerprint of the default size for the given AtomContainer. * *@param container The AtomContainer for which a Fingerprint is generated *@param ringFinder An instance of {@link org.openscience.cdk.ringsearch.AllRingsFinder} * @exception CDKException if there is a timeout in ring or aromaticity perception * @return A {@link BitSet} representing the fingerprint */ @TestMethod("testGetFingerprint_IAtomContainer") public BitSet getFingerprint(IAtomContainer container, AllRingsFinder ringFinder) throws CDKException { int position = -1; logger.debug("Entering Fingerprinter"); logger.debug("Starting Aromaticity Detection"); long before = System.currentTimeMillis(); AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(container); CDKHueckelAromaticityDetector.detectAromaticity(container); long after = System.currentTimeMillis(); logger.debug("time for aromaticity calculation: " + (after - before) + " milliseconds"); logger.debug("Finished Aromaticity Detection"); BitSet bitSet = new BitSet(size); int[] hashes = findPathes(container, searchDepth); for (int hash : hashes) { position = new java.util.Random(hash).nextInt(size); bitSet.set(position); } return bitSet; } /** * Generates a fingerprint of the default size for the given AtomContainer. * *@param container The AtomContainer for which a Fingerprint is generated */ @TestMethod("testGetFingerprint_IAtomContainer") public BitSet getFingerprint(IAtomContainer container) throws CDKException { return getFingerprint(container, null); } /** * Get all paths of lengths 0 to the specified length. * * This method will find all paths upto length N starting from each * atom in the molecule and return the unique set of such paths. * * @param container The molecule to search * @param searchDepth The maximum path length desired * @return A Map of path strings, keyed on themselves */ protected int[] findPathes(IAtomContainer container, int searchDepth) { List allPaths = new ArrayList(); Map> cache = new HashMap>(); for (IAtom startAtom : container.atoms()) { List> p = PathTools.getPathsOfLengthUpto(container, startAtom, searchDepth); for (List path : p) { StringBuffer sb = new StringBuffer(); IAtom x = path.get(0); // TODO if we ever get more than 255 elements, this will fail // maybe we should use 0 for pseudo atoms and malformed symbols? if (x instanceof IPseudoAtom) sb.append((char) Symbols.byAtomicNumber.length + 1); else { Integer atnum = Symbols.getAtomicNumber(x.getSymbol()); if (atnum != null) sb.append((char) atnum.intValue()); else sb.append((char) Symbols.byAtomicNumber.length + 1); } for (int i = 1; i < path.size(); i++) { final IAtom[] y = {path.get(i)}; Map m = cache.get( x ); final IBond[] b = { m != null ? m.get( y[0] ) : null }; if ( b[0] == null ) { b[0] = container.getBond(x, y[0]); cache.put( x, new HashMap() { {put(y[0], b[0]); } } ); } sb.append(getBondSymbol(b[0])); sb.append(convertSymbol(y[0].getSymbol())); x = y[0]; } // we store the lexicographically lower one of the // string and its reverse StringBuffer revForm = new StringBuffer(sb); revForm.reverse(); if (sb.toString().compareTo(revForm.toString()) <= 0) allPaths.add(sb); else allPaths.add(revForm); } } // now lets clean stuff up Set cleanPath = new HashSet(); for (StringBuffer s : allPaths) { if (cleanPath.contains( s.toString() )) continue; String s2 = s.reverse().toString(); if (cleanPath.contains(s2)) continue; cleanPath.add(s2); } // convert paths to hashes int[] hashes = new int[cleanPath.size()]; int i= 0; for (String s: cleanPath) hashes[i++] = s.hashCode(); return hashes; } private String convertSymbol(String symbol) { String returnSymbol = queryReplace.get( symbol ); return returnSymbol == null ? symbol : returnSymbol; } /** * Gets the bondSymbol attribute of the Fingerprinter class * *@param bond Description of the Parameter *@return The bondSymbol value */ protected String getBondSymbol(IBond bond) { String bondSymbol = ""; if (bond.getFlag(CDKConstants.ISAROMATIC)) { bondSymbol = ":"; } else if (bond.getOrder() == IBond.Order.SINGLE) { bondSymbol = "-"; } else if (bond.getOrder() == IBond.Order.DOUBLE) { bondSymbol = "="; } else if (bond.getOrder() == IBond.Order.TRIPLE) { bondSymbol = "#"; } return bondSymbol; } @TestMethod("testGetSearchDepth") public int getSearchDepth() { return searchDepth; } @TestMethod("testGetSize") public int getSize() { return size; } } cdk-1.2.10/src/main/org/openscience/cdk/fingerprint/FingerprinterTool.java100644 0 0 6534 11570154753 23707 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2002-2007 Christoph Steinbeck * * 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 org.openscience.cdk.fingerprint; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.tools.LoggingTool; import java.util.ArrayList; import java.util.BitSet; import java.util.List; /** * Tool with helper methods for IFingerprint. * * @author steinbeck * @cdk.created 2002-02-24 * @cdk.keyword fingerprint * @cdk.module standard * @cdk.githash */ @TestClass("org.openscience.cdk.fingerprint.FingerprinterToolTest") public class FingerprinterTool { private final static LoggingTool logger = new LoggingTool(FingerprinterTool.class); /** * Checks whether all the positive bits in BitSet bs2 occur in BitSet bs1. If * so, the molecular structure from which bs2 was generated is a possible * substructure of bs1.

* * Example:

	 *  Molecule mol = MoleculeFactory.makeIndole();
	 *  BitSet bs = Fingerprinter.getFingerprint(mol);
	 *  Molecule frag1 = MoleculeFactory.makePyrrole();
	 *  BitSet bs1 = Fingerprinter.getFingerprint(frag1);
	 *  if (Fingerprinter.isSubset(bs, bs1)) {
	 *      System.out.println("Pyrrole is subset of Indole.");
	 *  }
	 *  
* *@param bs1 The reference BitSet *@param bs2 The BitSet which is compared with bs1 *@return True, if bs2 is a subset of bs1 *@cdk.keyword substructure search */ @TestMethod("testIsSubset_BitSet_BitSet") public static boolean isSubset(BitSet bs1, BitSet bs2) { BitSet clone = (BitSet) bs1.clone(); clone.and(bs2); if (clone.equals(bs2)) { return true; } return false; } /** * This lists all bits set in bs2 and not in bs2 (other way round not considered) in a list and to logger * * @param bs1 First bitset * @param bs2 Second bitset * @return An arrayList of Integers */ @TestMethod("testListDifferences_BitSet_BitSet") public static List listDifferences(BitSet bs1, BitSet bs2) { List l=new ArrayList(); logger.debug("Listing bit positions set in bs2 but not in bs1"); for (int f = 0; f < bs2.size(); f++) { if (bs2.get(f) && !bs1.get(f)) { l.add(f); logger.debug("Bit " + f + " not set in bs1"); } } return l; } } cdk-1.2.10/src/main/org/openscience/cdk/fingerprint/GraphOnlyFingerprinter.java100644 0 0 5723 11570154753 24674 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2002-2007 Egon Willighagen * * 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 org.openscience.cdk.fingerprint; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; import java.util.BitSet; import java.util.Map; import java.util.Random; /** * Specialized version of the {@link Fingerprinter} which does not take bond orders * into account. * * @author egonw * @cdk.created 2007-01-11 * @cdk.keyword fingerprint * @cdk.keyword similarity * @cdk.module standard * @cdk.githash * * @see org.openscience.cdk.fingerprint.Fingerprinter */ @TestClass("org.openscience.cdk.fingerprint.GraphOnlyFingerprinterTest") public class GraphOnlyFingerprinter extends Fingerprinter { /** * Creates a fingerprint generator of length defaultSize * and with a search depth of defaultSearchDepth. */ public GraphOnlyFingerprinter() { super(DEFAULT_SIZE, DEFAULT_SEARCH_DEPTH); } public GraphOnlyFingerprinter(int size) { super(size, DEFAULT_SEARCH_DEPTH); } public GraphOnlyFingerprinter(int size, int searchDepth) { super(size, searchDepth); } /** * Gets the bondSymbol attribute of the Fingerprinter class. Because we do * not consider bond orders to be important, we just return ""; * * @param bond Description of the Parameter * @return The bondSymbol value */ protected String getBondSymbol(IBond bond) { return ""; } @TestMethod("testFingerPrint,testFingerprint") public BitSet getFingerprint(IAtomContainer container, int size) throws Exception { int[] hashes = findPathes(container, super.getSearchDepth()); BitSet bitSet = new BitSet(size); for (int hash : hashes) { bitSet.set(new Random(hash).nextInt(size)); } return bitSet; } } cdk-1.2.10/src/main/org/openscience/cdk/fingerprint/IFingerprinter.java100644 0 0 3650 11570154753 23156 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 Egon Willighagen * * 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 org.openscience.cdk.fingerprint; import java.util.BitSet; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtomContainer; /** * Interface for fingerprint calculators. * * @author egonw * @cdk.keyword fingerprint * @cdk.module core * @cdk.githash */ public interface IFingerprinter { /** * Returns the fingerprint for the given IAtomContainer. * * @param container IAtomContainer for which the fingerprint should be calculated. * @return the fingerprint * @throws CDKException TODO */ public BitSet getFingerprint(IAtomContainer container) throws CDKException; /** * Returns the size of the fingerprints calculated. * * @return the size of the fingerprint */ public int getSize(); } cdk-1.2.10/src/main/org/openscience/cdk/fingerprint/MACCSFingerprinter.java100644 0 0 15603 11570154753 23635 0ustar 0 0 /* $Revision: 11674 $ $Author: rajarshi $ $Date: 2008-07-20 22:05:08 -0400 (Sun, 20 Jul 2008) $ * * Copyright (C) 2008 Rajarshi Guha * * 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 org.openscience.cdk.fingerprint; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.graph.ConnectivityChecker; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.interfaces.IRingSet; import org.openscience.cdk.ringsearch.AllRingsFinder; import org.openscience.cdk.smiles.smarts.SMARTSQueryTool; import org.openscience.cdk.tools.LoggingTool; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.BitSet; import java.util.Iterator; import java.util.List; /** * This fingerprinter generates 166 bit MACCS keys. *

* The SMARTS patterns for each of the features was taken from * RDKit. However given that there is no official and explicit listing of the original * key definitions, the results of this implementation may differ from others. * * This class assumes that aromaticity perception and atom typing have been performed * prior to generating the fingerprint * * Note Currently bits 1 and 44 are completely ignored since the RDKit defs * do not provide a definition and I can't find an official description of them * * @author Rajarshi Guha * @cdk.created 2008-07-23 * @cdk.keyword fingerprint * @cdk.keyword similarity * @cdk.module fingerprint * @cdk.githash */ @TestClass("org.openscience.cdk.fingerprint.MACCSFingerprinterTest") public class MACCSFingerprinter implements IFingerprinter { private static LoggingTool logger = new LoggingTool(MACCSFingerprinter.class); private MaccsKey[] keys = null; @TestMethod("testFingerprint") public MACCSFingerprinter() { try { keys = readKeyDef(); } catch (IOException e) { logger.debug(e); } catch (CDKException e) { logger.debug(e); } } /** * Calculates the substructure fingerprint for the given AtomContainer. */ @TestMethod("testFingerprint,testfp2") public BitSet getFingerprint(IAtomContainer atomContainer) throws CDKException { if (keys == null) throw new CDKException("Could not setup key definitions"); int bitsetLength = keys.length; BitSet fingerPrint = new BitSet(bitsetLength); SMARTSQueryTool sqt = new SMARTSQueryTool("C"); for (int i = 0; i < keys.length; i++) { String smarts = keys[i].getSmarts(); if (smarts.equals("?")) continue; int count = keys[i].getCount(); sqt.setSmarts(smarts); boolean status = sqt.matches(atomContainer); if (status) { if (count == 0) fingerPrint.set(i, true); else { List> matches = sqt.getUniqueMatchingAtoms(); if (matches.size() > count) fingerPrint.set(i, true); } } } // at this point we have skipped the entries whose pattern is "?" // (bits 1,44,125,166) so let try and do those features by hand // bit 125 aromatic ring count > 1 AllRingsFinder ringFinder = new AllRingsFinder(); IRingSet rings = ringFinder.findAllRings(atomContainer); int ringCount = 0; for (int i = 0; i < rings.getAtomContainerCount(); i++) { IAtomContainer ring = rings.getAtomContainer(i); boolean allAromatic = true; Iterator bonds = ring.bonds().iterator(); while (bonds.hasNext()) { IBond bond = bonds.next(); if (!bond.getFlag(CDKConstants.ISAROMATIC)) { allAromatic = false; break; } } if (allAromatic) ringCount++; if (ringCount > 1) { fingerPrint.set(124, true); break; } } // bit 166 (*).(*) IMoleculeSet part = ConnectivityChecker.partitionIntoMolecules(atomContainer); if (part.getMoleculeCount() > 1) fingerPrint.set(165,true); return fingerPrint; } @TestMethod("getsize") public int getSize() { if (keys != null) return keys.length; else return 0; } private MaccsKey[] readKeyDef() throws IOException, CDKException { List keys = new ArrayList(); String filename = "org/openscience/cdk/fingerprint/data/maccs.txt"; InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename); BufferedReader reader = new BufferedReader(new InputStreamReader(ins)); for (int i = 0; i < 32; i++) reader.readLine(); // now process the keys String line; while ((line = reader.readLine()) != null) { String data = line.trim().split("\\|")[0]; String[] toks = data.trim().split("\\s"); keys.add(new MaccsKey(toks[1], Integer.parseInt(toks[2]))); } if (keys.size() != 166) throw new CDKException("Found " + keys.size() + " keys during setup. Should be 166"); return keys.toArray(new MaccsKey[]{}); } private class MaccsKey { private String smarts; private int count; private MaccsKey(String smarts, int count) { this.smarts = smarts; this.count = count; } public String getSmarts() { return smarts; } public int getCount() { return count; } } } cdk-1.2.10/src/main/org/openscience/cdk/fingerprint/StandardSubstructureSets.java100644 0 0 3302 11570154753 25253 0ustar 0 0 package org.openscience.cdk.fingerprint; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.List; /** * Default sets of atom containers aimed for use with the substructure * * @author egonw * * @cdk.module fingerprint * @cdk.githash */ @TestClass("org.openscience.cdk.fingerprint.StandardSubstructureSetsTest") public class StandardSubstructureSets { private static String[] smarts = null; /** * @return A set of the functional groups. * @throws Exception if there is an error parsing SMILES for the functional groups */ @TestMethod("testGetFunctionalGroupSubstructureSet") public static String[] getFunctionalGroupSMARTS() throws Exception { if (smarts != null) return smarts; String filename = "org/openscience/cdk/fingerprint/data/SMARTS_InteLigand.txt"; InputStream ins = StandardSubstructureSets.class.getClassLoader().getResourceAsStream(filename); BufferedReader reader = new BufferedReader(new InputStreamReader(ins)); List tmp = new ArrayList(); String line; while ((line = reader.readLine()) != null) { if (line.startsWith("#") || line.trim().length() == 0) continue; String[] toks = line.split(":"); StringBuffer s = new StringBuffer(); for (int i = 1; i < toks.length-1; i++) s.append(toks[i]+":"); s.append(toks[toks.length-1]); tmp.add(s.toString().trim()); } smarts = tmp.toArray(new String[]{}); return smarts; } } cdk-1.2.10/src/main/org/openscience/cdk/fingerprint/SubstructureFingerprinter.java100644 0 0 115650 11570154753 25544 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2005-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.fingerprint; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.smiles.smarts.SMARTSQueryTool; import java.util.BitSet; /** * {@link IFingerprinter} that gives a bit set which has a size equal to the number * of substructures it was constructed from. A set bit indicates that that * substructure was found at least once in the molecule for which the * fingerprint was calculated. The fingerprint currently supports 307 * substructures, listed below: * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Bit positionDescriptionPattern
0Primary carbon[CX4H3][#6]
1Secondary carbon[CX4H2]([#6])[#6]
2Tertiary carbon[CX4H1]([#6])([#6])[#6]
3Quaternary carbon[CX4]([#6])([#6])([#6])[#6]
4Alkene[CX3;$([H2]),$([H1][#6]),$(C([#6])[#6])]=[CX3;$([H2]),$([H1][#6]),$(C([#6])[#6])]
5Alkyne[CX2]#[CX2]
6Allene[CX3]=[CX2]=[CX3]
7Alkylchloride[ClX1][CX4]
8Alkylfluoride[FX1][CX4]
9Alkylbromide[BrX1][CX4]
10Alkyliodide[IX1][CX4]
11Alcohol[OX2H][CX4;!$(C([OX2H])[O,S,#7,#15])]
12Primary alcohol[OX2H][CX4H2;!$(C([OX2H])[O,S,#7,#15])]
13Secondary alcohol[OX2H][CX4H;!$(C([OX2H])[O,S,#7,#15])]
14Tertiary alcohol[OX2H][CX4D4;!$(C([OX2H])[O,S,#7,#15])]
15Dialkylether[OX2]([CX4;!$(C([OX2])[O,S,#7,#15,F,Cl,Br,I])])[CX4;!$(C([OX2])[O,S,#7,#15])]
16Dialkylthioether[SX2]([CX4;!$(C([OX2])[O,S,#7,#15,F,Cl,Br,I])])[CX4;!$(C([OX2])[O,S,#7,#15])]
17Alkylarylether[OX2](c)[CX4;!$(C([OX2])[O,S,#7,#15,F,Cl,Br,I])]
18Diarylether[c][OX2][c]
19Alkylarylthioether[SX2](c)[CX4;!$(C([OX2])[O,S,#7,#15,F,Cl,Br,I])]
20Diarylthioether[c][SX2][c]
21Oxonium[O+;!$([O]~[!#6]);!$([S]*~[#7,#8,#15,#16])]
22Amine[NX3+0,NX4+;!$([N]~[!#6]);!$([N]*~[#7,#8,#15,#16])]
23Primary aliph amine[NX3H2+0,NX4H3+;!$([N][!C]);!$([N]*~[#7,#8,#15,#16])]
24Secondary aliph amine[NX3H1+0,NX4H2+;!$([N][!C]);!$([N]*~[#7,#8,#15,#16])]
25Tertiary aliph amine[NX3H0+0,NX4H1+;!$([N][!C]);!$([N]*~[#7,#8,#15,#16])]
26Quaternary aliph ammonium[NX4H0+;!$([N][!C]);!$([N]*~[#7,#8,#15,#16])]
27Primary arom amine[NX3H2+0,NX4H3+]c
28Secondary arom amine[NX3H1+0,NX4H2+;!$([N][!c]);!$([N]*~[#7,#8,#15,#16])]
29Tertiary arom amine[NX3H0+0,NX4H1+;!$([N][!c]);!$([N]*~[#7,#8,#15,#16])]
30Quaternary arom ammonium[NX4H0+;!$([N][!c]);!$([N]*~[#7,#8,#15,#16])]
31Secondary mixed amine[NX3H1+0,NX4H2+;$([N]([c])[C]);!$([N]*~[#7,#8,#15,#16])]
32Tertiary mixed amine[NX3H0+0,NX4H1+;$([N]([c])([C])[#6]);!$([N]*~[#7,#8,#15,#16])]
33Quaternary mixed ammonium[NX4H0+;$([N]([c])([C])[#6][#6]);!$([N]*~[#7,#8,#15,#16])]
34Ammonium[N+;!$([N]~[!#6]);!$(N=*);!$([N]*~[#7,#8,#15,#16])]
35Alkylthiol[SX2H][CX4;!$(C([SX2H])~[O,S,#7,#15])]
36Dialkylthioether[SX2]([CX4;!$(C([SX2])[O,S,#7,#15,F,Cl,Br,I])])[CX4;!$(C([SX2])[O,S,#7,#15])]
37Alkylarylthioether[SX2](c)[CX4;!$(C([SX2])[O,S,#7,#15])]
38Disulfide[SX2D2][SX2D2]
391,2-Aminoalcohol[OX2H][CX4;!$(C([OX2H])[O,S,#7,#15,F,Cl,Br,I])][CX4;!$(C([N])[O,S,#7,#15])][NX3;!$(NC=[O,S,N])]
401,2-Diol[OX2H][CX4;!$(C([OX2H])[O,S,#7,#15])][CX4;!$(C([OX2H])[O,S,#7,#15])][OX2H]
411,1-Diol[OX2H][CX4;!$(C([OX2H])([OX2H])[O,S,#7,#15])][OX2H]
42Hydroperoxide[OX2H][OX2]
43Peroxo[OX2D2][OX2D2]
44Organolithium compounds[LiX1][#6,#14]
45Organomagnesium compounds[MgX2][#6,#14]
46Organometallic compounds[!#1;!#5;!#6;!#7;!#8;!#9;!#14;!#15;!#16;!#17;!#33;!#34;!#35;!#52;!#53;!#85]~[#6;!-]
47Aldehyde[$([CX3H][#6]),$([CX3H2])]=[OX1]
48Ketone[#6][CX3](=[OX1])[#6]
49Thioaldehyde[$([CX3H][#6]),$([CX3H2])]=[SX1]
50Thioketone[#6][CX3](=[SX1])[#6]
51Imine[NX2;$([N][#6]),$([NH]);!$([N][CX3]=[#7,#8,#15,#16])]=[CX3;$([CH2]),$([CH][#6]),$([C]([#6])[#6])]
52Immonium[NX3+;!$([N][!#6]);!$([N][CX3]=[#7,#8,#15,#16])]
53Oxime[NX2](=[CX3;$([CH2]),$([CH][#6]),$([C]([#6])[#6])])[OX2H]
54Oximether[NX2](=[CX3;$([CH2]),$([CH][#6]),$([C]([#6])[#6])])[OX2][#6;!$(C=[#7,#8])]
55Acetal[OX2]([#6;!$(C=[O,S,N])])[CX4;!$(C(O)(O)[!#6])][OX2][#6;!$(C=[O,S,N])]
56Hemiacetal[OX2H][CX4;!$(C(O)(O)[!#6])][OX2][#6;!$(C=[O,S,N])]
57Aminal[NX3v3;!$(NC=[#7,#8,#15,#16])]([#6])[CX4;!$(C(N)(N)[!#6])][NX3v3;!$(NC=[#7,#8,#15,#16])][#6]
58Hemiaminal[NX3v3;!$(NC=[#7,#8,#15,#16])]([#6])[CX4;!$(C(N)(N)[!#6])][OX2H]
59Thioacetal[SX2]([#6;!$(C=[O,S,N])])[CX4;!$(C(S)(S)[!#6])][SX2][#6;!$(C=[O,S,N])]
60Thiohemiacetal[SX2]([#6;!$(C=[O,S,N])])[CX4;!$(C(S)(S)[!#6])][OX2H]
61Halogen acetal like[NX3v3,SX2,OX2;!$(*C=[#7,#8,#15,#16])][CX4;!$(C([N,S,O])([N,S,O])[!#6])][FX1,ClX1,BrX1,IX1]
62Acetal like[NX3v3,SX2,OX2;!$(*C=[#7,#8,#15,#16])][CX4;!$(C([N,S,O])([N,S,O])[!#6])][FX1,ClX1,BrX1,IX1,NX3v3,SX2,OX2;!$(*C=[#7,#8,#15,#16])]
63Halogenmethylen ester and similar[NX3v3,SX2,OX2;$(**=[#7,#8,#15,#16])][CX4;!$(C([N,S,O])([N,S,O])[!#6])][FX1,ClX1,BrX1,IX1]
64NOS methylen ester and similar[NX3v3,SX2,OX2;$(**=[#7,#8,#15,#16])][CX4;!$(C([N,S,O])([N,S,O])[!#6])][NX3v3,SX2,OX2;!$(*C=[#7,#8,#15,#16])]
65Hetero methylen ester and similar[NX3v3,SX2,OX2;$(**=[#7,#8,#15,#16])][CX4;!$(C([N,S,O])([N,S,O])[!#6])][FX1,ClX1,BrX1,IX1,NX3v3,SX2,OX2;!$(*C=[#7,#8,#15,#16])]
66Cyanhydrine[NX1]#[CX2][CX4;$([CH2]),$([CH]([CX2])[#6]),$(C([CX2])([#6])[#6])][OX2H]
67Chloroalkene[ClX1][CX3]=[CX3]
68Fluoroalkene[FX1][CX3]=[CX3]
69Bromoalkene[BrX1][CX3]=[CX3]
70Iodoalkene[IX1][CX3]=[CX3]
71Enol[OX2H][CX3;$([H1]),$(C[#6])]=[CX3]
72Endiol[OX2H][CX3;$([H1]),$(C[#6])]=[CX3;$([H1]),$(C[#6])][OX2H]
73Enolether[OX2]([#6;!$(C=[N,O,S])])[CX3;$([H0][#6]),$([H1])]=[CX3]
74Enolester[OX2]([CX3]=[OX1])[#6X3;$([#6][#6]),$([H1])]=[#6X3;!$(C[OX2H])]
75Enamine[NX3;$([NH2][CX3]),$([NH1]([CX3])[#6]),$([N]([CX3])([#6])[#6]);!$([N]*=[#7,#8,#15,#16])][CX3;$([CH]),$([C][#6])]=[CX3]
76Thioenol[SX2H][CX3;$([H1]),$(C[#6])]=[CX3]
77Thioenolether[SX2]([#6;!$(C=[N,O,S])])[CX3;$(C[#6]),$([CH])]=[CX3]
78Acylchloride[CX3;$([R0][#6]),$([H1R0])](=[OX1])[ClX1]
79Acylfluoride[CX3;$([R0][#6]),$([H1R0])](=[OX1])[FX1]
80Acylbromide[CX3;$([R0][#6]),$([H1R0])](=[OX1])[BrX1]
81Acyliodide[CX3;$([R0][#6]),$([H1R0])](=[OX1])[IX1]
82Acylhalide[CX3;$([R0][#6]),$([H1R0])](=[OX1])[FX1,ClX1,BrX1,IX1]
83Carboxylic acid[CX3;$([R0][#6]),$([H1R0])](=[OX1])[$([OX2H]),$([OX1-])]
84Carboxylic ester[CX3;$([R0][#6]),$([H1R0])](=[OX1])[OX2][#6;!$(C=[O,N,S])]
85Lactone[#6][#6X3R](=[OX1])[#8X2][#6;!$(C=[O,N,S])]
86Carboxylic anhydride[CX3;$([H0][#6]),$([H1])](=[OX1])[#8X2][CX3;$([H0][#6]),$([H1])](=[OX1])
87Carboxylic acid derivative[$([#6X3H0][#6]),$([#6X3H])](=[!#6])[!#6]
88Carbothioic acid[CX3;!R;$([C][#6]),$([CH]);$([C](=[OX1])[$([SX2H]),$([SX1-])]),$([C](=[SX1])[$([OX2H]),$([OX1-])])]
89Carbothioic S ester[CX3;$([R0][#6]),$([H1R0])](=[OX1])[SX2][#6;!$(C=[O,N,S])]
90Carbothioic S lactone[#6][#6X3R](=[OX1])[#16X2][#6;!$(C=[O,N,S])]
91Carbothioic O ester[CX3;$([H0][#6]),$([H1])](=[SX1])[OX2][#6;!$(C=[O,N,S])]
92Carbothioic O lactone[#6][#6X3R](=[SX1])[#8X2][#6;!$(C=[O,N,S])]
93Carbothioic halide[CX3;$([H0][#6]),$([H1])](=[SX1])[FX1,ClX1,BrX1,IX1]
94Carbodithioic acid[CX3;!R;$([C][#6]),$([CH]);$([C](=[SX1])[SX2H])]
95Carbodithioic ester[CX3;!R;$([C][#6]),$([CH]);$([C](=[SX1])[SX2][#6;!$(C=[O,N,S])])]
96Carbodithiolactone[#6][#6X3R](=[SX1])[#16X2][#6;!$(C=[O,N,S])]
97Amide[CX3;$([R0][#6]),$([H1R0])](=[OX1])[#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
98Primary amide[CX3;$([R0][#6]),$([H1R0])](=[OX1])[NX3H2]
99Secondary amide[CX3;$([R0][#6]),$([H1R0])](=[OX1])[#7X3H1][#6;!$(C=[O,N,S])]
100Tertiary amide[CX3;$([R0][#6]),$([H1R0])](=[OX1])[#7X3H0]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])]
101Lactam[#6R][#6X3R](=[OX1])[#7X3;$([H1][#6;!$(C=[O,N,S])]),$([H0]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
102Alkyl imide[#6X3;$([H0][#6]),$([H1])](=[OX1])[#7X3H0]([#6])[#6X3;$([H0][#6]),$([H1])](=[OX1])
103N hetero imide[#6X3;$([H0][#6]),$([H1])](=[OX1])[#7X3H0]([!#6])[#6X3;$([H0][#6]),$([H1])](=[OX1])
104Imide acidic[#6X3;$([H0][#6]),$([H1])](=[OX1])[#7X3H1][#6X3;$([H0][#6]),$([H1])](=[OX1])
105Thioamide[$([CX3;!R][#6]),$([CX3H;!R])](=[SX1])[#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
106Thiolactam[#6R][#6X3R](=[SX1])[#7X3;$([H1][#6;!$(C=[O,N,S])]),$([H0]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
107Oximester[#6X3;$([H0][#6]),$([H1])](=[OX1])[#8X2][#7X2]=,:[#6X3;$([H0]([#6])[#6]),$([H1][#6]),$([H2])]
108Amidine[NX3;!$(NC=[O,S])][CX3;$([CH]),$([C][#6])]=[NX2;!$(NC=[O,S])]
109Hydroxamic acid[CX3;$([H0][#6]),$([H1])](=[OX1])[#7X3;$([H1]),$([H0][#6;!$(C=[O,N,S])])][$([OX2H]),$([OX1-])]
110Hydroxamic acid ester[CX3;$([H0][#6]),$([H1])](=[OX1])[#7X3;$([H1]),$([H0][#6;!$(C=[O,N,S])])][OX2][#6;!$(C=[O,N,S])]
111Imidoacid[CX3R0;$([H0][#6]),$([H1])](=[NX2;$([H1]),$([H0][#6;!$(C=[O,N,S])])])[$([OX2H]),$([OX1-])]
112Imidoacid cyclic[#6R][#6X3R](=,:[#7X2;$([H1]),$([H0][#6;!$(C=[O,N,S])])])[$([OX2H]),$([OX1-])]
113Imidoester[CX3R0;$([H0][#6]),$([H1])](=[NX2;$([H1]),$([H0][#6;!$(C=[O,N,S])])])[OX2][#6;!$(C=[O,N,S])]
114Imidolactone[#6R][#6X3R](=,:[#7X2;$([H1]),$([H0][#6;!$(C=[O,N,S])])])[OX2][#6;!$(C=[O,N,S])]
115Imidothioacid[CX3R0;$([H0][#6]),$([H1])](=[NX2;$([H1]),$([H0][#6;!$(C=[O,N,S])])])[$([SX2H]),$([SX1-])]
116Imidothioacid cyclic[#6R][#6X3R](=,:[#7X2;$([H1]),$([H0][#6;!$(C=[O,N,S])])])[$([SX2H]),$([SX1-])]
117Imidothioester[CX3R0;$([H0][#6]),$([H1])](=[NX2;$([H1]),$([H0][#6;!$(C=[O,N,S])])])[SX2][#6;!$(C=[O,N,S])]
118Imidothiolactone[#6R][#6X3R](=,:[#7X2;$([H1]),$([H0][#6;!$(C=[O,N,S])])])[SX2][#6;!$(C=[O,N,S])]
119Amidine[#7X3v3;!$(N([#6X3]=[#7X2])C=[O,S])][CX3R0;$([H1]),$([H0][#6])]=[NX2v3;!$(N(=[#6X3][#7X3])C=[O,S])]
120Imidolactam[#6][#6X3R;$([H0](=[NX2;!$(N(=[#6X3][#7X3])C=[O,S])])[#7X3;!$(N([#6X3]=[#7X2])C=[O,S])]),$([H0](-[NX3;!$(N([#6X3]=[#7X2])C=[O,S])])=,:[#7X2;!$(N(=[#6X3][#7X3])C=[O,S])])]
121Imidoylhalide[CX3R0;$([H0][#6]),$([H1])](=[NX2;$([H1]),$([H0][#6;!$(C=[O,N,S])])])[FX1,ClX1,BrX1,IX1]
122Imidoylhalide cyclic[#6R][#6X3R](=,:[#7X2;$([H1]),$([H0][#6;!$(C=[O,N,S])])])[FX1,ClX1,BrX1,IX1]
123Amidrazone[$([$([#6X3][#6]),$([#6X3H])](=[#7X2v3])[#7X3v3][#7X3v3]),$([$([#6X3][#6]),$([#6X3H])]([#7X3v3])=[#7X2v3][#7X3v3])]
124Alpha aminoacid[NX3,NX4+;!$([N]~[!#6]);!$([N]*~[#7,#8,#15,#16])][C][CX3](=[OX1])[OX2H,OX1-]
125Alpha hydroxyacid[OX2H][C][CX3](=[OX1])[OX2H,OX1-]
126Peptide middle[NX3;$([N][CX3](=[OX1])[C][NX3,NX4+])][C][CX3](=[OX1])[NX3;$([N][C][CX3](=[OX1])[NX3,OX2,OX1-])]
127Peptide C term[NX3;$([N][CX3](=[OX1])[C][NX3,NX4+])][C][CX3](=[OX1])[OX2H,OX1-]
128Peptide N term[NX3,NX4+;!$([N]~[!#6]);!$([N]*~[#7,#8,#15,#16])][C][CX3](=[OX1])[NX3;$([N][C][CX3](=[OX1])[NX3,OX2,OX1-])]
129Carboxylic orthoester[#6][OX2][CX4;$(C[#6]),$([CH])]([OX2][#6])[OX2][#6]
130Ketene[CX3]=[CX2]=[OX1]
131Ketenacetal[#7X2,#8X3,#16X2;$(*[#6,#14])][#6X3]([#7X2,#8X3,#16X2;$(*[#6,#14])])=[#6X3]
132Nitrile[NX1]#[CX2]
133Isonitrile[CX1-]#[NX2+]
134Vinylogous carbonyl or carboxyl derivative[#6X3](=[OX1])[#6X3]=,:[#6X3][#7,#8,#16,F,Cl,Br,I]
135Vinylogous acid[#6X3](=[OX1])[#6X3]=,:[#6X3][$([OX2H]),$([OX1-])]
136Vinylogous ester[#6X3](=[OX1])[#6X3]=,:[#6X3][#6;!$(C=[O,N,S])]
137Vinylogous amide[#6X3](=[OX1])[#6X3]=,:[#6X3][#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
138Vinylogous halide[#6X3](=[OX1])[#6X3]=,:[#6X3][FX1,ClX1,BrX1,IX1]
139Carbonic acid dieester[#6;!$(C=[O,N,S])][#8X2][#6X3](=[OX1])[#8X2][#6;!$(C=[O,N,S])]
140Carbonic acid esterhalide[#6;!$(C=[O,N,S])][OX2;!R][CX3](=[OX1])[OX2][FX1,ClX1,BrX1,IX1]
141Carbonic acid monoester[#6;!$(C=[O,N,S])][OX2;!R][CX3](=[OX1])[$([OX2H]),$([OX1-])]
142Carbonic acid derivatives[!#6][#6X3](=[!#6])[!#6]
143Thiocarbonic acid dieester[#6;!$(C=[O,N,S])][#8X2][#6X3](=[SX1])[#8X2][#6;!$(C=[O,N,S])]
144Thiocarbonic acid esterhalide[#6;!$(C=[O,N,S])][OX2;!R][CX3](=[SX1])[OX2][FX1,ClX1,BrX1,IX1]
145Thiocarbonic acid monoester[#6;!$(C=[O,N,S])][OX2;!R][CX3](=[SX1])[$([OX2H]),$([OX1-])]
146Urea[#7X3;!$([#7][!#6])][#6X3](=[OX1])[#7X3;!$([#7][!#6])]
147Thiourea[#7X3;!$([#7][!#6])][#6X3](=[SX1])[#7X3;!$([#7][!#6])]
148Isourea[#7X2;!$([#7][!#6])]=,:[#6X3]([#8X2&!$([#8][!#6]),OX1-])[#7X3;!$([#7][!#6])]
149Isothiourea[#7X2;!$([#7][!#6])]=,:[#6X3]([#16X2&!$([#16][!#6]),SX1-])[#7X3;!$([#7][!#6])]
150Guanidine[N;v3X3,v4X4+][CX3](=[N;v3X2,v4X3+])[N;v3X3,v4X4+]
151Carbaminic acid[NX3]C(=[OX1])[O;X2H,X1-]
152Urethan[#7X3][#6](=[OX1])[#8X2][#6]
153Biuret[#7X3][#6](=[OX1])[#7X3][#6](=[OX1])[#7X3]
154Semicarbazide[#7X3][#7X3][#6X3]([#7X3;!$([#7][#7])])=[OX1]
155Carbazide[#7X3][#7X3][#6X3]([#7X3][#7X3])=[OX1]
156Semicarbazone[#7X2](=[#6])[#7X3][#6X3]([#7X3;!$([#7][#7])])=[OX1]
157Carbazone[#7X2](=[#6])[#7X3][#6X3]([#7X3][#7X3])=[OX1]
158Thiosemicarbazide[#7X3][#7X3][#6X3]([#7X3;!$([#7][#7])])=[SX1]
159Thiocarbazide[#7X3][#7X3][#6X3]([#7X3][#7X3])=[SX1]
160Thiosemicarbazone[#7X2](=[#6])[#7X3][#6X3]([#7X3;!$([#7][#7])])=[SX1]
161Thiocarbazone[#7X2](=[#6])[#7X3][#6X3]([#7X3][#7X3])=[SX1]
162Isocyanate[NX2]=[CX2]=[OX1]
163Cyanate[OX2][CX2]#[NX1]
164Isothiocyanate[NX2]=[CX2]=[SX1]
165Thiocyanate[SX2][CX2]#[NX1]
166Carbodiimide[NX2]=[CX2]=[NX2]
167Orthocarbonic derivatives[CX4H0]([O,S,#7])([O,S,#7])([O,S,#7])[O,S,#7,F,Cl,Br,I]
168Phenol[OX2H][c]
1691,2-Diphenol[OX2H][c][c][OX2H]
170Arylchloride[Cl][c]
171Arylfluoride[F][c]
172Arylbromide[Br][c]
173Aryliodide[I][c]
174Arylthiol[SX2H][c]
175Iminoarene[c]=[NX2;$([H1]),$([H0][#6;!$([C]=[N,S,O])])]
176Oxoarene[c]=[OX1]
177Thioarene[c]=[SX1]
178Hetero N basic H[nX3H1+0]
179Hetero N basic no H[nX3H0+0]
180Hetero N nonbasic[nX2,nX3+]
181Hetero O[o]
182Hetero S[sX2]
183Heteroaromatic[a;!c]
184Nitrite[NX2](=[OX1])[O;$([X2]),$([X1-])]
185Thionitrite[SX2][NX2]=[OX1]
186Nitrate[$([NX3](=[OX1])(=[OX1])[O;$([X2]),$([X1-])]),$([NX3+]([OX1-])(=[OX1])[O;$([X2]),$([X1-])])]
187Nitro[$([NX3](=O)=O),$([NX3+](=O)[O-])][!#8]
188Nitroso[NX2](=[OX1])[!#7;!#8]
189Azide[NX1]~[NX2]~[NX2,NX1]
190Acylazide[CX3](=[OX1])[NX2]~[NX2]~[NX1]
191Diazo[$([#6]=[NX2+]=[NX1-]),$([#6-]-[NX2+]#[NX1])]
192Diazonium[#6][NX2+]#[NX1]
193Nitrosamine[#7;!$(N*=O)][NX2]=[OX1]
194Nitrosamide[NX2](=[OX1])N-*=O
195N-Oxide[$([#7+][OX1-]),$([#7v5]=[OX1]);!$([#7](~[O])~[O]);!$([#7]=[#7])]
196Hydrazine[NX3;$([H2]),$([H1][#6]),$([H0]([#6])[#6]);!$(NC=[O,N,S])][NX3;$([H2]),$([H1][#6]),$([H0]([#6])[#6]);!$(NC=[O,N,S])]
197Hydrazone[NX3;$([H2]),$([H1][#6]),$([H0]([#6])[#6]);!$(NC=[O,N,S])][NX2]=[#6]
198Hydroxylamine[NX3;$([H2]),$([H1][#6]),$([H0]([#6])[#6]);!$(NC=[O,N,S])][OX2;$([H1]),$(O[#6;!$(C=[N,O,S])])]
199Sulfon[$([SX4](=[OX1])(=[OX1])([#6])[#6]),$([SX4+2]([OX1-])([OX1-])([#6])[#6])]
200Sulfoxide[$([SX3](=[OX1])([#6])[#6]),$([SX3+]([OX1-])([#6])[#6])]
201Sulfonium[S+;!$([S]~[!#6]);!$([S]*~[#7,#8,#15,#16])]
202Sulfuric acid[SX4](=[OX1])(=[OX1])([$([OX2H]),$([OX1-])])[$([OX2H]),$([OX1-])]
203Sulfuric monoester[SX4](=[OX1])(=[OX1])([$([OX2H]),$([OX1-])])[OX2][#6;!$(C=[O,N,S])]
204Sulfuric diester[SX4](=[OX1])(=[OX1])([OX2][#6;!$(C=[O,N,S])])[OX2][#6;!$(C=[O,N,S])]
205Sulfuric monoamide[SX4](=[OX1])(=[OX1])([#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])])[$([OX2H]),$([OX1-])]
206Sulfuric diamide[SX4](=[OX1])(=[OX1])([#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])])[#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
207Sulfuric esteramide[SX4](=[OX1])(=[OX1])([#7X3][#6;!$(C=[O,N,S])])[OX2][#6;!$(C=[O,N,S])]
208Sulfuric derivative[SX4D4](=[!#6])(=[!#6])([!#6])[!#6]
209Sulfonic acid[SX4;$([H1]),$([H0][#6])](=[OX1])(=[OX1])[$([OX2H]),$([OX1-])]
210Sulfonamide[SX4;$([H1]),$([H0][#6])](=[OX1])(=[OX1])[#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
211Sulfonic ester[SX4;$([H1]),$([H0][#6])](=[OX1])(=[OX1])[OX2][#6;!$(C=[O,N,S])]
212Sulfonic halide[SX4;$([H1]),$([H0][#6])](=[OX1])(=[OX1])[FX1,ClX1,BrX1,IX1]
213Sulfonic derivative[SX4;$([H1]),$([H0][#6])](=[!#6])(=[!#6])[!#6]
214Sulfinic acid[SX3;$([H1]),$([H0][#6])](=[OX1])[$([OX2H]),$([OX1-])]
215Sulfinic amide[SX3;$([H1]),$([H0][#6])](=[OX1])[#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
216Sulfinic ester[SX3;$([H1]),$([H0][#6])](=[OX1])[OX2][#6;!$(C=[O,N,S])]
217Sulfinic halide[SX3;$([H1]),$([H0][#6])](=[OX1])[FX1,ClX1,BrX1,IX1]
218Sulfinic derivative[SX3;$([H1]),$([H0][#6])](=[!#6])[!#6]
219Sulfenic acid[SX2;$([H1]),$([H0][#6])][$([OX2H]),$([OX1-])]
220Sulfenic amide[SX2;$([H1]),$([H0][#6])][#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
221Sulfenic ester[SX2;$([H1]),$([H0][#6])][OX2][#6;!$(C=[O,N,S])]
222Sulfenic halide[SX2;$([H1]),$([H0][#6])][FX1,ClX1,BrX1,IX1]
223Sulfenic derivative[SX2;$([H1]),$([H0][#6])][!#6]
224Phosphine[PX3;$([H3]),$([H2][#6]),$([H1]([#6])[#6]),$([H0]([#6])([#6])[#6])]
225Phosphine oxide[PX4;$([H3]=[OX1]),$([H2](=[OX1])[#6]),$([H1](=[OX1])([#6])[#6]),$([H0](=[OX1])([#6])([#6])[#6])]
226Phosphonium[P+;!$([P]~[!#6]);!$([P]*~[#7,#8,#15,#16])]
227Phosphorylen[PX4;$([H3]=[CX3]),$([H2](=[CX3])[#6]),$([H1](=[CX3])([#6])[#6]),$([H0](=[CX3])([#6])([#6])[#6])]
228Phosphonic acid[PX4;$([H1]),$([H0][#6])](=[OX1])([$([OX2H]),$([OX1-])])[$([OX2H]),$([OX1-])]
229Phosphonic monoester[PX4;$([H1]),$([H0][#6])](=[OX1])([$([OX2H]),$([OX1-])])[OX2][#6;!$(C=[O,N,S])]
230Phosphonic diester[PX4;$([H1]),$([H0][#6])](=[OX1])([OX2][#6;!$(C=[O,N,S])])[OX2][#6;!$(C=[O,N,S])]
231Phosphonic monoamide[PX4;$([H1]),$([H0][#6])](=[OX1])([$([OX2H]),$([OX1-])])[#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
232Phosphonic diamide[PX4;$([H1]),$([H0][#6])](=[OX1])([#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])])[#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
233Phosphonic esteramide[PX4;$([H1]),$([H0][#6])](=[OX1])([OX2][#6;!$(C=[O,N,S])])[#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
234Phosphonic acid derivative[PX4;$([H1]),$([H0][#6])](=[!#6])([!#6])[!#6]
235Phosphoric acid[PX4D4](=[OX1])([$([OX2H]),$([OX1-])])([$([OX2H]),$([OX1-])])[$([OX2H]),$([OX1-])]
236Phosphoric monoester[PX4D4](=[OX1])([$([OX2H]),$([OX1-])])([$([OX2H]),$([OX1-])])[OX2][#6;!$(C=[O,N,S])]
237Phosphoric diester[PX4D4](=[OX1])([$([OX2H]),$([OX1-])])([OX2][#6;!$(C=[O,N,S])])[OX2][#6;!$(C=[O,N,S])]
238Phosphoric triester[PX4D4](=[OX1])([OX2][#6;!$(C=[O,N,S])])([OX2][#6;!$(C=[O,N,S])])[OX2][#6;!$(C=[O,N,S])]
239Phosphoric monoamide[PX4D4](=[OX1])([$([OX2H]),$([OX1-])])([$([OX2H]),$([OX1-])])[#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
240Phosphoric diamide[PX4D4](=[OX1])([$([OX2H]),$([OX1-])])([#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])])[#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
241Phosphoric triamide[PX4D4](=[OX1])([#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])])([#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])])[#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
242Phosphoric monoestermonoamide[PX4D4](=[OX1])([$([OX2H]),$([OX1-])])([OX2][#6;!$(C=[O,N,S])])[#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
243Phosphoric diestermonoamide[PX4D4](=[OX1])([OX2][#6;!$(C=[O,N,S])])([OX2][#6;!$(C=[O,N,S])])[#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
244Phosphoric monoesterdiamide[PX4D4](=[OX1])([OX2][#6;!$(C=[O,N,S])])([#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])])[#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
245Phosphoric acid derivative[PX4D4](=[!#6])([!#6])([!#6])[!#6]
246Phosphinic acid[PX4;$([H2]),$([H1][#6]),$([H0]([#6])[#6])](=[OX1])[$([OX2H]),$([OX1-])]
247Phosphinic ester[PX4;$([H2]),$([H1][#6]),$([H0]([#6])[#6])](=[OX1])[OX2][#6;!$(C=[O,N,S])]
248Phosphinic amide[PX4;$([H2]),$([H1][#6]),$([H0]([#6])[#6])](=[OX1])[#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
249Phosphinic acid derivative[PX4;$([H2]),$([H1][#6]),$([H0]([#6])[#6])](=[!#6])[!#6]
250Phosphonous acid[PX3;$([H1]),$([H0][#6])]([$([OX2H]),$([OX1-])])[$([OX2H]),$([OX1-])]
251Phosphonous monoester[PX3;$([H1]),$([H0][#6])]([$([OX2H]),$([OX1-])])[OX2][#6;!$(C=[O,N,S])]
252Phosphonous diester[PX3;$([H1]),$([H0][#6])]([OX2][#6;!$(C=[O,N,S])])[OX2][#6;!$(C=[O,N,S])]
253Phosphonous monoamide[PX3;$([H1]),$([H0][#6])]([$([OX2H]),$([OX1-])])[#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
254Phosphonous diamide[PX3;$([H1]),$([H0][#6])]([#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])])[#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
255Phosphonous esteramide[PX3;$([H1]),$([H0][#6])]([OX2][#6;!$(C=[O,N,S])])[#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
256Phosphonous derivatives[PX3;$([D2]),$([D3][#6])]([!#6])[!#6]
257Phosphinous acid[PX3;$([H2]),$([H1][#6]),$([H0]([#6])[#6])][$([OX2H]),$([OX1-])]
258Phosphinous ester[PX3;$([H2]),$([H1][#6]),$([H0]([#6])[#6])][OX2][#6;!$(C=[O,N,S])]
259Phosphinous amide[PX3;$([H2]),$([H1][#6]),$([H0]([#6])[#6])][#7X3;$([H2]),$([H1][#6;!$(C=[O,N,S])]),$([#7]([#6;!$(C=[O,N,S])])[#6;!$(C=[O,N,S])])]
260Phosphinous derivatives[PX3;$([H2]),$([H1][#6]),$([H0]([#6])[#6])][!#6]
261Quart silane[SiX4]([#6])([#6])([#6])[#6]
262Non-quart silane[SiX4;$([H1]([#6])([#6])[#6]),$([H2]([#6])[#6]),$([H3][#6]),$([H4])]
263Silylmonohalide[SiX4]([FX1,ClX1,BrX1,IX1])([#6])([#6])[#6]
264Het trialkylsilane[SiX4]([!#6])([#6])([#6])[#6]
265Dihet dialkylsilane[SiX4]([!#6])([!#6])([#6])[#6]
266Trihet alkylsilane[SiX4]([!#6])([!#6])([!#6])[#6]
267Silicic acid derivative[SiX4]([!#6])([!#6])([!#6])[!#6]
268Trialkylborane[BX3]([#6])([#6])[#6]
269Boric acid derivatives[BX3]([!#6])([!#6])[!#6]
270Boronic acid derivative[BX3]([!#6])([!#6])[!#6]
271Borohydride[BH1,BH2,BH3,BH4]
272Quaternary boron[BX4]
273Aromatica
274Heterocyclic[!#6;!R0]
275Epoxide[OX2r3]1[#6r3][#6r3]1
276NH aziridine[NX3H1r3]1[#6r3][#6r3]1
277Spiro[D4R;$(*(@*)(@*)(@*)@*)]
278Annelated rings[R;$(*(@*)(@*)@*);!$([R2;$(*(@*)(@*)(@*)@*)])]@[R;$(*(@*)(@*)@*);!$([R2;$(*(@*)(@*)(@*)@*)])]
279Bridged rings[R;$(*(@*)(@*)@*);!$([D4R;$(*(@*)(@*)(@*)@*)]);!$([R;$(*(@*)(@*)@*);!$([R2;$(*(@*)(@*)(@*)@*)])]@[R;$(*(@*)(@*)@*);!$([R2;$(*(@*)(@*)(@*)@*)])])]
280Sugar pattern 1[OX2;$([r5]1@C@C@C(O)@C1),$([r6]1@C@C@C(O)@C(O)@C1)]
281Sugar pattern 2[OX2;$([r5]1@C(!@[OX2,NX3,SX2,FX1,ClX1,BrX1,IX1])@C@C@C1),$([r6]1@C(!@[OX2,NX3,SX2,FX1,ClX1,BrX1,IX1])@C@C@C@C1)]
282Sugar pattern combi[OX2;$([r5]1@C(!@[OX2,NX3,SX2,FX1,ClX1,BrX1,IX1])@C@C(O)@C1),$([r6]1@C(!@[OX2,NX3,SX2,FX1,ClX1,BrX1,IX1])@C@C(O)@C(O)@C1)]
283Sugar pattern 2 reducing[OX2;$([r5]1@C(!@[OX2H1])@C@C@C1),$([r6]1@C(!@[OX2H1])@C@C@C@C1)]
284Sugar pattern 2 alpha[OX2;$([r5]1@[C@@](!@[OX2,NX3,SX2,FX1,ClX1,BrX1,IX1])@C@C@C1),$([r6]1@[C@@](!@[OX2,NX3,SX2,FX1,ClX1,BrX1,IX1])@C@C@C@C1)]
285Sugar pattern 2 beta[OX2;$([r5]1@[C@](!@[OX2,NX3,SX2,FX1,ClX1,BrX1,IX1])@C@C@C1),$([r6]1@[C@](!@[OX2,NX3,SX2,FX1,ClX1,BrX1,IX1])@C@C@C@C1)]
286Conjugated double bond*=*[*]=,#,:[*]
287Conjugated tripple bond*#*[*]=,#,:[*]
288Cis double bond*/[D2]=[D2]/*
289Trans double bond*/[D2]=[D2]/*
290Mixed anhydrides[$(*=O),$([#16,#14,#5]),$([#7]([#6]=[OX1]))][#8X2][$(*=O),$([#16,#14,#5]),$([#7]([#6]=[OX1]))]
291Halogen on hetero[FX1,ClX1,BrX1,IX1][!#6]
292Halogen multi subst[F,Cl,Br,I;!$([X1]);!$([X0-])]
293Trifluoromethyl[FX1][CX4;!$([H0][Cl,Br,I]);!$([F][C]([F])([F])[F])]([FX1])([FX1])
294C ONS bond[#6]~[#7,#8,#16]
295Charged[!+0]
296Anion[-1,-2,-3,-4,-5,-6,-7]
297Kation[+1,+2,+3,+4,+5,+6,+7]
298Salt([-1,-2,-3,-4,-5,-6,-7]).([+1,+2,+3,+4,+5,+6,+7])
2991,3-Tautomerizable[$([#7X2,OX1,SX1]=*[!H0;!$([a;!n])]),$([#7X3,OX2,SX2;!H0]*=*),$([#7X3,OX2,SX2;!H0]*:n)]
3001,5-Tautomerizable[$([#7X2,OX1,SX1]=,:**=,:*[!H0;!$([a;!n])]),$([#7X3,OX2,SX2;!H0]*=**=*),$([#7X3,OX2,SX2;!H0]*=,:**:n)]
301Rotatable bond[!$(*#*)&!D1]-!@[!$(*#*)&!D1]
302Michael acceptor[CX3]=[CX3][$([CX3]=[O,N,S]),$(C#[N]),$([S,P]=[OX1]),$([NX3]=O),$([NX3+](=O)[O-])]
303Dicarbodiazene[CX3](=[OX1])[NX2]=[NX2][CX3](=[OX1])
304CH-acidic[$([CX4;!$([H0]);!$(C[!#6;!$([P,S]=O);!$(N(~O)~O)])][$([CX3]=[O,N,S]),$(C#[N]),$([S,P]=[OX1]),$([NX3]=O),$([NX3+](=O)[O-]);!$(*[S,O,N;H1,H2]);!$([*+0][S,O;X1-])]),$([CX4;!$([H0])]1[CX3]=[CX3][CX3]=[CX3]1)]
305CH-acidic strong[CX4;!$([H0]);!$(C[!#6;!$([P,S]=O);!$(N(~O)~O)])]([$([CX3]=[O,N,S]),$(C#[N]),$([S,P]=[OX1]),$([NX3]=O),$([NX3+](=O)[O-]);!$(*[S,O,N;H1,H2]);!$([*+0][S,O;X1-])])[$([CX3]=[O,N,S]),$(C#[N]),$([S,P]=[OX1]),$([NX3]=O),$([NX3+](=O)[O-]);!$(*[S,O,N;H1,H2]);!$([*+0][S,O;X1-])]
306Chiral center specified[$([*@](~*)(~*)(*)*),$([*@H](*)(*)*),$([*@](~*)(*)*),$([*@H](~*)~*)]
* * * @author egonw * @cdk.created 2005-12-30 * * @cdk.keyword fingerprint * @cdk.keyword similarity * * @cdk.module fingerprint * @cdk.githash */ @TestClass("org.openscience.cdk.fingerprint.SubstructureFingerprinterTest") public class SubstructureFingerprinter implements IFingerprinter { private String[] smarts; /** * Set up the fingerprinter to use the fragments from {@link org.openscience.cdk.fingerprint.StandardSubstructureSets}. */ @TestMethod("testFingerprint") public SubstructureFingerprinter() { try { smarts = StandardSubstructureSets.getFunctionalGroupSMARTS(); } catch (Exception e) { smarts = null; } } /** * Set up the fingerprinter to use a user-defined set of fragments. * * @param smarts The collection of fragments to look for */ @TestMethod("testUserFunctionalGroups") public SubstructureFingerprinter(String[] smarts) { this.smarts = smarts; } /** * Calculates the substructure fingerprint for the given AtomContainer. */ @TestMethod("testUserFunctionalGroups,testFingerprint") public BitSet getFingerprint(IAtomContainer atomContainer) throws CDKException { if (smarts == null) { throw new CDKException("No substructures were defined"); } int bitsetLength = smarts.length; BitSet fingerPrint = new BitSet(bitsetLength); SMARTSQueryTool sqt = new SMARTSQueryTool("C"); for (int i = 0; i < smarts.length; i++) { String pattern = smarts[i]; sqt.setSmarts(pattern); boolean status = sqt.matches(atomContainer); if (status) fingerPrint.set(i, true); } return fingerPrint; } @TestMethod("testSize") public int getSize() { return smarts.length; } } cdk-1.2.10/src/main/org/openscience/cdk/formula/AdductFormula.java100644 0 0 25565 11570154753 22130 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2007 Miguel Rojasch * * 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. * * 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.formula; import org.openscience.cdk.DefaultChemObjectBuilder; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.*; import java.util.ArrayList; import java.util.Iterator; import java.util.List; /** * Class defining an adduct object in a MolecularFormula. It maintains * a list of list IMolecularFormula.

* * Examples: *

    *
  • [C2H4O2+Na]+
  • *
* * @cdk.module data * @author miguelrojasch * @cdk.created 2007-11-20 * @cdk.keyword molecular formula */ @TestClass("org.openscience.cdk.formula.AdductFormulaTest") public class AdductFormula implements Iterable, IAdductFormula, Cloneable{ /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is incompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = -811384981700039389L; /** Internal List of IMolecularFormula. */ private List components; /** * Constructs an empty AdductFormula. * * @see #AdductFormula(IMolecularFormula) */ public AdductFormula() { components = new ArrayList(); } /** * Constructs an AdductFormula with a copy AdductFormula of another * AdductFormula (A shallow copy, i.e., with the same objects as in * the original AdductFormula). * * @param formula An MolecularFormula to copy from * @see #AdductFormula() */ public AdductFormula(IMolecularFormula formula) { components = new ArrayList(); components.add(0, formula); } /** * Adds an molecularFormula to this chemObject. * * @param formula The molecularFormula to be added to this chemObject */ @TestMethod("testAddMolecularFormula_IMolecularFormula") public void addMolecularFormula(IMolecularFormula formula) { components.add(formula); } /** * Adds all molecularFormulas in the AdductFormula to this chemObject. * * @param formulaSet The MolecularFormulaSet */ @TestMethod("testAdd_IMolecularFormulaSet") public void add(IMolecularFormulaSet formulaSet) { for (IMolecularFormula mf : formulaSet.molecularFormulas()){ addMolecularFormula(mf); } /* * notifyChanged() is called by addAtomContainer() */ } /** * True, if the AdductFormula contains the given IIsotope object and not * the instance. The method looks for other isotopes which has the same * symbol, natural abundance and exact mass. * * @param isotope The IIsotope this AdductFormula is searched for * @return True, if the AdductFormula contains the given isotope object */ @TestMethod("testContains_IIsotope") public boolean contains(IIsotope isotope) { for(Iterator it = isotopes().iterator(); it.hasNext(); ) { IIsotope thisIsotope = it.next(); if(isTheSame(thisIsotope, isotope)){ return true; } } return false; } /** * Returns the partial charge of this Adduct. If the charge * has not been set the return value is Double.NaN. * * @return the charge of this Adduct * * @see #setCharge */ @TestMethod("testGetCharge") public Integer getCharge() { Integer charge = 0; Iterator componentIterator = components.iterator(); while (componentIterator.hasNext()) { charge += componentIterator.next().getCharge(); } return charge; } /** * Checks a set of Nodes for the occurrence of the isotope in the * adduct formula from a particular isotope. It returns 0 if the does not exist. * * @param isotope The IIsotope to look for * @return The occurrence of this isotope in this adduct * @see #getIsotopeCount() */ @TestMethod("testGetIsotopeCount_IIsotope") public int getIsotopeCount(IIsotope isotope) { int count = 0; Iterator componentIterator = components.iterator(); while (componentIterator.hasNext()) { count += componentIterator.next().getIsotopeCount(isotope); } return count; } /** * Checks a set of Nodes for the number of different isotopes in the * adduct formula. * * @return The the number of different isotopes in this adduct formula * @see #getIsotopeCount(IIsotope) */ @TestMethod("testGetIsotopeCount") public int getIsotopeCount() { return isotopesList().size(); } /** * Returns an Iterator for looping over all isotopes in this adduct formula. * * @return An Iterator with the isotopes in this adduct formula */ @TestMethod("testIsotopes") public Iterable isotopes() { return new Iterable() { public Iterator iterator() { return isotopesList().iterator(); } }; } /** * Returns a List for looping over all isotopes in this adduct formula. * * @return A List with the isotopes in this adduct formula */ private List isotopesList() { List isotopes = new ArrayList(); Iterator componentIterator = components.iterator(); while (componentIterator.hasNext()) { Iterator compIsotopes = componentIterator.next().isotopes().iterator(); while (compIsotopes.hasNext()) { IIsotope isotope = compIsotopes.next(); if (!isotopes.contains(isotope)) { isotopes.add(isotope); } } } return isotopes; } /** * No use this method. The charge is defined in each * IMolecularFormula. * * @param charge The partial charge * @deprecated * * @see #getCharge */ @TestMethod("testSetCharge") public void setCharge(Integer charge) { throw new java.lang.IllegalAccessError(); } /** * Returns an Iterable for looping over all IMolecularFormula * in this adduct formula. * * @return An Iterable with the IMolecularFormula in this adduct formula */ @TestMethod("testMolecularFormulas") public Iterable molecularFormulas() { return components; } /** * Returns an Iterator for looping over all IMolecularFormula * in this adduct formula. * * @return An Iterator with the IMolecularFormula in this adduct formula */ @TestMethod("testIterator") public Iterator iterator() { return components.iterator(); } /** * Returns the number of MolecularFormulas in this AdductFormula. * * @return The number of MolecularFormulas in this AdductFormula */ @TestMethod("testSize") public int size() { return components.size(); } /** * True, if the AdductFormula contains the given IMolecularFormula object. * * @param formula The IMolecularFormula this AdductFormula is searched for * @return True, if the AdductFormula contains the given IMolecularFormula object */ @TestMethod("testContains_IMolecularFormula") public boolean contains(IMolecularFormula formula) { return components.contains(formula); } /** * * Returns the MolecularFormula at position number in the * chemObject. * * @param position The position of the IMolecularFormula to be returned. * @return The IMolecularFormula at position number . */ @TestMethod("testGetMolecularFormulas_int") public IMolecularFormula getMolecularFormula(int position) { return components.get(position); } /** * Removes all IMolecularFormula from this chemObject. */ @TestMethod("testRemoveAllMolecularFormulas") public void removeAllMolecularFormulas() { components.clear(); } /** * Removes an IMolecularFormula from this chemObject. * * @param formula The IMolecularFormula to be removed from this chemObject */ @TestMethod("testRemoveMolecularFormula_IMolecularFormula") public void removeMolecularFormula(IMolecularFormula formula) { components.remove(formula); } /** * Removes an MolecularFormula from this chemObject. * * @param position The position of the MolecularFormula to be removed from this chemObject */ @TestMethod("testRemoveMolecularFormula_int") public void removeMolecularFormula(int position) { components.remove(position); } /** * Clones this AdductFormula object and its content. * * @return The cloned object */ @TestMethod("testClone") public Object clone() throws CloneNotSupportedException { // /* it is not a super class of chemObject */ // AdductFormula clone = (AdductFormula) super.clone(); // // start from scratch // clone.removeAllMolecularFormulas(); // // clone all molecularFormulas // Iterator iterForm = this.molecularFormulas(); // while(iterForm.hasNext()){ // clone.addMolecularFormula((IMolecularFormula) iterForm.next().clone()); // } AdductFormula clone = new AdductFormula(); for(IMolecularFormula form: this.molecularFormulas()){ clone.addMolecularFormula((IMolecularFormula) form.clone()); } return clone; } /** * Compare to IIsotope. The method doesn't compare instance but if they * have the same symbol, natural abundance and exact mass. * * @param isotopeOne The first Isotope to compare * @param isotopeTwo The second Isotope to compare * @return True, if both isotope are the same */ private boolean isTheSame(IIsotope isotopeOne, IIsotope isotopeTwo) { if(isotopeOne.getSymbol() != isotopeTwo.getSymbol() ) return false; if(isotopeOne.getNaturalAbundance() != isotopeTwo.getNaturalAbundance() ) return false; if(isotopeOne.getExactMass() != isotopeTwo.getExactMass() ) return false; return true; } public IChemObjectBuilder getBuilder() { return DefaultChemObjectBuilder.getInstance(); } } cdk-1.2.10/src/main/org/openscience/cdk/formula/IsotopeContainer.java100644 0 0 6245 11570154753 22635 0ustar 0 0 package org.openscience.cdk.formula; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IMolecularFormula; import org.openscience.cdk.tools.manipulator.MolecularFormulaManipulator; /** * This class defines a isotope container. It contains in principle a * IMolecularFormula, a mass and intensity/abundance value. * * @author Miguel Rojas Cherto * * @cdk.module formula */ @TestClass("org.openscience.cdk.formula.IsotopeContainerTest") public class IsotopeContainer{ private IMolecularFormula form; private double masOs; private double inte; /** * Constructor of the IsotopeContainer object. */ public IsotopeContainer(){ } /** * Constructor of the IsotopeContainer object setting a IMolecularFormula * object and intensity value. * * @param formula The formula of this container * @param intensity The intensity of this container */ @TestMethod("testIsotopeContainer_IMolecularFormula_double") public IsotopeContainer(IMolecularFormula formula, double intensity){ form = formula; if(formula != null) masOs = MolecularFormulaManipulator.getTotalExactMass(formula); inte = intensity; } /** * Constructor of the IsotopeContainer object setting a mass * and intensity value. * * @param mass The mass of this container * @param intensity The intensity of this container */ @TestMethod("testIsotopeContainer_double_double") public IsotopeContainer(double mass, double intensity){ masOs = mass; inte = intensity; } /** * Set IMolecularFormula object of this container. * * @param formula The IMolecularFormula of the this container */ @TestMethod("testSetFormula_IMolecularFormula") public void setFormula(IMolecularFormula formula){ form = formula; } /** * Set the mass value of this container. * * @param mass The mass of the this container */ @TestMethod("testSetMass_double") public void setMass(double mass){ masOs = mass; } /** * Set the intensity value of this container. * * @param intensity The intensity of the this container */ @TestMethod("testSetIntensity_double") public void setIntensity(double intensity){ inte = intensity; } /** * Get the IMolecularFormula object of this container. * * @return The IMolecularformula of the this container */ @TestMethod("testGetFormula") public IMolecularFormula getFormula(){ return form; } /** * Get the mass value of this container. * * @return The mass of the this container */ @TestMethod("testGetMass") public double getMass(){ return masOs; } /** * Get the intensity value of this container. * * @return The intensity of the this container */ @TestMethod("testGetIntensity") public double getIntensity(){ return inte; } /** * Clones this IsotopeContainer object and its content. * * @return The cloned object */ @TestMethod("testClone") public Object clone() throws CloneNotSupportedException { IsotopeContainer isoClone = new IsotopeContainer(); isoClone.setFormula(getFormula()); isoClone.setIntensity(getIntensity()); isoClone.setMass(getMass()); return isoClone; } } cdk-1.2.10/src/main/org/openscience/cdk/formula/IsotopePattern.java100644 0 0 6472 11570154753 22332 0ustar 0 0 package org.openscience.cdk.formula; import java.util.ArrayList; import java.util.List; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; /** * This class defines the properties of a deisotoped * pattern distribution. A isotope pattern is a set of * compounds with different set of isotopes. * * @author Miguel Rojas Cherto * * @cdk.module formula */ @TestClass("org.openscience.cdk.formula.IsotopePatternTest") public class IsotopePattern { private List isotopeCList = new ArrayList(); private int monoIsotopePosition; private double chargI=0; /** * Constructor of the IsotopePattern object. */ public IsotopePattern(){ } /** * Set the mono isotope object. * * @param isoContainer The IsotopeContainer object */ @TestMethod("testSetMonoIsotope_IsotopeContainer") public void setMonoIsotope(IsotopeContainer isoContainer){ isotopeCList.add(isoContainer); monoIsotopePosition = isotopeCList.indexOf(isoContainer); } /** * Add an isotope object. * * @param isoContainer The IsotopeContainer object */ @TestMethod("testAddIsotope_IsotopeContainer") public void addIsotope(IsotopeContainer isoContainer){ isotopeCList.add(isoContainer); } /** * Returns the mono-isotope peak that form this isotope pattern. * * @return The IsotopeContainer acting as mono-isotope */ @TestMethod("testGetMonoIsotope") public IsotopeContainer getMonoIsotope(){ return isotopeCList.get(monoIsotopePosition); } /** * Returns the all isotopes that form this isotope pattern. * * @return The IsotopeContainer acting as mono-isotope */ @TestMethod("testGetIsotopes") public List getIsotopes(){ return isotopeCList; } /** * Returns the a isotopes given a specific position. * * @param position position of the isotope to return * @return The isotope */ @TestMethod("testGetIsotope_int") public IsotopeContainer getIsotope(int position){ return isotopeCList.get(position); } /** * Returns the number of isotopes in this pattern. * * @return The number of isotopes */ @TestMethod("testGetNumberOfIsotopes") public int getNumberOfIsotopes(){ return isotopeCList.size(); } /** * Set the charge in this pattern. * * @param charge The charge value */ @TestMethod("testSetCharge_double") public void setCharge(double charge) { chargI = charge; } /** * Get the charge in this pattern. * * @return The charge value */ @TestMethod("testGetCharge") public double getCharge() { return chargI; } /** * Clones this IsotopePattern object and its content. * * @return The cloned object */ @TestMethod("testClone") public Object clone() throws CloneNotSupportedException { IsotopePattern isoClone = new IsotopePattern(); IsotopeContainer isoHighest = getMonoIsotope(); for(IsotopeContainer isoContainer: isotopeCList){ if(isoHighest.equals(isoContainer)) isoClone.setMonoIsotope((IsotopeContainer) isoContainer.clone()); else isoClone.addIsotope((IsotopeContainer) isoContainer.clone()); } isoClone.setCharge(getCharge()); return isoClone; } } cdk-1.2.10/src/main/org/openscience/cdk/formula/IsotopePatternGenerator.java100644 0 0 20614 11570154753 24213 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2007 Miguel Rojasch * * 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. * * 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.formula; import java.util.HashMap; import java.util.Iterator; import java.util.Set; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.config.IsotopeFactory; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IIsotope; import org.openscience.cdk.interfaces.IMolecularFormula; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.manipulator.MolecularFormulaManipulator; /** * Generates all Combinatorial chemical isotopes given a structure. * * @cdk.module formula * @author Miguel Rojas Cherto * @cdk.created 2007-11-20 * @cdk.githash * * @cdk.keyword isotope pattern * */ @TestClass("org.openscience.cdk.formula.IsotopePatternGeneratorTest") public class IsotopePatternGenerator{ private IChemObjectBuilder builder = null; private IsotopeFactory isoFactory; private IsotopePattern abundance_Mass = null; private LoggingTool logger = new LoggingTool(IsotopePatternGenerator.class); /** Minimal abundance of the isotopes to be added in the combinatorial search.*/ private double minAbundance = .1; /** * Constructor for the IsotopeGenerator. */ public IsotopePatternGenerator(){ this(0.1); } /** * Constructor for the IsotopeGenerator. * * @param minAb Minimal abundance of the isotopes to be added * in the combinatorial search * */ public IsotopePatternGenerator(double minAb){ minAbundance = minAb; logger.info("Generating all Isotope structures with IsotopeGenerator"); } /** * Get all combinatorial chemical isotopes given a structure. * * @param molFor The IMolecularFormula to start * @return A IsotopePattern object containing the different combinations */ public IsotopePattern getIsotopes(IMolecularFormula molFor){ if(builder==null){ try { isoFactory = IsotopeFactory.getInstance(molFor.getBuilder()); builder = molFor.getBuilder(); } catch (Exception e) { e.printStackTrace(); } } String mf = MolecularFormulaManipulator.getString(molFor,true); // Divide the chemical formula into tokens (element and coefficients) HashMap tokens = new HashMap(); IMolecularFormula molecularFormula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula(mf, builder); for(IIsotope isos :molecularFormula.isotopes()) tokens.put(isos.getSymbol(), molecularFormula.getIsotopeCount(isos)); int atomCount; for(IIsotope isos : molecularFormula.isotopes()){ String elementSymbol = isos.getSymbol(); atomCount = tokens.get(elementSymbol); for (int i = 0; i < atomCount; i++) { if (!calculateAbundanceAndMass(elementSymbol)) { } } } IsotopePattern isoP = IsotopePatternManipulator.sortAndNormalizedByIntensity(abundance_Mass); isoP = cleanAbundance(isoP, minAbundance); IsotopePattern isoPattern = IsotopePatternManipulator.sortByMass(isoP); return isoPattern; } /** * Calculates the mass and abundance of all isotopes generated by adding one * atom. Receives the periodic table element and calculate the isotopes, if * there exist a previous calculation, add these new isotopes. In the * process of adding the new isotopes, remove those that has an abundance * less than setup parameter minAbundance, and remove duplicated masses. * * @param elementSymbol The chemical element symbol * @return */ private boolean calculateAbundanceAndMass(String elementSymbol) { IIsotope[] isotopes = isoFactory.getIsotopes(elementSymbol); if (isotopes == null) return false; if (isotopes.length == 0) return false; double mass, previousMass, abundance, totalAbundance, newAbundance; HashMap isotopeMassAndAbundance = new HashMap(); IsotopePattern currentISOPattern = new IsotopePattern(); // Generate isotopes for the current atom (element) for (int i = 0; i < isotopes.length; i++) { mass = isotopes[i].getExactMass(); abundance = isotopes[i].getNaturalAbundance(); currentISOPattern.addIsotope(new IsotopeContainer(mass, abundance)); } // Verify if there is a previous calculation. If it exists, add the new // isotopes if (abundance_Mass == null) { abundance_Mass = currentISOPattern; return true; } else { for (int i = 0; i < abundance_Mass.getNumberOfIsotopes(); i++) { totalAbundance = abundance_Mass.getIsotopes().get(i).getIntensity(); if (totalAbundance == 0) continue; for (int j = 0; j < currentISOPattern.getNumberOfIsotopes(); j++) { abundance = currentISOPattern.getIsotopes().get(j).getIntensity(); mass = abundance_Mass.getIsotopes().get(i).getMass(); if (abundance == 0) continue; newAbundance = totalAbundance * abundance * 0.01f; mass += currentISOPattern.getIsotopes().get(j).getMass(); // Filter duplicated masses previousMass = searchMass(isotopeMassAndAbundance.keySet(), mass); if (isotopeMassAndAbundance.containsKey(previousMass)) { newAbundance += isotopeMassAndAbundance .get(previousMass); mass = previousMass; } // Filter isotopes too small if (isNotZero(newAbundance)) { isotopeMassAndAbundance.put(mass, newAbundance); } previousMass = 0; } } Iterator itr = isotopeMassAndAbundance.keySet().iterator(); int i = 0; abundance_Mass = new IsotopePattern(); while (itr.hasNext()) { mass = itr.next(); abundance_Mass.addIsotope(new IsotopeContainer(mass, isotopeMassAndAbundance.get(mass))); i++; } } return true; } /** * Search the key mass in this Set. * * @param keySet The Set object * @param mass The mass to look for * @return The key value */ private double searchMass(Set keySet, double mass) { double TOLERANCE = 0.00005f; double diff; for (double key : keySet) { diff = Math.abs(key - mass); if (diff < TOLERANCE) return key; } return 0.0d; } /** * Detection if the value is zero. * * @param number The number to analyze * @return TRUE, if it zero */ private boolean isNotZero(double number) { double pow = (double) Math.pow(10, 6); int fraction = (int) (number * pow); if (fraction <= 0) return false; return true; } /** * Normalize the intensity (relative abundance) of all isotopes in relation * of the most abundant isotope. * * @param isopattern The IsotopePattern object * @param minAbundance The minimum abundance * @return The IsotopePattern cleaned */ private IsotopePattern cleanAbundance(IsotopePattern isopattern, double minAbundance) { double intensity, biggestIntensity = 0.0f; for (IsotopeContainer sc : isopattern.getIsotopes()) { intensity = sc.getIntensity(); if (intensity > biggestIntensity) biggestIntensity = intensity; } for (IsotopeContainer sc : isopattern.getIsotopes()) { intensity = sc.getIntensity(); intensity /= biggestIntensity; if (intensity < 0) intensity = 0; sc.setIntensity(intensity); } IsotopePattern sortedIsoPattern = new IsotopePattern(); sortedIsoPattern.setMonoIsotope(new IsotopeContainer(isopattern.getIsotopes().get(0).getMass(),isopattern.getIsotopes().get(0).getIntensity())); for (int i = 1; i < isopattern.getNumberOfIsotopes();i++) { if (isopattern.getIsotopes().get(i).getIntensity() >= (minAbundance )) sortedIsoPattern.addIsotope(new IsotopeContainer(isopattern.getIsotopes().get(i).getMass(),isopattern.getIsotopes().get(i).getIntensity())); } return sortedIsoPattern; } }cdk-1.2.10/src/main/org/openscience/cdk/formula/IsotopePatternManipulator.java100644 0 0 10522 11570154753 24555 0ustar 0 0 package org.openscience.cdk.formula; import java.util.List; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; /** * Class to manipulate IsotopePattern objects. * * @author Miguel Rojas Cherto * * @cdk.module formula */ @TestClass("org.openscience.cdk.formula.IsotopePatternManipulatorTest") public class IsotopePatternManipulator { /** * Return the isotope pattern normalized to the highest abundance * * @param isotopeP The IsotopePattern object to normalize * @return The IsotopePattern normalized */ @TestMethod("testNormalize_IsotopePattern") public static IsotopePattern normalize(IsotopePattern isotopeP){ IsotopeContainer isoHighest = null; double biggestAbundance = 0; /*Extraction of the isoContainer with the highest abundance*/ for(IsotopeContainer isoContainer: isotopeP.getIsotopes()){ double abundance = isoContainer.getIntensity(); if(biggestAbundance < abundance){ biggestAbundance = abundance; isoHighest = isoContainer; } } /*Normalize*/ IsotopePattern isoNormalized = new IsotopePattern(); for(IsotopeContainer isoContainer: isotopeP.getIsotopes()){ double inten = isoContainer.getIntensity()/isoHighest.getIntensity(); IsotopeContainer icClone; try { icClone = (IsotopeContainer) isoContainer.clone(); icClone.setIntensity(inten); if(isoHighest.equals(isoContainer)) isoNormalized.setMonoIsotope(icClone); else isoNormalized.addIsotope(icClone); } catch (CloneNotSupportedException e) { e.printStackTrace(); } } isoNormalized.setCharge(isotopeP.getCharge()); return isoNormalized; } /** * Return the isotope pattern sorted and normalized by intensity * to the highest abundance. * * @param isotopeP The IsotopePattern object to sort * @return The IsotopePattern sorted */ @TestMethod("testSortAndNormalizedByIntensity_IsotopePattern") public static IsotopePattern sortAndNormalizedByIntensity(IsotopePattern isotopeP){ IsotopePattern isoNorma = normalize(isotopeP); return sortByIntensity(isoNorma); } /** * Return the isotope pattern sorted by intensity * to the highest abundance. * * @param isotopeP The IsotopePattern object to sort * @return The IsotopePattern sorted */ @TestMethod("testSortByIntensity_IsotopePattern") public static IsotopePattern sortByIntensity(IsotopePattern isotopeP){ try { IsotopePattern isoSort = new IsotopePattern(); List listISO = ((IsotopePattern)isotopeP.clone()).getIsotopes(); int length = listISO.size()-1; for(int i = length ; i >= 0 ; i--){ double intensity = 0; IsotopeContainer isoHighest = null; for(IsotopeContainer isoContainer: listISO){ if(isoContainer.getIntensity() > intensity){ isoHighest = isoContainer; intensity = isoContainer.getIntensity(); } } if(i == length) isoSort.setMonoIsotope((IsotopeContainer) isoHighest.clone()); else isoSort.addIsotope((IsotopeContainer) isoHighest.clone()); listISO.remove(isoHighest); } isoSort.setCharge(isotopeP.getCharge()); return isoSort; } catch (CloneNotSupportedException e) { e.printStackTrace(); } return null; } /** * Return the isotope pattern sorted by mass * to the highest abundance. * * @param isotopeP The IsotopePattern object to sort * @return The IsotopePattern sorted */ @TestMethod("testSortByMass_IsotopePattern") public static IsotopePattern sortByMass(IsotopePattern isotopeP){ try { IsotopePattern isoSort = new IsotopePattern(); List listISO = ((IsotopePattern)isotopeP.clone()).getIsotopes(); int length = listISO.size()-1; for(int i = length ; i >= 0 ; i--){ double mass = 100000; IsotopeContainer isoHighest = null; for(IsotopeContainer isoContainer: listISO){ if(isoContainer.getMass() < mass){ isoHighest = isoContainer; mass = isoContainer.getMass(); } } if(i == length) isoSort.setMonoIsotope((IsotopeContainer) isoHighest.clone()); else isoSort.addIsotope((IsotopeContainer) isoHighest.clone()); listISO.remove(isoHighest); } isoSort.setCharge(isotopeP.getCharge()); return isoSort; } catch (CloneNotSupportedException e) { e.printStackTrace(); } return null; } } cdk-1.2.10/src/main/org/openscience/cdk/formula/IsotopePatternSimilarity.java100644 0 0 7510 11570154753 24373 0ustar 0 0 package org.openscience.cdk.formula; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; /** * This class gives a score hit of similarity between two different * isotope abundance pattern. * * @author Miguel Rojas Cherto * * @cdk.module formula */ @TestClass("org.openscience.cdk.formula.IsotopePatternSimilarityTest") public class IsotopePatternSimilarity{ private double chargeToAdd; private double tolerance_ppm = 1; private static double massE = 0.0005485; /** * Constructor for the IsotopePatternSimilarity object. */ public IsotopePatternSimilarity() { } /** * Set the tolerance of the mass accuracy. * * @param tolerance The tolerance value */ @TestMethod("testSeTolerance_double") public void seTolerance(double tolerance) { tolerance_ppm = tolerance; } /** * Get the tolerance of the mass accuracy. * * @return The tolerance value */ @TestMethod("testGetTolerance") public double getTolerance(){ return tolerance_ppm; } /** * Compare the IMolecularFormula with a isotope * abundance pattern. * * * @param isoto1 The Isotope pattern reference (predicted) * @param isoto2 The Isotope pattern reference (detected) * @return The hit score of similarity */ @TestMethod("testCompare_IsotopePattern_IsotopePattern") public double compare(IsotopePattern isoto1, IsotopePattern isoto2){ IsotopePattern iso1 = IsotopePatternManipulator.sortAndNormalizedByIntensity(isoto1); IsotopePattern iso2 = IsotopePatternManipulator.sortAndNormalizedByIntensity(isoto2); /*charge to add*/ if(isoto1.getCharge() == 1) chargeToAdd = massE; else if(isoto1.getCharge() == -1) chargeToAdd = -massE; else chargeToAdd = 0; for(IsotopeContainer isoC: iso1.getIsotopes()){ double mass = isoC.getMass(); isoC.setMass(mass+chargeToAdd); } double diffMass, diffAbun, factor, totalFactor = 0d; double score = 0d, tempScore; // Maximum number of isotopes to be compared according predicted isotope // pattern. It is assumed that this will have always more isotopeContainers int length = iso1.getNumberOfIsotopes(); for (int i = 0 ; i< length; i++){ IsotopeContainer isoContainer = iso1.getIsotopes().get(i); factor = isoContainer.getIntensity(); totalFactor += factor; // Search for the closest isotope in the second pattern (detected) to the // current isotope (predicted pattern) int closestDp = getClosestDataDiff(isoContainer, iso2); if (closestDp == -1) continue; diffMass = isoContainer.getMass() - iso2.getIsotopes().get(closestDp).getMass(); diffMass = Math.abs(diffMass); diffAbun = 1.0d - (isoContainer.getIntensity() / iso2.getIsotopes().get(closestDp).getIntensity()); diffAbun = Math.abs(diffAbun); tempScore = 1 - (diffMass + diffAbun); if (tempScore < 0) tempScore = 0; score += (tempScore * factor); } return score / totalFactor; } /** * Search and find the closest difference in an array in terms of mass and * intensity. Always return the position in this List. * * @param diffValue The difference to look for * @param normMass A List of normalized masses * @return The position in the List */ private int getClosestDataDiff(IsotopeContainer isoContainer, IsotopePattern pattern) { double diff = 100; int posi = -1; for(int i = 0 ; i < pattern.getNumberOfIsotopes(); i++) { double tempDiff = Math.abs((isoContainer.getMass()) - pattern.getIsotopes().get(i).getMass()); if (tempDiff <= (tolerance_ppm/isoContainer.getMass()) && tempDiff < diff){ diff = tempDiff; posi = i; } } return posi; } } cdk-1.2.10/src/main/org/openscience/cdk/formula/MassToFormulaTool.java100644 0 0 47405 11570154753 22765 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2007 Miguel Rojasch * * 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 org.openscience.cdk.formula; import java.io.IOException; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.AtomTypeFactory; import org.openscience.cdk.config.IsotopeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.formula.rules.ChargeRule; import org.openscience.cdk.formula.rules.ElementRule; import org.openscience.cdk.formula.rules.IRule; import org.openscience.cdk.formula.rules.ToleranceRangeRule; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IElement; import org.openscience.cdk.interfaces.IIsotope; import org.openscience.cdk.interfaces.IMolecularFormula; import org.openscience.cdk.interfaces.IMolecularFormulaSet; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.manipulator.MolecularFormulaManipulator; import org.openscience.cdk.tools.manipulator.MolecularFormulaRangeManipulator; /** *

Tool to determine molecular formula consistent with a given accurate mass. The * molecular formulas are not validate. It only consist in generate combination according * object (see MolecularFormulaChecker). * *

 *   MassToFormulaTool mf = new MassToFormulaTool();
 *   double myMass = 133.004242;
 *   IMolecularFormulaSet mfSet = mf.generate(myMass);
 * 
* *

The elements are listed according on difference with the proposed mass. * * * @cdk.module formula * @author miguelrojasch * @cdk.created 2007-03-01 * @cdk.githash */ @TestClass("org.openscience.cdk.formula.MassToFormulaToolTest") public class MassToFormulaTool { private LoggingTool logger = new LoggingTool(MassToFormulaTool.class); private IChemObjectBuilder builder; /** */ AtomTypeFactory factory; /** matrix to follow for the permutations.*/ private int[][] matrix_Base; /** Array listing the order of the elements to be shown according probability occurrence.*/ private String[] orderElements; /** A List with all rules to be applied. see IRule.*/ private List rules; private MolecularFormulaRange mfRange; private Double charge; private Double tolerance; /** * Construct an instance of MassToFormulaTool. It is necessary because different * matrix have to build. Furthermore the default restrictions are initiated. * * @see #setDefaultRestrictions() */ public MassToFormulaTool(IChemObjectBuilder builder) { this.builder = builder; logger.info("Initiate MassToForumlaTool"); factory = AtomTypeFactory.getInstance(builder); this.orderElements = generateOrderE(); setDefaultRestrictions(); } /** * Set the restrictions that must be presents in the molecular formula. * * @param rulesNew The restrictions to impose * * @see #getRestrictions() * @see #setDefaultRestrictions() * @see IRule */ @TestMethod("testSetRestrictions_List") public void setRestrictions(List rulesNew) throws CDKException { Iterator itRules = rulesNew.iterator(); while(itRules.hasNext()){ IRule rule = itRules.next(); if(rule instanceof ElementRule){ mfRange = (MolecularFormulaRange) ((Object[])rule.getParameters())[0]; //removing the rule Iterator oldRuleIt = rules.iterator(); while(oldRuleIt.hasNext()){ IRule oldRule = oldRuleIt.next(); if(oldRule instanceof ElementRule){ rules.remove(oldRule); rules.add(rule); break; } } this.matrix_Base = getMatrix(mfRange.getIsotopeCount()); }else if(rule instanceof ChargeRule){ this.charge = (Double) ((Object[])rule.getParameters())[0]; //removing the rule Iterator oldRuleIt = rules.iterator(); while(oldRuleIt.hasNext()){ IRule oldRule = oldRuleIt.next(); if(oldRule instanceof ChargeRule){ rules.remove(oldRule); rules.add(rule); break; } } }else if(rule instanceof ToleranceRangeRule){ this.tolerance = (Double) ((Object[])rule.getParameters())[1]; //removing the rule Iterator oldRuleIt = rules.iterator(); while(oldRuleIt.hasNext()){ IRule oldRule = oldRuleIt.next(); if(oldRule instanceof ToleranceRangeRule){ rules.remove(oldRule); rules.add(rule); break; } } }else{ rules.add(rule); } } } /** * Get the restrictions that must be presents in the molecular formula. * * @return The restrictions to be imposed * * @see #setDefaultRestrictions() */ @TestMethod("testGetRestrictions") public List getRestrictions(){ return this.rules; } /** * Set the default restrictions that must be presents in the molecular formula. * * @see #getRestrictions() */ @TestMethod("testSetDefaultRestrictions") public void setDefaultRestrictions(){ try { callDefaultRestrictions(); } catch (CDKException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } } /** * Create the default restrictions. They are:

* * The major isotopes = C, H, O and N

* Charge = 0.0, indicating neutral compound

* Tolerance = 0.05 amu

* @throws ClassNotFoundException * @throws IOException * @throws CDKException * @throws IOException * */ private void callDefaultRestrictions() throws CDKException, IOException { List rules1 = new ArrayList(); IsotopeFactory ifac = IsotopeFactory.getInstance(builder); // restriction for occurrence elements MolecularFormulaRange mfRange1 = new MolecularFormulaRange(); mfRange1.addIsotope( ifac.getMajorIsotope("C"), 0, 15); mfRange1.addIsotope( ifac.getMajorIsotope("H"), 0, 15); mfRange1.addIsotope( ifac.getMajorIsotope("N"), 0, 15); mfRange1.addIsotope( ifac.getMajorIsotope("O"), 0, 15); IRule rule = new ElementRule(); Object[] params = new Object[1]; params[0] = mfRange1; rule.setParameters(params); rules1.add(rule); // occurrence for charge rule = new ChargeRule(); // default 0.0 neutral rules1.add(rule); charge = (Double) ((Object[])rule.getParameters())[0]; // occurrence for tolerance rule = new ToleranceRangeRule(); // default 0.05 rules1.add(rule); this.tolerance = (Double) ((Object[])rule.getParameters())[1]; this.matrix_Base = getMatrix(mfRange1.getIsotopeCount()); this.mfRange = mfRange1; this.rules = rules1; } /** * Method that actually does the work of extracting the molecular formula. * * @param mass molecular formula to create from the mass * @return the filled molecular formulas as IMolecularFormulaSet */ @TestMethod("testGenerate_double") public IMolecularFormulaSet generate(double mass) { if(mass <= 0.0){ logger.error("Proposed mass is not valid: ",mass); return null; } IMolecularFormula minimalMF = MolecularFormulaRangeManipulator.getMinimalFormula(mfRange,builder); IMolecularFormula maximalMF = MolecularFormulaRangeManipulator.getMaximalFormula(mfRange,builder); double massMim = MolecularFormulaManipulator.getTotalExactMass(minimalMF)-tolerance; double massMap = MolecularFormulaManipulator.getTotalExactMass(maximalMF)+tolerance; if(massMim > mass || massMap < mass){ logger.error("Proposed mass is out of the range: ",mass); return null; } IMolecularFormulaSet molecularFormulaSet = builder.newMolecularFormulaSet(); int[][] matrix = this.matrix_Base; int numberElements = mfRange.getIsotopeCount(); // put IIsotope into a list List isotopes_TO = new ArrayList(); Iterator isIt = mfRange.isotopes().iterator(); while(isIt.hasNext()) isotopes_TO.add(isIt.next()); isotopes_TO = orderList(isotopes_TO); for(int i = 0; i < matrix.length ; i++){ /*constructing initial combinations*/ int[] value_In = new int[numberElements]; for(int j= 0; j < numberElements ; j++){ if(matrix[i][j] == 0) value_In[j] = 0; else value_In[j] = 1; } /*find number of element to combine*/ int count_E = 0; ArrayList elem_Pos = new ArrayList(); for(int j= 0 ; j< matrix[1].length; j++) if(value_In[j] != 0){ count_E++; elem_Pos.add(j); } boolean flag = true; /*first position those first starting at the left*/ int possChan = 0; String lastMFString = ""; while(flag){ // // print all combinations -------------------------------------------------- // System.out.print(elem_Pos.get(possChan).intValue()+">"); // for(int j= 0 ; j< matrix[1].length; j++) // System.out.print(isotopes_TO.get(j).getSymbol()+value_In[j]+"-"); // System.out.println(); // // print all combinations -------------------------------------------------- // control if some of the element is contained. E.g. C(1-3)H(1-3) // the matrix 01 or 10 can not exist boolean flagBreak = false; for(int j= 0 ; j< matrix[1].length; j++){ int min = mfRange.getIsotopeCountMin(isotopes_TO.get(j)); if(value_In[j] == 0) if(min != 0) flagBreak = true; } if(flagBreak) break; /*Find max occurence given a mass for a element with minimal elements*/ int occurence = getMaxOccurence(mass, elem_Pos.get(possChan).intValue(),value_In,isotopes_TO); /*at least one*/ if (occurence == 0) break; int maxx = mfRange.getIsotopeCountMax(isotopes_TO.get(elem_Pos.get(possChan).intValue())); int minn = mfRange.getIsotopeCountMin(isotopes_TO.get(elem_Pos.get(possChan).intValue())); /*restriction of the number of max and min number for a element*/ if(occurence < minn | maxx < occurence){ /* when is not in the occurrence that means that we have to * restart one value to the predecessor.*/ if (possChan < elem_Pos.size()-1){ /*Means that is possible to fit the next*/ if (maxx < occurence) value_In[elem_Pos.get(possChan).intValue()] = maxx; possChan++; }else{ boolean foundZ = false; for(int z= possChan-1; z >= 0 ; z--){ if (value_In[elem_Pos.get(z).intValue()] != 1){ possChan = z; foundZ = true; int newValue = value_In[elem_Pos.get(possChan).intValue()]-1; value_In[elem_Pos.get(possChan).intValue()] = newValue; for(int j= possChan+1; j < elem_Pos.size() ; j++){ int p = elem_Pos.get(j).intValue(); value_In[p] = 1; } possChan++; break; } } if(!foundZ) break; } continue; } /*final not occurrence*/ /*set the occurrence into the matrix*/ value_In[elem_Pos.get(possChan).intValue()] = occurence; double massT = calculateMassT(isotopes_TO,value_In); double diff_new = Math.abs(mass - (massT)); if(diff_new < tolerance){ IMolecularFormula myMF = getFormula(isotopes_TO,value_In); String newMFString = MolecularFormulaManipulator.getString(myMF); if(!newMFString.equals(lastMFString)){ molecularFormulaSet.addMolecularFormula(myMF); lastMFString = newMFString; } } if(count_E == 1)/*only valid for the first random 1000*/ break; if (possChan < elem_Pos.size()-1){ /*Means that is possible to fit the next*/ // value_In[elem_Pos.get(possChan).intValue()] = maxx; possChan++; }else{ boolean foundZ = false; for(int z= possChan-1; z >= 0 ; z--){ if (value_In[elem_Pos.get(z).intValue()] != 1){ possChan = z; foundZ = true; int newValue = value_In[elem_Pos.get(possChan).intValue()]-1; value_In[elem_Pos.get(possChan).intValue()] = newValue; for(int j= possChan+1; j < elem_Pos.size() ; j++){ int p = elem_Pos.get(j).intValue(); value_In[p] = 1; } possChan++; break; } } if(!foundZ) break; } } } return returnOrdered(mass, molecularFormulaSet); } /** * Put the order the List of IIsotope according the probability occurrence. * * @param isotopes_TO The List of IIsotope * @return The list of IIsotope ordered */ private List orderList(List isotopes_TO) { List newOrderList = new ArrayList(); for(int i = 0 ; i < orderElements.length; i++){ String symbol = orderElements[i]; Iterator itIso = isotopes_TO.iterator(); while(itIso.hasNext()){ IIsotope isotopeToCo = itIso.next(); if(isotopeToCo.getSymbol().equals(symbol)){ newOrderList.add(isotopeToCo); } } } return newOrderList; } /** * generate the order of the Elements according probability occurrence., * beginning the C, H, O, N, Si, P, S, F, Cl, Br, I, Sn, B, Pb, Tl, Ba, In, Pd, * Pt, Os, Ag, Zr, Se, Zn, Cu, Ni, Co, Fe, Cr, Ti, Ca, K, Al, Mg, Na, Ce, * Hg, Au, Ir, Re, W, Ta, Hf, Lu, Yb, Tm, Er, Ho, Dy, Tb, Gd, Eu, Sm, Pm, * Nd, Pr, La, Cs, Xe, Te, Sb, Cd, Rh, Ru, Tc, Mo, Nb, Y, Sr, Rb, Kr, As, * Ge, Ga, Mn, V, Sc, Ar, Ne, Be, Li, Tl, Pb, Bi, Po, At, Rn, Fr, Ra, Ac, * Th, Pa, U, Np, Pu. * * @return Array with the elements ordered. * */ private String[] generateOrderE(){ String[] listElements = new String[]{ "C", "H", "O", "N", "Si", "P", "S", "F", "Cl", "Br", "I", "Sn", "B", "Pb", "Tl", "Ba", "In", "Pd", "Pt", "Os", "Ag", "Zr", "Se", "Zn", "Cu", "Ni", "Co", "Fe", "Cr", "Ti", "Ca", "K", "Al", "Mg", "Na", "Ce", "Hg", "Au", "Ir", "Re", "W", "Ta", "Hf", "Lu", "Yb", "Tm", "Er", "Ho", "Dy", "Tb", "Gd", "Eu", "Sm", "Pm", "Nd", "Pr", "La", "Cs", "Xe", "Te", "Sb", "Cd", "Rh", "Ru", "Tc", "Mo", "Nb", "Y", "Sr", "Rb", "Kr", "As", "Ge", "Ga", "Mn", "V", "Sc", "Ar", "Ne", "Be", "Li", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu"}; return listElements; } /** * Get the maximal occurrence of this List. * * @param massTo * @param element_pos * @param matrix * @param elemToCond_new * @return The occurrence value */ private int getMaxOccurence(double massTo, int element_pos, int[] matrix,List isoToCond_new) { double massIn = isoToCond_new.get(element_pos).getExactMass(); double massToM = massTo; for(int i = 0; i < matrix.length ; i++) if (i != element_pos) if(matrix[i] != 0) massToM -= isoToCond_new.get(i).getExactMass()*matrix[i]; int value = (int)((massToM+1)/massIn); return value; } /** * Set the formula molecular as IMolecularFormula object. * * @param elemToCond_new List with IIsotope * @param value_In Array matrix with occurrences * @return The IMolecularFormula */ private IMolecularFormula getFormula(List isoToCond_new, int[] value_In) { IMolecularFormula mf = builder.newMolecularFormula();; for(int i = 0; i < isoToCond_new.size() ; i++){ if(value_In[i] != 0){ for(int j = 0 ; j < value_In[i] ; j ++) mf.addIsotope(isoToCond_new.get(i)); } } mf = putInOrder(mf); return mf; } /** * Put in order the elements of the molecular formula. * * @param formula The IMolecularFormula to put in order * @return IMolecularFormula object */ private IMolecularFormula putInOrder(IMolecularFormula formula) { IMolecularFormula new_formula = formula.getBuilder().newMolecularFormula(); for(int i = 0 ; i < orderElements.length; i++){ IElement element = builder.newElement(orderElements[i]); if(MolecularFormulaManipulator.containsElement(formula,element)){ Iterator isotopes = MolecularFormulaManipulator.getIsotopes(formula, element).iterator(); while(isotopes.hasNext()){ IIsotope isotope = isotopes.next(); new_formula.addIsotope(isotope,formula.getIsotopeCount(isotope)); } } } // new_mf.setCharge(charge); return new_formula; } /** * Calculate the mass total given the elements and their respective occurrences. * * @param elemToCond_new The IIsotope to calculate * @param value_In Array matrix with occurrences * @return The sum total */ private double calculateMassT(List isoToCond_new, int[] value_In) { double result = 0; for(int i = 0; i < isoToCond_new.size() ; i++){ if(value_In[i] != 0){ result += isoToCond_new.get(i).getExactMass()*value_In[i]; } } return result; } /** * Return all molecular formulas but ordered according the tolerance difference between masses. * * @param mass The mass to analyze * @param formulaSet The IMolecularFormulaSet to order * @return The IMolecularFormulaSet ordered */ private IMolecularFormulaSet returnOrdered(double mass, IMolecularFormulaSet formulaSet){ IMolecularFormulaSet solutions_new = null; if(formulaSet.size() != 0){ double valueMin = 100; int i_final = 0; solutions_new = formulaSet.getBuilder().newMolecularFormulaSet(); List listI = new ArrayList(); for (int j = 0; j < formulaSet.size() ; j++){ for (int i = 0; i < formulaSet.size() ; i++){ if(listI.contains(i)) continue; double value = MolecularFormulaManipulator.getTotalExactMass(formulaSet.getMolecularFormula(i)); double diff = Math.abs(mass - Math.abs(value)); if (valueMin > diff){ valueMin = diff; i_final = i; } } valueMin = 100; solutions_new.addMolecularFormula(formulaSet.getMolecularFormula(i_final)); listI.add(i_final); } } return solutions_new; } /** * Get the corresponding matrix and create it. * * @param size Size of the matrix to be created * @return the matrix with the permutations */ private int[][] getMatrix(int size){ logger.info("Creating matrix for isotopes combination"); int lengthM = (int) Math.pow(2, size); lengthM--;// less 1 because the matrix 00000 we don't need int[][] matrix = new int[lengthM][size]; int[] combi = new int[size]; for(int j = 0 ; j < size ; j ++){ combi[j] = 0; } int posChang = size - 1; int posRemov = size - 1; for(int i = 0 ; i < lengthM; i++){ // cleaning to zeros for(int j = posRemov ; j < size ; j ++){ combi[j] = 0; } combi[posChang] = 1; for(int j = 0 ; j < size ; j ++) matrix[i][j] = combi[j]; if(posChang == size - 1){ //find where is zero position, place to change for(int j = posChang ; j >= 0 ; j --){ if(combi[j] == 0){ posChang = j; posRemov = j+1; break; } } }else{ //look for the last zero for(int j = posChang ; j < size ; j ++){ if(combi[j] == 0){ posChang = j; } } } } return matrix; } } cdk-1.2.10/src/main/org/openscience/cdk/formula/MolecularFormula.java100644 0 0 27704 11570154753 22644 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2007 Miguel Rojasch * * 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. * * 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.formula; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.DefaultChemObjectBuilder; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IIsotope; import org.openscience.cdk.interfaces.IMolecularFormula; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; /** * Class defining a molecular formula object. It maintains * a list of list {@link IIsotope}. * *

Examples: *

    *
  • [C5H5]-
  • *
  • C6H6
  • *
  • 12C513CH6
  • *
* * @cdk.module data * @author miguelrojasch * @cdk.created 2007-11-20 * @cdk.keyword molecular formula */ @TestClass("org.openscience.cdk.formula.MolecularFormulaTest") public class MolecularFormula implements IMolecularFormula, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is imcompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = -2011407700837295287L; private Map isotopes; /** * The partial charge of the molecularFormula. The default value is Double.NaN. */ private Integer charge = (Integer) CDKConstants.UNSET; /** * A hashtable for the storage of any kind of properties of this IChemObject. */ private Map properties; /** * Constructs an empty MolecularFormula. */ public MolecularFormula() { isotopes = new HashMap(); } /** * Adds an molecularFormula to this MolecularFormula. * * @param formula The molecularFormula to be added to this chemObject * @return The IMolecularFormula */ @TestMethod("testAdd_IMolecularFormula") public IMolecularFormula add(IMolecularFormula formula) { for (IIsotope newIsotope : formula.isotopes()) { addIsotope(newIsotope,formula.getIsotopeCount(newIsotope)); } if(formula.getCharge() != null)charge += formula.getCharge(); return this; } /** * Adds an Isotope to this MolecularFormula one time. * * @param isotope The isotope to be added to this MolecularFormula * @see #addIsotope(IIsotope, int) */ @TestMethod("addIsotope_IIsotope") public IMolecularFormula addIsotope(IIsotope isotope) { return this.addIsotope(isotope, 1); } /** * Adds an Isotope to this MolecularFormula in a number of occurrences. * * @param isotope The isotope to be added to this MolecularFormula * @param count The number of occurrences to add * @see #addIsotope(IIsotope) */ @TestMethod("testAddIsotope_IIsotope_int") public IMolecularFormula addIsotope(IIsotope isotope, int count) { boolean flag = false; for (IIsotope thisIsotope : isotopes()) { if(isTheSame(thisIsotope, isotope)){ isotopes.put(thisIsotope, isotopes.get(thisIsotope) + count); flag = true; break; } } if(!flag){ isotopes.put(isotope, count); } return this; } /** * True, if the MolecularFormula contains the given IIsotope object and not * the instance. The method looks for other isotopes which has the same * symbol, natural abundance and exact mass. * * @param isotope The IIsotope this MolecularFormula is searched for * @return True, if the MolecularFormula contains the given isotope object */ @TestMethod("testContains_IIsotope") public boolean contains(IIsotope isotope) { for (IIsotope thisIsotope : isotopes()) { if(isTheSame(thisIsotope, isotope)){ return true; } } return false; } /** * Returns the partial charge of this IMolecularFormula. If the charge * has not been set the return value is Double.NaN. * * @return the charge of this IMolecularFormula * * @see #setCharge */ @TestMethod("testGetCharge") public Integer getCharge() { return charge; } /** * Checks a set of Nodes for the occurrence of the isotope in the * IMolecularFormula from a particular isotope. It returns 0 if the does not exist. * * @param isotope The IIsotope to look for * @return The occurrence of this isotope in this IMolecularFormula * @see #getIsotopeCount() */ @TestMethod("testGetIsotopeCount_IIsotope") public int getIsotopeCount(IIsotope isotope) { return !contains(isotope) ? 0 : isotopes.get(getIsotope(isotope)); } /** * Checks a set of Nodes for the number of different isotopes in the * IMolecularFormula. * * @return The the number of different isotopes in this IMolecularFormula * @see #getIsotopeCount(IIsotope) */ @TestMethod("testGetIsotopeCount") public int getIsotopeCount() { return isotopes.size(); } /** * Get the isotope instance given an IIsotope. The instance is those * that has the isotope with the same symbol, natural abundance and * exact mass. * * @param isotope The IIsotope for looking for * @return The IIsotope instance * @see #isotopes */ private IIsotope getIsotope(IIsotope isotope){ for (IIsotope thisIsotope : isotopes()) { if(isTheSame(isotope,thisIsotope)) return thisIsotope; } return null; } /** * Returns an Iterator for looping over all isotopes in this IMolecularFormula. * * @return An Iterator with the isotopes in this IMolecularFormula */ @TestMethod("testIsotopes") public Iterable isotopes() { return isotopes.keySet(); } /** * Sets the partial charge of this IMolecularFormula. * * @param charge The partial charge * * @see #getCharge */ @TestMethod("testSetCharge_Integer") public void setCharge(Integer charge) { this.charge = charge; } /** * Removes all isotopes of this molecular formula. */ @TestMethod("testRemoveAllIsotopes") public void removeAllIsotopes() { isotopes.clear(); } /** * Removes the given isotope from the MolecularFormula. * * @param isotope The IIsotope to be removed */ @TestMethod("testRemoveIsotope_IIsotope") public void removeIsotope(IIsotope isotope) { isotopes.remove(getIsotope(isotope)); } /** * Clones this MolecularFormula object and its content. I should * integrate into ChemObject. * * @return The cloned object */ @TestMethod("testClone") public Object clone() throws CloneNotSupportedException { // /* it is not a super class of chemObject */ // MolecularFormula clone = (MolecularFormula) super.clone(); // // start from scratch // clone.removeAllIsotopes(); // // clone all isotopes // Iterator iterIso = this.isotopes(); // while(iterIso.hasNext()){ // IIsotope isotope = iterIso.next(); // clone.addIsotope((IIsotope) isotope.clone(),getIsotopeCount(isotope)); // } MolecularFormula clone = new MolecularFormula(); for (IIsotope isotope : isotopes()) { clone.addIsotope((IIsotope) isotope.clone(),getIsotopeCount(isotope)); } clone.setCharge(getCharge()); return clone; } /** * Lazy creation of properties hash. I should * integrate into ChemObject. * * @return Returns in instance of the properties */ private Map lazyProperties(){ if (properties == null) { properties = new Hashtable(); } return properties; } /** * Sets a property for a IChemObject. I should * integrate into ChemObject. * *@param description An object description of the property (most likely a * unique string) *@param property An object with the property itself *@see #getProperty *@see #removeProperty */ @TestMethod("testSetProperty_Object_Object") public void setProperty(Object description, Object property){ lazyProperties().put(description, property); } /** * Removes a property for a IChemObject. I should * integrate into ChemObject. * *@param description The object description of the property (most likely a * unique string) *@see #setProperty *@see #getProperty */ @TestMethod("testRemoveProperty_Object") public void removeProperty(Object description){ if (properties == null) { return; } lazyProperties().remove(description); } /** * Returns a property for the IChemObject. I should * integrate into ChemObject. * *@param description An object description of the property (most likely a * unique string) *@return The object containing the property. Returns null if * propert is not set. *@see #setProperty *@see #removeProperty */ @TestMethod("testGetProperty_Object") public Object getProperty(Object description){ if (properties != null) { return lazyProperties().get(description); } return null; } /** * Returns a Map with the IChemObject's properties.I should * integrate into ChemObject. * *@return The object's properties as an Hashtable *@see #setProperties */ @TestMethod("testGetProperties") public Map getProperties(){ return lazyProperties(); } /** * Sets the properties of this object. * *@param properties a Hashtable specifying the property values *@see #getProperties */ @TestMethod("testSetProperties_Hashtable") public void setProperties(Map properties){ Iterator keys = properties.keySet().iterator(); while (keys.hasNext()) { Object key = keys.next(); lazyProperties().put(key, properties.get(key)); } } /** * Compare to IIsotope. The method doesn't compare instance but if they * have the same symbol, natural abundance and exact mass. * * @param isotopeOne The first Isotope to compare * @param isotopeTwo The second Isotope to compare * @return True, if both isotope are the same */ @TestMethod("testIsTheSame") protected boolean isTheSame(IIsotope isotopeOne, IIsotope isotopeTwo) { Double natAbund1 = isotopeOne.getNaturalAbundance(); Double natAbund2 = isotopeTwo.getNaturalAbundance(); Double exactMass1 = isotopeOne.getExactMass(); Double exactMass2 = isotopeTwo.getExactMass(); if (natAbund1 == null) natAbund1 = -1.0; if (natAbund2 == null) natAbund2 = -1.0; if (exactMass1 == null) exactMass1 = -1.0; if (exactMass2 == null) exactMass2 = -1.0; if(!isotopeOne.getSymbol().equals(isotopeTwo.getSymbol() )) return false; if(natAbund1.doubleValue() != natAbund2) return false; return exactMass1.doubleValue() == exactMass2; } public IChemObjectBuilder getBuilder() { return DefaultChemObjectBuilder.getInstance(); } } cdk-1.2.10/src/main/org/openscience/cdk/formula/MolecularFormulaChecker.java100644 0 0 11057 11570154753 24123 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2007 Miguel Rojasch * * 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 org.openscience.cdk.formula; import java.util.Iterator; import java.util.List; import java.util.Map; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.formula.rules.IRule; import org.openscience.cdk.interfaces.IMolecularFormula; import org.openscience.cdk.tools.LoggingTool; /** *

Validate a molecular formula given in IMolecularformula object. The * validation is based according different rules that you have to introduce before * see IRule. * * @cdk.module formula * @author miguelrojasch * @cdk.created 2007-11-20 * @cdk.keyword molecule, molecular formula * @see IRule */ @TestClass("org.openscience.cdk.formula.MolecularFormulaCheckerTest") public class MolecularFormulaChecker { private LoggingTool logger = new LoggingTool(MolecularFormulaChecker.class); /** List of IRules to be applied in the validation.*/ private List rules; /** * Construct an instance of MolecularFormulaChecker. It must be initialized * with the rules to applied. * * @param rules A List with IRule to be applied */ public MolecularFormulaChecker(List rules) { this.rules = rules; } /** * Get the IRules to be applied to validate the IMolecularFormula. * * @return A List with IRule */ @TestMethod("testGetRules") public List getRules(){ return rules; } /** * Validate if a IMolecularFormula is valid. The result more close to 1 means * maximal probability to be valid. Opposite more close to 0 means minimal * probability to be valid. To know the result in each IRule use * {@link #isValid(IMolecularFormula)} * * @param formula The IMolecularFormula value * @return The percent of the validity * @see #isValid(IMolecularFormula) */ @TestMethod("testIsValidSum_IMolecularFormula") public Double isValidSum(IMolecularFormula formula){ double result = 1.0; IMolecularFormula formulaWith = isValid(formula); Map properties = formulaWith.getProperties(); Iterator iterRules = rules.iterator(); while(iterRules.hasNext()){ result *= (Double)properties.get(iterRules.next().getClass()); } return result; } /** * Validate if a IMolecularFormula is valid. The results of each IRule which * has to be applied is put into IMolecularFormula as properties. To extract * the result final as the product of rule's result use * {@link #isValidSum(IMolecularFormula)}. * * @param formula The IMolecularFormula value * @return formulaWith The IMolecularFormula with the results for each * IRule into properties * @see #isValidSum(IMolecularFormula) */ @TestMethod("testIsValid_IMolecularFormula") public IMolecularFormula isValid(IMolecularFormula formula){ logger = new LoggingTool(this); logger.info("Generating the validity of the molecular formula"); if(formula.getIsotopeCount() == 0){ logger.error("Proposed molecular formula has not elements"); return formula; } Iterator iterRules = rules.iterator(); try { while(iterRules.hasNext()){ IRule rule = iterRules.next(); double result = rule.validate(formula); formula.setProperty(rule.getClass(), result); } } catch (CDKException e) { e.printStackTrace(); } return formula; } } cdk-1.2.10/src/main/org/openscience/cdk/formula/MolecularFormulaRange.java100644 0 0 16653 11570154753 23622 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2007 Miguel Rojasch * * 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. * * 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.formula; import java.util.HashMap; import java.util.Iterator; import java.util.Map; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IIsotope; /** * Class defining a expanded molecular formula object. The Isotopes don't have * a fix occurrence in the MolecularFormula but they have a range.

* With this class man can define a MolecularFormula which contains certain IIsotope * with a maximum and minimum occurrence. * * Examples: *

    *
  • [C(1-5)H(4-10)]-
  • *
* * @cdk.module formula * @author miguelrojasch * @cdk.created 2007-11-20 * @cdk.keyword molecular formula */ @TestClass("org.openscience.cdk.formula.MolecularFormulaRangeTest") public class MolecularFormulaRange implements Cloneable { private Map isotopesMax; private Map isotopesMin; /** * Constructs an empty MolecularFormulaExpand. */ public MolecularFormulaRange() { isotopesMax = new HashMap(); isotopesMin = new HashMap(); } /** * Adds an Isotope to this MolecularFormulaExpand in a number of * maximum and minimum occurrences allowed. * * @param isotope The isotope to be added to this MolecularFormulaExpand * @param countMax The maximal number of occurrences to add * @param countMin The minimal number of occurrences to add * */ @TestMethod("testAddIsotope_IIsotope_int_int") public void addIsotope(IIsotope isotope, int countMin, int countMax) { boolean flag = false; for(Iterator it = isotopes().iterator(); it.hasNext(); ) { IIsotope thisIsotope = it.next(); if(isTheSame(thisIsotope, isotope)){ isotopesMax.put(thisIsotope, countMax); isotopesMin.put(thisIsotope, countMin); flag = true; break; } } if(!flag){ isotopesMax.put(isotope, countMax); isotopesMin.put(isotope, countMin); } } /** * True, if the MolecularFormulaExpand contains the given IIsotope. * The method looks for other isotopes which has the same * symbol, natural abundance and exact mass. * * @param isotope The IIsotope this MolecularFormula is searched for * @return True, if the MolecularFormula contains the given isotope object */ @TestMethod("testContains_IIsotope") public boolean contains(IIsotope isotope) { for(Iterator it = isotopes().iterator(); it.hasNext(); ) { IIsotope thisIsotope = it.next(); if(isTheSame(thisIsotope, isotope)){ return true; } } return false; } /** * Checks a set of Nodes for the maximal occurrence of the isotope in the * MolecularFormulaExpand from a particular isotope. It returns -1 if the Isotope * does not exist. * * @param isotope The IIsotope to look for * @return The occurrence of this isotope in this IMolecularFormula */ @TestMethod("testGetIsotopeCountMax_IIsotope") public int getIsotopeCountMax(IIsotope isotope) { return !contains(isotope) ? -1 : isotopesMax.get(getIsotope(isotope)); } /** * Checks a set of Nodes for the minimal occurrence of the isotope in the * MolecularFormulaExpand from a particular isotope. It returns -1 if the Isotope * does not exist. * * @param isotope The IIsotope to look for * @return The occurrence of this isotope in this IMolecularFormula */ @TestMethod("testGetIsotopeCountMin_IIsotope") public int getIsotopeCountMin(IIsotope isotope) { return !contains(isotope) ? -1 : isotopesMin.get(getIsotope(isotope)); } /** * Checks a set of Nodes for the number of different isotopes in the * MolecularFormulaExpand. * * @return The the number of different isotopes in this MolecularFormulaExpand */ @TestMethod("testGetIsotopeCount") public int getIsotopeCount() { return isotopesMax.size(); } /** * Get the isotope instance given an IIsotope. The instance is those * that has the isotope with the same symbol, natural abundance and * exact mass. * * @param isotope The IIsotope for looking for * @return The IIsotope instance * @see #isotopes */ private IIsotope getIsotope(IIsotope isotope){ for(Iterator it = isotopes().iterator(); it.hasNext(); ) { IIsotope thisIsotope = it.next(); if(isTheSame(isotope,thisIsotope)) return thisIsotope; } return null; } /** * Returns an Iterator for looping over all isotopes in this MolecularFormulaExpand. * * @return An Iterator with the isotopes in this MolecularFormulaExpand */ @TestMethod("testIsotopes") public Iterable isotopes() { return new Iterable(){ public Iterator iterator() { return isotopesMax.keySet().iterator(); } }; } /** * Removes all isotopes of this molecular formula. */ @TestMethod("testRemoveAllIsotopes") public void removeAllIsotopes() { isotopesMax.clear(); isotopesMin.clear(); } /** * Removes the given isotope from the MolecularFormulaExpand. * * @param isotope The IIsotope to be removed */ @TestMethod("testRemoveIsotope_IIsotope") public void removeIsotope(IIsotope isotope) { isotopesMax.remove(getIsotope(isotope)); isotopesMin.remove(getIsotope(isotope)); } /** * Clones this MolecularFormulaExpand object and its content. I should * integrate into ChemObject. * * @return The cloned object */ @TestMethod("testClone") public Object clone() throws CloneNotSupportedException { MolecularFormulaRange clone = new MolecularFormulaRange(); Iterator iterIso = this.isotopes().iterator(); while(iterIso.hasNext()){ IIsotope isotope = iterIso.next(); clone.addIsotope((IIsotope) isotope.clone(),getIsotopeCountMin(isotope),getIsotopeCountMax(isotope)); } return clone; } /** * Compare to IIsotope. The method doesn't compare instance but if they * have the same symbol, natural abundance and exact mass. * * @param isotopeOne The first Isotope to compare * @param isotopeTwo The second Isotope to compare * @return True, if both isotope are the same */ private boolean isTheSame(IIsotope isotopeOne, IIsotope isotopeTwo) { if(isotopeOne.getSymbol() != isotopeTwo.getSymbol() ) return false; if(isotopeOne.getNaturalAbundance() != isotopeTwo.getNaturalAbundance() ) return false; if(isotopeOne.getExactMass() != isotopeTwo.getExactMass() ) return false; return true; } } cdk-1.2.10/src/main/org/openscience/cdk/formula/MolecularFormulaSet.java100644 0 0 16011 11570154753 23305 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2007 Miguel Rojasch * * 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. * * 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.formula; import java.util.ArrayList; import java.util.Iterator; import java.util.List; import org.openscience.cdk.DefaultChemObjectBuilder; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IMolecularFormula; import org.openscience.cdk.interfaces.IMolecularFormulaSet; /** * Class defining an set object of MolecularFormulas. It maintains * a list of list IMolecularFormula.

* * @cdk.module data * @author miguelrojasch * @cdk.created 2007-11-20 * @cdk.keyword molecular formula */ @TestClass("org.openscience.cdk.formula.MolecularFormulaSetTest") public class MolecularFormulaSet implements Iterable, IMolecularFormulaSet, Cloneable { /** * Determines if a de-serialized object is compatible with this class. * * This value must only be changed if and only if the new version * of this class is imcompatible with the old version. See Sun docs * for details. */ private static final long serialVersionUID = -2043178712150212550L; /** Internal List of IMolecularFormula. */ private List components; /** * Constructs an empty MolecularFormulaSet. * * @see #MolecularFormulaSet(IMolecularFormula) */ public MolecularFormulaSet() { components = new ArrayList(); } /** * Constructs a MolecularFormulaSet with a copy MolecularFormulaSet of another * MolecularFormulaSet (A shallow copy, i.e., with the same objects as in * the original MolecularFormulaSet). * * @param formula An MolecularFormula to copy from * @see #MolecularFormulaSet() */ public MolecularFormulaSet(IMolecularFormula formula) { components = new ArrayList(); components.add(0, formula); } /** * Adds all molecularFormulas in the MolecularFormulaSet to this chemObject. * * @param formulaSet The MolecularFormulaSet */ @TestMethod("testAdd_IMolecularFormulaSet") public void add(IMolecularFormulaSet formulaSet) { for (IMolecularFormula mf : formulaSet.molecularFormulas()){ addMolecularFormula(mf); } /* * notifyChanged() is called by addAtomContainer() */ } /** * Adds an molecularFormula to this chemObject. * * @param formula The molecularFormula to be added to this chemObject */ @TestMethod("testAdd_IMolecularFormula") public void addMolecularFormula(IMolecularFormula formula) { components.add(formula); } /** * Returns an Iterable for looping over all IMolecularFormula * in this MolecularFormulaSet. * * @return An Iterable with the IMolecularFormula in this MolecularFormulaSet */ @TestMethod("testMolecularFormulas") public Iterable molecularFormulas() { return components; } /** * Returns an Iterator for looping over all IMolecularFormula * in this MolecularFormulaSet. * * @return An Iterator with the IMolecularFormula in this MolecularFormulaSet */ @TestMethod("testIterator") public Iterator iterator() { return components.iterator(); } /** * Returns the number of MolecularFormulas in this MolecularFormulaSet. * * @return The number of MolecularFormulas in this MolecularFormulaSet */ @TestMethod("testSize") public int size() { return components.size(); } /** * True, if the MolecularFormulaSet contains the given IMolecularFormula object. * * @param formula The IMolecularFormula this MolecularFormulaSet is searched for * @return True, if the MolecularFormulaSet contains the given IMolecularFormula object */ @TestMethod("testContains_IMolecularFormula") public boolean contains(IMolecularFormula formula) { return components.contains(formula); } /** * * Returns the MolecularFormula at position number in the * chemObject. * * @param position The position of the IMolecularFormula to be returned. * @return The IMolecularFormula at position number . */ @TestMethod("testGetMolecularFormula_int") public IMolecularFormula getMolecularFormula(int position) { return components.get(position); } /** * Removes all IMolecularFormula from this chemObject. */ @TestMethod("testRemoveAllMolecularFormulas") public void removeAllMolecularFormulas() { components.clear(); } /** * Removes an IMolecularFormula from this chemObject. * * @param formula The IMolecularFormula to be removed from this chemObject */ @TestMethod("testRemoveMolecularFormula_IMolecularFormula") public void removeMolecularFormula(IMolecularFormula formula) { components.remove(formula); } /** * Removes an MolecularFormula from this chemObject. * * @param position The position of the MolecularFormula to be removed from this chemObject */ @TestMethod("testRemoveMolecularFormula_int") public void removeMolecularFormula(int position) { components.remove(position); } /** * Clones this MolecularFormulaSet object and its content. * * @return The cloned object */ @TestMethod("testClone") public Object clone() throws CloneNotSupportedException { // /* it is not a super class of chemObject */ // MolecularFormulaSet clone = (MolecularFormulaSet) super.clone(); // // start from scratch // clone.removeAllMolecularFormulas(); // // clone all molecularFormulas // Iterator iterForm = this.molecularFormulas(); // while(iterForm.hasNext()){ // clone.addMolecularFormula((IMolecularFormula) iterForm.next().clone()); // } MolecularFormulaSet clone = new MolecularFormulaSet(); for (IMolecularFormula mf : this.molecularFormulas()){ clone.addMolecularFormula((IMolecularFormula) mf.clone()); } return clone; } public IChemObjectBuilder getBuilder() { return DefaultChemObjectBuilder.getInstance(); } } cdk-1.2.10/src/main/org/openscience/cdk/formula/rules/ChargeRule.java100644 0 0 6766 11570154753 22533 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2007 Miguel Rojasch * * 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. * * 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.formula.rules; import java.io.IOException; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IMolecularFormula; import org.openscience.cdk.tools.LoggingTool; /** * This class validate if the charge in the IMolecularFormula correspond with * a specific value. As default it is defined as neutral == 0.0. * * *

This rule uses these parameters: * * * * * * * * * * * *
NameDefaultDescription
charge0.0The Charge of MolecularFormula
* * @cdk.module formula * @author miguelrojasch * @cdk.created 2007-11-20 */ public class ChargeRule implements IRule{ private LoggingTool logger; private double charge = 0.0; /** * Constructor for the ChargeRule object. * * @throws IOException If an error occurs when reading atom type information * @throws ClassNotFoundException If an error occurs during tom typing */ public ChargeRule() { logger = new LoggingTool(this); } /** * Sets the parameters attribute of the ChargeRule object. * * @param params The new parameters value * @throws CDKException Description of the Exception * * @see #getParameters */ public void setParameters(Object[] params) throws CDKException { if (params.length != 1) throw new CDKException("ChargeRule expects only one parameter"); if(!(params[0] instanceof Double)) throw new CDKException("The parameter must be of type Double"); charge = (Double) params[0]; } /** * Gets the parameters attribute of the ChargeRule object. * * @return The parameters value * @see #setParameters */ public Object[] getParameters() { // return the parameters as used for the rule validation Object[] params = new Object[1]; params[0] = charge; return params; } /** * Validate the charge of this IMolecularFormula. * * @param formula Parameter is the IMolecularFormula * @return A double value meaning 1.0 True, 0.0 False */ public double validate(IMolecularFormula formula) throws CDKException { logger.info("Start validation of ",formula); if (formula.getCharge() == null) { return 0.0; } else if(formula.getCharge() == charge) { return 1.0; } else { return 0.0; } } } cdk-1.2.10/src/main/org/openscience/cdk/formula/rules/ElementRule.java100644 0 0 12773 11570154753 22746 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2007 Miguel Rojasch * * 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. * * 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.formula.rules; import java.io.IOException; import java.util.Iterator; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.formula.MolecularFormulaRange; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IElement; import org.openscience.cdk.interfaces.IIsotope; import org.openscience.cdk.interfaces.IMolecularFormula; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.manipulator.MolecularFormulaManipulator; /** * This class validate if the occurrence of the IElements in the IMolecularFormula * are into a limits. As default defines all elements of the periodic table with * a occurrence of zero to 100. * * *

This rule uses these parameters: * * * * * * * * * * * *
NameDefaultDescription
elementsC,H,N,OThe IELements to be analyzed
* * @cdk.module formula * @author miguelrojasch * @cdk.created 2007-11-20 */ public class ElementRule implements IRule{ private LoggingTool logger; private MolecularFormulaRange mfRange; /** * Constructor for the ElementRule object. * * @throws IOException If an error occurs when reading atom type information * @throws ClassNotFoundException If an error occurs during tom typing */ public ElementRule(){ logger = new LoggingTool(this); } /** * Sets the parameters attribute of the ElementRule object. * * @param params The new parameters value * @throws CDKException Description of the Exception * * @see #getParameters */ public void setParameters(Object[] params) throws CDKException { if (params.length != 1) throw new CDKException("ElementRule expects one parameters"); if(!(params[0] instanceof MolecularFormulaRange)) throw new CDKException("The parameter must be of type MolecularFormulaExpand"); mfRange = (MolecularFormulaRange)params[0]; } /** * Gets the parameters attribute of the ElementRule object. * * @return The parameters value * @see #setParameters */ public Object[] getParameters() { // return the parameters as used for the rule validation Object[] params = new Object[1]; params[0] = mfRange; return params; } /** * Validate the occurrence of this IMolecularFormula. * * @param formula Parameter is the IMolecularFormula * @return An ArrayList containing 9 elements in the order described above */ public double validate(IMolecularFormula formula) throws CDKException { logger.info("Start validation of ",formula); ensureDefaultOccurElements(formula.getBuilder()); double isValid = 1.0; Iterator itElem = MolecularFormulaManipulator.elements(formula).iterator(); while(itElem.hasNext()){ IElement element = itElem.next(); int occur = MolecularFormulaManipulator.getElementCount(formula, element); IIsotope elemIsotope = formula.getBuilder().newIsotope(element.getSymbol()); if((occur < mfRange.getIsotopeCountMin(elemIsotope)) || ( occur > mfRange.getIsotopeCountMax(elemIsotope))) { isValid = 0.0; break; } } return isValid; } /** * Initiate the MolecularFormulaExpand with the maximum and minimum occurrence of the Elements. * In this case all elements of the periodic table are loaded. */ private void ensureDefaultOccurElements(IChemObjectBuilder builder){ if (mfRange == null) { String[] elements = new String[]{ "C", "H", "O", "N", "Si", "P", "S", "F", "Cl", "Br", "I", "Sn", "B", "Pb", "Tl", "Ba", "In", "Pd", "Pt", "Os", "Ag", "Zr", "Se", "Zn", "Cu", "Ni", "Co", "Fe", "Cr", "Ti", "Ca", "K", "Al", "Mg", "Na", "Ce", "Hg", "Au", "Ir", "Re", "W", "Ta", "Hf", "Lu", "Yb", "Tm", "Er", "Ho", "Dy", "Tb", "Gd", "Eu", "Sm", "Pm", "Nd", "Pr", "La", "Cs", "Xe", "Te", "Sb", "Cd", "Rh", "Ru", "Tc", "Mo", "Nb", "Y", "Sr", "Rb", "Kr", "As", "Ge", "Ga", "Mn", "V", "Sc", "Ar", "Ne", "Be", "Li", "Tl", "Pb", "Bi", "Po", "At", "Rn", "Fr", "Ra", "Ac", "Th", "Pa", "U", "Np", "Pu"}; mfRange = new MolecularFormulaRange(); for(int i = 0; i < elements.length ; i++) mfRange.addIsotope( builder.newIsotope(elements[i]), 0, 50); } } } cdk-1.2.10/src/main/org/openscience/cdk/formula/rules/IRule.java100644 0 0 4736 11570154753 21525 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2007 Miguel Rojasch * * 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. * * 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.formula.rules; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IMolecularFormula; /** * Interface which groups all method that validate a IMolecularFormula. * * @cdk.module formula * @author miguelrojasch * @cdk.created 2007-11-20 */ public interface IRule { /** * Sets the parameters for this rule. * * Must be done before calling calculate as * the parameters influence the validation outcome. * * @param params An array of Object containing the parameters for this rule * @throws CDKException if invalid number of type of parameters are passed to it * @see #getParameters */ public void setParameters(Object[] params) throws CDKException; /** * Returns the current parameter values. * * @return An array of Object containing the parameter values * @see #setParameters * */ public Object[] getParameters(); /** * Analyze the validity for the given IMolecularFormula. * * @param formula An {@link IMolecularFormula} for which this rule * should be analyzed * @return A double value between 0 and 1. 1 meaning 100% valid * and 0 not valid * @throws CDKException if an error occurs during the validation. See * documentation for individual rules */ public double validate(IMolecularFormula formula) throws CDKException; }cdk-1.2.10/src/main/org/openscience/cdk/formula/rules/IsotopePatternRule.java100644 0 0 11472 11570154753 24330 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2007 Miguel Rojasch * * 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. * * 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.formula.rules; import java.io.IOException; import java.util.List; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.formula.IsotopeContainer; import org.openscience.cdk.formula.IsotopePattern; import org.openscience.cdk.formula.IsotopePatternGenerator; import org.openscience.cdk.formula.IsotopePatternManipulator; import org.openscience.cdk.formula.IsotopePatternSimilarity; import org.openscience.cdk.interfaces.IMolecularFormula; import org.openscience.cdk.tools.LoggingTool; /** * This class validate if the Isotope Pattern from a given IMolecularFormula * correspond with other to compare. * * *

This rule uses these parameters: * * * * * * * * * * * *
NameDefaultDescription
isotopePatternList The Isotope Pattern to compare
* * @cdk.module formula * @author Miguel Rojas Cherto * @cdk.created 2007-11-20 */ public class IsotopePatternRule implements IRule{ private LoggingTool logger; /** Accuracy on the mass measuring isotope pattern*/ private double toleranceMass = 0.001; private IsotopePattern pattern; IsotopePatternGenerator isotopeGe; private IsotopePatternSimilarity is; /** * Constructor for the IsotopePatternRule object. * * @throws IOException If an error occurs when reading atom type information * @throws ClassNotFoundException If an error occurs during tom typing */ public IsotopePatternRule() { isotopeGe = new IsotopePatternGenerator(0.01); is = new IsotopePatternSimilarity(); is.seTolerance(toleranceMass); logger = new LoggingTool(this); } /** * Sets the parameters attribute of the IsotopePatternRule object. * * @param params The new parameters value * @throws CDKException Description of the Exception * * @see #getParameters */ public void setParameters(Object[] params) throws CDKException { if (params.length != 2) throw new CDKException("IsotopePatternRule expects two parameter"); if(!(params[0] instanceof List )) throw new CDKException("The parameter one must be of type List"); if(!(params[1] instanceof Double )) throw new CDKException("The parameter two must be of type Double"); pattern = new IsotopePattern(); for(double[] listISO:(List) params[0]){ pattern.addIsotope(new IsotopeContainer(listISO[0],listISO[1])); } is.seTolerance((Double) params[1]); } /** * Gets the parameters attribute of the IsotopePatternRule object. * * @return The parameters value * @see #setParameters */ public Object[] getParameters() { // return the parameters as used for the rule validation Object[] params = new Object[2]; params[0] = pattern; params[1] = toleranceMass; return params; } /** * Validate the isotope pattern of this IMolecularFormula. Important, first * you have to add with the {@link #setParameters(Object[])} a IMolecularFormulaSet * which represents the isotope pattern to compare. * * @param formula Parameter is the IMolecularFormula * @return A double value meaning 1.0 True, 0.0 False */ public double validate(IMolecularFormula formula) throws CDKException { logger.info("Start validation of ",formula); IsotopePatternGenerator isotopeGe = new IsotopePatternGenerator(0.1); IsotopePattern patternIsoPredicted = isotopeGe.getIsotopes(formula); IsotopePattern patternIsoNormalize = IsotopePatternManipulator.normalize(patternIsoPredicted); return is.compare(pattern, patternIsoNormalize); } } cdk-1.2.10/src/main/org/openscience/cdk/formula/rules/MMElementRule.java100644 0 0 25751 11570154753 23200 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2007 Miguel Rojasch * * 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. * * 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.formula.rules; import java.io.IOException; import java.util.HashMap; import java.util.Iterator; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IElement; import org.openscience.cdk.interfaces.IMolecularFormula; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.manipulator.MolecularFormulaManipulator; /** * This class validate if the occurrence of the IElements in the IMolecularFormula, for * metabolites, are into a maximal limit according paper: . The study is from 2 different mass spectral * databases and according different mass of the metabolites. The analysis don't * take account if the IElement is not contained in the matrix. It will be jumped.

* The rules is based from Tobias Kind paper with the title "Seven Golden Rules for heuristic * filtering of molecular formula" {@cdk.cite kind2007}. * *

This rule uses these parameters: * * * * * * * * * * * * * * * * *
NameDefaultDescription
databasewilleyMass spectral databases extraction
massRange< 500Mass to take account
* * @cdk.module formula * @author miguelrojasch * @cdk.created 2007-11-20 */ public class MMElementRule implements IRule{ /** Database used. As default Willey.*/ private Database databaseUsed = Database.WILEY; /** Mass range used. As default lower than 500.*/ private RangeMass rangeMassUsed = RangeMass.Minus500; private HashMap hashMap; private LoggingTool logger; /** A enumeration of the possible mass range * according the rules */ public static enum RangeMass { /** IMolecularFormula from a metabolite with a mass lower than 500 Da. */ Minus500, /** IMolecularFormula from a metabolite with a mass lower than 1000 Da. */ Minus1000, /** IMolecularFormula from a metabolite with a mass lower than 2000 Da. */ Minus2000, /** IMolecularFormula from a metabolite with a mass lower than 3000 Da. */ Minus3000 } /** A enumeration of the possible databases * according the rules */ public static enum Database { /** Wiley mass spectral database. */ WILEY, /** Dictionary of Natural Products Online mass spectral database. */ DNP } /** * Constructor for the MMElementRule object. * * @throws IOException If an error occurs when reading atom type information * @throws ClassNotFoundException If an error occurs during tom typing */ public MMElementRule(){ logger = new LoggingTool(this); // initiate Hashmap default this.hashMap = getWisley_500(); } /** * Sets the parameters attribute of the MMElementRule object. * * @param params The new parameters value * @throws CDKException Description of the Exception * * @see #getParameters */ public void setParameters(Object[] params) throws CDKException { if (params.length > 2) throw new CDKException("MMElementRule only expects maximal two parameters"); if(params[0] != null){ if (!(params[0] instanceof Database) ) throw new CDKException("The parameter must be of type Database enum"); databaseUsed = (Database) params[0]; } if(params.length > 1 && params[1] != null){ if (!(params[1] instanceof RangeMass) ) throw new CDKException("The parameter must be of type RangeMass enum"); rangeMassUsed = (RangeMass) params[1]; } if((databaseUsed == Database.DNP)&&(rangeMassUsed == RangeMass.Minus500)) this.hashMap = getDNP_500(); else if((databaseUsed == Database.DNP)&&(rangeMassUsed == RangeMass.Minus1000)) this.hashMap = getDNP_1000(); else if((databaseUsed == Database.DNP)&&(rangeMassUsed == RangeMass.Minus2000)) this.hashMap = getDNP_2000(); else if((databaseUsed == Database.DNP)&&(rangeMassUsed == RangeMass.Minus3000)) this.hashMap = getDNP_3000(); else if((databaseUsed == Database.WILEY)&&(rangeMassUsed == RangeMass.Minus500)) this.hashMap = getWisley_500(); else if((databaseUsed == Database.WILEY)&&(rangeMassUsed == RangeMass.Minus1000)) this.hashMap = getWisley_1000(); else if((databaseUsed == Database.WILEY)&&(rangeMassUsed == RangeMass.Minus2000)) this.hashMap = getWisley_2000(); } /** * Gets the parameters attribute of the MMElementRule object. * * @return The parameters value * @see #setParameters */ public Object[] getParameters() { // return the parameters as used for the rule validation Object[] params = new Object[2]; params[0] = databaseUsed; params[1] = rangeMassUsed; return params; } /** * Validate the occurrence of this IMolecularFormula. * * @param formula Parameter is the IMolecularFormula * @return An ArrayList containing 9 elements in the order described above */ public double validate(IMolecularFormula formula) throws CDKException { logger.info("Start validation of ",formula); double isValid = 1.0; Iterator itElem = MolecularFormulaManipulator.elements(formula).iterator(); while(itElem.hasNext()){ IElement element = itElem.next(); int occur = MolecularFormulaManipulator.getElementCount(formula, element); if(occur > hashMap.get(element.getSymbol())){ isValid = 0.0; break; } } return isValid; } /** * Get the map linking the symbol of the element and number maximum of occurrence. * For the analysis with the DNP database and mass lower than 500 Da. * * @return The HashMap of the symbol linked with the maximum occurrence */ private HashMap getDNP_500(){ HashMap map = new HashMap(); map.put("C", 29); map.put("H", 72); map.put("N", 10); map.put("O", 18); map.put("P", 4); map.put("S", 7); map.put("F", 15); map.put("Cl", 8); map.put("Br", 5); return map; } /** * Get the map linking the symbol of the element and number maximum of occurrence. * For the analysis with the DNP database and mass lower than 1000 Da. * * @return The HashMap of the symbol linked with the maximum occurrence */ private HashMap getDNP_1000(){ HashMap map = new HashMap(); map.put("C", 66); map.put("H", 126); map.put("N", 25); map.put("O", 27); map.put("P", 6); map.put("S", 8); map.put("F", 16); map.put("Cl", 11); map.put("Br", 8); return map; } /** * Get the map linking the symbol of the element and number maximum of occurrence. * For the analysis with the DNP database and mass lower than 2000 Da. * * @return The HashMap of the symbol linked with the maximum occurrence */ private HashMap getDNP_2000(){ HashMap map = new HashMap(); map.put("C", 115); map.put("H", 236); map.put("N", 32); map.put("O", 63); map.put("P", 6); map.put("S", 8); map.put("F", 16); map.put("Cl", 11); map.put("Br", 8); return map; } /** * Get the map linking the symbol of the element and number maximum of occurrence. * For the analysis with the DNP database and mass lower than 3000 Da. * * @return The HashMap of the symbol linked with the maximum occurrence */ private HashMap getDNP_3000(){ HashMap map = new HashMap(); map.put("C", 162); map.put("H", 208); map.put("N", 48); map.put("O", 78); map.put("P", 6); map.put("S", 9); map.put("F", 16); map.put("Cl", 11); map.put("Br", 8); return map; } /** * Get the map linking the symbol of the element and number maximum of occurrence. * For the analysis with the Wisley database and mass lower than 500 Da. * * @return The HashMap of the symbol linked with the maximum occurrence */ private HashMap getWisley_500(){ HashMap map = new HashMap(); map.put("C", 39); map.put("H", 72); map.put("N", 20); map.put("O", 20); map.put("P", 9); map.put("S", 10); map.put("F", 16); map.put("Cl", 10); map.put("Br", 4); map.put("Br", 8); return map; } /** * Get the map linking the symbol of the element and number maximum of occurrence. * For the analysis with the Wisley database and mass lower than 1000 Da. * * @return The HashMap of the symbol linked with the maximum occurrence */ private HashMap getWisley_1000(){ HashMap map = new HashMap(); map.put("C", 78); map.put("H", 126); map.put("N", 20); map.put("O", 27); map.put("P", 9); map.put("S", 14); map.put("F", 34); map.put("Cl", 12); map.put("Br", 8); map.put("Si", 14); return map; } /** * Get the map linking the symbol of the element and number maximum of occurrence. * For the analysis with the Wisley database and mass lower than 2000 Da. * * @return The HashMap of the symbol linked with the maximum occurrence */ private HashMap getWisley_2000(){ HashMap map = new HashMap(); map.put("C", 156); map.put("H", 180); map.put("N", 20); map.put("O", 40); map.put("P", 9); map.put("S", 14); map.put("F", 48); map.put("Cl", 12); map.put("Br", 10); map.put("Si", 15); return map; } } cdk-1.2.10/src/main/org/openscience/cdk/formula/rules/NitrogenRule.java100644 0 0 11315 11570154753 23131 0ustar 0 0 /* $RCSfile$ * $Author: egonw $ * $Date: 2008-05-11 08:06:41 +0200 (Sun, 11 May 2008) $ * $Revision: 10958 $ * * Copyright (C) 2007 Miguel Rojasch * * 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. * * 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.formula.rules; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IMolecularFormula; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.manipulator.MolecularFormulaManipulator; /** * This class validate if the rule of nitrogen is kept. *

If a compound has an odd number of nitrogen atoms, * then the molecular ion (the [M]+) will have an odd mass and the value for m/e will be odd.

*

If a compound has no nitrogen atom or an even number of nitrogen atoms, then the m/e value of [M]+ will be even.

* * *

This rule uses these parameters: * * * * * * * * * * * *
NameDefaultDescription
charge0.0The Nitrogen rule of MolecularFormula
* * @cdk.module formula * @author miguelrojasch * @cdk.created 2008-06-11 */ public class NitrogenRule implements IRule{ private LoggingTool logger; /** * Constructor for the NitrogenRule object. */ public NitrogenRule() { logger = new LoggingTool(this); } /** * Sets the parameters attribute of the NitrogenRule object. * * @param params The new parameters value * @throws CDKException Description of the Exception * * @see #getParameters */ public void setParameters(Object[] params) throws CDKException { if (params != null) throw new CDKException("NitrogenRule doesn't expect parameters"); } /** * Gets the parameters attribute of the NitrogenRule object. * * @return The parameters value * @see #setParameters */ public Object[] getParameters() { return null; } /** * Validate the nitrogen rule of this IMolecularFormula. * * @param formula Parameter is the IMolecularFormula * @return A double value meaning 1.0 True, 0.0 False */ public double validate(IMolecularFormula formula) throws CDKException { logger.info("Start validation of ",formula); double mass = MolecularFormulaManipulator.getTotalMassNumber(formula); if(mass == 0) return 0.0; int numberN = MolecularFormulaManipulator.getElementCount(formula, formula.getBuilder().newElement("N")); numberN += getOthers(formula); if(formula.getCharge() == null || formula.getCharge() == 0 || !isOdd(Math.abs(formula.getCharge()))){ if(isOdd(mass) && isOdd(numberN)) { return 1.0; } else if(!isOdd(mass) && ( numberN == 0 || !isOdd(numberN))){ return 1.0; } else return 0.0; }else{ if(!isOdd(mass) && isOdd(numberN)) { return 1.0; } else if(isOdd(mass) && ( numberN == 0 || !isOdd(numberN))){ return 1.0; } else return 0.0; } } /** * Get the number of other elements which affect to the calculation of the nominal mass. * For example Fe, Co, Hg, Pt, As. * * @param formula The IMolecularFormula to analyze * @return Number of elements */ private int getOthers(IMolecularFormula formula) { int number = 0; String[] elements = {"Co","Hg","Pt","As"}; for(int i = 0 ; i < elements.length; i++) number += MolecularFormulaManipulator.getElementCount(formula, formula.getBuilder().newElement(elements[i])); return number; } /** * Determine if a integer is odd. * * @param value The value to analyze * @return True, if the integer is odd */ private boolean isOdd(double value) { if(value % 2 == 0) return false; else return true; } } cdk-1.2.10/src/main/org/openscience/cdk/formula/rules/RDBERule.java100644 0 0 32343 11570154753 22064 0ustar 0 0 /* $RCSfile$ * $Author: egonw $ * $Date: 2008-05-11 08:06:41 +0200 (Sun, 11 May 2008) $ * $Revision: 10958 $ * * Copyright (C) 2007 Miguel Rojasch * * 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. * * 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.formula.rules; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IIsotope; import org.openscience.cdk.interfaces.IMolecularFormula; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.manipulator.MolecularFormulaManipulator; import java.util.*; /** *

Ring Double Bond Equivalents (RDBE) or * Double Bond Equivalents (DBE) are calculated from valence values of * elements contained in a formula and should tell the number of bonds - or rings. * Since this formula will fail for MFs with higher valence states such as * N(V), P(V), S(IV) or S(VI), this method will focus on the lowest valence state for these elements.

*

The equation used is: D = 1 + [0.5 SUM_i(N_i(V_I-2))]

*

where D is the unsaturation, i is the total number of different elements in the composition, N_i the number * of atoms of element i, and Vi is the common valence of the atom i.

*

This rule uses these parameters: * * * * * * * * * * * *
NameDefaultDescription
charge0.0The RDBE rule of MolecularFormula
* * @cdk.module formula * @author miguelrojasch * @cdk.created 2008-06-11 */ public class RDBERule implements IRule{ private static Map oxidationStateTable = null; private LoggingTool logger; private double min = -0.5; private double max = 30; /** * Constructor for the RDBE object. */ public RDBERule() { logger = new LoggingTool(this); createTable(); } /** * Sets the parameters attribute of the RDBE object. * * @param params The new parameters value * @throws CDKException Description of the Exception * * @see #getParameters */ public void setParameters(Object[] params) throws CDKException { if (params.length != 2) throw new CDKException("RDBERule expects two parameters"); if(!(params[0] instanceof Double)) throw new CDKException("The 1 parameter must be of type Double"); if(!(params[1] instanceof Double)) throw new CDKException("The 2 parameter must be of type Double"); min = (Double)params[0]; max = (Double)params[1]; } /** * Gets the parameters attribute of the RDBRule object. * * @return The parameters value * @see #setParameters */ public Object[] getParameters() { // return the parameters as used for the rule validation Object[] params = new Object[2]; params[0] = min; params[1] = max; return params; } /** * Validate the RDBRule of this IMolecularFormula. * * @param formula Parameter is the IMolecularFormula * @return A double value meaning 1.0 True, 0.0 False */ public double validate(IMolecularFormula formula) throws CDKException { logger.info("Start validation of ",formula); List RDBEList = getRDBEValue(formula); for(Iterator it = RDBEList.iterator(); it.hasNext();){ double RDBE = it.next(); if(min <= RDBE && RDBE <= 30) if(validate(formula, RDBE)) return 1.0; } return 0.0; } /** * Validate the ion state. It takes into account that neutral, nonradical compounds * always have an even-numbered pair-wiser arrangement of binding electrons signilizaded * by an integer DBE value. Charged compounds due to soft ionzation techniques * will give an odd number of binding electrons and a fractional DBE (X.05). * * @param formula Parameter is the IMolecularFormula * @param value The RDBE value * @return True, if corresponds with */ public boolean validate(IMolecularFormula formula, double value) throws CDKException { double charge = 0.0; if(formula.getCharge() != CDKConstants.UNSET) charge = formula.getCharge(); long iPart = (long) value; double fPart = value - iPart; if(fPart == 0.0 && charge == 0) return true; if(fPart != 0.0 && charge != 0) return true; else return false; } /** * Method to extract the Ring Double Bond Equivalents (RDB) value. It test all possible * oxidation states. * * @param formula The IMolecularFormula object * @return The RDBE value * @see #createTable() */ public List getRDBEValue(IMolecularFormula formula) { List RDBEList = new ArrayList(); // The number of combinations with repetition // (v+n-1)!/[n!(v-1)!] int nE = 0; // number of elements to change List nV = new ArrayList(); // number of valence changing for(Iterator it = formula.isotopes().iterator(); it.hasNext();){ IIsotope isotope = it.next(); int[] valence = getOxidationState(formula.getBuilder().newAtom(isotope.getSymbol())); if(valence.length != 1){ for(int i = 0; i < valence.length; i++){ nV.add(valence[i]); } nE += MolecularFormulaManipulator.getElementCount(formula, formula.getBuilder().newElement(isotope.getSymbol())); } } double RDBE = 0; if(nE == 0){ for(Iterator it = formula.isotopes().iterator(); it.hasNext();){ IIsotope isotope = it.next(); int[] valence = getOxidationState(formula.getBuilder().newAtom(isotope.getSymbol())); double value = (valence[0]-2)*formula.getIsotopeCount(isotope)/2.0; RDBE += value; } RDBE += 1; RDBEList.add(RDBE); }else{ double RDBE_1 = 0; for(Iterator it = formula.isotopes().iterator(); it.hasNext();){ IIsotope isotope = it.next(); int[] valence = getOxidationState(formula.getBuilder().newAtom(isotope.getSymbol())); double value = (valence[0]-2)*formula.getIsotopeCount(isotope)*0.5; RDBE_1 += value; } String[] valences = new String[nV.size()]; for(int i = 0 ; i < valences.length; i++) valences[i] = Integer.toString(nV.get(i)); Combinations c = new Combinations(valences, nE); while (c.hasMoreElements()) { double RDBE_int = 0.0; Object[] combo = (Object[])c.nextElement(); for (int i = 0; i < combo.length; i++) { int value = (Integer.parseInt((String)combo[i])-2)/2; RDBE_int += value; } RDBE = 1 + RDBE_1 + RDBE_int; RDBEList.add(RDBE); } } return RDBEList; } /** * Get the common oxidation state given a atom. * * @param newAtom The IAtom * @return The oxidation state value */ private int[] getOxidationState(IAtom newAtom) { return oxidationStateTable.get(newAtom.getSymbol()); } /** * Create the table with the common oxidation states */ private void createTable() { if (oxidationStateTable == null) { oxidationStateTable = new HashMap(); oxidationStateTable.put("H", new int[]{1}); // oxidationStateTable.put("Li", 1); // oxidationStateTable.put("Be", 2); oxidationStateTable.put("B", new int[]{3}); oxidationStateTable.put("C", new int[]{4}); oxidationStateTable.put("N", new int[]{3}); oxidationStateTable.put("O", new int[]{2}); oxidationStateTable.put("F", new int[]{1}); oxidationStateTable.put("Na", new int[]{1}); oxidationStateTable.put("Mg", new int[]{2}); oxidationStateTable.put("Al", new int[]{3}); oxidationStateTable.put("Si", new int[]{4}); oxidationStateTable.put("P", new int[]{3,5}); oxidationStateTable.put("S", new int[]{2,4,6}); oxidationStateTable.put("Cl", new int[]{1}); // oxidationStateTable.put("K", 1); // oxidationStateTable.put("Ca", 2); // oxidationStateTable.put("Ga", 3); // oxidationStateTable.put("Ge", 4); // oxidationStateTable.put("As", 5); // oxidationStateTable.put("Se", 6); // oxidationStateTable.put("Br", 7); // oxidationStateTable.put("Rb", 1); // oxidationStateTable.put("Sr", 2); // oxidationStateTable.put("In", 3); // oxidationStateTable.put("Sn", 4); // oxidationStateTable.put("Sb", 5); // oxidationStateTable.put("Te", 6); oxidationStateTable.put("I", new int[]{1}); // oxidationStateTable.put("Cs", 1); // oxidationStateTable.put("Ba", 2); // oxidationStateTable.put("Tl", 3); // oxidationStateTable.put("Pb", 4); // oxidationStateTable.put("Bi", 5); // oxidationStateTable.put("Po", 6); // oxidationStateTable.put("At", 7); // oxidationStateTable.put("Fr", 1); // oxidationStateTable.put("Ra", 2); // oxidationStateTable.put("Cu", 2); // oxidationStateTable.put("Mn", 2); // oxidationStateTable.put("Co", 2); } } public class Combinations{ private Object[] inArray; private int n, m; private int[] index; private boolean hasMore = true; /** * Create a Combination to enumerate through all subsets of the * supplied Object array, selecting m at a time. * * @param inArray the group to choose from * @param m int the number to select in each choice */ public Combinations(Object[] inArray, int m){ this.inArray = inArray; this.n = inArray.length; this.m = m; /** * index is an array of ints that keep track of the next combination to return. * For example, an index on 5 things taken 3 at a time might contain {0 3 4}. * This index will be followed by {1 2 3}. Initially, the index is {0 ... m - 1}. */ index = new int[m]; for (int i = 0; i < m; i++) index[0] = 0; } /** * @return true, unless we have already returned the last combination. */ public boolean hasMoreElements() { return hasMore; } /** * Move the index forward a notch. The algorithm finds the rightmost * index element that can be incremented, increments it, and then * changes the elements to the right to each be 1 plus the element on their left. *

* For example, if an index of 5 things taken 3 at a time is at {0 3 4}, only the 0 can * be incremented without running out of room. The next index is {1, 1+1, 1+2) or * {1, 2, 3}. This will be followed by {1, 2, 4}, {1, 3, 4}, and {2, 3, 4}. *

* The algorithm is from Applied Combinatorics, by Alan Tucker. * */ private void moveIndex(){ int i = rightmostIndexBelowMax(); if (i >= 0){ index[i] = index[i] + 1; for (int j = i + 1; j < m; j++) index[j] = index[j-1]; }else hasMore = false; } /** * @return java.lang.Object, the next combination from the supplied Object array. *

* Actually, an array of Objects is returned. The declaration must say just Object, * because the Combinations class implements Enumeration, which declares that the * nextElement() returns a plain Object. Users must cast the returned object to (Object[]). */ public Object nextElement() { if (!hasMore) return null; Object[] out = new Object[m]; for (int i = 0; i < m; i++){ out[i] = inArray[index[i]]; } moveIndex(); return out; } /** * @return int, the index which can be bumped up. */ private int rightmostIndexBelowMax(){ for (int i = m-1; i >= 0; i--){ int s = n -1; if (index[i] != s) return i; } return -1; } } } cdk-1.2.10/src/main/org/openscience/cdk/formula/rules/ToleranceRangeRule.java100644 0 0 10025 11570154753 24232 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2007 Miguel Rojasch * * 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. * * 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.formula.rules; import java.io.IOException; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IMolecularFormula; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.manipulator.MolecularFormulaManipulator; /** * This class validate if the mass from an IMolecularFormula is * between the tolerance range give a experimental mass. As default * the mass to range is 0.0. * * *

This rule uses these parameters: * * * * * * * * * * * * * * * * *
NameDefaultDescription
mass0.0The Mass which the MolecularFormula has to be compared
tolerance0.05The range tolerance
* * @cdk.module formula * @author miguelrojasch * @cdk.created 2007-11-20 */ public class ToleranceRangeRule implements IRule{ private LoggingTool logger; private double mass = 0.0; private double tolerance = 0.05; /** * Constructor for the ToleranceRangeRule object. * * @throws IOException If an error occurs when reading atom type information * @throws ClassNotFoundException If an error occurs during tom typing */ public ToleranceRangeRule(){ logger = new LoggingTool(this); } /** * Sets the parameters attribute of the ToleranceRangeRule object. * * @param params The new parameters value * @throws CDKException Description of the Exception * * @see #getParameters */ public void setParameters(Object[] params) throws CDKException { if (params.length > 2) throw new CDKException("ToleranceRangeRule expects only two parameter"); if(!(params[0] instanceof Double)) throw new CDKException("The parameter 0 must be of type Double"); if(!(params[1] instanceof Double)) throw new CDKException("The parameter 1 must be of type Double"); mass = (Double) params[0]; tolerance = (Double) params[1]; } /** * Gets the parameters attribute of the ToleranceRangeRule object. * * @return The parameters value * @see #setParameters */ public Object[] getParameters() { // return the parameters as used for the rule validation Object[] params = new Object[2]; params[0] = mass; params[1] = tolerance; return params; } /** * Validate the Tolerance Range of this IMolecularFormula. * * @param formula Parameter is the IMolecularFormula * @return A double value meaning 1.0 True, 0.0 False */ public double validate(IMolecularFormula formula) throws CDKException { logger.info("Start validation of ",formula); double totalExactMass = MolecularFormulaManipulator.getTotalExactMass(formula); if(Math.abs(totalExactMass - mass) > tolerance) return 0.0; else return 1.0; } } cdk-1.2.10/src/main/org/openscience/cdk/geometry/AtomTools.java100644 0 0 45162 11570154753 21500 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.geometry; import java.util.List; import javax.vecmath.Point3d; import javax.vecmath.Vector3d; import org.openscience.cdk.Atom; import org.openscience.cdk.AtomContainer; import org.openscience.cdk.Bond; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.interfaces.IAtom; /** * A set of static utility classes for geometric calculations on Atoms. * * @author Peter Murray-Rust * @cdk.githash * @cdk.created 2003-06-14 */ public class AtomTools { public final static double TETRAHEDRAL_ANGLE = 2.0 * Math.acos(1.0 / Math.sqrt(3.0)); /** * Generate coordinates for all atoms which are singly bonded and have * no coordinates. This is useful when hydrogens are present but have * no coords. It knows about C, O, N, S only and will give tetrahedral or * trigonal geometry elsewhere. Bond lengths are computed from covalent radii * if available. Angles are tetrahedral or trigonal * * @param atomContainer the set of atoms involved * * @cdk.keyword coordinate calculation * @cdk.keyword 3D model */ public static void add3DCoordinates1(AtomContainer atomContainer) { // atoms without coordinates AtomContainer noCoords = new AtomContainer(); // get vector of possible referenceAtoms? AtomContainer refAtoms = new AtomContainer(); for (int i = 0; i < atomContainer.getAtomCount(); i++) { IAtom atom = atomContainer.getAtom(i); // is this atom without 3D coords, and has only one ligand? if (atom.getPoint3d() == null) { java.util.List connectedAtoms = atomContainer.getConnectedAtomsList(atom); if (connectedAtoms.size() == 1) { IAtom refAtom = (IAtom)connectedAtoms.get(0);; if (refAtom.getPoint3d() != null) { refAtoms.addAtom(refAtom); // store atoms with no coords and ref atoms in a // single container noCoords.addAtom(atom); noCoords.addAtom(refAtom); // bond is required to extract ligands noCoords.addBond(new Bond(atom, refAtom, CDKConstants.BONDORDER_SINGLE)); } } } } // now add coordinates to ligands of reference atoms // use default length of 1.0, which can be adjusted later double length = 1.0; double angle = TETRAHEDRAL_ANGLE; for (int i = 0; i < refAtoms.getAtomCount(); i++) { IAtom refAtom = refAtoms.getAtom(i); java.util.List noCoordLigands = noCoords.getConnectedAtomsList(refAtom); int nLigands = noCoordLigands.size(); int nwanted = nLigands; String elementType = refAtom.getSymbol(); // try to deal with lone pairs on small hetero if (elementType.equals("N") || elementType.equals("O") || elementType.equals("S")) { nwanted = 3; } Point3d[] newPoints = calculate3DCoordinatesForLigands( atomContainer, refAtom, nwanted, length, angle); for (int j = 0; j < nLigands; j++) { IAtom ligand = (IAtom)noCoordLigands.get(j); Point3d newPoint = rescaleBondLength(refAtom, ligand, newPoints[j]); ligand.setPoint3d(newPoint); } } } /** * Rescales Point2 so that length 1-2 is sum of covalent radii. * if covalent radii cannot be found, use bond length of 1.0 * * @param atom1 stationary atom * @param atom2 moveable atom * @param point2 coordinates for atom 2 * @return new coords for atom 2 */ public static Point3d rescaleBondLength( IAtom atom1, IAtom atom2, Point3d point2) { Point3d point1 = atom1.getPoint3d(); double d1 = atom1.getCovalentRadius(); double d2 = atom2.getCovalentRadius(); // in case we have no covalent radii, set to 1.0 double distance = (d1 < 0.1 || d2 < 0.1) ? 1.0 : atom1.getCovalentRadius() + atom2.getCovalentRadius(); Vector3d vect = new Vector3d(point2); vect.sub(point1); vect.normalize(); vect.scale(distance); Point3d newPoint = new Point3d(point1); newPoint.add(vect); return newPoint; } /** * Adds 3D coordinates for singly-bonded ligands of a reference atom (A). * Initially designed for hydrogens. The ligands of refAtom are identified * and those with 3D coordinates used to generate the new points. (This * allows structures with partially known 3D coordinates to be used, as when * groups are added.) * "Bent" and "non-planar" groups can be formed by taking a subset of the * calculated points. Thus R-NH2 could use 2 of the 3 points calculated * from (1,iii) * nomenclature: A is point to which new ones are "attached". * A may have ligands B, C... * B may have ligands J, K.. * points X1, X2... are returned * The cases (see individual routines, which use idealised geometry by default): * (0) zero ligands of refAtom. The resultant points are randomly oriented: * (i) 1 points required; +x,0,0 * (ii) 2 points: use +x,0,0 and -x,0,0 * (iii) 3 points: equilateral triangle in xy plane * (iv) 4 points x,x,x, x,-x,-x, -x,x,-x, -x,-x,x * (1a) 1 ligand(B) of refAtom which itself has a ligand (J) * (i) 1 points required; vector along AB vector * (ii) 2 points: 2 vectors in ABJ plane, staggered and eclipsed wrt J * (iii) 3 points: 1 staggered wrt J, the others +- gauche wrt J * (1b) 1 ligand(B) of refAtom which has no other ligands. A random J is * generated and (1a) applied * (2) 2 ligands(B, C) of refAtom A * (i) 1 points required; vector in ABC plane bisecting AB, AC. If ABC is * linear, no points * (ii) 2 points: 2 vectors at angle ang, whose resultant is 2i * (3) 3 ligands(B, C, D) of refAtom A * (i) 1 points required; if A, B, C, D coplanar, no points. * else vector is resultant of BA, CA, DA * fails if atom itself has no coordinates or >4 ligands * * @param atomContainer describing the ligands of refAtom. It could be the * whole molecule, or could be a selected subset of ligands * @param refAtom (A) to which new ligands coordinates could be added * @param length A-X length * @param angle B-A-X angle (used in certain cases) * @return Point3D[] points calculated. If request could not be fulfilled (e.g. * too many atoms, or strange geometry, returns empty array (zero length, * not null) * * @cdk.keyword coordinate generation */ public static Point3d[] calculate3DCoordinatesForLigands( AtomContainer atomContainer, IAtom refAtom, int nwanted, double length, double angle) { Point3d newPoints[] = new Point3d[0]; Point3d aPoint = refAtom.getPoint3d(); // get ligands List connectedAtoms = atomContainer.getConnectedAtomsList(refAtom); if (connectedAtoms == null) { return newPoints; } int nligands = connectedAtoms.size(); AtomContainer ligandsWithCoords = new AtomContainer(); for (int i = 0; i < nligands; i++) { Atom ligand = (Atom) connectedAtoms.get(i); if (ligand.getPoint3d() != null) { ligandsWithCoords.addAtom(ligand); } } int nwithCoords = ligandsWithCoords.getAtomCount(); // too many ligands at present if (nwithCoords > 3) { return newPoints; } if (nwithCoords == 0) { newPoints = calculate3DCoordinates0(refAtom.getPoint3d(), nwanted, length); } else if (nwithCoords == 1) { // ligand on A IAtom bAtom = ligandsWithCoords.getAtom(0); connectedAtoms = ligandsWithCoords.getConnectedAtomsList(bAtom); // does B have a ligand (other than A) Atom jAtom = null; for (int i = 0; i < connectedAtoms.size(); i++) { Atom connectedAtom = (Atom) connectedAtoms.get(i); if (!connectedAtom.equals(refAtom)) { jAtom = connectedAtom; break; } } newPoints = calculate3DCoordinates1(aPoint, bAtom.getPoint3d(), (jAtom != null) ? jAtom.getPoint3d() : null, nwanted, length, angle); } else if (nwithCoords == 2) { Point3d bPoint = ligandsWithCoords.getAtom(0).getPoint3d(); Point3d cPoint = ligandsWithCoords.getAtom(1).getPoint3d(); newPoints = calculate3DCoordinates2(aPoint, bPoint, cPoint, nwanted, length, angle); } else if (nwithCoords == 3) { Point3d bPoint = ligandsWithCoords.getAtom(0).getPoint3d(); Point3d cPoint = ligandsWithCoords.getAtom(1).getPoint3d(); Point3d dPoint = ligandsWithCoords.getAtom(2).getPoint3d(); newPoints = new Point3d[1]; newPoints[0] = calculate3DCoordinates3(aPoint, bPoint, cPoint, dPoint, length); } return newPoints; } /** * Calculates substituent points. * Calculate substituent points for * (0) zero ligands of aPoint. The resultant points are randomly oriented: * (i) 1 points required; +x,0,0 * (ii) 2 points: use +x,0,0 and -x,0,0 * (iii) 3 points: equilateral triangle in xy plane * (iv) 4 points x,x,x, x,-x,-x, -x,x,-x, -x,-x,x where 3x**2 = bond length * * @param aPoint to which substituents are added * @param nwanted number of points to calculate (1-4) * @param length from aPoint * * @return Point3d[] nwanted points (or zero if failed) */ public static Point3d[] calculate3DCoordinates0(Point3d aPoint, int nwanted, double length) { Point3d points[] = new Point3d[0]; if (nwanted == 1) { points = new Point3d[1]; points[0] = new Point3d(aPoint); points[0].add(new Vector3d(length, 0.0, 0.0)); } else if (nwanted == 2) { points[0] = new Point3d(aPoint); points[0].add(new Vector3d(length, 0.0, 0.0)); points[1] = new Point3d(aPoint); points[1].add(new Vector3d(-length, 0.0, 0.0)); } else if (nwanted == 3) { points[0] = new Point3d(aPoint); points[0].add(new Vector3d(length, 0.0, 0.0)); points[1] = new Point3d(aPoint); points[1].add(new Vector3d(-length * 0.5, -length * 0.5 * Math.sqrt(3.0), 0.0f)); points[2] = new Point3d(aPoint); points[2].add(new Vector3d(-length * 0.5, length * 0.5 * Math.sqrt(3.0), 0.0f)); } else if (nwanted == 4) { double dx = length / Math.sqrt(3.0); points[0] = new Point3d(aPoint); points[0].add(new Vector3d(dx, dx, dx)); points[1] = new Point3d(aPoint); points[1].add(new Vector3d(dx, -dx, -dx)); points[2] = new Point3d(aPoint); points[2].add(new Vector3d(-dx, -dx, dx)); points[3] = new Point3d(aPoint); points[3].add(new Vector3d(-dx, dx, -dx)); } return points; } /** * Calculate new point(s) X in a B-A system to form B-A-X. * Use C as reference for * staggering about the B-A bond * * (1a) 1 ligand(B) of refAtom (A) which itself has a ligand (C) * (i) 1 points required; vector along AB vector * (ii) 2 points: 2 vectors in ABC plane, staggered and eclipsed wrt C * (iii) 3 points: 1 staggered wrt C, the others +- gauche wrt C * If C is null, a random non-colinear C is generated * * @param aPoint to which substituents are added * @param nwanted number of points to calculate (1-3) * @param length A-X length * @param angle B-A-X angle * * @return Point3d[] nwanted points (or zero if failed) */ public static Point3d[] calculate3DCoordinates1( Point3d aPoint, Point3d bPoint, Point3d cPoint, int nwanted, double length, double angle) { Point3d points[] = new Point3d[nwanted]; // BA vector Vector3d ba = new Vector3d(aPoint); ba.sub(bPoint); ba.normalize(); // if no cPoint, generate a random reference if (cPoint == null) { Vector3d cVector = getNonColinearVector(ba); cPoint = new Point3d(cVector); } // CB vector Vector3d cb = new Vector3d(bPoint); cb.sub(cPoint); cb.normalize(); // if A, B, C colinear, replace C by random point double cbdotba = cb.dot(ba); if (cbdotba > 0.999999) { Vector3d cVector = getNonColinearVector(ba); cPoint = new Point3d(cVector); cb = new Vector3d(bPoint); cb.sub(cPoint); } // cbxba = c x b Vector3d cbxba = new Vector3d(); cbxba.cross(cb, ba); cbxba.normalize(); // create three perp axes ba, cbxba, and ax Vector3d ax = new Vector3d(); ax.cross(cbxba, ba); ax.normalize(); double drot = Math.PI * 2.0 / (double) nwanted; for (int i = 0; i < nwanted; i++) { double rot = (double) i * drot; points[i] = new Point3d(aPoint); Vector3d vx = new Vector3d(ba); vx.scale(-Math.cos(angle) * length); Vector3d vy = new Vector3d(ax); vy.scale(Math.cos(rot) * length); Vector3d vz = new Vector3d(cbxba); vz.scale(Math.sin(rot) * length); points[i].add(vx); points[i].add(vy); points[i].add(vz); } return points; } /** * Calculate new point(s) X in a B-A-C system. It forms form a B-A(-C)-X system. * * (2) 2 ligands(B, C) of refAtom A * (i) 1 points required; vector in ABC plane bisecting AB, AC. If ABC is * linear, no points * (ii) 2 points: 2 points X1, X2, X1-A-X2 = angle about 2i vector * * @param aPoint to which substituents are added * @param bPoint first ligand of A * @param cPoint second ligand of A * @param nwanted number of points to calculate (1-2) * @param length A-X length * @param angle B-A-X angle * * @return Point3d[] nwanted points (or zero if failed) */ public static Point3d[] calculate3DCoordinates2( Point3d aPoint, Point3d bPoint, Point3d cPoint, int nwanted, double length, double angle) { Point3d newPoints[] = new Point3d[0]; double ang2 = angle / 2.0; Vector3d ba = new Vector3d(aPoint); ba.sub(bPoint); Vector3d ca = new Vector3d(aPoint); ca.sub(cPoint); Vector3d baxca = new Vector3d(); baxca.cross(ba, ca); if (baxca.length() < 0.00000001) { ; // linear } else if (nwanted == 1) { newPoints = new Point3d[1]; Vector3d ax = new Vector3d(ba); ax.add(ca); ax.normalize(); ax.scale(length); newPoints[0] = new Point3d(aPoint); newPoints[0].add(ax); } else if (nwanted == 2) { newPoints = new Point3d[2]; Vector3d ax = new Vector3d(ba); ax.add(ca); ax.normalize(); baxca.normalize(); baxca.scale(Math.sin(ang2) * length); ax.scale(Math.cos(ang2) * length); newPoints[0] = new Point3d(aPoint); newPoints[0].add(ax); newPoints[0].add(baxca); newPoints[1] = new Point3d(aPoint); newPoints[1].add(ax); newPoints[1].sub(baxca); } return newPoints; } /** * Calculate new point X in a B-A(-D)-C system. It forms a B-A(-D)(-C)-X system. * * (3) 3 ligands(B, C, D) of refAtom A * (i) 1 points required; if A, B, C, D coplanar, no points. * else vector is resultant of BA, CA, DA * * @param aPoint to which substituents are added * @param bPoint first ligand of A * @param cPoint second ligand of A * @param dPoint third ligand of A * @param length A-X length * * @return Point3d nwanted points (or null if failed (coplanar)) */ public static Point3d calculate3DCoordinates3( Point3d aPoint, Point3d bPoint, Point3d cPoint, Point3d dPoint, double length) { Vector3d v1 = new Vector3d(aPoint); v1.sub(bPoint); Vector3d v2 = new Vector3d(aPoint); v2.sub(cPoint); Vector3d v3 = new Vector3d(aPoint); v3.sub(dPoint); Vector3d v = new Vector3d(bPoint); v.add(cPoint); v.add(dPoint); if (v.length() < 0.00001) { return null; } v.normalize(); v.scale(length); Point3d point = new Point3d(aPoint); point.add(v); return point; } final static Vector3d XV = new Vector3d(1.0, 0.0, 0.0); final static Vector3d YV = new Vector3d(0.0, 1.0, 0.0); // gets a point not on vector a...b; this can be used to define a plan or cross products private static Vector3d getNonColinearVector(Vector3d ab) { Vector3d cr = new Vector3d(); cr.cross(ab, XV); if (cr.length() > 0.00001) { return XV; } else { return YV; } } } cdk-1.2.10/src/main/org/openscience/cdk/geometry/BondTools.java100644 0 0 56444 11570154753 21467 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2002-2003 The Jmol Project * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.geometry; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.graph.invariant.MorganNumbersTools; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; import javax.vecmath.Point2d; import java.util.ArrayList; import java.util.List; import java.util.TreeMap; /** * A set of static utility classes for geometric calculations on {@link IBond}s. * The methods for detecting stereo configurations are described in CDK news, vol 2, p. 64 - 66. * * @author shk3 * @cdk.created 2005-08-04 * @cdk.module standard * @cdk.githash */ @TestClass("org.openscience.cdk.geometry.BondToolsTest") public class BondTools { // FIXME: class JavaDoc should use {@cdk.cite BLA} for the CDK News article /** * Tells if a certain bond is center of a valid double bond configuration. * * @param container The atomcontainer. * @param bond The bond. * @return true=is a potential configuration, false=is not. */ @TestMethod("testIsValidDoubleBondConfiguration_IAtomContainer_IBond") public static boolean isValidDoubleBondConfiguration(IAtomContainer container, IBond bond) { //org.openscience.cdk.interfaces.IAtom[] atoms = bond.getAtoms(); List connectedAtoms = container.getConnectedAtomsList(bond.getAtom(0)); IAtom from = null; for (IAtom connectedAtom : connectedAtoms) { if (connectedAtom != bond.getAtom(1)) { from = connectedAtom; } } boolean[] array = new boolean[container.getBondCount()]; for (int i = 0; i < array.length; i++) { array[i] = true; } if (isStartOfDoubleBond(container, bond.getAtom(0), from, array) && isEndOfDoubleBond(container, bond.getAtom(1), bond.getAtom(0), array) && !bond.getFlag(CDKConstants.ISAROMATIC)) { return (true); } else { return (false); } } /** * Says if two atoms are in cis or trans position around a double bond. * The atoms have to be given to the method like this: firstOuterAtom - firstInnerAtom = secondInnterAtom - secondOuterAtom * * @param firstOuterAtom See above. * @param firstInnerAtom See above. * @param secondInnerAtom See above. * @param secondOuterAtom See above. * @param ac The atom container the atoms are in. * @return true=trans, false=cis. * @exception CDKException The atoms are not in a double bond configuration (no double bond in the middle, same atoms on one side) */ @TestMethod("testIsCisTrans_IAtom_IAtom_IAtom_IAtom_IAtomContainer") public static boolean isCisTrans(IAtom firstOuterAtom, IAtom firstInnerAtom, IAtom secondInnerAtom, IAtom secondOuterAtom, IAtomContainer ac) throws CDKException { if (!isValidDoubleBondConfiguration(ac, ac.getBond(firstInnerAtom, secondInnerAtom))) { throw new CDKException("There is no valid double bond configuration between your inner atoms!"); } boolean firstDirection = isLeft(firstOuterAtom, firstInnerAtom, secondInnerAtom); boolean secondDirection = isLeft(secondOuterAtom, secondInnerAtom, firstInnerAtom); return firstDirection == secondDirection; } /** * Says if an atom is on the left side of a another atom seen from a certain * atom or not * * @param whereIs The atom the position of which is returned * @param viewFrom The atom from which to look * @param viewTo The atom to which to look * @return true=is left, false = is not */ @TestMethod("testIsLeft_IAtom_IAtom_IAtom") public static boolean isLeft(IAtom whereIs, IAtom viewFrom, IAtom viewTo) { double angle = giveAngleBothMethods(viewFrom, viewTo, whereIs, false); if (angle < 0) { return (false); } else { return (true); } } /** * Returns true if the two atoms are within the distance fudge * factor of each other. * * @param atom1 Description of Parameter * @param atom2 Description of Parameter * @param distanceFudgeFactor Description of Parameter * @return Description of the Returned Value * @cdk.keyword join-the-dots * @cdk.keyword bond creation */ @TestMethod("testCloseEnoughToBond_IAtom_IAtom_double") public static boolean closeEnoughToBond(IAtom atom1, IAtom atom2, double distanceFudgeFactor) { if (atom1 != atom2) { double distanceBetweenAtoms = atom1.getPoint3d().distance(atom2.getPoint3d()); double bondingDistance = atom1.getCovalentRadius() + atom2.getCovalentRadius(); if (distanceBetweenAtoms <= (distanceFudgeFactor * bondingDistance)) { return true; } } return false; } /** * Gives the angle between two lines starting at atom from and going to to1 * and to2. If bool=false the angle starts from the middle line and goes from * 0 to PI or 0 to -PI if the to2 is on the left or right side of the line. If * bool=true the angle goes from 0 to 2PI. * * @param from the atom to view from. * @param to1 first direction to look in. * @param to2 second direction to look in. * @param bool true=angle is 0 to 2PI, false=angel is -PI to PI. * @return The angle in rad. */ @TestMethod("testGiveAngleBothMethods_IAtom_IAtom_IAtom_boolean") public static double giveAngleBothMethods(IAtom from, IAtom to1, IAtom to2, boolean bool) { return giveAngleBothMethods(from.getPoint2d(), to1.getPoint2d(), to2.getPoint2d(),bool); } @TestMethod("testGiveAngleBothMethods_Point2d_Point2d_Point2d_boolean") public static double giveAngleBothMethods(Point2d from, Point2d to1, Point2d to2, boolean bool) { double[] A = new double[2]; from.get(A); double[] B = new double[2]; to1.get(B); double[] C = new double[2]; to2.get(C); double angle1 = Math.atan2((B[1] - A[1]), (B[0] - A[0])); double angle2 = Math.atan2((C[1] - A[1]), (C[0] - A[0])); double angle = angle2 - angle1; if (angle2 < 0 && angle1 > 0 && angle2 < -(Math.PI / 2)) { angle = Math.PI + angle2 + Math.PI - angle1; } if (angle2 > 0 && angle1 < 0 && angle1 < -(Math.PI / 2)) { angle = -Math.PI + angle2 - Math.PI - angle1; } if (bool && angle < 0) { return (2 * Math.PI + angle); } else { return (angle); } } /** * Says if an atom is the end of a double bond configuration * * @param atom The atom which is the end of configuration * @param container The atomContainer the atom is in * @param parent The atom we came from * @param doubleBondConfiguration The array indicating where double bond * configurations are specified (this method ensures that there is * actually the possibility of a double bond configuration) * @return false=is not end of configuration, true=is */ private static boolean isEndOfDoubleBond(IAtomContainer container, IAtom atom, IAtom parent, boolean[] doubleBondConfiguration) { if (container.getBondNumber(atom, parent) == -1 || doubleBondConfiguration.length <= container.getBondNumber(atom, parent) || !doubleBondConfiguration[container.getBondNumber(atom, parent)]) { return false; } int hcount; if (atom.getHydrogenCount() == CDKConstants.UNSET) hcount = 0; else hcount = atom.getHydrogenCount(); int lengthAtom = container.getConnectedAtomsList(atom).size() + hcount; if (parent.getHydrogenCount() == CDKConstants.UNSET) hcount = 0; else hcount = parent.getHydrogenCount(); int lengthParent = container.getConnectedAtomsList(parent).size() + hcount; if (container.getBond(atom, parent) != null) { if (container.getBond(atom, parent).getOrder() == CDKConstants.BONDORDER_DOUBLE && (lengthAtom == 3 || (lengthAtom == 2 && atom.getSymbol().equals("N"))) && (lengthParent == 3 || (lengthParent == 2 && parent.getSymbol().equals("N")))) { List atoms = container.getConnectedAtomsList(atom); IAtom one = null; IAtom two = null; for (IAtom conAtom : atoms) { if (conAtom != parent && one == null) { one = conAtom; } else if (conAtom != parent && one != null) { two = conAtom; } } String[] morgannumbers = MorganNumbersTools.getMorganNumbersWithElementSymbol(container); if ((one != null && two == null && atom.getSymbol().equals("N") && Math.abs(giveAngleBothMethods(parent, atom, one, true)) > Math.PI / 10) || (!atom.getSymbol().equals("N") && one != null && two != null && !morgannumbers[container.getAtomNumber(one)].equals(morgannumbers[container.getAtomNumber(two)]))) { return (true); } else { return (false); } } } return (false); } /** * Says if an atom is the start of a double bond configuration * * @param a The atom which is the start of configuration * @param container The atomContainer the atom is in * @param parent The atom we came from * @param doubleBondConfiguration The array indicating where double bond * configurations are specified (this method ensures that there is * actually the possibility of a double bond configuration) * @return false=is not start of configuration, true=is */ private static boolean isStartOfDoubleBond(IAtomContainer container, IAtom a, IAtom parent, boolean[] doubleBondConfiguration) { int hcount; if (a.getHydrogenCount() == CDKConstants.UNSET) hcount = 0; else hcount = a.getHydrogenCount(); int lengthAtom = container.getConnectedAtomsList(a).size() + hcount; if (lengthAtom != 3 && (lengthAtom != 2 && !(a.getSymbol().equals("N")))) { return (false); } List atoms = container.getConnectedAtomsList(a); IAtom one = null; IAtom two = null; boolean doubleBond = false; IAtom nextAtom = null; for (IAtom atom : atoms) { if (atom != parent && container.getBond(atom, a).getOrder() == CDKConstants.BONDORDER_DOUBLE && isEndOfDoubleBond(container, atom, a, doubleBondConfiguration)) { doubleBond = true; nextAtom = atom; } if (atom != nextAtom && one == null) { one = atom; } else if (atom != nextAtom && one != null) { two = atom; } } String[] morgannumbers = MorganNumbersTools.getMorganNumbersWithElementSymbol(container); if (one != null && ((!a.getSymbol().equals("N") && two != null && !morgannumbers[container.getAtomNumber(one)].equals(morgannumbers[container.getAtomNumber(two)]) && doubleBond && doubleBondConfiguration[container.getBondNumber(a, nextAtom)]) || (doubleBond && a.getSymbol().equals("N") && Math.abs(giveAngleBothMethods(nextAtom, a, parent, true)) > Math.PI / 10))) { return (true); } else { return (false); } } /** * Says if an atom as a center of a tetrahedral chirality. * This method uses wedge bonds. 3D coordinates are not taken into account. If there * are no wedge bonds around a potential stereo center, it will not be found. * *@param atom The atom which is the center *@param container The atomContainer the atom is in *@return 0=is not tetrahedral;>1 is a certain depiction of * tetrahedrality (evaluated in parse chain) */ @TestMethod("testIsTetrahedral_IAtomContainer_IAtom_boolean") public static int isTetrahedral(IAtomContainer container, IAtom atom, boolean strict) { List atoms = container.getConnectedAtomsList(atom); if (atoms.size() != 4) { return (0); } java.util.List bonds = container.getConnectedBondsList(atom); int up = 0; int down = 0; for (IBond bond : bonds) { if (bond.getStereo() == CDKConstants.STEREO_BOND_NONE || bond.getStereo() == CDKConstants.STEREO_BOND_UNDEFINED) { } if (bond.getStereo() == CDKConstants.STEREO_BOND_UP) { up++; } if (bond.getStereo() == CDKConstants.STEREO_BOND_DOWN) { down++; } } if (up == 1 && down == 1) { return 1; } if (up == 2 && down == 2) { if (stereosAreOpposite(container, atom)) { return 2; } return 0; } if (up == 1 && down == 0 && !strict) { return 3; } if (down == 1 && up == 0 && !strict) { return 4; } if (down == 2 && up == 1 && !strict) { return 5; } if (down == 1 && up == 2 && !strict) { return 6; } return 0; } /** * Says if an atom as a center of a trigonal-bipyramidal or actahedral * chirality. This method uses wedge bonds. 3D coordinates are not taken into account. If there * are no wedge bonds around a potential stereo center, it will not be found. * *@param atom The atom which is the center *@param container The atomContainer the atom is in *@return true=is square planar, false=is not */ @TestMethod("testIsTrigonalBipyramidalOrOctahedral_IAtomContainer_IAtom") public static int isTrigonalBipyramidalOrOctahedral(IAtomContainer container, IAtom atom) { List atoms = container.getConnectedAtomsList(atom); if (atoms.size() < 5 || atoms.size() > 6) { return (0); } java.util.List bonds = container.getConnectedBondsList(atom); int up = 0; int down = 0; for (IBond bond : bonds) { if (bond.getStereo() == CDKConstants.STEREO_BOND_UNDEFINED || bond.getStereo() == CDKConstants.STEREO_BOND_NONE) { } if (bond.getStereo() == CDKConstants.STEREO_BOND_UP) { up++; } if (bond.getStereo() == CDKConstants.STEREO_BOND_DOWN) { down++; } } if (up == 1 && down == 1) { if(atoms.size()==5) return 1; else return 2; } return 0; } /** * Says if an atom as a center of any valid stereo configuration or not. * This method uses wedge bonds. 3D coordinates are not taken into account. If there * are no wedge bonds around a potential stereo center, it will not be found. * *@param stereoAtom The atom which is the center *@param container The atomContainer the atom is in *@return true=is a stereo atom, false=is not */ @TestMethod("testIsStereo_IAtomContainer_IAtom") public static boolean isStereo(IAtomContainer container, IAtom stereoAtom) { List atoms = container.getConnectedAtomsList(stereoAtom); if (atoms.size() < 4 || atoms.size() > 6) { return (false); } List bonds = container.getConnectedBondsList(stereoAtom); int stereo = 0; for (IBond bond : bonds) { if (bond.getStereo() != 0) { stereo++; } } if (stereo == 0) { return false; } int differentAtoms = 0; for (int i = 0; i < atoms.size(); i++) { boolean isDifferent = true; for (int k = 0; k < i; k++) { if (atoms.get(i).getSymbol().equals(atoms.get(k).getSymbol())) { isDifferent = false; break; } } if (isDifferent) { differentAtoms++; } } if (differentAtoms != atoms.size()) { long[] morgannumbers = MorganNumbersTools.getMorganNumbers(container); List differentSymbols = new ArrayList(); for (IAtom atom : atoms) { if (!differentSymbols.contains(atom.getSymbol())) { differentSymbols.add(atom.getSymbol()); } } int[] onlyRelevantIfTwo = new int[2]; if (differentSymbols.size() == 2) { for (IAtom atom : atoms) { if (differentSymbols.indexOf(atom.getSymbol()) == 0) { onlyRelevantIfTwo[0]++; } else { onlyRelevantIfTwo[1]++; } } } boolean[] symbolsWithDifferentMorganNumbers = new boolean[differentSymbols.size()]; List[] symbolsMorganNumbers = new ArrayList[symbolsWithDifferentMorganNumbers.length]; for (int i = 0; i < symbolsWithDifferentMorganNumbers.length; i++) { symbolsWithDifferentMorganNumbers[i] = true; symbolsMorganNumbers[i] = new ArrayList(); } for (IAtom atom : atoms) { int elementNumber = differentSymbols.indexOf(atom.getSymbol()); if (symbolsMorganNumbers[elementNumber].contains(morgannumbers[container.getAtomNumber(atom)])) { symbolsWithDifferentMorganNumbers[elementNumber] = false; } else { symbolsMorganNumbers[elementNumber].add(morgannumbers[container.getAtomNumber(atom)]); } } int numberOfSymbolsWithDifferentMorganNumbers = 0; for (boolean symbolWithDifferentMorganNumber : symbolsWithDifferentMorganNumbers) { if (symbolWithDifferentMorganNumber) { numberOfSymbolsWithDifferentMorganNumbers++; } } if (numberOfSymbolsWithDifferentMorganNumbers != differentSymbols.size()) { if ((atoms.size() == 5 || atoms.size() == 6) && (numberOfSymbolsWithDifferentMorganNumbers + differentAtoms > 2 || (differentAtoms == 2 && onlyRelevantIfTwo[0] > 1 && onlyRelevantIfTwo[1] > 1))) { return (true); } return isSquarePlanar(container, stereoAtom) && (numberOfSymbolsWithDifferentMorganNumbers + differentAtoms > 2 || (differentAtoms == 2 && onlyRelevantIfTwo[0] > 1 && onlyRelevantIfTwo[1] > 1)); } } return (true); } /** * Says if an atom as a center of a square planar chirality. * This method uses wedge bonds. 3D coordinates are not taken into account. If there * are no wedge bonds around a potential stereo center, it will not be found. * *@param atom The atom which is the center *@param container The atomContainer the atom is in *@return true=is square planar, false=is not */ @TestMethod("testIsSquarePlanar_IAtomContainer_IAtom") public static boolean isSquarePlanar(IAtomContainer container, IAtom atom) { List atoms = container.getConnectedAtomsList(atom); if (atoms.size() != 4) { return (false); } List bonds = container.getConnectedBondsList(atom); int up = 0; int down = 0; for (IBond bond : bonds) { if (bond.getStereo() == CDKConstants.STEREO_BOND_UNDEFINED || bond.getStereo() == CDKConstants.STEREO_BOND_NONE) { } if (bond.getStereo() == CDKConstants.STEREO_BOND_UP) { up++; } if (bond.getStereo() == CDKConstants.STEREO_BOND_DOWN) { down++; } } return up == 2 && down == 2 && !stereosAreOpposite(container, atom); } /** * Says if of four atoms connected two one atom the up and down bonds are * opposite or not, i. e.if it's tetrehedral or square planar. The method * does not check if there are four atoms and if two or up and two are down * *@param atom The atom which is the center *@param container The atomContainer the atom is in *@return true=are opposite, false=are not */ @TestMethod("testStereosAreOpposite_IAtomContainer_IAtom") public static boolean stereosAreOpposite(IAtomContainer container, IAtom atom) { List atoms = container.getConnectedAtomsList(atom); TreeMap hm = new TreeMap(); for (int i = 1; i < atoms.size(); i++) { hm.put(giveAngle(atom, atoms.get(0), atoms.get(i)), i); } Object[] ohere = hm.values().toArray(); int stereoOne = container.getBond(atom, atoms.get(0)).getStereo(); int stereoOpposite = container.getBond(atom, atoms.get((Integer) ohere[1])).getStereo(); return stereoOpposite == stereoOne; } /** * Calls giveAngleBothMethods with bool = true * *@param from the atom to view from *@param to1 first direction to look in *@param to2 second direction to look in *@return The angle in rad from 0 to 2*PI */ @TestMethod("testGiveAngle_IAtom_IAtom_IAtom") public static double giveAngle(IAtom from, IAtom to1, IAtom to2) { return (giveAngleBothMethods(from, to1, to2, true)); } /** * Calls giveAngleBothMethods with bool = false * *@param from the atom to view from *@param to1 first direction to look in *@param to2 second direction to look in *@return The angle in rad from -PI to PI */ @TestMethod("testGiveAngleFromMiddle_IAtom_IAtom_IAtom") public static double giveAngleFromMiddle(IAtom from, IAtom to1, IAtom to2) { return (giveAngleBothMethods(from, to1, to2, false)); } @TestMethod("testMakeUpDownBonds_IAtomContainer") public static void makeUpDownBonds(IAtomContainer container){ for (int i = 0; i < container.getAtomCount(); i++) { IAtom a = container.getAtom(i); if (container.getConnectedAtomsList(a).size() == 4) { int up = 0; int down = 0; int hs = 0; IAtom h = null; for (int k = 0; k < 4; k++) { IAtom conAtom = container.getConnectedAtomsList(a).get(k); int stereo = container.getBond(a,conAtom).getStereo(); if (stereo == CDKConstants.STEREO_BOND_UP) { up++; } else if (stereo == CDKConstants.STEREO_BOND_DOWN) { down++; } else if (stereo == CDKConstants.STEREO_BOND_NONE && conAtom.getSymbol().equals("H")) { h = conAtom; hs++; } else { h = null; } } if (up == 0 && down == 1 && h != null && hs == 1) { container.getBond(a, h).setStereo(CDKConstants.STEREO_BOND_UP); } if (up == 1 && down == 0 && h != null && hs == 1) { container.getBond(a, h).setStereo(CDKConstants.STEREO_BOND_DOWN); } } } } } cdk-1.2.10/src/main/org/openscience/cdk/geometry/CrystalGeometryTools.java100644 0 0 21653 11570154753 23734 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2002-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.geometry; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.ICrystal; import javax.vecmath.Point3d; import javax.vecmath.Vector3d; /** * A set of static methods for working with crystal coordinates. * * @cdk.module standard * @cdk.githash * * @author Egon Willighagen * * @cdk.keyword fractional coordinates, crystal */ @TestClass("org.openscience.cdk.geometry.CrystalGeometryToolsTest") public class CrystalGeometryTools { /** * Inverts three cell axes. * * @return a 3x3 matrix with the three cartesian vectors representing * the unit cell axes. The a axis is the first row. */ @TestMethod("testCalcInvertedAxes_Vector3d_Vector3d_Vector3d") public static Vector3d[] calcInvertedAxes(Vector3d aAxis, Vector3d bAxis, Vector3d cAxis) { double det = aAxis.x*bAxis.y*cAxis.z - aAxis.x*bAxis.z*cAxis.y - aAxis.y*bAxis.x*cAxis.z + aAxis.y*bAxis.z*cAxis.x + aAxis.z*bAxis.x*cAxis.y - aAxis.z*bAxis.y*cAxis.x; Vector3d[] invaxes = new Vector3d[3]; invaxes[0] = new Vector3d(); invaxes[0].x = (bAxis.y*cAxis.z - bAxis.z*cAxis.y)/det; invaxes[0].y = (bAxis.z*cAxis.x - bAxis.x*cAxis.z)/det; invaxes[0].z = (bAxis.x*cAxis.y - bAxis.y*cAxis.x)/det; invaxes[1] = new Vector3d(); invaxes[1].x = (aAxis.z*cAxis.y - aAxis.y*cAxis.z)/det; invaxes[1].y = (aAxis.x*cAxis.z - aAxis.z*cAxis.x)/det; invaxes[1].z = (aAxis.y*cAxis.x - aAxis.x*cAxis.y)/det; invaxes[2] = new Vector3d(); invaxes[2].x = (aAxis.y*bAxis.z - aAxis.z*bAxis.y)/det; invaxes[2].y = (aAxis.z*bAxis.x - aAxis.x*bAxis.z)/det; invaxes[2].z = (aAxis.x*bAxis.y - aAxis.y*bAxis.x)/det; return invaxes; } /** * @cdk.dictref blue-obelisk:convertCartesianIntoFractionalCoordinates */ @TestMethod("testCartesianToFractional_Vector3d_Vector3d_Vector3d_Point3d") public static Point3d cartesianToFractional(Vector3d aAxis, Vector3d bAxis, Vector3d cAxis, Point3d cartPoint) { Vector3d[] invaxis = calcInvertedAxes(aAxis,bAxis,cAxis); Point3d frac = new Point3d(); frac.x = invaxis[0].x*cartPoint.x + invaxis[0].y*cartPoint.y + invaxis[0].z*cartPoint.z; frac.y = invaxis[1].x*cartPoint.x + invaxis[1].y*cartPoint.y + invaxis[1].z*cartPoint.z; frac.z = invaxis[2].x*cartPoint.x + invaxis[2].y*cartPoint.y + invaxis[2].z*cartPoint.z; return frac; } /** * @cdk.dictref blue-obelisk:convertFractionIntoCartesianCoordinates */ @TestMethod("testFractionalToCartesian_Vector3d_Vector3d_Vector3d_Point3d") public static Point3d fractionalToCartesian(Vector3d aAxis, Vector3d bAxis, Vector3d cAxis, Point3d frac) { Point3d cart = new Point3d(); cart.x = frac.x*aAxis.x + frac.y*bAxis.x + frac.z*cAxis.x; cart.y = frac.x*aAxis.y + frac.y*bAxis.y + frac.z*cAxis.y; cart.z = frac.x*aAxis.z + frac.y*bAxis.z + frac.z*cAxis.z; return cart; } /** * Calculates cartesian vectors for unit cell axes from axes lengths and angles * between axes. * *

To calculate cartesian coordinates, it places the a axis on the x axes, * the b axis in the xy plane, making an angle gamma with the a axis, and places * the c axis to fullfil the remaining constraints. (See also * the * CCL archive.) * * @param alength length of the a axis * @param blength length of the b axis * @param clength length of the c axis * @param alpha angle between b and c axes in degrees * @param beta angle between a and c axes in degrees * @param gamma angle between a and b axes in degrees * @return an array of Vector3d objects with the three cartesian vectors representing * the unit cell axes. * * @cdk.keyword notional coordinates * @cdk.dictref blue-obelisk:convertNotionalIntoCartesianCoordinates */ @TestMethod("testNotionalToCartesian_double_double_double_double_double_double") public static Vector3d[] notionalToCartesian(double alength, double blength, double clength, double alpha, double beta, double gamma) { Vector3d[] axes = new Vector3d[3]; /* 1. align the a axis with x axis */ axes[0] = new Vector3d(); axes[0].x = alength; axes[0].y = 0.0; axes[0].z = 0.0; double toRadians = Math.PI/180.0; /* some intermediate variables */ double cosalpha = Math.cos(toRadians*alpha); double cosbeta = Math.cos(toRadians*beta); double cosgamma = Math.cos(toRadians*gamma); double singamma = Math.sin(toRadians*gamma); /* 2. place the b is in xy plane making a angle gamma with a */ axes[1] = new Vector3d(); axes[1].x = blength*cosgamma; axes[1].y = blength*singamma; axes[1].z = 0.0; /* 3. now the c axis, with more complex maths */ axes[2] = new Vector3d(); double volume = alength * blength * clength * Math.sqrt(1.0 - cosalpha*cosalpha - cosbeta*cosbeta - cosgamma*cosgamma + 2.0*cosalpha*cosbeta*cosgamma); axes[2].x = clength*cosbeta; axes[2].y = clength*(cosalpha-cosbeta*cosgamma)/singamma; axes[2].z = volume/(alength*blength*singamma); return axes; } /** * @cdk.dictref blue-obelisk:convertCartesianIntoNotionalCoordinates */ @TestMethod("testCartesianToNotional_Vector3d_Vector3d_Vector3d") public static double[] cartesianToNotional(Vector3d aAxis, Vector3d bAxis, Vector3d cAxis) { double[] notionalCoords = new double[6]; notionalCoords[0] = aAxis.length(); notionalCoords[1] = bAxis.length(); notionalCoords[2] = cAxis.length(); notionalCoords[3] = bAxis.angle(cAxis)*180.0/Math.PI; notionalCoords[4] = aAxis.angle(cAxis)*180.0/Math.PI; notionalCoords[5] = aAxis.angle(bAxis)*180.0/Math.PI; return notionalCoords; } /** * Determines if this model contains fractional (crystal) coordinates. * * @return boolean indication that 3D coordinates are available */ public static boolean hasCrystalCoordinates(IAtomContainer container) { java.util.Iterator atoms = container.atoms().iterator(); while (atoms.hasNext()) { if (((IAtom)atoms.next()).getFractionalPoint3d() == null) { return false; } } return true; } /** * Creates cartesian coordinates for all Atoms in the Crystal. */ public static void fractionalToCartesian(ICrystal crystal) { java.util.Iterator atoms = crystal.atoms().iterator(); Vector3d aAxis = crystal.getA(); Vector3d bAxis = crystal.getB(); Vector3d cAxis = crystal.getC(); while (atoms.hasNext()) { IAtom atom = (IAtom)atoms.next(); Point3d fracPoint = atom.getFractionalPoint3d(); if (fracPoint != null) { atom.setPoint3d(fractionalToCartesian(aAxis,bAxis,cAxis, fracPoint)); } } } } cdk-1.2.10/src/main/org/openscience/cdk/geometry/GeometryTools.java100644 0 0 152405 11570154753 22412 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 1997-2008 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.geometry; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IRing; import org.openscience.cdk.interfaces.IRingSet; import org.openscience.cdk.tools.LoggingTool; import javax.vecmath.Point2d; import javax.vecmath.Point3d; import javax.vecmath.Vector2d; import javax.vecmath.Vector3d; import java.awt.*; import java.util.*; import java.util.List; /** * A set of static utility classes for geometric calculations and operations. * This class is extensively used, for example, by JChemPaint to edit molecule. * All methods in this class change the coordinates of the atoms. Use GeometryTools if you use an external set of coordinates (e. g. renderingCoordinates from RendererModel) * * @author seb * @author Stefan Kuhn * @author Egon Willighagen * @author Ludovic Petain * @author Christian Hoppe * @author Niels Out * * @cdk.module standard * @cdk.githash */ public class GeometryTools { private static LoggingTool logger = new LoggingTool(GeometryTools.class); /** * Adds an automatically calculated offset to the coordinates of all atoms * such that all coordinates are positive and the smallest x or y coordinate * is exactly zero. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param atomCon AtomContainer for which all the atoms are translated to * positive coordinates */ public static void translateAllPositive(IAtomContainer atomCon) { double minX = Double.MAX_VALUE; double minY = Double.MAX_VALUE; Iterator atoms = atomCon.atoms().iterator(); while (atoms.hasNext()) { IAtom atom = (IAtom)atoms.next(); if (atom.getPoint2d() != null) { if (atom.getPoint2d().x < minX) { minX = atom.getPoint2d().x; } if (atom.getPoint2d().y < minY) { minY = atom.getPoint2d().y; } } } logger.debug("Translating: minx=" + minX + ", minY=" + minY); translate2D(atomCon, minX * -1, minY * -1); } /** * Translates the given molecule by the given Vector. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param atomCon The molecule to be translated *@param transX translation in x direction *@param transY translation in y direction */ public static void translate2D(IAtomContainer atomCon, double transX, double transY) { translate2D(atomCon, new Vector2d(transX, transY)); } /** * Scales a molecule such that it fills a given percentage of a given * dimension * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param atomCon The molecule to be scaled *@param areaDim The dimension to be filled *@param fillFactor The percentage of the dimension to be filled */ public static void scaleMolecule(IAtomContainer atomCon, Dimension areaDim, double fillFactor) { Dimension molDim = get2DDimension(atomCon); double widthFactor = (double) areaDim.width / (double) molDim.width; double heightFactor = (double) areaDim.height / (double) molDim.height; double scaleFactor = Math.min(widthFactor, heightFactor) * fillFactor; scaleMolecule(atomCon, scaleFactor); } /** * Multiplies all the coordinates of the atoms of the given molecule with the * scalefactor. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param atomCon The molecule to be scaled *@param scaleFactor Description of the Parameter */ public static void scaleMolecule(IAtomContainer atomCon, double scaleFactor) { for (int i = 0; i < atomCon.getAtomCount(); i++) { if (atomCon.getAtom(i).getPoint2d() != null) { atomCon.getAtom(i).getPoint2d().x *= scaleFactor; atomCon.getAtom(i).getPoint2d().y *= scaleFactor; } } } /** * Centers the molecule in the given area * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param atomCon molecule to be centered *@param areaDim dimension in which the molecule is to be centered */ public static void center(IAtomContainer atomCon, Dimension areaDim) { Dimension molDim = get2DDimension(atomCon); int transX = (areaDim.width - molDim.width) / 2; int transY = (areaDim.height - molDim.height) / 2; translateAllPositive(atomCon); translate2D(atomCon, new Vector2d(transX, transY)); } /** * Translates a molecule from the origin to a new point denoted by a vector. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param atomCon molecule to be translated *@param vector dimension that represents the translation vector */ public static void translate2D(IAtomContainer atomCon, Vector2d vector) { for (IAtom atom : atomCon.atoms()) { if (atom.getPoint2d() != null) { atom.getPoint2d().add(vector); } else { logger.warn("Could not translate atom in 2D space"); } } } /** * Rotates a molecule around a given center by a given angle * *@param atomCon The molecule to be rotated *@param center A point giving the rotation center *@param angle The angle by which to rotate the molecule, in radians */ public static void rotate(IAtomContainer atomCon, Point2d center, double angle) { Point2d point; double costheta = Math.cos(angle); double sintheta = Math.sin(angle); IAtom atom; for (int i = 0; i < atomCon.getAtomCount(); i++) { atom = atomCon.getAtom(i); point = atom.getPoint2d(); double relativex = point.x - center.x; double relativey = point.y - center.y; point.x = relativex * costheta - relativey * sintheta + center.x; point.y = relativex * sintheta + relativey * costheta + center.y; } } /** * Rotates a 3D point about a specified line segment by a specified angle. * * The code is based on code available here. * Positive angles are anticlockwise looking down the axis towards the origin. * Assume right hand coordinate system. * * @param atom The atom to rotate * @param p1 The first point of the line segment * @param p2 The second point of the line segment * @param angle The angle to rotate by (in degrees) */ public static void rotate(IAtom atom, Point3d p1, Point3d p2, double angle) { double costheta, sintheta; Point3d r = new Point3d(); r.x = p2.x - p1.x; r.y = p2.y - p1.y; r.z = p2.z - p1.z; normalize(r); angle = angle * Math.PI / 180.0; costheta = Math.cos(angle); sintheta = Math.sin(angle); Point3d p = atom.getPoint3d(); p.x -= p1.x; p.y -= p1.y; p.z -= p1.z; Point3d q = new Point3d(0, 0, 0); q.x += (costheta + (1 - costheta) * r.x * r.x) * p.x; q.x += ((1 - costheta) * r.x * r.y - r.z * sintheta) * p.y; q.x += ((1 - costheta) * r.x * r.z + r.y * sintheta) * p.z; q.y += ((1 - costheta) * r.x * r.y + r.z * sintheta) * p.x; q.y += (costheta + (1 - costheta) * r.y * r.y) * p.y; q.y += ((1 - costheta) * r.y * r.z - r.x * sintheta) * p.z; q.z += ((1 - costheta) * r.x * r.z - r.y * sintheta) * p.x; q.z += ((1 - costheta) * r.y * r.z + r.x * sintheta) * p.y; q.z += (costheta + (1 - costheta) * r.z * r.z) * p.z; q.x += p1.x; q.y += p1.y; q.z += p1.z; atom.setPoint3d(q); } /** * Normalizes a point. * * @param point The point to normalize */ public static void normalize(Point3d point) { double sum = Math.sqrt(point.x * point.x + point.y * point.y + point.z * point.z); point.x = point.x / sum; point.y = point.y / sum; point.z = point.z / sum; } /** * Returns the java.awt.Dimension of a molecule * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param atomCon of which the dimension should be returned *@return The java.awt.Dimension of this molecule */ public static Dimension get2DDimension(IAtomContainer atomCon) { double[] minmax = getMinMax(atomCon); double maxX = minmax[2]; double maxY = minmax[3]; double minX = minmax[0]; double minY = minmax[1]; return new Dimension((int) (maxX - minX + 1), (int) (maxY - minY + 1)); } /** * Returns the minimum and maximum X and Y coordinates of the atoms in the * AtomContainer. The output is returned as:

	 *   minmax[0] = minX;
	 *   minmax[1] = minY;
	 *   minmax[2] = maxX;
	 *   minmax[3] = maxY;
	 * 
* See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param container Description of the Parameter *@return An four int array as defined above. */ public static double[] getMinMax(IAtomContainer container) { double maxX = -Double.MAX_VALUE; double maxY = -Double.MAX_VALUE; double minX = Double.MAX_VALUE; double minY = Double.MAX_VALUE; for (int i = 0; i < container.getAtomCount(); i++) { IAtom atom = container.getAtom(i); if (atom.getPoint2d() != null) { if (atom.getPoint2d().x > maxX) { maxX = atom.getPoint2d().x; } if (atom.getPoint2d().x < minX) { minX = atom.getPoint2d().x; } if (atom.getPoint2d().y > maxY) { maxY = atom.getPoint2d().y; } if (atom.getPoint2d().y < minY) { minY = atom.getPoint2d().y; } } } double[] minmax = new double[4]; minmax[0] = minX; minmax[1] = minY; minmax[2] = maxX; minmax[3] = maxY; return minmax; } /** * Translates a molecule from the origin to a new point denoted by a vector. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param atomCon molecule to be translated *@param p Description of the Parameter */ public static void translate2DCentreOfMassTo(IAtomContainer atomCon, Point2d p) { Point2d com = get2DCentreOfMass(atomCon); Vector2d translation = new Vector2d(p.x - com.x, p.y - com.y); Iterator atoms = atomCon.atoms().iterator(); while (atoms.hasNext()) { IAtom atom = (IAtom)atoms.next(); if (atom.getPoint2d() != null) { atom.getPoint2d().add(translation); } } } /** * Calculates the center of the given atoms and returns it as a Point2d * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param atoms The vector of the given atoms *@return The center of the given atoms as Point2d */ public static Point2d get2DCenter(Iterable atoms) { double xsum = 0; double ysum = 0; int length = 0; for (IAtom atom : atoms) { if (atom.getPoint2d() != null) { xsum += atom.getPoint2d().x; ysum += atom.getPoint2d().y; length++; } } return new Point2d(xsum / (double) length, ysum / (double) length); } /** * Calculates the center of the given atoms and returns it as a Point2d * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param atoms The Iterator of the given atoms *@return The center of the given atoms as Point2d */ public static Point2d get2DCenter(Iterator atoms) { IAtom atom; double xsum = 0; double ysum = 0; int length = 0; while (atoms.hasNext()) { atom = (IAtom)atoms.next(); if (atom.getPoint2d() != null) { xsum += atom.getPoint2d().x; ysum += atom.getPoint2d().y; } ++length; } return new Point2d(xsum / (double) length, ysum / (double) length); } /** * Returns the geometric center of all the rings in this ringset. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param ringSet Description of the Parameter *@return the geometric center of the rings in this ringset */ public static Point2d get2DCenter(IRingSet ringSet) { double centerX = 0; double centerY = 0; for (int i = 0; i < ringSet.getAtomContainerCount(); i++) { Point2d centerPoint = get2DCenter((IRing)ringSet.getAtomContainer(i)); centerX += centerPoint.x; centerY += centerPoint.y; } return new Point2d(centerX / ((double) ringSet.getAtomContainerCount()), centerY / ((double) ringSet.getAtomContainerCount())); } /** * Calculates the center of mass for the Atoms in the * AtomContainer for the 2D coordinates. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param ac AtomContainer for which the center of mass is calculated *@return Null, if any of the atomcontainer {@link IAtom}'s masses are null *@cdk.keyword center of mass */ public static Point2d get2DCentreOfMass(IAtomContainer ac) { double xsum = 0.0; double ysum = 0.0; double totalmass = 0.0; Iterator atoms = ac.atoms().iterator(); while (atoms.hasNext()) { IAtom a = (IAtom) atoms.next(); Double mass = a.getExactMass(); if (mass == null) return null; totalmass += mass; xsum += mass * a.getPoint2d().x; ysum += mass * a.getPoint2d().y; } return new Point2d(xsum / totalmass, ysum / totalmass); } /** * Returns the geometric center of all the atoms in the atomContainer. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param container Description of the Parameter *@return the geometric center of the atoms in this atomContainer */ public static Point2d get2DCenter(IAtomContainer container) { double centerX = 0; double centerY = 0; double counter = 0; Iterator atoms = container.atoms().iterator(); while (atoms.hasNext()) { IAtom atom = (IAtom)atoms.next(); if (atom.getPoint2d() != null) { centerX += atom.getPoint2d().x; centerY += atom.getPoint2d().y; counter++; } } return new Point2d(centerX / (counter), centerY / (counter)); } /** * Translates the geometric 2DCenter of the given * AtomContainer container to the specified Point2d p. * *@param container AtomContainer which should be translated. *@param p New Location of the geometric 2D Center. *@see #get2DCenter *@see #translate2DCentreOfMassTo */ public static void translate2DCenterTo(IAtomContainer container, Point2d p) { Point2d com = get2DCenter(container); Vector2d translation = new Vector2d(p.x - com.x, p.y - com.y); Iterator atoms = container.atoms().iterator(); while (atoms.hasNext()) { IAtom atom = (IAtom)atoms.next(); if (atom.getPoint2d() != null) { atom.getPoint2d().add(translation); } } } /** * Calculates the center of mass for the Atoms in the * AtomContainer for the 2D coordinates. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param ac AtomContainer for which the center of mass is calculated *@return Description of the Return Value *@cdk.keyword center of mass * @cdk.dictref blue-obelisk:calculate3DCenterOfMass */ public static Point3d get3DCentreOfMass(IAtomContainer ac) { double xsum = 0.0; double ysum = 0.0; double zsum = 0.0; double totalmass = 0.0; Iterator atoms = ac.atoms().iterator(); while (atoms.hasNext()) { IAtom a = (IAtom)atoms.next(); Double mass = a.getExactMass(); // some sanity checking if (a.getPoint3d() == null) return null; if (mass == null) return null; totalmass += mass; xsum += mass * a.getPoint3d().x; ysum += mass * a.getPoint3d().y; zsum += mass * a.getPoint3d().z; } return new Point3d(xsum / totalmass, ysum / totalmass, zsum / totalmass); } /** * Returns the geometric center of all the atoms in this atomContainer. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param ac Description of the Parameter *@return the geometric center of the atoms in this atomContainer */ public static Point3d get3DCenter(IAtomContainer ac) { double centerX = 0; double centerY = 0; double centerZ = 0; double counter = 0; Iterator atoms = ac.atoms().iterator(); while (atoms.hasNext()) { IAtom atom = (IAtom)atoms.next(); if (atom.getPoint3d() != null) { centerX += atom.getPoint3d().x; centerY += atom.getPoint3d().y; centerZ += atom.getPoint3d().z; counter++; } } return new Point3d(centerX / (counter), centerY / (counter), centerZ / (counter)); } /** * Gets the angle attribute of the GeometryTools class * *@param xDiff Description of the Parameter *@param yDiff Description of the Parameter *@return The angle value */ public static double getAngle(double xDiff, double yDiff) { double angle = 0; // logger.debug("getAngle->xDiff: " + xDiff); // logger.debug("getAngle->yDiff: " + yDiff); if (xDiff >= 0 && yDiff >= 0) { angle = Math.atan(yDiff / xDiff); } else if (xDiff < 0 && yDiff >= 0) { angle = Math.PI + Math.atan(yDiff / xDiff); } else if (xDiff < 0 && yDiff < 0) { angle = Math.PI + Math.atan(yDiff / xDiff); } else if (xDiff >= 0 && yDiff < 0) { angle = 2 * Math.PI + Math.atan(yDiff / xDiff); } return angle; } /** * Gets the coordinates of two points (that represent a bond) and calculates * for each the coordinates of two new points that have the given distance * vertical to the bond. * *@param coords The coordinates of the two given points of the bond like this * [point1x, point1y, point2x, point2y] *@param dist The vertical distance between the given points and those to * be calculated *@return The coordinates of the calculated four points */ public static int[] distanceCalculator(int[] coords, double dist) { double angle; if ((coords[2] - coords[0]) == 0) { angle = Math.PI / 2; } else { angle = Math.atan(((double) coords[3] - (double) coords[1]) / ((double) coords[2] - (double) coords[0])); } int begin1X = (int) (Math.cos(angle + Math.PI / 2) * dist + coords[0]); int begin1Y = (int) (Math.sin(angle + Math.PI / 2) * dist + coords[1]); int begin2X = (int) (Math.cos(angle - Math.PI / 2) * dist + coords[0]); int begin2Y = (int) (Math.sin(angle - Math.PI / 2) * dist + coords[1]); int end1X = (int) (Math.cos(angle - Math.PI / 2) * dist + coords[2]); int end1Y = (int) (Math.sin(angle - Math.PI / 2) * dist + coords[3]); int end2X = (int) (Math.cos(angle + Math.PI / 2) * dist + coords[2]); int end2Y = (int) (Math.sin(angle + Math.PI / 2) * dist + coords[3]); return new int[]{begin1X, begin1Y, begin2X, begin2Y, end1X, end1Y, end2X, end2Y}; } public static double[] distanceCalculator(double[] coords, double dist) { double angle; if ((coords[2] - coords[0]) == 0) { angle = Math.PI / 2; } else { angle = Math.atan(((double) coords[3] - (double) coords[1]) / ((double) coords[2] - (double) coords[0])); } double begin1X = (Math.cos(angle + Math.PI / 2) * dist + coords[0]); double begin1Y = (Math.sin(angle + Math.PI / 2) * dist + coords[1]); double begin2X = (Math.cos(angle - Math.PI / 2) * dist + coords[0]); double begin2Y = (Math.sin(angle - Math.PI / 2) * dist + coords[1]); double end1X = (Math.cos(angle - Math.PI / 2) * dist + coords[2]); double end1Y = (Math.sin(angle - Math.PI / 2) * dist + coords[3]); double end2X = (Math.cos(angle + Math.PI / 2) * dist + coords[2]); double end2Y = (Math.sin(angle + Math.PI / 2) * dist + coords[3]); return new double[]{begin1X, begin1Y, begin2X, begin2Y, end1X, end1Y, end2X, end2Y}; } /** * Writes the coordinates of the atoms participating the given bond into an * array. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param bond The given bond *@return The array with the coordinates */ public static int[] getBondCoordinates(IBond bond) { if (bond.getAtom(0).getPoint2d() == null || bond.getAtom(1).getPoint2d() == null) { logger.error("getBondCoordinates() called on Bond without 2D coordinates!"); return new int[0]; } int beginX = (int) bond.getAtom(0).getPoint2d().x; int endX = (int) bond.getAtom(1).getPoint2d().x; int beginY = (int) bond.getAtom(0).getPoint2d().y; int endY = (int) bond.getAtom(1).getPoint2d().y; return new int[]{beginX, beginY, endX, endY}; } /** * Returns the atom of the given molecule that is closest to the given * coordinates. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param xPosition The x coordinate *@param yPosition The y coordinate *@param atomCon The molecule that is searched for the closest atom *@return The atom that is closest to the given coordinates */ public static IAtom getClosestAtom(int xPosition, int yPosition, IAtomContainer atomCon) { IAtom closestAtom = null; IAtom currentAtom; double smallestMouseDistance = -1; double mouseDistance; double atomX; double atomY; for (int i = 0; i < atomCon.getAtomCount(); i++) { currentAtom = atomCon.getAtom(i); atomX = currentAtom.getPoint2d().x; atomY = currentAtom.getPoint2d().y; mouseDistance = Math.sqrt(Math.pow(atomX - xPosition, 2) + Math.pow(atomY - yPosition, 2)); if (mouseDistance < smallestMouseDistance || smallestMouseDistance == -1) { smallestMouseDistance = mouseDistance; closestAtom = currentAtom; } } return closestAtom; } /** * Returns the atom of the given molecule that is closest to the given * coordinates. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param xPosition The x coordinate *@param yPosition The y coordinate *@param atomCon The molecule that is searched for the closest atom *@return The atom that is closest to the given coordinates */ public static IAtom getClosestAtom(double xPosition, double yPosition, IAtomContainer atomCon) { IAtom closestAtom = null; IAtom currentAtom; double smallestMouseDistance = -1; double mouseDistance; double atomX; double atomY; for (int i = 0; i < atomCon.getAtomCount(); i++) { currentAtom = atomCon.getAtom(i); atomX = currentAtom.getPoint2d().x; atomY = currentAtom.getPoint2d().y; mouseDistance = Math.sqrt(Math.pow(atomX - xPosition, 2) + Math.pow(atomY - yPosition, 2)); if (mouseDistance < smallestMouseDistance || smallestMouseDistance == -1) { smallestMouseDistance = mouseDistance; closestAtom = currentAtom; } } return closestAtom; } /** * Returns the bond of the given molecule that is closest to the given * coordinates. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param xPosition The x coordinate *@param yPosition The y coordinate *@param atomCon The molecule that is searched for the closest bond *@return The bond that is closest to the given coordinates */ public static IBond getClosestBond(int xPosition, int yPosition, IAtomContainer atomCon) { Point2d bondCenter; IBond closestBond = null; double smallestMouseDistance = -1; double mouseDistance; Iterator bonds = atomCon.bonds().iterator(); while (bonds.hasNext()) { IBond currentBond = (IBond) bonds.next(); bondCenter = get2DCenter(currentBond.atoms()); mouseDistance = Math.sqrt(Math.pow(bondCenter.x - xPosition, 2) + Math.pow(bondCenter.y - yPosition, 2)); if (mouseDistance < smallestMouseDistance || smallestMouseDistance == -1) { smallestMouseDistance = mouseDistance; closestBond = currentBond; } } return closestBond; } /** * Returns the bond of the given molecule that is closest to the given * coordinates. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param xPosition The x coordinate *@param yPosition The y coordinate *@param atomCon The molecule that is searched for the closest bond *@return The bond that is closest to the given coordinates */ public static IBond getClosestBond(double xPosition, double yPosition, IAtomContainer atomCon) { Point2d bondCenter; IBond closestBond = null; double smallestMouseDistance = -1; double mouseDistance; Iterator bonds = atomCon.bonds().iterator(); while (bonds.hasNext()) { IBond currentBond = (IBond) bonds.next(); bondCenter = get2DCenter(currentBond.atoms()); mouseDistance = Math.sqrt(Math.pow(bondCenter.x - xPosition, 2) + Math.pow(bondCenter.y - yPosition, 2)); if (mouseDistance < smallestMouseDistance || smallestMouseDistance == -1) { smallestMouseDistance = mouseDistance; closestBond = currentBond; } } return closestBond; } /** * Sorts a Vector of atoms such that the 2D distances of the atom locations * from a given point are smallest for the first atoms in the vector * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param point The point from which the distances to the atoms are measured *@param atoms The atoms for which the distances to point are measured */ public static void sortBy2DDistance(IAtom[] atoms, Point2d point) { double distance1; double distance2; IAtom atom1; IAtom atom2; boolean doneSomething; do { doneSomething = false; for (int f = 0; f < atoms.length - 1; f++) { atom1 = atoms[f]; atom2 = atoms[f + 1]; distance1 = point.distance(atom1.getPoint2d()); distance2 = point.distance(atom2.getPoint2d()); if (distance2 < distance1) { atoms[f] = atom2; atoms[f + 1] = atom1; doneSomething = true; } } } while (doneSomething); } /** * Determines the scale factor for displaying a structure loaded from disk in * a frame. An average of all bond length values is produced and a scale * factor is determined which would scale the given molecule such that its * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param container The AtomContainer for which the ScaleFactor is to be * calculated *@param bondLength The target bond length *@return The ScaleFactor with which the AtomContainer must be * scaled to have the target bond length */ public static double getScaleFactor(IAtomContainer container, double bondLength) { double currentAverageBondLength = getBondLengthAverage(container); if(currentAverageBondLength==0 || Double.isNaN(currentAverageBondLength)) return 1; return bondLength / currentAverageBondLength; } /** * An average of all 2D bond length values is produced. Bonds which have * Atom's with no coordinates are disregarded. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param container The AtomContainer for which the average bond length is to be * calculated *@return the average bond length */ public static double getBondLengthAverage(IAtomContainer container) { double bondLengthSum = 0; Iterator bonds = container.bonds().iterator(); int bondCounter = 0; while (bonds.hasNext()) { IBond bond = bonds.next(); IAtom atom1 = bond.getAtom(0); IAtom atom2 = bond.getAtom(1); if (atom1.getPoint2d() != null && atom2.getPoint2d() != null) { bondCounter++; bondLengthSum += getLength2D(bond); } } return bondLengthSum / bondCounter; } /** * Returns the geometric length of this bond in 2D space. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param bond Description of the Parameter *@return The geometric length of this bond */ public static double getLength2D(IBond bond) { if (bond.getAtom(0) == null || bond.getAtom(1) == null) { return 0.0; } Point2d point1 = bond.getAtom(0).getPoint2d(); Point2d point2 = bond.getAtom(1).getPoint2d(); if (point1 == null || point2 == null) { return 0.0; } return point1.distance(point2); } /** * Determines if this AtomContainer contains 2D coordinates. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param container Description of the Parameter *@return boolean indication that 2D coordinates are available */ public static boolean has2DCoordinates(IAtomContainer container) { return has2DCoordinatesNew(container)>0; } /** * Determines if this AtomContainer contains 2D coordinates for some or all molecules. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * * *@param container the molecule to be considered * @return 0 no 2d, 1=some, 2= for each atom */ public static int has2DCoordinatesNew(IAtomContainer container) { if (container == null) return 0; boolean no2d=false; boolean with2d=false; for (IAtom atom : container.atoms()) { if (atom.getPoint2d() == null) { no2d = true; } else { with2d = true; } } if(!no2d && with2d){ return 2; } else if(no2d && with2d){ return 1; } else{ return 0; } } /** * Determines if this Atom contains 2D coordinates. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param atom Description of the Parameter *@return boolean indication that 2D coordinates are available */ public static boolean has2DCoordinates(IAtom atom) { return (atom.getPoint2d() != null); } /** * Determines if this Bond contains 2D coordinates. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param bond Description of the Parameter *@return boolean indication that 2D coordinates are available */ public static boolean has2DCoordinates(IBond bond) { for (IAtom iAtom : bond.atoms()) { if (iAtom.getPoint2d() == null) { return false; } } return true; } /** * Determines if this model contains 3D coordinates * *@param container the molecule to consider *@return boolean indication that 3D coordinates are available */ public static boolean has3DCoordinates(IAtomContainer container) { boolean hasinfo = true; for (IAtom atom : container.atoms()) { if (atom.getPoint3d() == null) { return false; } } return hasinfo; } /** * Determines the normalized vector orthogonal on the vector p1->p2. * *@param point1 Description of the Parameter *@param point2 Description of the Parameter *@return Description of the Return Value */ public static Vector2d calculatePerpendicularUnitVector(Point2d point1, Point2d point2) { Vector2d vector = new Vector2d(); vector.sub(point2, point1); vector.normalize(); // Return the perpendicular vector return new Vector2d(-1.0 * vector.y, vector.x); } /** * Calculates the normalization factor in order to get an average bond length * of 1.5. It takes only into account Bond's with two atoms. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param container Description of the Parameter *@return The normalizationFactor value */ public static double getNormalizationFactor(IAtomContainer container) { double bondlength = 0.0; double ratio; /* * Desired bond length for storing structures in MDL mol files * This should probably be set externally (from system wide settings) */ double desiredBondLength = 1.5; // loop over all bonds and determine the mean bond distance int counter = 0; for (IBond bond : container.bonds()) { // only consider two atom bonds into account if (bond.getAtomCount() == 2) { counter++; IAtom atom1 = bond.getAtom(0); IAtom atom2 = bond.getAtom(1); bondlength += Math.sqrt(Math.pow(atom1.getPoint2d().x - atom2.getPoint2d().x, 2) + Math.pow(atom1.getPoint2d().y - atom2.getPoint2d().y, 2)); } } bondlength = bondlength / counter; ratio = desiredBondLength / bondlength; return ratio; } /** * Determines the best alignment for the label of an atom in 2D space. It * returns 1 if left aligned, and -1 if right aligned. * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param container Description of the Parameter *@param atom Description of the Parameter *@return The bestAlignmentForLabel value */ public static int getBestAlignmentForLabel(IAtomContainer container, IAtom atom) { double overallDiffX = 0; for (IAtom connectedAtom : container.getConnectedAtomsList(atom)) { overallDiffX += connectedAtom.getPoint2d().x - atom.getPoint2d().x; } if (overallDiffX <= 0) { return 1; } else { return -1; } } /** * Determines the best alignment for the label of an atom in 2D space. It * returns 1 if right (=default) aligned, and -1 if left aligned. * returns 2 if top aligned, and -2 if H is aligned below the atom * See comment for center(IAtomContainer atomCon, Dimension areaDim, HashMap renderingCoordinates) for details on coordinate sets * *@param container Description of the Parameter *@param atom Description of the Parameter *@return The bestAlignmentForLabel value */ public static int getBestAlignmentForLabelXY(IAtomContainer container, IAtom atom) { double overallDiffX = 0; double overallDiffY = 0; for (IAtom connectedAtom : container.getConnectedAtomsList(atom)) { overallDiffX += connectedAtom.getPoint2d().x - atom.getPoint2d().x; overallDiffY += connectedAtom.getPoint2d().y - atom.getPoint2d().y; } if (overallDiffX <= 0) { if (overallDiffX < overallDiffY) return 1;//right aligned else return 2;//top aligned. } else { if (overallDiffX > overallDiffY) return -1;//left aligned else return -2;//H below aligned } } /** * Returns the atoms which are closes to an atom in an AtomContainer by * distance in 3d. * *@param container The AtomContainer to examine *@param startAtom the atom to start from *@param max the number of neighbours to return *@return the average bond length *@exception CDKException Description of the Exception */ public static List findClosestInSpace(IAtomContainer container, IAtom startAtom, int max) throws CDKException { Point3d originalPoint = startAtom.getPoint3d(); if (originalPoint == null) { throw new CDKException("No point3d, but findClosestInSpace is working on point3ds"); } Map atomsByDistance = new TreeMap(); for (IAtom atom : container.atoms()) { if (atom != startAtom) { if (atom.getPoint3d() == null) { throw new CDKException("No point3d, but findClosestInSpace is working on point3ds"); } double distance = atom.getPoint3d().distance(originalPoint); atomsByDistance.put(distance, atom); } } // FIXME: should there not be some sort here?? Set keySet = atomsByDistance.keySet(); Iterator keyIter = keySet.iterator(); List returnValue = new ArrayList(); int i = 0; while (keyIter.hasNext() && i < max) { returnValue.add(atomsByDistance.get(keyIter.next())); i++; } return (returnValue); } /** * Returns a Map with the AtomNumbers, the first number corresponds to the first (or the largest * AtomContainer) atomcontainer. It is recommend to sort the atomContainer due to their number of atoms before * calling this function. * * The molecules needs to be aligned before! (coordinates are needed) * *@param firstAtomContainer the (largest) first aligned AtomContainer which is the reference *@param secondAtomContainer the second aligned AtomContainer *@param searchRadius the radius of space search from each atom *@return a Map of the mapped atoms *@exception CDKException Description of the Exception */ public static Map mapAtomsOfAlignedStructures(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, double searchRadius, Map mappedAtoms)throws CDKException { //to return the mapping setProperty("MappedAtom",AtomNumber) //logger.debug("**** MAP ATOMS ****"); getLargestAtomContainer(firstAtomContainer,secondAtomContainer); double[][] distanceMatrix=new double[firstAtomContainer.getAtomCount()][secondAtomContainer.getAtomCount()]; for (int i=0;i mappedAtoms, boolean Coords3d) { //logger.debug("**** GT getBondLengthRMSD ****"); Iterator firstAtoms=mappedAtoms.keySet().iterator(); IAtom centerAtomFirstMolecule; IAtom centerAtomSecondMolecule; List connectedAtoms; double sum=0; double n=0; double distance1=0; double distance2=0; setVisitedFlagsToFalse(firstAtomContainer); setVisitedFlagsToFalse(secondAtomContainer); while(firstAtoms.hasNext()){ centerAtomFirstMolecule=firstAtomContainer.getAtom(firstAtoms.next()); centerAtomFirstMolecule.setFlag(CDKConstants.VISITED, true); centerAtomSecondMolecule=secondAtomContainer.getAtom(mappedAtoms.get(firstAtomContainer.getAtomNumber(centerAtomFirstMolecule))); connectedAtoms=firstAtomContainer.getConnectedAtomsList(centerAtomFirstMolecule); for (int i=0;i mappedAtoms) { //logger.debug("**** GT getAngleRMSD ****"); Iterator firstAtoms=mappedAtoms.keySet().iterator(); //logger.debug("mappedAtoms:"+mappedAtoms.toString()); IAtom firstAtomfirstAC; IAtom centerAtomfirstAC; IAtom firstAtomsecondAC; IAtom secondAtomsecondAC; IAtom centerAtomsecondAC; double angleFirstMolecule; double angleSecondMolecule; double sum=0; double n=0; while(firstAtoms.hasNext()){ int firstAtomNumber= firstAtoms.next(); centerAtomfirstAC=firstAtomContainer.getAtom(firstAtomNumber); List connectedAtoms=firstAtomContainer.getConnectedAtomsList(centerAtomfirstAC); if (connectedAtoms.size() >1){ //logger.debug("If "+centerAtomfirstAC.getSymbol()+" is the center atom :"); for (int i=0; i < connectedAtoms.size()-1;i++){ firstAtomfirstAC=(IAtom)connectedAtoms.get(i); for (int j=i+1; j < connectedAtoms.size();j++){ angleFirstMolecule=getAngle(centerAtomfirstAC,firstAtomfirstAC,(IAtom)connectedAtoms.get(j)); centerAtomsecondAC=secondAtomContainer.getAtom(mappedAtoms.get(firstAtomContainer.getAtomNumber(centerAtomfirstAC))); firstAtomsecondAC=secondAtomContainer.getAtom(mappedAtoms.get(firstAtomContainer.getAtomNumber(firstAtomfirstAC))); secondAtomsecondAC=secondAtomContainer.getAtom(mappedAtoms.get(firstAtomContainer.getAtomNumber((IAtom)connectedAtoms.get(j)))); angleSecondMolecule=getAngle(centerAtomsecondAC,firstAtomsecondAC,secondAtomsecondAC); sum=sum+Math.pow(angleFirstMolecule-angleSecondMolecule,2); n++; //logger.debug("Error for the "+firstAtomfirstAC.getSymbol().toLowerCase()+"-"+centerAtomfirstAC.getSymbol()+"-"+connectedAtoms[j].getSymbol().toLowerCase()+" Angle :"+deltaAngle+" degrees"); } } }//if } return Math.sqrt(sum/n); } private static double getAngle(IAtom atom1, IAtom atom2, IAtom atom3){ Vector3d centerAtom = new Vector3d(); centerAtom.x=atom1.getPoint3d().x; centerAtom.y=atom1.getPoint3d().y; centerAtom.z=atom1.getPoint3d().z; Vector3d firstAtom = new Vector3d(); Vector3d secondAtom = new Vector3d(); firstAtom.x=atom2.getPoint3d().x; firstAtom.y=atom2.getPoint3d().y; firstAtom.z=atom2.getPoint3d().z; secondAtom.x=atom3.getPoint3d().x; secondAtom.y=atom3.getPoint3d().y; secondAtom.z=atom3.getPoint3d().z; firstAtom.sub(centerAtom); secondAtom.sub(centerAtom); return firstAtom.angle(secondAtom); } /** * Return the RMSD between the 2 aligned molecules. * *@param firstAtomContainer the (largest) first aligned AtomContainer which is the reference *@param secondAtomContainer the second aligned AtomContainer *@param mappedAtoms Map: a Map of the mapped atoms *@param Coords3d boolean: true if molecules has 3D coords, false if molecules has 2D coords *@return double: the value of the RMSD *@exception CDKException if there is an error in getting mapped atoms * **/ public static double getAllAtomRMSD(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, Map mappedAtoms, boolean Coords3d)throws CDKException { //logger.debug("**** GT getAllAtomRMSD ****"); double sum=0; double RMSD; Iterator firstAtoms=mappedAtoms.keySet().iterator(); int firstAtomNumber; int secondAtomNumber; int n=0; while(firstAtoms.hasNext()){ firstAtomNumber= firstAtoms.next(); try{ secondAtomNumber= mappedAtoms.get(firstAtomNumber); IAtom firstAtom=firstAtomContainer.getAtom(firstAtomNumber); if (Coords3d){ sum=sum+Math.pow(firstAtom.getPoint3d().distance(secondAtomContainer.getAtom(secondAtomNumber).getPoint3d()),2); n++; }else{ sum=sum+Math.pow(firstAtom.getPoint2d().distance(secondAtomContainer.getAtom(secondAtomNumber).getPoint2d()),2); n++; } }catch (Exception ex){ throw new CDKException(ex.getMessage(), ex); } } RMSD=Math.sqrt(sum/n); return RMSD; } /** * Return the RMSD of the heavy atoms between the 2 aligned molecules. * *@param firstAtomContainer the (largest) first aligned AtomContainer which is the reference *@param secondAtomContainer the second aligned AtomContainer *@param mappedAtoms Map: a Map of the mapped atoms *@param hetAtomOnly boolean: true if only hetero atoms should be considered *@param Coords3d boolean: true if molecules has 3D coords, false if molecules has 2D coords *@return double: the value of the RMSD * **/ public static double getHeavyAtomRMSD(IAtomContainer firstAtomContainer, IAtomContainer secondAtomContainer, Map mappedAtoms, boolean hetAtomOnly ,boolean Coords3d) { //logger.debug("**** GT getAllAtomRMSD ****"); double sum=0; double RMSD=0; Iterator firstAtoms=mappedAtoms.keySet().iterator(); int firstAtomNumber=0; int secondAtomNumber=0; int n=0; while(firstAtoms.hasNext()){ firstAtomNumber=firstAtoms.next(); secondAtomNumber=mappedAtoms.get(firstAtomNumber); IAtom firstAtom=firstAtomContainer.getAtom(firstAtomNumber); if (hetAtomOnly){ if (!firstAtom.getSymbol().equals("H") && !firstAtom.getSymbol().equals("C")){ if (Coords3d){ sum=sum+Math.pow(((Point3d)firstAtom.getPoint3d()).distance(secondAtomContainer.getAtom(secondAtomNumber).getPoint3d()),2); n++; }else{ sum=sum+Math.pow(((Point2d)firstAtom.getPoint2d()).distance(secondAtomContainer.getAtom(secondAtomNumber).getPoint2d()),2); n++; } } }else{ if (!firstAtom.getSymbol().equals("H")){ if (Coords3d){ sum=sum+Math.pow(((Point3d)firstAtom.getPoint3d()).distance(secondAtomContainer.getAtom(secondAtomNumber).getPoint3d()),2); n++; }else{ sum=sum+Math.pow(((Point2d)firstAtom.getPoint2d()).distance(secondAtomContainer.getAtom(secondAtomNumber).getPoint2d()),2); n++; } } } } RMSD=Math.sqrt(sum/n); return RMSD; } /** * An average of all 3D bond length values is produced, using point3ds in atoms. * Atom's with no coordinates are disregarded. * *@param container The AtomContainer for which the average bond length is to be * calculated *@return the average bond length */ public static double getBondLengthAverage3D(IAtomContainer container) { double bondLengthSum = 0; int bondCounter = 0; for (IBond bond : container.bonds()) { IAtom atom1 = bond.getAtom(0); IAtom atom2 = bond.getAtom(1); if (atom1.getPoint3d() != null && atom2.getPoint3d() != null) { bondCounter++; bondLengthSum += atom1.getPoint3d().distance(atom2.getPoint3d()); } } return bondLengthSum / bondCounter; } } cdk-1.2.10/src/main/org/openscience/cdk/geometry/IRDFWeightFunction.java100644 0 0 3365 11570154753 23140 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2005-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.geometry; import org.openscience.cdk.interfaces.IAtom; /** * Weight function used in the RDFCalculator. * * @cdk.module extra * @cdk.githash * * @author Egon Willighagen * @cdk.created 2005-01-14 * * @see org.openscience.cdk.geometry.RDFCalculator */ public interface IRDFWeightFunction { /** * Calculates the weight for the interaction between the two atoms. * * @param atom First atom. * @param atom2 Second atom. */ public double calculate(IAtom atom, IAtom atom2); } cdk-1.2.10/src/main/org/openscience/cdk/geometry/Projector.java100644 0 0 4600 11570154753 21476 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.geometry; import java.util.HashMap; import javax.vecmath.Point2d; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; /** * Tool to make projections from 3D to 2D * * @cdk.keyword projection in 2D * @cdk.githash */ public class Projector { public static void project2D(IAtomContainer container) { for (int i = 0; i < container.getAtomCount(); i++) { IAtom atom = container.getAtom(i); if (atom.getPoint3d() != null) { atom.setPoint2d( new Point2d( atom.getPoint3d().x, atom.getPoint3d().y ) ); } else { // should throw an exception } } } public static void project2D(IAtomContainer container, HashMap renderingCoordinates) { for (int i = 0; i < container.getAtomCount(); i++) { IAtom atom = container.getAtom(i); if (atom.getPoint3d() != null) { atom.setPoint2d( new Point2d( atom.getPoint3d().x, atom.getPoint3d().y ) ); renderingCoordinates.put(atom,new Point2d(atom.getPoint3d().x,atom.getPoint3d().y)); } else { // should throw an exception } } } } cdk-1.2.10/src/main/org/openscience/cdk/geometry/RDFCalculator.java100644 0 0 15467 11570154753 22211 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2005-2007 The Chemistry Development Kit (CDK) project * 2009 Egon Willighagen * * 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 org.openscience.cdk.geometry; import java.util.Iterator; import javax.vecmath.Point3d; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.tools.LoggingTool; /** * Calculator of radial distribution functions. The RDF has bins defined around * a point, i.e. the first bin starts at 0 Å and ends at 0.5*resolution * Å, and the second bins ends at 1.5*resolution Å. * *

By default, the RDF is unweighted. By implementing and registering a * RDFWeightFunction, the RDF can become weighted. For example, * to weight according to partial charge interaction, this code could be used: *

 * RDFCalculator calculator = new RDFCalculator(0.0, 5.0, 0.1, 0.0,
 *     new RDFWeightFunction() {
 *         public double calculate(Atom atom, Atom atom2) {
 *             return atom.getCharge()*atom2.getCharge();
 *         }
 *     }
 * );
 * 
* * @cdk.module extra * @cdk.githash * * @author Egon Willighagen * @cdk.created 2005-01-10 * * @cdk.keyword radial distribution function * @cdk.keyword RDF * * @see org.openscience.cdk.geometry.IRDFWeightFunction */ public class RDFCalculator { private static LoggingTool logger = new LoggingTool(RDFCalculator.class); private double startCutoff; private double cutoff; private double resolution; private double peakWidth; private IRDFWeightFunction weightFunction; /** * Constructs a RDF calculator that calculates a unweighted, digitized * RDF function. * * @param startCutoff radial length in Ångstrom at which the RDF starts * @param cutoff radial length in Ångstrom at which the RDF stops * @param resolution width of the bins * @param peakWidth width of the gaussian applied to the peaks in Ångstrom */ public RDFCalculator(double startCutoff, double cutoff, double resolution, double peakWidth) { this(startCutoff, cutoff, resolution, peakWidth, null); } /** * Constructs a RDF calculator that calculates a digitized * RDF function. * * @param startCutoff radial length in Ångstrom at which the RDF starts * @param cutoff radial length in Ångstrom at which the RDF stops * @param resolution width of the bins * @param peakWidth width of the gaussian applied to the peaks in Ångstrom * @param weightFunction the weight function. If null, then an unweighted RDF is * calculated */ public RDFCalculator(double startCutoff, double cutoff, double resolution, double peakWidth, IRDFWeightFunction weightFunction) { this.startCutoff = startCutoff; this.cutoff = cutoff; this.resolution = resolution; this.peakWidth = peakWidth; this.weightFunction = weightFunction; } /** * Calculates a RDF for Atom atom in the environment * of the atoms in the AtomContainer. */ public double[] calculate(IAtomContainer container, IAtom atom) { int length = (int)((cutoff-startCutoff)/resolution) + 1; logger.debug("Creating RDF of length ", length); // the next we need for Gaussian smoothing int binsToFillOnEachSide = (int)(peakWidth*3.0/resolution); double sigmaSquare = Math.pow(peakWidth, 2.0); // factors is only half a Gaussian, taking advantage of being symmetrical! double[] factors = new double[binsToFillOnEachSide]; double totalArea = 0.0; if (factors.length > 0) { factors[0] = 1; for (int binCounter=1; binCounter atomsInContainer = container.atoms().iterator(); while (atomsInContainer.hasNext()) { IAtom atomInContainer = (IAtom)atomsInContainer.next(); if (atom == atomInContainer) continue; // don't include the central atom distance = atomPoint.distance(atomInContainer.getPoint3d()); index = (int)((distance-startCutoff)/this.resolution); double weight = 1.0; if (weightFunction != null) { weight = weightFunction.calculate(atom, atomInContainer); } if (factors.length > 0) { // apply Gaussian smoothing rdf[index] += weight*factors[0]; for (int binCounter=1; binCounter= 0) { rdf[index - binCounter] += diff; } if ((index + binCounter) < length) { rdf[index + binCounter] += diff; } } } else { rdf[index] += weight; // unweighted } } return rdf; } } cdk-1.2.10/src/main/org/openscience/cdk/geometry/ZMatrixTools.java100644 0 0 10774 11570154753 22177 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.geometry; import javax.vecmath.AxisAngle4d; import javax.vecmath.Matrix3d; import javax.vecmath.Point3d; import javax.vecmath.Vector3d; /** * A set of static utility classes for dealing with Z matrices. * * @cdk.module io * @cdk.githash * @cdk.keyword Z-matrix * * @cdk.created 2004-02-09 * @cdk.bug 1653028 */ public class ZMatrixTools { /** * Takes the given Z Matrix coordinates and converts them to cartesian coordinates. * The first Atom end up in the origin, the second on on the x axis, and the third * one in the XY plane. The rest is added by applying the Zmatrix distances, angles * and dihedrals. Angles are in degrees. * * @param distances Array of distance variables of the Z matrix * @param angles Array of angle variables of the Z matrix * @param dihedrals Array of distance variables of the Z matrix * @param first_atoms Array of atom ids of the first invoked atom in distance, angle and dihedral * @param second_atoms Array of atom ids of the second invoked atom in angle and dihedral * @param third_atoms Array of atom ids of the third invoked atom in dihedral * * @cdk.dictref blue-obelisk:zmatrixCoordinatesIntoCartesianCoordinates */ public static Point3d[] zmatrixToCartesian(double[] distances, int[] first_atoms, double[] angles, int[] second_atoms, double[] dihedrals, int[] third_atoms) { Point3d[] cartesianCoords = new Point3d[distances.length]; for (int index=0; index * * 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. * * 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.geometry.alignment; import javax.vecmath.Point3d; import org.openscience.cdk.Atom; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.IsotopeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.tools.LoggingTool; import Jama.EigenvalueDecomposition; import Jama.Matrix; /** * Aligns two structures to minimize the RMSD using the Kabsch algorithm. * *

This class is an implementation of the Kabsch algorithm ({@cdk.cite KAB76}, {@cdk.cite KAB78}) * and evaluates the optimal rotation matrix (U) to minimize the RMSD between the two structures. * Since the algorithm assumes that the number of points are the same in the two structures * it is the job of the caller to pass the proper number of atoms from the two structures. Constructors * which take whole AtomContainer's are provided but they should have the same number * of atoms. * The algorithm allows for the use of atom weightings and by default all points are given a weight of 1.0 * *

Example usage can be: *

 * AtomContainer ac1, ac2;
 *
 * try {
 *    KabschAlignment sa = new KabschAlignment(ac1.getAtoms(),ac2.getAtoms());
 *    sa.align();
 *    System.out.println(sa.getRMSD());
 * } catch (CDKException e){}
 * 
* In many cases, molecules will be aligned based on some common substructure. * In this case the center of masses calculated during alignment refer to these * substructures rather than the whole molecules. To superimpose the molecules * for display, the second molecule must be rotated and translated by calling * rotateAtomContainer. However, since this will also translate the * second molecule, the first molecule should also be translated to the center of mass * of the substructure specifed for this molecule. This center of mass can be obtained * by a call to getCenterOfMass and then manually translating the coordinates. * Thus an example would be *
 * AtomContainer ac1, ac2;  // whole molecules
 * Atom[] a1, a2;           // some subset of atoms from the two molecules
 * KabschAlignment sa;
 * 
 * try {
 *    sa = new KabschAlignment(a1,a2);
 *    sa.align();
 * } catch (CDKException e){}
 *
 * Point3d cm1 = sa.getCenterOfMass();
 * for (int i = 0; i < ac1.getAtomCount(); i++) {
 *    Atom a = ac1.getAtomAt(i);
 *    a.setX3d( a.getPoint3d().x - cm1.x );
 *    a.setY3d( a.getPoint3d().y - cm1.y );
 *    a.setY3d( a.getPoint3d().z - cm1.z );
 * }
 * sa.rotateAtomContainer(ac2);
 *
 * // display the two AtomContainer's
 *
* * @author Rajarshi Guha * @cdk.created 2004-12-11 * @cdk.builddepends Jama-1.0.1.jar * @cdk.depends Jama-1.0.1.jar * @cdk.dictref blue-obelisk:alignmentKabsch * @cdk.githash */ @TestClass("org.openscience.cdk.geometry.alignment.KabschAlignmentTest") public class KabschAlignment { private LoggingTool logger = new LoggingTool(KabschAlignment.class); private double[][] U; private double rmsd = -1.0; private Point3d[] p1,p2,rp; // rp are the rotated coordinates private double[] wts; private int npoint; private Point3d cm1, cm2; private double[] atwt1, atwt2; private Point3d[] getPoint3dArray(IAtom[] a) { Point3d[] p = new Point3d[ a.length ]; for (int i = 0; i < a.length; i++) { p[i] = new Point3d( a[i].getPoint3d() ); } return(p); } private Point3d[] getPoint3dArray(IAtomContainer ac) { Point3d[] p = new Point3d[ ac.getAtomCount() ]; for (int i = 0; i < ac.getAtomCount(); i++) { p[i] = new Point3d( ac.getAtom(i).getPoint3d() ); } return(p); } private double[] getAtomicMasses(IAtom[] a) { double[] am = new double[a.length]; IsotopeFactory factory = null; try { factory = IsotopeFactory.getInstance(a[0].getBuilder()); } catch (Exception e) { logger.error("Error while instantiating the isotope factory: ", e.getMessage()); logger.debug(e); } assert factory != null; for (int i = 0; i < a.length; i++) { am[i] = factory.getMajorIsotope( a[i].getSymbol() ).getExactMass(); } return(am); } private double[] getAtomicMasses(IAtomContainer ac) { double[] am = new double[ac.getAtomCount()]; IsotopeFactory factory = null; try { factory = IsotopeFactory.getInstance(ac.getAtom(0).getBuilder()); } catch (Exception e) { logger.error("Error while instantiating the isotope factory: ", e.getMessage()); logger.debug(e); } assert factory != null; for (int i = 0; i < ac.getAtomCount(); i++) { am[i] = factory.getMajorIsotope( ac.getAtom(i).getSymbol() ).getExactMass(); } return(am); } private Point3d getCenterOfMass(Point3d[] p, double[] atwt) { double x = 0.; double y = 0.; double z = 0.; double totalmass = 0.; for (int i = 0; i < p.length; i++) { x += atwt[i]*p[i].x; y += atwt[i]*p[i].y; z += atwt[i]*p[i].z; totalmass += atwt[i]; } return( new Point3d(x/totalmass, y/totalmass, z/totalmass) ); } /** * Sets up variables for the alignment algorithm. * * The algorithm allows for atom weighting and the default is 1.0 for all * atoms. * * @param al1 An array of {@link Atom} objects * @param al2 An array of {@link Atom} objects. This array will have its coordinates rotated * so that the RMDS is minimzed to the coordinates of the first array * @throws CDKException if the number of Atom's are not the same in the two arrays */ public KabschAlignment(Atom[] al1, Atom[] al2) throws CDKException { if (al1.length != al2.length) { throw new CDKException("The Atom[]'s being aligned must have the same numebr of atoms"); } this.npoint = al1.length; this.p1 = getPoint3dArray(al1); this.p2 = getPoint3dArray(al2); this.wts = new double[this.npoint]; this.atwt1 = getAtomicMasses(al1); this.atwt2 = getAtomicMasses(al2); for (int i = 0; i < this.npoint; i++) this.wts[i] = 1.0; } /** * Sets up variables for the alignment algorithm. * * @param al1 An array of {@link Atom} objects * @param al2 An array of {@link Atom} objects. This array will have its coordinates rotated * so that the RMDS is minimzed to the coordinates of the first array * @param wts A vector atom weights. * @throws CDKException if the number of Atom's are not the same in the two arrays or * length of the weight vector is not the same as the Atom arrays */ public KabschAlignment(Atom[] al1, Atom[] al2, double[] wts) throws CDKException { if (al1.length != al2.length) { throw new CDKException("The Atom[]'s being aligned must have the same number of atoms"); } if (al1.length != wts.length) { throw new CDKException("Number of weights must equal number of atoms"); } this.npoint = al1.length; this.p1 = getPoint3dArray(al1); this.p2 = getPoint3dArray(al2); this.wts = new double[this.npoint]; System.arraycopy(wts, 0, this.wts, 0, this.npoint); this.atwt1 = getAtomicMasses(al1); this.atwt2 = getAtomicMasses(al2); } /** * Sets up variables for the alignment algorithm. * * The algorithm allows for atom weighting and the default is 1.0 for all * atoms. * * @param ac1 An {@link IAtomContainer} * @param ac2 An {@link IAtomContainer}. This AtomContainer will have its coordinates rotated * so that the RMDS is minimzed to the coordinates of the first one * @throws CDKException if the number of atom's are not the same in the two AtomContainer's */ @TestMethod("testAlign") public KabschAlignment(IAtomContainer ac1, IAtomContainer ac2) throws CDKException { if (ac1.getAtomCount() != ac2.getAtomCount()) { throw new CDKException("The AtomContainer's being aligned must have the same number of atoms"); } this.npoint = ac1.getAtomCount(); this.p1 = getPoint3dArray(ac1); this.p2 = getPoint3dArray(ac2); this.wts = new double[npoint]; for (int i = 0; i < npoint; i++) this.wts[i] = 1.0; this.atwt1 = getAtomicMasses(ac1); this.atwt2 = getAtomicMasses(ac2); } /** * Sets up variables for the alignment algorithm. * * @param ac1 An {@link IAtomContainer} * @param ac2 An {@link IAtomContainer}. This AtomContainer will have its coordinates rotated * so that the RMDS is minimzed to the coordinates of the first one * @param wts A vector atom weights. * @throws CDKException if the number of atom's are not the same in the two AtomContainer's or * length of the weight vector is not the same as number of atoms. */ public KabschAlignment(IAtomContainer ac1, IAtomContainer ac2, double[] wts) throws CDKException { if (ac1.getAtomCount() != ac2.getAtomCount()) { throw new CDKException("The AtomContainer's being aligned must have the same number of atoms"); } if (ac1.getAtomCount() != wts.length) { throw new CDKException("Number of weights must equal number of atoms"); } this.npoint = ac1.getAtomCount(); this.p1 = getPoint3dArray(ac1); this.p2 = getPoint3dArray(ac2); this.wts = new double[npoint]; System.arraycopy(wts, 0, this.wts, 0, npoint); this.atwt1 = getAtomicMasses(ac1); this.atwt2 = getAtomicMasses(ac2); } /** * Perform an alignment. * * This method aligns to set of atoms which should have been specified * prior to this call */ @TestMethod("testAlign") public void align() { Matrix tmp; // get center of gravity and translate both to 0,0,0 this.cm1 = new Point3d(); this.cm2 = new Point3d(); this.cm1 = getCenterOfMass(p1, atwt1); this.cm2 = getCenterOfMass(p2, atwt2); // move the points for (int i = 0; i < this.npoint; i++) { p1[i].x = p1[i].x - this.cm1.x; p1[i].y = p1[i].y - this.cm1.y; p1[i].z = p1[i].z - this.cm1.z; p2[i].x = p2[i].x - this.cm2.x; p2[i].y = p2[i].y - this.cm2.y; p2[i].z = p2[i].z - this.cm2.z; } // get the R matrix double[][] tR = new double[3][3]; for (int i = 0; i < this.npoint; i++) { wts[i] = 1.0; } for (int i = 0; i < this.npoint; i++) { tR[0][0] += p1[i].x * p2[i].x * wts[i]; tR[0][1] += p1[i].x * p2[i].y * wts[i]; tR[0][2] += p1[i].x * p2[i].z * wts[i]; tR[1][0] += p1[i].y * p2[i].x * wts[i]; tR[1][1] += p1[i].y * p2[i].y * wts[i]; tR[1][2] += p1[i].y * p2[i].z * wts[i]; tR[2][0] += p1[i].z * p2[i].x * wts[i]; tR[2][1] += p1[i].z * p2[i].y * wts[i]; tR[2][2] += p1[i].z * p2[i].z * wts[i]; } double[][] R = new double[3][3]; tmp = new Matrix(tR); R = tmp.transpose().getArray(); // now get the RtR (=R'R) matrix double[][] RtR = new double[3][3]; Matrix jamaR = new Matrix(R); tmp = tmp.times(jamaR); RtR = tmp.getArray(); // get eigenvalues of RRt (a's) Matrix jamaRtR = new Matrix(RtR); EigenvalueDecomposition ed = jamaRtR.eig(); double[] mu = ed.getRealEigenvalues(); double[][] a = ed.getV().getArray(); // Jama returns the eigenvalues in increasing order so // swap the eigenvalues and vectors double tmp2 = mu[2]; mu[2] = mu[0]; mu[0] = tmp2; for (int i = 0; i < 3; i++) { tmp2 = a[i][2]; a[i][2] = a[i][0]; a[i][0] = tmp2; } // make sure that the a3 = a1 x a2 a[0][2] = (a[1][0]*a[2][1]) - (a[1][1]*a[2][0]); a[1][2] = (a[0][1]*a[2][0]) - (a[0][0]*a[2][1]); a[2][2] = (a[0][0]*a[1][1]) - (a[0][1]*a[1][0]); // lets work out the b vectors double[][] b = new double[3][3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { b[i][j] += R[i][k] * a[k][j]; } b[i][j] = b[i][j] / Math.sqrt(mu[j]); } } // normalize and set b3 = b1 x b2 double norm1 = 0.; double norm2 = 0.; for (int i = 0; i < 3; i++) { norm1 += b[i][0]*b[i][0]; norm2 += b[i][1]*b[i][1]; } norm1 = Math.sqrt(norm1); norm2 = Math.sqrt(norm2); for (int i = 0; i < 3; i++) { b[i][0] = b[i][0] / norm1; b[i][1] = b[i][1] / norm2; } b[0][2] = (b[1][0]*b[2][1]) - (b[1][1]*b[2][0]); b[1][2] = (b[0][1]*b[2][0]) - (b[0][0]*b[2][1]); b[2][2] = (b[0][0]*b[1][1]) - (b[0][1]*b[1][0]); // get the rotation matrix double[][] tU = new double[3][3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { for (int k = 0; k < 3; k++) { tU[i][j] += b[i][k]*a[j][k]; } } } // take the transpose U = new double[3][3]; for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { U[i][j] = tU[j][i]; } } // now eval the RMS error // first, rotate the second set of points and ... this.rp = new Point3d[ this.npoint ]; for (int i = 0; i < this.npoint; i++) { this.rp[i] = new Point3d( U[0][0]*p2[i].x + U[0][1]*p2[i].y + U[0][2]*p2[i].z, U[1][0]*p2[i].x + U[1][1]*p2[i].y + U[1][2]*p2[i].z, U[2][0]*p2[i].x + U[2][1]*p2[i].y + U[2][2]*p2[i].z ); } // ... then eval rms double rms = 0.; for (int i = 0; i < this.npoint; i++) { rms += (p1[i].x-this.rp[i].x)*(p1[i].x-this.rp[i].x) + (p1[i].y-this.rp[i].y)*(p1[i].y-this.rp[i].y) + (p1[i].z-this.rp[i].z)*(p1[i].z-this.rp[i].z); } this.rmsd = Math.sqrt(rms / this.npoint); } /** * Returns the RMSD from the alignment. * * If align() has not been called the return value is -1.0 * * @return The RMSD for this alignment * @see #align */ @TestMethod("testAlign") public double getRMSD() { return(this.rmsd); } /** * Returns the rotation matrix (u). * * @return A double[][] representing the rotation matrix * @see #align */ @TestMethod("testAlign") public double[][] getRotationMatrix() { return(this.U); } /** * Returns the center of mass for the first molecule or fragment used in the calculation. * * This method is useful when using this class to align the coordinates * of two molecules and them displaying them superimposed. Since the center of * mass used during the alignment may not be based on the whole molecule (in * general common substructures are aligned), when preparing molecules for display * the first molecule should be translated to the center of mass. Then displaying the * first molecule and the rotated version of the second one will result in superimposed * structures. * * @return A Point3d containing the coordinates of the center of mass */ public Point3d getCenterOfMass() { return(this.cm1); } /** * Rotates the {@link IAtomContainer} coordinates by the rotation matrix. * * In general if you align a subset of atoms in a AtomContainer * this function can be applied to the whole AtomContainer to rotate all * atoms. This should be called with the second AtomContainer (or Atom[]) * that was passed to the constructor. * * Note that the AtomContainer coordinates also get translated such that the * center of mass of the original fragment used to calculate the alignment is at the origin. * * @param ac The {@link IAtomContainer} whose coordinates are to be rotated */ public void rotateAtomContainer(IAtomContainer ac) { Point3d[] p = getPoint3dArray( ac ); for (int i = 0; i < ac.getAtomCount(); i++) { // translate the the origin we have calculated p[i].x = p[i].x - this.cm2.x; p[i].y = p[i].y - this.cm2.y; p[i].z = p[i].z - this.cm2.z; // do the actual rotation ac.getAtom(i).setPoint3d( new Point3d( U[0][0]*p[i].x + U[0][1]*p[i].y + U[0][2]*p[i].z, U[1][0]*p[i].x + U[1][1]*p[i].y + U[1][2]*p[i].z, U[2][0]*p[i].x + U[2][1]*p[i].y + U[2][2]*p[i].z ) ); } } } cdk-1.2.10/src/main/org/openscience/cdk/geometry/surface/NeighborList.java100644 0 0 11343 11570154753 23572 0ustar 0 0 /* * Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project * * 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. * * 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.geometry.surface; import org.openscience.cdk.interfaces.IAtom; import java.util.ArrayList; import java.util.HashMap; import java.util.List; /** * Creates a list of atoms neighboring each atom in the molecule. * *

The routine is a simplified version of the neighbor list described * in {@cdk.cite EIS95} and is based on the implementation by Peter McCluskey. * Due to the fact that it divides the cube into a fixed number of sub cubes, * some accuracy may be lost. * * @author Rajarshi Guha * @cdk.created 2005-05-09 * @cdk.module extra * @cdk.githash */ public class NeighborList { HashMap boxes; double boxSize; IAtom[] atoms; public NeighborList(IAtom[] atoms, double radius) { this.atoms = atoms; this.boxes = new HashMap(); this.boxSize = 2 * radius; for (int i = 0; i < atoms.length; i++) { String key = getKeyString(atoms[i]); if (this.boxes.containsKey(key)) { List arl = this.boxes.get(key); arl.add(i); this.boxes.put( key, arl ); } else { this.boxes.put( key, new ArrayList() ); } } } private String getKeyString(IAtom atom) { double x = atom.getPoint3d().x; double y = atom.getPoint3d().y; double z = atom.getPoint3d().z; int k1,k2,k3; k1 = (int)(Math.floor(x/ boxSize)); k2 = (int)(Math.floor(y/ boxSize)); k3 = (int)(Math.floor(z/ boxSize)); String key = Integer.toString(k1) + " " + Integer.toString(k2) + " " + Integer.toString(k3) + " " ; return(key); } private int[] getKeyArray(IAtom atom) { double x = atom.getPoint3d().x; double y = atom.getPoint3d().y; double z = atom.getPoint3d().z; int k1,k2,k3; k1 = (int)(Math.floor(x/ boxSize)); k2 = (int)(Math.floor(y/ boxSize)); k3 = (int)(Math.floor(z/ boxSize)); int[] ret = { k1, k2, k3 }; return(ret); } public int getNumberOfNeighbors(int i) { return getNeighbors(i).length; } public int[] getNeighbors(int ii) { double maxDist2 = this.boxSize *this.boxSize; IAtom ai = this.atoms[ii]; int[] key = getKeyArray(ai); ArrayList nlist = new ArrayList(); int[] bval = {-1,0,1}; for (int i = 0; i < bval.length; i++) { int x = bval[i]; for (int j = 0; j < bval.length; j++) { int y = bval[j]; for (int k = 0; k < bval.length; k++) { int z = bval[k]; String keyj = Integer.toString(key[0]+x) + " " + Integer.toString(key[1]+y) + " " + Integer.toString(key[2]+z) + " " ; if (boxes.containsKey(keyj)) { ArrayList nbrs = (ArrayList)boxes.get(keyj); for (int l = 0; l < nbrs.size(); l++) { int i2 = (Integer) nbrs.get(l); if (i2 != ii) { IAtom aj = atoms[i2]; double x12 = aj.getPoint3d().x - ai.getPoint3d().x; double y12 = aj.getPoint3d().y - ai.getPoint3d().y; double z12 = aj.getPoint3d().z - ai.getPoint3d().z; double d2 = x12*x12 + y12*y12 + z12*z12; if (d2 < maxDist2) nlist.add(i2); } } } } } } Object[] tmp = nlist.toArray(); int[] ret = new int[ tmp.length ]; for (int j = 0; j < tmp.length; j++) ret[j] = (Integer) tmp[j]; return(ret); } } cdk-1.2.10/src/main/org/openscience/cdk/geometry/surface/NumericalSurface.java100644 0 0 30626 11570154753 24436 0ustar 0 0 /* * Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project * * 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. * * 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.geometry.surface; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.PeriodicTable; import org.openscience.cdk.tools.manipulator.AtomContainerManipulator; import javax.vecmath.Point3d; import java.util.ArrayList; import java.util.Iterator; /** * A class representing the solvent acessible surface area surface of a molecule. * *

This class is based on the Python implementation of the DCLM method * ({@cdk.cite EIS95}) by Peter McCluskey, which is a non-analytical method to generate a set of points * representing the solvent accessible surface area of a molecule. * *

The neighbor list is a simplified version of that * described in {@cdk.cite EIS95} and as a result, the surface areas of the atoms may not be exact * (compared to analytical calculations). The tessellation is slightly different from * that described by McCluskey and uses recursive subdivision starting from an icosahedral * representation. * *

The default solvent radius used is 1.4A and setting this to 0 will give the * Van der Waals surface. The accuracy can be increased by increasing the tessellation * level, though the default of 4 is a good balance between accuracy and speed. * * @author Rajarshi Guha * @cdk.created 2005-05-08 * @cdk.module extra * @cdk.githash * @cdk.bug 1846421 */ public class NumericalSurface { private LoggingTool logger; double solvent_radius = 1.4; int tesslevel = 4; IAtom[] atoms; ArrayList[] surf_points; double[] areas; double[] volumes; /** * Constructor to initialize the surface calculation with default values. * * This constructor use the Van der Waals radii as defined in org/openscience/cdk/config/data/jmol_atomtypes.txt * of the source distribution. Also uses a tesselation level of 4 and solvent radius of 1.4A. * * @param atomContainer The {@link IAtomContainer} for which the surface is to be calculated */ public NumericalSurface(IAtomContainer atomContainer) { this.atoms = AtomContainerManipulator.getAtomArray(atomContainer); logger = new LoggingTool(this); } /** * Constructor to initialize the surface calculation with user specified values. * * This constructor use the Van der Waals radii as defined in org/openscience/cdk/config/data/jmol_atomtypes.txt * of the source distribution * * @param atomContainer The {@link IAtomContainer} for which the surface is to be calculated * @param solvent_radius The radius of a solvent molecule that is used to extend * the radius of each atom. Setting to 0 gives the Van der Waals surface * @param tesslevel The number of levels that the subdivision algorithm for tessllation * should use */ public NumericalSurface(IAtomContainer atomContainer, double solvent_radius, int tesslevel) { this.solvent_radius = solvent_radius; this.atoms = AtomContainerManipulator.getAtomArray(atomContainer); this.tesslevel = tesslevel; logger = new LoggingTool(this); } /** * Evaluate the surface. * * This method generates the points on the accessible surface area of each atom * as well as calculating the surface area of each atom */ public void calculateSurface() { // get r_f and geometric center Point3d cp = new Point3d(0,0,0); double max_radius = 0; for (int i = 0; i < atoms.length; i++) { double vdwr = PeriodicTable.getVdwRadius(atoms[i].getSymbol()); if (vdwr+solvent_radius > max_radius) max_radius = PeriodicTable.getVdwRadius(atoms[i].getSymbol())+solvent_radius; cp.x = cp.x + atoms[i].getPoint3d().x; cp.y = cp.y + atoms[i].getPoint3d().y; cp.z = cp.z + atoms[i].getPoint3d().z; } cp.x = cp.x / atoms.length; cp.y = cp.y / atoms.length; cp.z = cp.z / atoms.length; // do the tesselation Tessellate tess = new Tessellate("ico",tesslevel); tess.doTessellate(); logger.info("Got tesselation, number of triangles = "+tess.getNumberOfTriangles()); // get neighbor list NeighborList nbrlist = new NeighborList(atoms, max_radius+solvent_radius); logger.info("Got neighbor list"); /* for (int i = 0; i < atoms.length; i++) { int[] nlist = nbrlist.getNeighbors(i); logger.debug("Atom "+i+": "); for (int j = 0; j < nlist.length; j++) logger.debug(j+" "); logger.debug(""); } */ // loop over atoms and get surface points this.surf_points = new ArrayList[ atoms.length ]; this.areas = new double[ atoms.length ]; this.volumes = new double[ atoms.length ]; for (int i = 0; i < atoms.length; i++) { int point_density = tess.getNumberOfTriangles()*3; Point3d[][] points = atomicSurfacePoints(nbrlist, i, atoms[i], tess); translatePoints(i, points, point_density, atoms[i], cp); } logger.info("Obtained points, areas and volumes"); } /** * Get an array of all the points on the molecular surface. * * This returns an array of Point3d objects representing all the points * on the molecular surface * * @return An array of Point3d objects */ public Point3d[] getAllSurfacePoints() { int npt = 0; for (int i = 0; i < this.surf_points.length; i++) npt += this.surf_points[i].size(); Point3d[] ret = new Point3d[npt]; int j = 0; for (int i = 0; i < this.surf_points.length; i++) { ArrayList arl = this.surf_points[i]; for (Iterator it = arl.iterator(); it.hasNext();) { ret[j] = (Point3d)it.next(); j++; } } return(ret); } /** * Get an array of the points on the accessible surface of a specific atom. * * @param atomIdx The index of the atom. Ranges from 0 to n-1, where n is the * number of atoms in the AtomContainer that the surface was calculated for * @return An array of Point3d objects * @throws CDKException if the atom index is outside the range of allowable indices */ public Point3d[] getSurfacePoints(int atomIdx) throws CDKException { if (atomIdx >= this.surf_points.length) { throw new CDKException("Atom index was out of bounds"); } ArrayList arl = this.surf_points[atomIdx]; Point3d[] ret = new Point3d[arl.size()]; for (int i = 0; i < arl.size(); i++) ret[i] = (Point3d)arl.get(i); return(ret); } /** * Get the surface area for the specified atom. * * @param atomIdx The index of the atom. Ranges from 0 to n-1, where n is the * number of atoms in the AtomContainer that the surface was calculated for * @return A double representing the accessible surface area of the atom * @throws CDKException if the atom index is outside the range of allowable indices */ public double getSurfaceArea(int atomIdx) throws CDKException { if (atomIdx >= this.surf_points.length) { throw new CDKException("Atom index was out of bounds"); } return(this.areas[atomIdx]); } /** * Get an array containing the accessible surface area for each atom. * * @return An array of double giving the surface areas of all the atoms */ public double[] getAllSurfaceAreas() { return(this.areas); } /** * Get the total surface area for the AtomContainer. * * @return A double containing the total surface area of the AtomContainer for * which the surface was calculated for */ public double getTotalSurfaceArea() { double ta = 0.0; for (int i =0; i < this.areas.length; i++) ta += this.areas[i]; return(ta); } private void translatePoints(int atmIdx, Point3d[][] points, int point_density, IAtom atom, Point3d cp) { double total_radius = PeriodicTable.getVdwRadius(atom.getSymbol()) + solvent_radius; double area = 4 * Math.PI * (total_radius*total_radius) * points.length / point_density; double sumx = 0.0; double sumy = 0.0; double sumz = 0.0; for (int i = 0; i < points.length; i++) { Point3d p = points[i][1]; sumx += p.x; sumy += p.y; sumz += p.z; } double vconst = 4.0/3.0 * Math.PI / (double)point_density; double dotp1 = (atom.getPoint3d().x - cp.x)*sumx + (atom.getPoint3d().y - cp.y)*sumy + (atom.getPoint3d().z - cp.z)*sumz; double volume = vconst*(total_radius*total_radius) *dotp1 + (total_radius*total_radius*total_radius)*points.length; this.areas[atmIdx] = area; this.volumes[atmIdx] = volume; ArrayList tmp = new ArrayList(); for (int i = 0; i < points.length; i++) tmp.add( points[i][0] ); this.surf_points[atmIdx] = tmp; } private Point3d[][] atomicSurfacePoints(NeighborList nbrlist, int currAtomIdx, IAtom atom, Tessellate tess) { double total_radius = PeriodicTable.getVdwRadius(atom.getSymbol()) + solvent_radius; double total_radius2 = total_radius*total_radius; double twice_total_radius = 2*total_radius; int[] nlist = nbrlist.getNeighbors(currAtomIdx); double[][] data = new double[ nlist.length ][4]; for (int i = 0; i < nlist.length; i++) { double x12 = atoms[nlist[i]].getPoint3d().x - atom.getPoint3d().x; double y12 = atoms[nlist[i]].getPoint3d().y - atom.getPoint3d().y; double z12 = atoms[nlist[i]].getPoint3d().z - atom.getPoint3d().z; double d2 = x12*x12 + y12*y12 + z12*z12; double tmp = PeriodicTable.getVdwRadius(atoms[nlist[i]].getSymbol()) + solvent_radius; tmp = tmp * tmp; double thresh = (d2 + total_radius2 - tmp) / twice_total_radius; data[i][0] = x12; data[i][1] = y12; data[i][2] = z12; data[i][3] = thresh; } Point3d[] tess_points = tess.getTessAsPoint3ds(); ArrayList points = new ArrayList(); for (int i = 0; i < tess_points.length; i++) { Point3d pt = tess_points[i]; boolean buried = false; for (int j = 0; j < data.length; j++) { if (data[j][0] * pt.x + data[j][1] * pt.y + data[j][2] * pt.z > data[j][3]) { buried = true; break; } } if (buried == false) { Point3d[] tmp = new Point3d[2]; tmp[0] = new Point3d( total_radius * pt.x + atom.getPoint3d().x, total_radius * pt.y + atom.getPoint3d().y, total_radius * pt.z + atom.getPoint3d().z ); tmp[1] = pt; points.add( tmp ); } } // the first column contains the transformed points // and the second column contains the points from the // original unit tesselation Point3d[][] ret = new Point3d[ points.size() ][2]; for (int i = 0; i < points.size(); i++) { Point3d[] tmp = (Point3d[])points.get(i); ret[i][0] = tmp[0]; ret[i][1] = tmp[1]; } return(ret); } } cdk-1.2.10/src/main/org/openscience/cdk/geometry/surface/Tessellate.java100644 0 0 15554 11570154753 23316 0ustar 0 0 /* * Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project * * 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. * * 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.geometry.surface; import javax.vecmath.Point3d; /** * Performs a tessellation of the unit sphere. * * This class generates the coordinates of the triangles that will * tessellate the unit sphere. The algorithm is recursive subdivision * of an initial representation which can be tetrahedral, octahedral or * icoshedral. The default is icosahedral. The number of points generated * depends on the level of subdivision. The default is 4 levels and with the * initial icoshedral representation this gives 1536 points. *

* The constants for the tetrahedral and icosahedral representations were * taken from http://eeg.sourceforge.net/eegdoc/eeg_toolbox/sphere_tri.html * * @author Rajarshi Guha * @cdk.created 2005-05-08 * @cdk.module extra * @cdk.githash */ public class Tessellate { Triangle[] oldtess; int maxlevel; public Tessellate() { this.oldtess = this.repIco(); this.maxlevel = 4; } public Tessellate(String type, int level) { if (type.equals("tet")) this.oldtess = this.repTet(); else if (type.equals("oct")) this.oldtess = this.repOct(); else if (type.equals("ico")) this.oldtess = this.repIco(); this.maxlevel = level; } private Point3d midpoint(Point3d p1, Point3d p2) { double x,y,z; x = 0.5 * (p1.x + p2.x); y = 0.5 * (p1.y + p2.y); z = 0.5 * (p1.z + p2.z); return( new Point3d(x,y,z) ); } private void normalize(Point3d p) { double mag = p.x*p.x + p.y*p.y + p.z*p.z; if (mag != 0.0) { mag = 1.0 / Math.sqrt(mag); p.x = p.x * mag; p.y = p.y * mag; p.z = p.z * mag; } } public void doTessellate() { for (int j = 1; j < maxlevel; j++) { int oldN = this.oldtess.length; int newN = oldN * 4; Triangle[] newtess = new Triangle[ newN ]; for (int i = 0; i < oldN; i++) { Triangle old = oldtess[i]; Point3d p1 = midpoint(old.p1, old.p3); Point3d p2 = midpoint(old.p1, old.p2); Point3d p3 = midpoint(old.p2, old.p3); normalize(p1); normalize(p2); normalize(p3); newtess[i*4] = new Triangle(old.p1, p2, p1); newtess[i*4+1] = new Triangle(p2, old.p2, p3); newtess[i*4+2] = new Triangle(p1,p2,p3); newtess[i*4+3] = new Triangle(p1,p3,old.p3); } oldtess = new Triangle[newN]; for (int i = 0; i < newN; i++) oldtess[i] = newtess[i]; } } public int getNumberOfTriangles() { return(oldtess.length); } public Triangle[] getTessAsTriangles() { return(oldtess); } public Point3d[] getTessAsPoint3ds() { Point3d[] ret = new Point3d[ getNumberOfTriangles()*3 ]; for (int i = 0; i < getNumberOfTriangles(); i++) { ret[i*3] = oldtess[i].p1; ret[i*3+1] = oldtess[i].p2; ret[i*3+2] = oldtess[i].p3; } return(ret); } private Triangle[] repTet() { double sqrt3 = 0.5773502692; Point3d[] v = { new Point3d(sqrt3, sqrt3, sqrt3), new Point3d(-sqrt3, -sqrt3, sqrt3), new Point3d(-sqrt3,sqrt3,-sqrt3), new Point3d(sqrt3,-sqrt3,-sqrt3) }; Triangle[] rep = { new Triangle( v[0],v[1],v[2] ), new Triangle( v[0],v[3],v[1] ), new Triangle( v[2],v[1],v[3] ), new Triangle( v[3],v[0],v[2] ) }; return(rep); } private Triangle[] repOct() { Point3d[] v = { new Point3d(1.0,0.0,0.0), new Point3d(-1.0,0.0,0.0), new Point3d(0.0,1.0,0.0), new Point3d(0.0,-1.0,0.0), new Point3d(0.0,0.0,1.0), new Point3d(0.0,0.0,-1.0) }; Triangle[] rep = { new Triangle( v[0], v[4], v[2] ), new Triangle( v[2], v[4], v[1] ), new Triangle( v[1], v[4], v[3] ), new Triangle( v[3], v[4], v[0] ), new Triangle( v[0], v[2], v[5] ), new Triangle( v[2], v[1], v[5] ), new Triangle( v[1], v[3], v[5] ), new Triangle( v[3], v[0], v[5] ) }; return(rep); } private Triangle[] repIco() { double tau = 0.8506508084; double one = 0.5257311121; Point3d[] v = { new Point3d( tau, one, 0.0 ), new Point3d( -tau, one, 0.0 ), new Point3d( -tau, -one, 0.0 ), new Point3d( tau, -one, 0.0 ), new Point3d( one, 0.0 , tau ), new Point3d( one, 0.0 , -tau ), new Point3d( -one, 0.0 , -tau ), new Point3d( -one, 0.0 , tau ), new Point3d( 0.0 , tau, one ), new Point3d( 0.0 , -tau, one ), new Point3d( 0.0 , -tau, -one ), new Point3d( 0.0 , tau, -one ) }; Triangle[] rep = { new Triangle( v[4], v[8], v[7] ), new Triangle( v[4], v[7], v[9] ), new Triangle( v[5], v[6], v[11] ), new Triangle( v[5], v[10], v[6] ), new Triangle( v[0], v[4], v[3] ), new Triangle( v[0], v[3], v[5] ), new Triangle( v[2], v[7], v[1] ), new Triangle( v[2], v[1], v[6] ), new Triangle( v[8], v[0], v[11] ), new Triangle( v[8], v[11], v[1] ), new Triangle( v[9], v[10], v[3] ), new Triangle( v[9], v[2], v[10] ), new Triangle( v[8], v[4], v[0] ), new Triangle( v[11], v[0], v[5] ), new Triangle( v[4], v[9], v[3] ), new Triangle( v[5], v[3], v[10] ), new Triangle( v[7], v[8], v[1] ), new Triangle( v[6], v[1], v[11] ), new Triangle( v[7], v[2], v[9] ), new Triangle( v[6], v[10], v[2] ) }; return(rep); } } cdk-1.2.10/src/main/org/openscience/cdk/geometry/surface/Triangle.java100644 0 0 2450 11570154753 22725 0ustar 0 0 /* * Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project * * 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. * * 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.geometry.surface; import javax.vecmath.Point3d; /** * Representation of a triangle in 3D. * * By default this class represent the triangle in clockwise * fashion. * * @author Rajarshi Guha * @cdk.module extra * @cdk.githash */ public class Triangle { Point3d p1,p2,p3; public Triangle( Point3d p1, Point3d p2, Point3d p3 ) { this.p1 = p1; this.p2 = p2; this.p3 = p3; } } cdk-1.2.10/src/main/org/openscience/cdk/graph/AtomContainerAtomPermutor.java100644 0 0 5535 11570154753 24127 0ustar 0 0 /* * $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.graph; import org.openscience.cdk.Atom; import org.openscience.cdk.AtomContainer; import org.openscience.cdk.interfaces.IAtomContainer; /** * This class allows to iterate trough the set of all possible * permutations of the atom order in a given atom container. * It allows to check for a dependency of algorithm results * on the atom order. * *

The permutation code here is based on a pseudo code example * on a tutorial site created and maintained by Phillip P. Fuchs: * http://www.geocities.com/permute_it/pseudo2.html. * *@author steinbeck * @cdk.githash *@cdk.created 2005-05-04 *@cdk.keyword permutation */ public class AtomContainerAtomPermutor extends AtomContainerPermutor { public AtomContainerAtomPermutor(AtomContainer ac) { setAtomContainer(ac); N = atomContainer.getAtomCount(); initBookkeeping(); initObjectArray(); } public void initObjectArray() { java.util.Iterator atoms = atomContainer.atoms().iterator(); objects = new Object[atomContainer.getAtomCount()]; int count = -1; while (atoms.hasNext()) { objects[++count] = atoms.next(); } } AtomContainer makeResult() { Atom[] atoms = new Atom[objects.length]; for (int f = 0; f < objects.length; f++) { atoms[f] = ((Atom)objects[f]); } IAtomContainer ac = atomContainer.getBuilder().newAtomContainer(atomContainer); ac.setAtoms(atoms); AtomContainer clone = null; try { clone = (AtomContainer)ac.clone(); } catch (CloneNotSupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); } return clone; } } cdk-1.2.10/src/main/org/openscience/cdk/graph/AtomContainerBondPermutor.java100644 0 0 5747 11570154753 24116 0ustar 0 0 /* * $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.graph; import org.openscience.cdk.AtomContainer; import org.openscience.cdk.interfaces.IBond; import java.util.Iterator; /** * This class allows to iterate trough the set of all possible * permutations of the bond order in a given atom container. * It allows to check for a dependency of algorithm results * on the bond order. * *

The permutation code here is based on a pseudo code example * on a tutorial site created and maintained by Phillip P. Fuchs: * http://www.geocities.com/permute_it/pseudo2.html. * *@author steinbeck * @cdk.githash *@cdk.created 2005-05-04 *@cdk.keyword permutation */ public class AtomContainerBondPermutor extends AtomContainerPermutor { public AtomContainerBondPermutor(AtomContainer ac) { setAtomContainer(ac); N = atomContainer.getBondCount(); initBookkeeping(); initObjectArray(); } public void initObjectArray() { Iterator bonds = atomContainer.bonds().iterator(); objects = new Object[atomContainer.getBondCount()]; int i = 0; while (bonds.hasNext()) { objects[i] = bonds.next(); i++; } } AtomContainer makeResult() { IBond[] bonds = new IBond[objects.length]; for (int f = 0; f < objects.length; f++) { bonds[f] = ((IBond)objects[f]); } AtomContainer ac = new AtomContainer(atomContainer); ac.setBonds(bonds); AtomContainer clone = null; try { clone = (AtomContainer)ac.clone(); } catch (CloneNotSupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); } return clone; } } cdk-1.2.10/src/main/org/openscience/cdk/graph/AtomContainerPermutor.java100644 0 0 5727 11570154753 23311 0ustar 0 0 /* * $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.graph; import java.util.Iterator; import org.openscience.cdk.AtomContainer; import org.openscience.cdk.tools.LoggingTool; /** * The permutation code here is based on a pseudo code example * on a tutorial site created and maintained by Phillip P. Fuchs: * http://www.geocities.com/permute_it/pseudo2.html. * *@author steinbeck * @cdk.githash *@cdk.created 2005-05-04 *@cdk.keyword permutation */ public abstract class AtomContainerPermutor implements Iterator { final static boolean debug = true; static int debugCounter = 0; int N, i, j; int[] bookkeeping; Object[] objects; private static LoggingTool logger = new LoggingTool(AtomContainerPermutor.class); AtomContainer atomContainer; public void setAtomContainer(AtomContainer ac) { this.atomContainer = ac; } public void initBookkeeping() { bookkeeping = new int[N + 1]; for (int f = 0; f <= N ; f++) { bookkeeping[f] = f; } i = 1; } public Object next() { bookkeeping[i] = bookkeeping[i] - 1; if (isOdd(i)) j = bookkeeping[i]; else j = 0; swap(i, j); i = 1; while(bookkeeping[i] == 0) { bookkeeping[i] = i; i++; } return makeResult(); } public boolean hasNext() { if (i < N) return true; return false; } public void remove() { // stupid method. not implemented. } void swap(int x, int y) { logger.debug("swapping order of " + x + " and " + y); Object o = objects[x]; objects[x] = objects[y]; objects[y] = o; } void initObjectArray() { // } AtomContainer makeResult() { return null; } /** * Returns true if this number is odd. */ boolean isOdd(int x) { return (x & 1 ) == 1; } } cdk-1.2.10/src/main/org/openscience/cdk/graph/BFSShortestPath.java100644 0 0 6447 11570154753 21773 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.graph; import org._3pq.jgrapht.Edge; import org._3pq.jgrapht.Graph; import org._3pq.jgrapht.traverse.BreadthFirstIterator; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * Utility class that finds the shortest bond path between two atoms using * a breadth first search. * * @author uli * * @cdk.module standard * @cdk.githash * @cdk.created 2004-10-19 */ @TestClass("org.openscience.cdk.graph.BFSShortestPathTest") public final class BFSShortestPath { private BFSShortestPath( ) {} // ensure non-instantiability. @TestMethod("testFindPathBetween_Graph_Object_Object") public static List findPathBetween( Graph graph, Object startVertex, Object endVertex ) { MyBreadthFirstIterator iter = new MyBreadthFirstIterator( graph, startVertex ); while( iter.hasNext( ) ) { Object vertex = iter.next( ); if( vertex.equals( endVertex ) ) { return createPath( iter, endVertex ); } } return null; } private static List createPath( MyBreadthFirstIterator iter, Object endVertex ) { List path = new ArrayList( ); while( true ) { Edge edge = iter.getSpanningTreeEdge( endVertex ); if( edge == null ) { break; } path.add( edge ); endVertex = edge.oppositeVertex( endVertex ); } Collections.reverse( path ); return path; } private static class MyBreadthFirstIterator extends BreadthFirstIterator { public MyBreadthFirstIterator(Graph g, Object startVertex) { super(g, startVertex); } protected void encounterVertex( Object vertex, Edge edge ) { super.encounterVertex( vertex, edge ); putSeenData( vertex, edge ); } public Edge getSpanningTreeEdge( Object vertex ) { return (Edge) getSeenData( vertex ); } } } cdk-1.2.10/src/main/org/openscience/cdk/graph/BiconnectivityInspector.java100644 0 0 15541 11570154753 23703 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.graph; import org._3pq.jgrapht.Edge; import org._3pq.jgrapht.Graph; import org._3pq.jgrapht.UndirectedGraph; import org._3pq.jgrapht.alg.ConnectivityInspector; import org._3pq.jgrapht.event.GraphEdgeChangeEvent; import org._3pq.jgrapht.event.GraphVertexChangeEvent; import org._3pq.jgrapht.graph.SimpleGraph; import org._3pq.jgrapht.graph.Subgraph; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import java.util.*; /** * Finds the biconnected components of a graph. * Two edges belong to the same biconnected component if and only if they are * identical or both belong to a simple cycle. * * @author Ulrich Bauer * * @cdk.module standard * @cdk.githash * * @cdk.builddepends jgrapht-0.5.3.jar * @cdk.depends jgrapht-0.5.3.jar */ @TestClass("org.openscience.cdk.graph.BiconnectivityInspectorTest") public class BiconnectivityInspector { private List biconnectedSets; private UndirectedGraph graph; /** * Creates a biconnectivity inspector for the specified undirected graph. * @param g the specified graph */ public BiconnectivityInspector(UndirectedGraph g) { graph = g; } private List lazyFindBiconnectedSets( ) { if( biconnectedSets == null ) { biconnectedSets = new ArrayList(); Iterator connectedSets = new ConnectivityInspector(graph).connectedSets().iterator(); while (connectedSets.hasNext()) { Set connectedSet = (Set) connectedSets.next(); if (connectedSet.size() == 1) { continue; } Graph subgraph = new Subgraph(graph, connectedSet, null); // do DFS // Stack for the DFS Stack vertexStack = new Stack(); Set visitedVertices = new HashSet(); Map parent = new HashMap(); List dfsVertices = new ArrayList(); Set treeEdges = new HashSet(); Object currentVertex = subgraph.vertexSet().toArray()[0]; vertexStack.push(currentVertex); visitedVertices.add(currentVertex); while (!vertexStack.isEmpty()) { currentVertex = vertexStack.pop(); Object parentVertex = parent.get(currentVertex); if (parentVertex != null) { Edge edge = subgraph.getEdge(parentVertex, currentVertex); // tree edge treeEdges.add(edge); } visitedVertices.add(currentVertex); dfsVertices.add(currentVertex); Iterator edges = subgraph.edgesOf(currentVertex).iterator(); while (edges.hasNext()) { // find a neighbour vertex of the current vertex Edge edge = (Edge)edges.next(); if (!treeEdges.contains(edge)) { Object nextVertex = edge.oppositeVertex(currentVertex); if (!visitedVertices.contains(nextVertex)) { vertexStack.push(nextVertex); parent.put(nextVertex, currentVertex); } else { // non-tree edge } } } } // DFS is finished. Now create the auxiliary graph h // Add all the tree edges as vertices in h SimpleGraph h = new SimpleGraph(); h.addAllVertices(treeEdges); visitedVertices.clear(); Set connected = new HashSet(); for (Iterator it = dfsVertices.iterator(); it.hasNext();) { Object v = it.next(); visitedVertices.add(v); // find all adjacent non-tree edges for (Iterator adjacentEdges = subgraph.edgesOf(v).iterator(); adjacentEdges.hasNext();) { Edge l = (Edge) adjacentEdges.next(); if (!treeEdges.contains(l)) { h.addVertex(l); Object u = l.oppositeVertex(v); // we need to check if (u,v) is a back-edge if (!visitedVertices.contains(u)) { while (u != v) { Object pu = parent.get(u); Edge f = subgraph.getEdge(u, pu); h.addEdge(f, l); if (!connected.contains(f)) { connected.add(f); u = pu; } else { u = v; } } } } } } ConnectivityInspector connectivityInspector = new ConnectivityInspector(h); biconnectedSets.addAll(connectivityInspector.connectedSets()); } } return biconnectedSets; } /** * Returns a list of Sets, where each set contains all edge that are * in the same biconnected component. All graph edges occur in exactly one set. * * @return a list of Sets, where each set contains all edge that are * in the same biconnected component */ @TestMethod("testBiconnectedSets") public List biconnectedSets( ) { return lazyFindBiconnectedSets( ); } /* public List hopcroftTarjanKnuthFindBiconnectedSets() { Map rank; Map parent; Map untagged; Map link; Stack activeStack; Map min; int nn; return biconnectedSets; } */ private void init() { biconnectedSets = null; } /** * @see org._3pq.jgrapht.event.GraphListener#edgeAdded(GraphEdgeChangeEvent) */ public void edgeAdded( GraphEdgeChangeEvent e ) { init( ); } /** * @see org._3pq.jgrapht.event.GraphListener#edgeRemoved(GraphEdgeChangeEvent) */ public void edgeRemoved( GraphEdgeChangeEvent e ) { init( ); } /** * @see org._3pq.jgrapht.event.VertexSetListener#vertexAdded(GraphVertexChangeEvent) */ public void vertexAdded( GraphVertexChangeEvent e ) { init( ); } /** * @see org._3pq.jgrapht.event.VertexSetListener#vertexRemoved(GraphVertexChangeEvent) */ public void vertexRemoved( GraphVertexChangeEvent e ) { init( ); } } cdk-1.2.10/src/main/org/openscience/cdk/graph/ConnectivityChecker.java100644 0 0 11477 11570154753 22772 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 1997-2007 The Chemistry Development Kit (CDK) project * * 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. * * 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.graph; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.*; import java.util.ArrayList; import java.util.List; /** * Tool class for checking whether the (sub)structure in an * AtomContainer is connected. * To check whether an AtomContainer is connected this code * can be used: *

 *  boolean isConnected = ConnectivityChecker.isConnected(atomContainer);
 * 
* *

A disconnected AtomContainer can be fragmented into connected * fragments by using code like: *

 *   MoleculeSet fragments = ConnectivityChecker.partitionIntoMolecules(disconnectedContainer);
 *   int fragmentCount = fragments.getMoleculeCount();
 * 
* * @cdk.module standard * @cdk.githash * * @cdk.keyword connectivity */ @TestClass("org.openscience.cdk.graph.ConnectivityCheckerTest") public class ConnectivityChecker { /** * Check whether a set of atoms in an {@link IAtomContainer} is connected. * * @param atomContainer The {@link IAtomContainer} to be check for connectedness * @return true if the {@link IAtomContainer} is connected */ @TestMethod("testIsConnected_IAtomContainer,testPartitionIntoMolecules_IsConnected_Consistency") public static boolean isConnected(IAtomContainer atomContainer) { // with one atom or less, we define it to be connected, as there is no // partitioning needed if (atomContainer.getAtomCount() < 2) return true; IAtomContainer newContainer = atomContainer.getBuilder().newAtomContainer(); IMolecule molecule = atomContainer.getBuilder().newMolecule(); List sphere = new ArrayList(); for (IAtom atom : atomContainer.atoms()) { atom.setFlag(CDKConstants.VISITED, false); newContainer.addAtom(atom); } for (IBond bond : atomContainer.bonds()) { bond.setFlag(CDKConstants.VISITED, false); newContainer.addBond(bond); } IAtom atom = newContainer.getAtom(0); sphere.add(atom); atom.setFlag(CDKConstants.VISITED, true); PathTools.breadthFirstSearch(newContainer, sphere, molecule); return molecule.getAtomCount() == atomContainer.getAtomCount(); } /** * Partitions the atoms in an AtomContainer into covalently connected components. * * @param atomContainer The AtomContainer to be partitioned into connected components, i.e. molecules * @return A MoleculeSet. * * @cdk.dictref blue-obelisk:graphPartitioning */ @TestMethod("testPartitionIntoMolecules_IAtomContainer,testPartitionIntoMoleculesKeepsAtomIDs,testPartitionIntoMolecules_IsConnected_Consistency") public static IMoleculeSet partitionIntoMolecules(IAtomContainer atomContainer) { IAtomContainer newContainer = atomContainer.getBuilder().newAtomContainer(); IMolecule molecule; IMoleculeSet molecules = atomContainer.getBuilder().newMoleculeSet(); List sphere = new ArrayList(); for (IAtom atom : atomContainer.atoms()) { atom.setFlag(CDKConstants.VISITED, false); newContainer.addAtom(atom); } for (IBond bond : atomContainer.bonds()) { bond.setFlag(CDKConstants.VISITED, false); newContainer.addBond(bond); } for (IElectronContainer eContainer : atomContainer.electronContainers()) { eContainer.setFlag(CDKConstants.VISITED, false); newContainer.addElectronContainer(eContainer); } while(newContainer.getAtomCount() > 0) { IAtom atom = newContainer.getAtom(0); molecule = atomContainer.getBuilder().newMolecule(); sphere.clear(); sphere.add(atom); atom.setFlag(CDKConstants.VISITED, true); PathTools.breadthFirstSearch(newContainer, sphere, molecule); molecules.addMolecule(molecule); newContainer.remove(molecule); } return molecules; } } cdk-1.2.10/src/main/org/openscience/cdk/graph/MinimalPathIterator.java100644 0 0 21466 11570154753 22743 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.graph; import org._3pq.jgrapht.DirectedGraph; import org._3pq.jgrapht.Edge; import org._3pq.jgrapht.Graph; import org._3pq.jgrapht.graph.DefaultDirectedGraph; import org._3pq.jgrapht.graph.SimpleGraph; import org._3pq.jgrapht.traverse.BreadthFirstIterator; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import java.util.*; /** * Iterates over all shortest paths between two vertices in an undirected, unweighted graph. * * @author Ulrich Bauer * * * @cdk.module standard * @cdk.githash * * @cdk.builddepends jgrapht-0.5.3.jar * @cdk.depends jgrapht-0.5.3.jar */ @TestClass("org.openscience.cdk.graph.MinimalPathIteratorTest") public class MinimalPathIterator implements Iterator { private Object sourceVertex, targetVertex; private Graph g; private DirectedGraph shortestPathGraph; private Stack edgeIteratorStack; private Stack vertexStack; private Object next; /** * Creates a minimal path iterator for the specified undirected graph. * @param g the specified graph * @param sourceVertex the start vertex for the paths * @param targetVertex the target vertex for the paths */ public MinimalPathIterator(SimpleGraph g, Object sourceVertex, Object targetVertex) { this.g = g; this.sourceVertex = sourceVertex; this.targetVertex = targetVertex; createShortestPathGraph(); } private void createShortestPathGraph() { /* shortestPathGraph = new DefaultDirectedGraph(); //shortestPathGraph.addAllVertices(g.vertexSet()); LinkedList queue = new LinkedList(); //encounter target vertex queue.addLast(targetVertex); shortestPathGraph.addVertex(targetVertex); int distance = 0; Object firstVertexOfNextLevel = targetVertex; Collection verticesOfNextLevel = new ArrayList(); while (!queue.isEmpty()) { //provide next vertex Object vertex = queue.removeFirst(); if (vertex == firstVertexOfNextLevel) { distance++; firstVertexOfNextLevel = null; verticesOfNextLevel.clear(); } //add unseen children of next vertex List edges = g.edgesOf(vertex); for(Iterator i = edges.iterator(); i.hasNext();) { Edge e = (Edge) i.next( ); Object opposite = e.oppositeVertex(vertex); if (!shortestPathGraph.containsVertex(opposite)) { //encounter vertex queue.addLast(opposite); shortestPathGraph.addVertex(opposite); verticesOfNextLevel.add(opposite); if (firstVertexOfNextLevel == null) { firstVertexOfNextLevel = opposite; } } if (verticesOfNextLevel.contains(opposite)) { shortestPathGraph.addEdge(opposite, vertex); } } } */ shortestPathGraph = new DefaultDirectedGraph(); shortestPathGraph.addVertex(targetVertex); // This map gives the distance of a vertex to the target vertex Map distanceMap = new HashMap(); for (MyBreadthFirstIterator iter = new MyBreadthFirstIterator(g, targetVertex); iter.hasNext(); ) { Object vertex = iter.next(); shortestPathGraph.addVertex(vertex); int distance = iter.level; distanceMap.put(vertex, Integer.valueOf(distance)); for (Iterator edges = g.edgesOf(vertex).iterator(); edges.hasNext();) { Edge edge = (Edge) edges.next(); Object opposite = edge.oppositeVertex(vertex); if (distanceMap.get(opposite) != null) { if (((Integer) distanceMap.get(opposite)).intValue() + 1 == distance) { shortestPathGraph.addVertex(opposite); shortestPathGraph.addEdge(vertex, opposite); } } } if (vertex == sourceVertex) { break; } } Iterator edgeIterator = shortestPathGraph.outgoingEdgesOf(sourceVertex).iterator(); edgeIteratorStack = new Stack(); edgeIteratorStack.push(edgeIterator); vertexStack = new Stack(); vertexStack.push(sourceVertex); } // private void createShortestPathWeightedGraph() { // shortestPathGraph = new DefaultDirectedGraph(); // //shortestPathGraph.addAllVertices(g.vertexSet()); // shortestPathGraph.addVertex(targetVertex); // // // This map gives the distance of a vertex to the target vertex // Map distanceMap = new HashMap(); // distanceMap.put(targetVertex, new Integer(0)); // // for (ClosestFirstIterator iter = new ClosestFirstIterator(g, targetVertex); iter.hasNext(); ) { // Object vertex = iter.next(); // shortestPathGraph.addVertex(vertex); // // Edge treeEdge = iter.getSpanningTreeEdge(vertex); // // // in the first iteration, vertex is the target vertex; therefore no tree edge exists // if (treeEdge != null) { // Object parent = treeEdge.oppositeVertex(vertex); // int distance = ((Integer)distanceMap.get(parent)).intValue() + 1; // distanceMap.put(vertex, new Integer(distance)); // // for (Iterator edges = g.edgesOf(vertex).iterator(); edges.hasNext();) { // Edge edge = (Edge) edges.next(); // Object opposite = edge.oppositeVertex(vertex); // if (distanceMap.get(opposite) != null) { // if (((Integer) distanceMap.get(opposite)).intValue() + 1 == distance) { // shortestPathGraph.addVertex(opposite); // shortestPathGraph.addEdge(vertex, opposite); // } // } // } // } // if (vertex == sourceVertex) { // break; // } // } // // Iterator edgeIterator = shortestPathGraph.outgoingEdgesOf(sourceVertex).iterator(); // // edgeIteratorStack = new Stack(); // edgeIteratorStack.push(edgeIterator); // // vertexStack = new Stack(); // vertexStack.push(sourceVertex); // // } @TestMethod("testMinimalPathIterator") public boolean hasNext() { if (next == null) { while (next == null && !edgeIteratorStack.isEmpty()) { Iterator edgeIterator = (Iterator) edgeIteratorStack.peek(); Object currentVertex = vertexStack.peek(); //logger.debug(currentVertex); if (edgeIterator.hasNext()) { Edge edge = (Edge)edgeIterator.next(); currentVertex = edge.oppositeVertex(currentVertex); edgeIterator = shortestPathGraph.outgoingEdgesOf(currentVertex).iterator(); edgeIteratorStack.push(edgeIterator); vertexStack.push(currentVertex); } else { if (currentVertex == targetVertex) { next = edgeList(g, vertexStack); } edgeIteratorStack.pop(); vertexStack.pop(); } } } return (next != null); } @TestMethod("testMinimalPathIterator") public Object next() { if (hasNext()) { Object result = next; next = null; return result; } else { return null; } } @TestMethod("testRemove") public void remove() { throw new UnsupportedOperationException(); } private List edgeList(Graph g, List vertexList) { List edgeList = new ArrayList(vertexList.size()-1); Iterator vertices = vertexList.iterator(); Object currentVertex = vertices.next(); while (vertices.hasNext()) { Object nextVertex = vertices.next(); edgeList.add(g.getAllEdges(currentVertex, nextVertex).get(0)); currentVertex = nextVertex; } return edgeList; } private static class MyBreadthFirstIterator extends BreadthFirstIterator { public MyBreadthFirstIterator(Graph g, Object startVertex) { super(g, startVertex); } int level = -1; private Object firstVertexOfNextLevel; protected void encounterVertex( Object vertex, Edge edge ) { super.encounterVertex(vertex, edge); if (firstVertexOfNextLevel == null) { firstVertexOfNextLevel = vertex; } } protected Object provideNextVertex( ) { Object nextVertex = super.provideNextVertex(); if (firstVertexOfNextLevel == nextVertex) { firstVertexOfNextLevel = null; level++; } return nextVertex; } } } cdk-1.2.10/src/main/org/openscience/cdk/graph/MoleculeGraphs.java100644 0 0 6261 11570154753 21714 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.graph; import org._3pq.jgrapht.graph.SimpleGraph; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; /** * Utility class to create a molecule graph for use with jgrapht. * * @author Ulrich Bauer * * * @cdk.module standard * @cdk.githash * * @cdk.builddepends jgrapht-0.5.3.jar * @cdk.depends jgrapht-0.5.3.jar */ @TestClass("org.openscience.cdk.graph.MoleculeGraphsTest") public class MoleculeGraphs { // make class non-instantiable private MoleculeGraphs() {} /** * Creates a molecule graph for use with jgrapht. * Bond orders are not respected. * * @param molecule the specified molecule * @return a graph representing the molecule */ @TestMethod("testGetMoleculeGraph_IAtomContainer") static public SimpleGraph getMoleculeGraph(IAtomContainer molecule) { SimpleGraph graph = new SimpleGraph(); for (int i=0; i * CAUTION: This recursive method sets the VISITED flag of each atom * does not reset it after finishing the search. If you want to do the * operation on the same collection of atoms more than once, you have * to set all the VISITED flags to false before each operation * by looping of the atoms and doing a * "atom.setFlag((CDKConstants.VISITED, false));" *

* Note that the path generated by the search will not contain the root atom, * but will contain the target atom * * @param molecule The AtomContainer to be searched * @param root The root atom to start the search at * @param target The target * @param path An AtomContainer to be filled with the path * @return true if the target atom was found during this function call */ @TestMethod("testDepthFirstTargetSearch_IAtomContainer_IAtom_IAtom_IAtomContainer") public static boolean depthFirstTargetSearch(IAtomContainer molecule, IAtom root, IAtom target, IAtomContainer path) { java.util.List bonds = molecule.getConnectedBondsList(root); IAtom nextAtom; root.setFlag(CDKConstants.VISITED, true); for (IBond bond : bonds) { nextAtom = bond.getConnectedAtom(root); if (!nextAtom.getFlag(CDKConstants.VISITED)) { path.addAtom(nextAtom); path.addBond(bond); if (nextAtom == target) { return true; } else { if (!depthFirstTargetSearch(molecule, nextAtom, target, path)) { // we did not find the target path.removeAtom(nextAtom); path.removeBond(bond); } else { return true; } } } } return false; } /** * Performs a breadthFirstSearch in an AtomContainer starting with a * particular sphere, which usually consists of one start atom. While * searching the graph, the method marks each visited atom. It then puts all * the atoms connected to the atoms in the given sphere into a new vector * which forms the sphere to search for the next recursive method call. All * atoms that have been visited are put into a molecule container. This * breadthFirstSearch does thus find the connected graph for a given start * atom. * * @param atomContainer The AtomContainer to be searched * @param sphere A sphere of atoms to start the search with * @param molecule A molecule into which all the atoms and bonds are stored * that are found during search */ @TestMethod("testBreadthFirstSearch_IAtomContainer_List_IMolecule") public static void breadthFirstSearch(IAtomContainer atomContainer, List sphere, IMolecule molecule) { // logger.debug("Staring partitioning with this ac: " + ac); breadthFirstSearch(atomContainer, sphere, molecule, -1); } /** * Returns the atoms which are closest to an atom in an AtomContainer by bonds. * If number of atoms in or below sphere x<max and number of atoms in or below sphere x+1>max then * atoms in or below sphere x+1 are returned. * * @param atomContainer The AtomContainer to examine * @param atom the atom to start from * @param max the number of neighbours to return * @return the average bond length */ @TestMethod("testFindClosestByBond") public static IAtom[] findClosestByBond(IAtomContainer atomContainer, IAtom atom, int max) { IMolecule mol = atomContainer.getBuilder().newMolecule(); List v = new ArrayList(); v.add(atom); breadthFirstSearch(atomContainer, v, mol, max); IAtom[] returnValue = new IAtom[mol.getAtomCount() - 1]; int k = 0; for (int i = 0; i < mol.getAtomCount(); i++) { if (mol.getAtom(i) != atom) { returnValue[k] = mol.getAtom(i); k++; } } return (returnValue); } /** * Performs a breadthFirstSearch in an AtomContainer starting with a * particular sphere, which usually consists of one start atom. While * searching the graph, the method marks each visited atom. It then puts all * the atoms connected to the atoms in the given sphere into a new vector * which forms the sphere to search for the next recursive method call. All * atoms that have been visited are put into a molecule container. This * breadthFirstSearch does thus find the connected graph for a given start * atom. * *

IMPORTANT: this method does not reset the VISITED flags, which must be * done if calling this method twice! * * @param atomContainer The AtomContainer to be searched * @param sphere A sphere of atoms to start the search with * @param molecule A molecule into which all the atoms and bonds are stored * that are found during search * @param max */ @TestMethod("testBreadthFirstSearch_IAtomContainer_List_IMolecule_int") public static void breadthFirstSearch(IAtomContainer atomContainer, List sphere, IMolecule molecule, int max) { IAtom nextAtom; List newSphere = new ArrayList(); for (IAtom atom : sphere) { //logger.debug("atoms "+ atom + f); //logger.debug("sphere size "+ sphere.size()); molecule.addAtom(atom); // first copy LonePair's and SingleElectron's of this Atom as they need // to be copied too List lonePairs = atomContainer.getConnectedLonePairsList(atom); //logger.debug("found #ec's: " + lonePairs.length); for (ILonePair lonePair : lonePairs) molecule.addLonePair(lonePair); List singleElectrons = atomContainer.getConnectedSingleElectronsList(atom); for (ISingleElectron singleElectron : singleElectrons) molecule.addSingleElectron(singleElectron); // now look at bonds List bonds = atomContainer.getConnectedBondsList(atom); for (IBond bond : bonds) { if (!bond.getFlag(CDKConstants.VISITED)) { molecule.addBond(bond); bond.setFlag(CDKConstants.VISITED, true); } nextAtom = bond.getConnectedAtom(atom); if (!nextAtom.getFlag(CDKConstants.VISITED)) { // logger.debug("wie oft???"); newSphere.add(nextAtom); nextAtom.setFlag(CDKConstants.VISITED, true); } } if (max > -1 && molecule.getAtomCount() > max) return; } if (newSphere.size() > 0) { breadthFirstSearch(atomContainer, newSphere, molecule, max); } } /** * Performs a breadthFirstTargetSearch in an AtomContainer starting with a * particular sphere, which usually consists of one start atom. While * searching the graph, the method marks each visited atom. It then puts all * the atoms connected to the atoms in the given sphere into a new vector * which forms the sphere to search for the next recursive method call. * The method keeps track of the sphere count and returns it as soon * as the target atom is encountered. * * @param atomContainer The AtomContainer in which the path search is to be performed. * @param sphere The sphere of atoms to start with. Usually just the starting atom * @param target The target atom to be searched * @param pathLength The current path length, incremented and passed in recursive calls. Call this method with "zero". * @param cutOff Stop the path search when this cutOff sphere count has been reatomContainerhed * @return The shortest path between the starting sphere and the target atom */ @TestMethod("testBreadthFirstTargetSearch_IAtomContainer_List_IAtom_int_int") public static int breadthFirstTargetSearch(IAtomContainer atomContainer, List sphere, IAtom target, int pathLength, int cutOff) { if (pathLength == 0) resetFlags(atomContainer); pathLength++; if (pathLength > cutOff) { return -1; } IAtom nextAtom; List newSphere = new ArrayList(); for (IAtom atom : sphere) { List bonds = atomContainer.getConnectedBondsList(atom); for (IBond bond : bonds) { if (!bond.getFlag(CDKConstants.VISITED)) { bond.setFlag(CDKConstants.VISITED, true); } nextAtom = bond.getConnectedAtom(atom); if (!nextAtom.getFlag(CDKConstants.VISITED)) { if (nextAtom == target) { return pathLength; } newSphere.add(nextAtom); nextAtom.setFlag(CDKConstants.VISITED, true); } } } if (newSphere.size() > 0) { return breadthFirstTargetSearch(atomContainer, newSphere, target, pathLength, cutOff); } return -1; } @TestMethod("testResetFlags_IAtomContainer") protected static void resetFlags(IAtomContainer atomContainer) { for (int f = 0; f < atomContainer.getAtomCount(); f++) { atomContainer.getAtom(f).setFlag(CDKConstants.VISITED, false); } for (int f = 0; f < atomContainer.getBondCount(); f++) { atomContainer.getBond(f).setFlag(CDKConstants.VISITED, false); } } /** * Returns the radius of the molecular graph. * * @param atomContainer The molecule to consider * @return The topological radius */ @TestMethod("testGetMolecularGraphRadius_IAtomContainer") public static int getMolecularGraphRadius(IAtomContainer atomContainer) { int natom = atomContainer.getAtomCount(); int[][] admat = AdjacencyMatrix.getMatrix(atomContainer); int[][] distanceMatrix = computeFloydAPSP(admat); int[] eta = new int[natom]; for (int i = 0; i < natom; i++) { int max = -99999; for (int j = 0; j < natom; j++) { if (distanceMatrix[i][j] > max) max = distanceMatrix[i][j]; } eta[i] = max; } int min = 999999; for (int anEta : eta) { if (anEta < min) min = anEta; } return min; } /** * Returns the diameter of the molecular graph. * * @param atomContainer The molecule to consider * @return The topological diameter */ @TestMethod("testGetMolecularGraphDiameter_IAtomContainer") public static int getMolecularGraphDiameter(IAtomContainer atomContainer) { int natom = atomContainer.getAtomCount(); int[][] admat = AdjacencyMatrix.getMatrix(atomContainer); int[][] distanceMatrix = computeFloydAPSP(admat); int[] eta = new int[natom]; for (int i = 0; i < natom; i++) { int max = -99999; for (int j = 0; j < natom; j++) { if (distanceMatrix[i][j] > max) max = distanceMatrix[i][j]; } eta[i] = max; } int max = -999999; for (int anEta : eta) { if (anEta > max) max = anEta; } return max; } /** * Returns the number of vertices that are a distance 'd' apart. *

* In this method, d is the topological distance (ie edge count). * * @param atomContainer The molecule to consider * @param distance The distance to consider * @return The number of vertices */ @TestMethod("testGetVertexCountAtDistance_IAtomContainer_int") public static int getVertexCountAtDistance(IAtomContainer atomContainer, int distance) { int natom = atomContainer.getAtomCount(); int[][] admat = AdjacencyMatrix.getMatrix(atomContainer); int[][] distanceMatrix = computeFloydAPSP(admat); int n = 0; for (int i = 0; i < natom; i++) { for (int j = 0; j < natom; j++) { if (distanceMatrix[i][j] == distance) n++; } } return n / 2; } /** * Returns a list of atoms in the shortest path between two atoms. *

* This method uses the Djikstra algorithm to find all the atoms in the shortest * path between the two specified atoms. The start and end atoms are also included * in the path returned * * @param atomContainer The molecule to search in * @param start The starting atom * @param end The ending atom * @return A List containing the atoms in the shortest path between start and * end inclusive */ @TestMethod("testGetShortestPath_IAtomContainer_IAtom_IAtom") public static List getShortestPath(IAtomContainer atomContainer, IAtom start, IAtom end) { int natom = atomContainer.getAtomCount(); int endNumber = atomContainer.getAtomNumber(end); int startNumber = atomContainer.getAtomNumber(start); int[] dist = new int[natom]; int[] previous = new int[natom]; for (int i = 0; i < natom; i++) { dist[i] = 99999999; previous[i] = -1; } dist[atomContainer.getAtomNumber(start)] = 0; List Slist = new ArrayList(); List Qlist = new ArrayList(); for (int i = 0; i < natom; i++) Qlist.add(i); while (true) { if (Qlist.size() == 0) break; // extract min int u = 999999; int index = 0; for (Integer tmp : Qlist) { if (dist[tmp] < u) { u = dist[tmp]; index = tmp; } } Qlist.remove(Qlist.indexOf(index)); Slist.add(atomContainer.getAtom(index)); if (index == endNumber) break; // relaxation List connected = atomContainer.getConnectedAtomsList(atomContainer.getAtom(index)); for (IAtom aConnected : connected) { int anum = atomContainer.getAtomNumber(aConnected); if (dist[anum] > dist[index] + 1) { // all edges have equals weights dist[anum] = dist[index] + 1; previous[anum] = index; } } } ArrayList tmp = new ArrayList(); int tmpSerial = endNumber; while (true) { tmp.add(0, atomContainer.getAtom(tmpSerial)); tmpSerial = previous[tmpSerial]; if (tmpSerial == startNumber) { tmp.add(0, atomContainer.getAtom(tmpSerial)); break; } } return tmp; } private static List> allPaths; /** * Get a list of all the paths between two atoms. *

* If the two atoms are the same an empty list is returned. Note that this problem * is NP-hard and so can take a long time for large graphs. * * @param atomContainer The molecule to consider * @param start The starting Atom of the path * @param end The ending Atom of the path * @return A List containing all the paths between the specified atoms */ @TestMethod("testGetAllPaths_IAtomContainer_IAtom_IAtom") public static List> getAllPaths(IAtomContainer atomContainer, IAtom start, IAtom end) { allPaths = new ArrayList>(); if (start.equals(end)) return allPaths; findPathBetween(atomContainer, start, end, new ArrayList()); return allPaths; } private static void findPathBetween(IAtomContainer atomContainer, IAtom start, IAtom end, List path) { if (start == end) { path.add(start); allPaths.add(new ArrayList(path)); path.remove(path.size() - 1); return; } if (path.contains(start)) return; path.add(start); List nbrs = atomContainer.getConnectedAtomsList(start); for (IAtom nbr : nbrs) findPathBetween(atomContainer, nbr, end, path); path.remove(path.size() - 1); } /** * Get the paths starting from an atom of specified length. *

* This method returns a set of paths. Each path is a List of atoms that * make up the path (ie they are sequentially connected). * * @param atomContainer The molecule to consider * @param start The starting atom * @param length The length of paths to look for * @return A List containing the paths found */ @TestMethod("testGetPathsOfLength_IAtomContainer_IAtom_int") public static List> getPathsOfLength(IAtomContainer atomContainer, IAtom start, int length) { List curPath = new ArrayList(); List> paths = new ArrayList>(); curPath.add(start); paths.add(curPath); for (int i = 0; i < length; i++) { List> tmpList = new ArrayList>(); for (List path : paths) { curPath = path; IAtom lastVertex = curPath.get(curPath.size() - 1); List neighbors = atomContainer.getConnectedAtomsList(lastVertex); for (IAtom neighbor : neighbors) { List newPath = new ArrayList(curPath); if (newPath.contains(neighbor)) continue; newPath.add(neighbor); tmpList.add(newPath); } } paths.clear(); paths.addAll(tmpList); } return (paths); } /** * Get all the paths starting from an atom of length 0 upto the specified length. *

* This method returns a set of paths. Each path is a List of atoms that * make up the path (ie they are sequentially connected). * * @param atomContainer The molecule to consider * @param start The starting atom * @param length The maximum length of paths to look for * @return A List containing the paths found */ @TestMethod("testGetPathsOfLengthUpto") public static List> getPathsOfLengthUpto(IAtomContainer atomContainer, IAtom start, int length) { List curPath = new ArrayList(); List> paths = new ArrayList>(); List> allpaths = new ArrayList>(); curPath.add(start); paths.add(curPath); allpaths.add(curPath); for (int i = 0; i < length; i++) { List> tmpList = new ArrayList>(); for (List path : paths) { curPath = path; IAtom lastVertex = curPath.get(curPath.size() - 1); List neighbors = atomContainer.getConnectedAtomsList(lastVertex); for (IAtom neighbor : neighbors) { List newPath = new ArrayList(curPath); if (newPath.contains(neighbor)) continue; newPath.add(neighbor); tmpList.add(newPath); } } paths.clear(); paths.addAll(tmpList); allpaths.addAll(tmpList); } return (allpaths); } } cdk-1.2.10/src/main/org/openscience/cdk/graph/SpanningTree.java100644 0 0 25616 11570154753 21424 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2001-2007 Nina Jeliazkova * * 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 org.openscience.cdk.graph; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.NoSuchAtomException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IRing; import org.openscience.cdk.interfaces.IRingSet; /** * Spanning tree of a molecule. * Used to discover the number of cyclic bonds in order to prevent the * inefficient AllRingsFinder to run for too long. * * @author Nina Jeliazkova * @cdk.module core * @cdk.githash * @cdk.dictref blue-obelisk:graphSpanningTree * @cdk.keyword spanning tree * @cdk.keyword ring finding * @cdk.bug 1817487 */ @TestClass("org.openscience.cdk.graph.SpanningTreeTest") public class SpanningTree { private final static String ATOM_NUMBER = "ST_ATOMNO"; private int[] parent = null; private int[][] cb = null; // what is cb??? cyclic bonds? protected boolean[] bondsInTree; private int sptSize = 0; private int edrSize = 0; private int bondsAcyclicCount = 0,bondsCyclicCount = 0; private IAtomContainer molecule = null; private int totalEdgeCount=0, totalVertexCount=0; private boolean disconnected; private boolean identifiedBonds; @TestMethod("testIsDisconnected") public boolean isDisconnected() { return disconnected; } @TestMethod("testSpanningTree_IAtomContainer") public SpanningTree(IAtomContainer atomContainer) { identifiedBonds = false; buildSpanningTree(atomContainer); } private boolean fastfind(int v1,int v2, boolean union) { int i = v1; while (parent[i] > 0) i = parent[i]; int j = v2; while (parent[j] > 0) j = parent[j]; int t ; while (parent[v1] > 0) { t = v1; v1 = parent[v1]; parent[t] = i; } while (parent[v2] > 0) { t = v2; v2 = parent[v2]; parent[t] = j; } if (union && (i!=j)) { if (parent[j] < parent[i]) { parent[j] = parent[j] + parent[i]-1; parent[i] = j; } else { parent[i] = parent[i] + parent[j]-1; parent[j] = i; } } return (i != j); } private void fastFindInit(int V) { parent = new int[V+1]; for (int i = 1; i <= V; i++) { parent[i] = 0; } } /* * Kruskal algorithm */ private void buildSpanningTree(IAtomContainer atomContainer){ disconnected = false; molecule = atomContainer; totalVertexCount = atomContainer.getAtomCount(); totalEdgeCount = atomContainer.getBondCount(); sptSize = 0;edrSize = 0; fastFindInit(totalVertexCount); for (int i = 0; i < totalVertexCount; i++) { (atomContainer.getAtom(i)).setProperty(ATOM_NUMBER, Integer.toString(i+1)); } IBond bond; int v1,v2; bondsInTree = new boolean[totalEdgeCount]; for (int b=0; b < totalEdgeCount; b++ ) { bondsInTree[b] = false; bond = atomContainer.getBond(b); v1 = Integer.parseInt((bond.getAtom(0)).getProperty(ATOM_NUMBER).toString()); v2 = Integer.parseInt((bond.getAtom(1)).getProperty(ATOM_NUMBER).toString()); //this below is a little bit slower //v1 = atomContainer.getAtomNumber(bond.getAtomAt(0))+1; //v2 = atomContainer.getAtomNumber(bond.getAtomAt(1))+1; if (fastfind(v1,v2,true)) { bondsInTree[b] = true; sptSize++; //logger.debug("ST : includes bond between atoms "+v1+","+v2); } if (sptSize>=(totalVertexCount-1)) break; } // if atomcontainer is connected then the number of bonds in the spanning tree = (No atoms-1) //i.e. edgesRings = new Bond[E-V+1]; //but to hold all bonds if atomContainer was disconnected then edgesRings = new Bond[E-sptSize]; if (sptSize != (totalVertexCount-1)) disconnected = true; for (int b=0; b < totalEdgeCount; b++ ) if (!bondsInTree[b]){ // edgesRings[edrSize] = atomContainer.getBondAt(b); edrSize++; } cb = new int[edrSize][totalEdgeCount]; for (int i = 0; i < edrSize; i++) for (int a = 0; a < totalEdgeCount; a++) cb[i][a] = 0; // remove ATOM_NUMBER props again for (IAtom atom : atomContainer.atoms()) atom.removeProperty(ATOM_NUMBER); } @TestMethod("testGetSpanningTree") public IAtomContainer getSpanningTree() { IAtomContainer ac = molecule.getBuilder().newAtomContainer(); for (int a=0 ; a < totalVertexCount; a++) ac.addAtom(molecule.getAtom(a)); for (int b=0; b < totalEdgeCount; b++ ) if (bondsInTree[b]) ac.addBond(molecule.getBond(b)); return ac; } @TestMethod("testGetPath_IAtomContainer_IAtom_IAtom") public IAtomContainer getPath(IAtomContainer spt,IAtom a1, IAtom a2) throws NoSuchAtomException { IAtomContainer path = spt.getBuilder().newAtomContainer(); PathTools.resetFlags(spt); path.addAtom(a1); PathTools.depthFirstTargetSearch(spt,a1,a2,path); if (path.getAtomCount() == 1) path.removeAtom(a1); // no path found: remove initial atom return path; } private IRing getRing(IAtomContainer spt, IBond bond) { IRing ring = spt.getBuilder().newRing(); PathTools.resetFlags(spt); ring.addAtom(bond.getAtom(0)); PathTools.depthFirstTargetSearch(spt,bond.getAtom(0),bond.getAtom(1),ring); ring.addBond(bond); return ring; } private void getBondsInRing(IAtomContainer mol, IRing ring, int[] bonds) { for (int i=0; i < ring.getBondCount(); i++ ) { int m = mol.getBondNumber(ring.getBond(i)); bonds[m] = 1; } } @TestMethod("testGetBasicRings") public IRingSet getBasicRings() throws NoSuchAtomException { IRingSet ringset = molecule.getBuilder().newRingSet(); IAtomContainer spt = getSpanningTree(); for (int i = 0; i < totalEdgeCount; i++) if (!bondsInTree[i]) ringset.addAtomContainer(getRing(spt,molecule.getBond(i))); return ringset; } /** * Returns an IAtomContainer which contains all the atoms and bonds which * are involved in ring systems. * * @see #getAllRings() * @see #getBasicRings() * @return the IAtomContainer as described above */ @TestMethod("testGetCyclicFragmentsContainer") public IAtomContainer getCyclicFragmentsContainer() { IAtomContainer fragContainer = this.molecule.getBuilder().newAtomContainer(); IAtomContainer spt = getSpanningTree(); for (int i = 0; i < totalEdgeCount; i++) if (!bondsInTree[i]) { IRing ring = getRing(spt, molecule.getBond(i)); for (int b = 0; b < ring.getBondCount(); b++) { IBond ringBond = ring.getBond(b); if (!fragContainer.contains(ringBond)) { fragContainer.addBond(ringBond); for (int atomCount = 0; atomCount < ringBond.getAtomCount(); atomCount++) { IAtom atom = ringBond.getAtom(atomCount); if (!fragContainer.contains(atom)) { atom.setFlag(CDKConstants.ISINRING, true); fragContainer.addAtom(atom); } } } } } return fragContainer; } /** * Identifies whether bonds are cyclic or not. It is used by several other methods. */ private void identifyBonds() { IAtomContainer spt = getSpanningTree(); IRing ring; int nBasicRings = 0; for (int i = 0; i < totalEdgeCount; i++) { if (!bondsInTree[i]) { ring = getRing(spt,molecule.getBond(i)); for (int b=0; b < ring.getBondCount(); b++ ) { int m = molecule.getBondNumber(ring.getBond(b)); cb[nBasicRings][m] = 1; } nBasicRings++; } } bondsAcyclicCount = 0; bondsCyclicCount = 0; for (int i = 0; i < totalEdgeCount; i++) { int s = 0; for (int j = 0; j < nBasicRings; j++) { s+= cb[j][i]; } switch(s) { case(0): { bondsAcyclicCount++; break; } case(1): { bondsCyclicCount ++; break; } default: { bondsCyclicCount ++; } } } identifiedBonds = true; } @TestMethod("testGetAllRings") public IRingSet getAllRings() throws NoSuchAtomException { IRingSet ringset = getBasicRings(); IRing newring; int nBasicRings = ringset.getAtomContainerCount(); for (int i = 0; i < nBasicRings; i++) getBondsInRing(molecule,(IRing) ringset.getAtomContainer(i), cb[i]); for (int i= 0; i < nBasicRings; i++) { for (int j= i+1; j < nBasicRings; j++) { //logger.debug("combining rings "+(i+1)+","+(j+1)); newring = combineRings(ringset, i, j); //newring = combineRings((Ring)ringset.get(i),(Ring)ringset.get(j)); if (newring != null) ringset.addAtomContainer(newring); } } return ringset; } @TestMethod("testGetSpanningTreeSize") public int getSpanningTreeSize() { return sptSize; } private IRing combineRings(IRingSet ringset, int i, int j) { int c = 0; for (int b= 0; b < cb[i].length; b++) { c = cb[i][b] + cb[j][b]; if (c > 1) break; //at least one common bond } if (c < 2) return null; IRing ring = molecule.getBuilder().newRing(); IRing ring1 = (IRing) ringset.getAtomContainer(i); IRing ring2 = (IRing) ringset.getAtomContainer(j); for (int b= 0; b < cb[i].length; b++) { c = cb[i][b] + cb[j][b]; if ((c == 1) && (cb[i][b] == 1)) ring.addBond(molecule.getBond(b)); else if ((c == 1) && (cb[j][b] == 1)) ring.addBond(molecule.getBond(b)); } for (int a = 0; a < ring1.getAtomCount(); a++) ring.addAtom(ring1.getAtom(a)); for (int a = 0; a < ring2.getAtomCount(); a++) ring.addAtom(ring2.getAtom(a)); return ring; } /** * @return Returns the bondsAcyclicCount. */ @TestMethod("testGetBondsAcyclicCount") public int getBondsAcyclicCount() { if (!identifiedBonds) identifyBonds(); return bondsAcyclicCount; } /** * @return Returns the bondsCyclicCount. */ @TestMethod("testGetBondsCyclicCount") public int getBondsCyclicCount() { if (!identifiedBonds) identifyBonds(); return bondsCyclicCount; } } cdk-1.2.10/src/main/org/openscience/cdk/graph/invariant/CanonicalLabeler.java100644 0 0 20362 11570154753 24171 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2001-2007 Oliver Horlacher * * 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 org.openscience.cdk.graph.invariant; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.smiles.InvPair; import java.util.*; /** * Canonically labels an atom container implementing * the algorithm published in David Weininger et.al. {@cdk.cite WEI89}. * The Collections.sort() method uses a merge sort which is * stable and runs in n log(n). * * @cdk.module standard * @cdk.githash * * @author Oliver Horlacher * @cdk.created 2002-02-26 * * @cdk.keyword canonicalization */ @TestClass("org.openscience.cdk.graph.invariant.CanonicalLabelerTest") public class CanonicalLabeler { public CanonicalLabeler() { } /** * Canonically label the fragment. The labels are set as atom property InvPair.CANONICAL_LABEL of type Integer, indicating the canonical order. * This is an implementation of the algorithm published in * David Weininger et.al. {@cdk.cite WEI89}. * *

The Collections.sort() method uses a merge sort which is * stable and runs in n log(n). * *

It is assumed that a chemicaly valid AtomContainer is provided: * this method does not check * the correctness of the AtomContainer. Negative H counts will * cause a NumberFormatException to be thrown. * @param atomContainer The molecule to label */ @TestMethod("testCanonLabel_IAtomContainer,testSomeMoleculeWithDifferentStartingOrder") public synchronized void canonLabel(IAtomContainer atomContainer) { if (atomContainer.getAtomCount() == 0) return; if (atomContainer.getAtomCount() == 1) { atomContainer.getAtom(0).setProperty(InvPair.CANONICAL_LABEL, 1); } ArrayList vect = createInvarLabel(atomContainer); step3(vect, atomContainer); } /** * @param v the invariance pair vector */ private void step2(ArrayList v, IAtomContainer atoms) { primeProduct(v, atoms); step3(v, atoms); } /** * @param v the invariance pair vector */ private void step3(ArrayList v, IAtomContainer atoms) { sortArrayList(v); rankArrayList(v); if (!isInvPart(v)) { step2(v, atoms); } else { //On first pass save, partitioning as symmetry classes. if (((InvPair) v.get(v.size()-1)).getCurr() < v.size()) { breakTies(v); step2(v, atoms); } // now apply the ranking for (Object aV : v) { ((InvPair) aV).commit(); } } } /** * Create initial invariant labeling corresponds to step 1 * * @return ArrayList containting the */ private ArrayList createInvarLabel(IAtomContainer atomContainer) { java.util.Iterator atoms = atomContainer.atoms().iterator(); IAtom a; StringBuffer inv; ArrayList vect = new ArrayList(); while(atoms.hasNext()) { a = (IAtom)atoms.next(); inv = new StringBuffer(); inv.append(atomContainer.getConnectedAtomsList(a).size() + (a.getHydrogenCount() == CDKConstants.UNSET ? 0 : a.getHydrogenCount())); //Num connections inv.append(atomContainer.getConnectedAtomsList(a).size()); //Num of non H bonds inv.append(a.getAtomicNumber() == CDKConstants.UNSET ? 0 : a.getAtomicNumber()); //Atomic number Double charge = a.getCharge(); if (charge == CDKConstants.UNSET) charge = 0.0; if (charge < 0) //Sign of charge inv.append(1); else inv.append(0); //Absolute charge inv.append((int)Math.abs( (a.getFormalCharge() == CDKConstants.UNSET ? 0.0 : a.getFormalCharge()))); //Hydrogen count inv.append((a.getHydrogenCount() == CDKConstants.UNSET ? 0 : a.getHydrogenCount())); vect.add(new InvPair(Long.parseLong(inv.toString()), a)); } return vect; } /** * Calculates the product of the neighbouring primes. * * @param v the invariance pair vector */ private void primeProduct(ArrayList v, IAtomContainer atomContainer) { Iterator it = v.iterator(); Iterator n; InvPair inv; IAtom a; long summ; while (it.hasNext()) { inv = (InvPair) it.next(); List neighbour = atomContainer.getConnectedAtomsList(inv.getAtom()); n = neighbour.iterator(); summ = 1; while (n.hasNext()) { a = (IAtom) n.next(); int next = ((InvPair)a.getProperty(InvPair.INVARIANCE_PAIR)).getPrime(); summ = summ * next; } inv.setLast(inv.getCurr()); inv.setCurr(summ); } } /** * Sorts the vector according to the current invariance, corresponds to step 3 * * @param v the invariance pair vector * @cdk.todo can this be done in one loop? */ private void sortArrayList(ArrayList v) { Collections.sort(v, new Comparator() { public int compare(Object o1, Object o2) { return (int) (((InvPair) o1).getCurr() - ((InvPair) o2).getCurr()); } }); Collections.sort(v, new Comparator() { public int compare(Object o1, Object o2) { return (int) (((InvPair) o1).getLast() - ((InvPair) o2).getLast()); } }); } /** * Rank atomic vector, corresponds to step 4. * * @param v the invariance pair vector */ private void rankArrayList(ArrayList v) { int num = 1; int[] temp = new int[v.size()]; InvPair last = (InvPair) v.get(0); Iterator it = v.iterator(); InvPair curr; for (int x = 0; it.hasNext(); x++) { curr = (InvPair) it.next(); if (!last.equals(curr)) { num++; } temp[x] = num; last = curr; } it = v.iterator(); for (int x = 0; it.hasNext(); x++) { curr = (InvPair) it.next(); curr.setCurr(temp[x]); curr.setPrime(); } } /** * Checks to see if the vector is invariantely partitioned * * @param v the invariance pair vector * @return true if the vector is invariantely partitioned, false otherwise */ private boolean isInvPart(ArrayList v) { if (((InvPair) v.get(v.size()-1)).getCurr() == v.size()) return true; Iterator it = v.iterator(); InvPair curr; while (it.hasNext()) { curr = (InvPair) it.next(); if (curr.getCurr() != curr.getLast()) return false; } return true; } /** * Break ties. Corresponds to step 7 * * @param v the invariance pair vector */ private void breakTies(ArrayList v) { Iterator it = v.iterator(); InvPair curr; InvPair last = null; int tie = 0; boolean found = false; for (int x = 0; it.hasNext(); x++) { curr = (InvPair) it.next(); curr.setCurr(curr.getCurr() * 2); curr.setPrime(); if (x != 0 && !found && curr.getCurr() == last.getCurr()) { tie = x - 1; found = true; } last = curr; } curr = (InvPair) v.get(tie); curr.setCurr(curr.getCurr() - 1); curr.setPrime(); } } cdk-1.2.10/src/main/org/openscience/cdk/graph/invariant/ConjugatedPiSystemsDetector.java100644 0 0 16236 11570154753 26456 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2004-2007 Kai Hartmann * * 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. * * 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.graph.invariant; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomContainerSet; import org.openscience.cdk.interfaces.IBond; import java.util.List; import java.util.Stack; /** * @author kaihartmann * @cdk.githash * @cdk.created 2004-09-17 * @cdk.module reaction * * @cdk.todo add negatively charged atoms (e.g. O-) to the pi system */ @TestClass("org.openscience.cdk.graph.invariant.ConjugatedPiSystemsDetectorTest") public class ConjugatedPiSystemsDetector { /** * Detect all conjugated pi systems in an AtomContainer. This method returns a AtomContainerSet * with Atom and Bond objects from the original AtomContainer. The aromaticity has to be known * before calling this method. * *

An example for detection of Radical Allyl: *

     *	Atom a0 = new Atom("C"); mol.addAtom(a0);
     *	Atom a1 = new Atom("C"); mol.addAtom(a1);
     *	Atom a2 = new Atom("C"); mol.addAtom(a2);
     *	Atom h1 = new Atom("H"); mol.addAtom(h1);
     *	Atom h2 = new Atom("H"); mol.addAtom(h2);
     *	Atom h3 = new Atom("H"); mol.addAtom(h3);
     *	Atom h4 = new Atom("H"); mol.addAtom(h4);
     *	Atom h5 = new Atom("H"); mol.addAtom(h5);
     *	mol.addBond(0, 1, IBond.Order.DOUBLE);
     *	mol.addBond(1, 2, IBond.Order.SINGLE);
     *	mol.addBond(0, 3, IBond.Order.SINGLE);
     *	mol.addBond(0, 4, IBond.Order.SINGLE);
     *	mol.addBond(1, 5, IBond.Order.SINGLE);
     *	mol.addBond(2, 6, IBond.Order.SINGLE);
     *	mol.addBond(2, 7, IBond.Order.SINGLE);
     *	SingleElectron se = new SingleElectron(a2);
     *	mol.addElectronContainer(se);
     *  
* *@param ac The AtomContainer for which to detect conjugated pi systems *@return The set of AtomContainers with conjugated pi systems */ @TestMethod("testDetectButadiene,test3Aminomethane_cation,testPiSystemWithCarbokation,testCyanoallene") public static IAtomContainerSet detect(IAtomContainer ac) { IAtomContainerSet piSystemSet = ac.getBuilder().newAtomContainerSet(); for (int i = 0; i < ac.getAtomCount(); i++) { IAtom atom = ac.getAtom(i); atom.setFlag(CDKConstants.VISITED, false); } for (int i = 0; i < ac.getAtomCount(); i++) { IAtom firstAtom = ac.getAtom(i); // if this atom was already visited in a previous DFS, continue if (firstAtom.getFlag(CDKConstants.VISITED) || checkAtom(ac, firstAtom) == -1) { continue; } IAtomContainer piSystem = ac.getBuilder().newAtomContainer(); Stack stack = new Stack(); piSystem.addAtom(firstAtom); stack.push(firstAtom); firstAtom.setFlag(CDKConstants.VISITED, true); // Start DFS from firstAtom while (!stack.empty()) { //boolean addAtom = false; IAtom currentAtom = stack.pop(); List atoms = ac.getConnectedAtomsList(currentAtom); List bonds = ac.getConnectedBondsList(currentAtom); for (int j = 0; j < atoms.size(); j++) { IAtom atom = atoms.get(j); IBond bond = bonds.get(j); if (!atom.getFlag(CDKConstants.VISITED)) { int check = checkAtom(ac, atom); if (check == 1) { piSystem.addAtom(atom); piSystem.addBond(bond); continue; // do not mark atom as visited if cumulative double bond } else if (check == 0) { piSystem.addAtom(atom); piSystem.addBond(bond); stack.push(atom); } atom.setFlag(CDKConstants.VISITED, true); } // close rings with one bond else if (!piSystem.contains(bond) && piSystem.contains(atom)) { piSystem.addBond(bond); } } } if (piSystem.getAtomCount() > 2) { piSystemSet.addAtomContainer(piSystem); } } return piSystemSet; } /** * Check an Atom whether it may be conjugated or not. * *@param ac The AtomContainer containing currentAtom *@param currentAtom The Atom to check *@return -1 if isolated, 0 if conjugated, 1 if cumulative db */ private static int checkAtom(IAtomContainer ac, IAtom currentAtom) { int check = -1; List atoms = ac.getConnectedAtomsList(currentAtom); List bonds = ac.getConnectedBondsList(currentAtom); if (currentAtom.getFlag(CDKConstants.ISAROMATIC)) { check = 0; } else if (currentAtom.getFormalCharge() == 1 /*&& currentAtom.getSymbol().equals("C")*/) { check = 0; } else if (currentAtom.getFormalCharge() == -1) { //// NEGATIVE CHARGES WITH A NEIGHBOOR PI BOND ////////////// int counterOfPi = 0; for (IAtom atom : atoms) { if (ac.getMaximumBondOrder(atom) != IBond.Order.SINGLE) { counterOfPi++; } } if(counterOfPi > 0) check = 0; }else { int se = ac.getConnectedSingleElectronsCount(currentAtom); if (se == 1) { check = 0; //// DETECTION of radicals }else if (ac.getConnectedLonePairsCount(currentAtom) > 0 /*&& (currentAtom.getSymbol().equals("N")*/) { check = 0; //// DETECTION of lone pair }else { int highOrderBondCount = 0; for (int j = 0; j < atoms.size(); j++) { IBond bond = bonds.get(j); if (bond == null || bond.getOrder() != IBond.Order.SINGLE) { highOrderBondCount++; } else { } } if (highOrderBondCount == 1) { check = 0; } else if (highOrderBondCount > 1) { check = 1; } } } return check; } } cdk-1.2.10/src/main/org/openscience/cdk/graph/invariant/EquivalentClassPartitioner.java100644 0 0 36224 11570154753 26343 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project * * 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. * * 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.graph.invariant; import org.openscience.cdk.AtomContainer; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.exception.NoSuchAtomException; import org.openscience.cdk.graph.PathTools; import org.openscience.cdk.graph.matrix.ConnectionMatrix; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.tools.LoggingTool; /** * An algorithm for topological symmetry. * This algorithm derived from the algorithm {@cdk.cite Hu94}. * @cdk.githash * *@author Junfeng Hao *@cdk.created 2003-09-24 *@cdk.dictref blue-obelisk:perceiveGraphSymmetry */ public class EquivalentClassPartitioner { private double[][] nodeMatrix; private double[][] bondMatrix; private double[] weight; private double[][] adjaMatrix; private int[][] apspMatrix; private int layerNumber; private int nodeNumber; private static double LOST=0.000000000001; private org.openscience.cdk.tools.LoggingTool logger; /** * Constructor for the TopologicalEquivalentClass object */ public EquivalentClassPartitioner(){} /** * Constructor for the TopologicalEquivalentClass object */ public EquivalentClassPartitioner(AtomContainer atomContainer) { adjaMatrix = ConnectionMatrix.getMatrix(atomContainer); apspMatrix = PathTools.computeFloydAPSP(adjaMatrix); layerNumber=1; nodeNumber=atomContainer.getAtomCount(); for(int i=1;ilayerNumber)layerNumber=apspMatrix[i][j]; nodeMatrix=new double[nodeNumber][layerNumber+1]; bondMatrix=new double[nodeNumber][layerNumber]; weight=new double[nodeNumber+1]; logger = new LoggingTool(this); } /** * Get the topological equivalent class of the molecule * * @param atomContainer atoms and bonds of the molecule * @return an array contains the automorphism partition of the molecule */ public int[] getTopoEquivClassbyHuXu(AtomContainer atomContainer) throws NoSuchAtomException { double nodeSequence[]=prepareNode(atomContainer); nodeMatrix=buildNodeMatrix(nodeSequence); bondMatrix=buildBondMatrix(); weight=buildWeightMatrix(nodeMatrix,bondMatrix); int AutomorphismPartition[]=findTopoEquivClass(weight); return AutomorphismPartition; } /** * Prepare the node identifier. The purpose of this is to increase the differentiatation * of the nodes. Detailed information please see the corresponding literature * * @param atomContainer atoms and bonds of the molecule * @return an array of node identifier */ public double[] prepareNode(AtomContainer atomContainer) { java.util.Iterator atoms=atomContainer.atoms().iterator(); double nodeSequence[]=new double[atomContainer.getAtomCount()]; int i = 0; while (atoms.hasNext()) { IAtom atom = (IAtom)atoms.next(); java.util.List bonds=atomContainer.getConnectedBondsList(atom); if(bonds.size()==1) { IBond bond0 = (IBond)bonds.get(0); if(atom.getSymbol().equals("C")) { if(bond0.getOrder()==IBond.Order.SINGLE)nodeSequence[i]=1;//CH3- else if(bond0.getOrder()==IBond.Order.DOUBLE)nodeSequence[i]=3;//CH2= else if(bond0.getOrder()==IBond.Order.TRIPLE)nodeSequence[i]=6;//CH# } else if(atom.getSymbol().equals("O")) { if(bond0.getOrder()==IBond.Order.SINGLE)nodeSequence[i]=14;//HO- else if(bond0.getOrder()==IBond.Order.DOUBLE)nodeSequence[i]=16;//O= } else if(atom.getSymbol().equals("N")) { if(bond0.getOrder()==IBond.Order.SINGLE)nodeSequence[i]=18;//NH2- else if(bond0.getOrder()==IBond.Order.DOUBLE) { if(atom.getCharge()==-1.0)nodeSequence[i]=27;//N= contains -1 charge else nodeSequence[i]=20;//NH= } else if(bond0.getOrder()==IBond.Order.TRIPLE)nodeSequence[i]=23;//N# } else if(atom.getSymbol().equals("S")) { if(bond0.getOrder()==IBond.Order.SINGLE)nodeSequence[i]=31;//HS- else if(bond0.getOrder()==IBond.Order.DOUBLE)nodeSequence[i]=33;//S= } else if(atom.getSymbol().equals("P"))nodeSequence[i]=38;//PH2- else if(atom.getSymbol().equals("F"))nodeSequence[i]=42;//F- else if(atom.getSymbol().equals("Cl"))nodeSequence[i]=43;//Cl- else if(atom.getSymbol().equals("Br"))nodeSequence[i]=44;//Br- else if(atom.getSymbol().equals("I"))nodeSequence[i]=45;//I- else { logger.debug("in case of a new node, please report this bug to cdk-devel@lists.sf.net."); } } else if(bonds.size()==2) { IBond bond0 = (IBond)bonds.get(0); IBond bond1 = (IBond)bonds.get(1); if(atom.getSymbol().equals("C")) { if(bond0.getOrder()==IBond.Order.SINGLE && bond1.getOrder()==IBond.Order.SINGLE) nodeSequence[i]=2;//-CH2- else if(bond0.getOrder()==IBond.Order.DOUBLE && bond1.getOrder()==IBond.Order.DOUBLE) nodeSequence[i]=10;//=C= else if((bond0.getOrder()==IBond.Order.SINGLE || bond1.getOrder()==IBond.Order.SINGLE) && (bond0.getOrder()==IBond.Order.DOUBLE || bond1.getOrder()==IBond.Order.DOUBLE)) nodeSequence[i]=5;//-CH= else if((bond0.getOrder()==IBond.Order.SINGLE || bond1.getOrder()==IBond.Order.TRIPLE) && (bond0.getOrder()==IBond.Order.TRIPLE || bond1.getOrder()==IBond.Order.TRIPLE)) nodeSequence[i]=9;//-C# else if(bond0.getFlag(CDKConstants.ISAROMATIC) && bond1.getFlag(CDKConstants.ISAROMATIC)) nodeSequence[i]=11;//ArCH } else if(atom.getSymbol().equals("N")) { if(bond0.getOrder()==IBond.Order.SINGLE && bond1.getOrder()==IBond.Order.SINGLE) nodeSequence[i]=19;//-NH- else if(bond0.getOrder()==IBond.Order.DOUBLE && bond1.getOrder()==IBond.Order.DOUBLE) nodeSequence[i]=28;//=N= with charge=-1 else if((bond0.getOrder()==IBond.Order.SINGLE || bond1.getOrder()==IBond.Order.SINGLE) && (bond0.getOrder()==IBond.Order.DOUBLE || bond1.getOrder()==IBond.Order.DOUBLE)) nodeSequence[i]=22;//-N= else if((bond0.getOrder()==IBond.Order.DOUBLE || bond1.getOrder()==IBond.Order.DOUBLE) && (bond0.getOrder()==IBond.Order.TRIPLE || bond1.getOrder()==IBond.Order.TRIPLE)) nodeSequence[i]=26;//=N# else if((bond0.getOrder()==IBond.Order.SINGLE || bond1.getOrder()==IBond.Order.SINGLE) && (bond0.getOrder()==IBond.Order.TRIPLE || bond1.getOrder()==IBond.Order.TRIPLE)) nodeSequence[i]=29;//-N# with charge=+1 else if(bond0.getFlag(CDKConstants.ISAROMATIC) && bond1.getFlag(CDKConstants.ISAROMATIC)) nodeSequence[i]=30;//ArN } else if(atom.getSymbol().equals("O")) { if(bond0.getOrder()==IBond.Order.SINGLE && bond1.getOrder()==IBond.Order.SINGLE) nodeSequence[i]=15;//-O- else if(bond0.getFlag(CDKConstants.ISAROMATIC) && bond1.getFlag(CDKConstants.ISAROMATIC)) nodeSequence[i]=17;//ArO } else if(atom.getSymbol().equals("S")) { if(bond0.getOrder()==IBond.Order.SINGLE && bond1.getOrder()==IBond.Order.SINGLE) nodeSequence[i]=32;//-S- else if(bond0.getOrder()==IBond.Order.DOUBLE && bond1.getOrder()==IBond.Order.DOUBLE) nodeSequence[i]=35;//=S= else if(bond0.getFlag(CDKConstants.ISAROMATIC) && bond1.getFlag(CDKConstants.ISAROMATIC)) nodeSequence[i]=37;//ArS } else if(atom.getSymbol().equals("P")) { if(bond0.getOrder()==IBond.Order.SINGLE && bond1.getOrder()==IBond.Order.SINGLE) nodeSequence[i]=39;//-PH- } else { logger.debug("in case of a new node, please report this bug to cdk-devel@lists.sf.net."); } } else if(bonds.size()==3) { IBond bond0 = (IBond)bonds.get(0); IBond bond1 = (IBond)bonds.get(1); IBond bond2 = (IBond)bonds.get(2); if(atom.getSymbol().equals("C")) { if(bond0.getOrder()==IBond.Order.SINGLE && bond1.getOrder()==IBond.Order.SINGLE && bond2.getOrder()==IBond.Order.SINGLE) nodeSequence[i]=4;//>C- else if(bond0.getOrder()==IBond.Order.DOUBLE || bond1.getOrder()==IBond.Order.DOUBLE ||bond2.getOrder()==IBond.Order.DOUBLE) nodeSequence[i]=8;//>C= else if(bond0.getFlag(CDKConstants.ISAROMATIC) && bond1.getFlag(CDKConstants.ISAROMATIC) && bond2.getFlag(CDKConstants.ISAROMATIC)) nodeSequence[i]=13;//ArC else if((bond0.getFlag(CDKConstants.ISAROMATIC) || bond1.getFlag(CDKConstants.ISAROMATIC) || bond2.getFlag(CDKConstants.ISAROMATIC)) && (bond0.getOrder()==IBond.Order.SINGLE || bond1.getOrder()==IBond.Order.SINGLE || bond2.getOrder()==IBond.Order.SINGLE)) nodeSequence[i]=12;//ArC- } else if(atom.getSymbol().equals("N")) { if(bond0.getOrder()==IBond.Order.SINGLE && bond1.getOrder()==IBond.Order.SINGLE && bond2.getOrder()==IBond.Order.SINGLE) nodeSequence[i]=21;//>N- else if(bond0.getOrder()==IBond.Order.SINGLE || bond1.getOrder()==IBond.Order.SINGLE || bond2.getOrder()==IBond.Order.SINGLE) nodeSequence[i]=25;//-N(=)= } else if(atom.getSymbol().equals("S")) { if(bond0.getOrder()==IBond.Order.DOUBLE || bond1.getOrder()==IBond.Order.DOUBLE || bond2.getOrder()==IBond.Order.DOUBLE) nodeSequence[i]=34;//>S= } else if(atom.getSymbol().equals("P")) { if(bond0.getOrder()==IBond.Order.SINGLE && bond1.getOrder()==IBond.Order.SINGLE && bond2.getOrder()==IBond.Order.SINGLE) nodeSequence[i]=40;//>P- } else { logger.debug("in case of a new node, please report this bug to cdk-devel@lists.sf.net."); } } else if(bonds.size()==4) { if(atom.getSymbol().equals("C"))nodeSequence[i]=7;//>C< else if(atom.getSymbol().equals("N"))nodeSequence[i]=24;//>N(=)- else if(atom.getSymbol().equals("S"))nodeSequence[i]=36;//>S(=)= else if(atom.getSymbol().equals("P"))nodeSequence[i]=41;//=P<- else { logger.debug("in case of a new node, please report this bug to cdk-devel@lists.sf.net."); } } i++; } return nodeSequence; } /** * Build node Matrix * * @param nodeSequence an array contains node number for each atom * @return node Matrix */ public double[][] buildNodeMatrix(double[] nodeSequence) { int i,j,k; for(i=0;icount) { count+=1; category[count]=weight[i]; } } return count; } /** * Get the final equivalent class * * @param weight array contains weight of the nodes * @return an array contains the automorphism partition */ public int[] getEquivalentClass(double[] weight) { double category[]=new double[weight.length]; int equivalentClass[]=new int[weight.length]; int i,j; int count=1; double t; category[1]=weight[1]; for(i=2;icount) { count+=1; category[count]=weight[i]; } } for(i=1;icount); return equivalentClass; } }cdk-1.2.10/src/main/org/openscience/cdk/graph/invariant/GIMatrix.java100644 0 0 76356 11570154753 22515 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 The Chemistry Development Kit (CDK) project * * 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. * * 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.graph.invariant; import org.openscience.cdk.graph.invariant.exception.BadMatrixFormatException; import org.openscience.cdk.graph.invariant.exception.IndexOutOfBoundsException; import org.openscience.cdk.graph.invariant.exception.MatrixNotInvertibleException; /** * This class is intended to provide the user an efficient way of implementing matrix of double number and * using normal operations (linear operations, addition, substraction, multiplication, inversion, concatenation) * on them. The internal representation of a matrix is an array of array of double objects. For the moment, * double class is the best way I have developped to perform exact operation on numbers; however, for * irdoubles, normal operations on float and doubles have to be performed, with the well-known risks of error * this implies. This class also provides a way of representing matrix as arrays of String for output use. * *

Please note that although in most books matrix elements' indexes take values between [1..n] I chose not * to disturb Java language way of calling indexes; so the indexes used here take values between [0..n-1] instead. * * @author Jean-Sebastien Senecal * @cdk.githash * @version 1.0 * @cdk.created 1999-05-20 */ public class GIMatrix { private double[][] array; // the matrix itself as an array of doubles private int m, n; // matrix's params (m=no of line, n=no of columns) /** * Class constructor. Uses an array of integers to create a new Matrix object. Note that integers * will be converted to double objects so mathematical operations may be properly performed and * provide exact solutions. The given array should be properly instantiated as a matrix i.e. it * must contain a fixed number of lines and columns, otherwise an exception will be thrown. * Array must be at leat 1x1. * @param array an array of integer (first index is the line, second is the column) * @exception BadMatrixFormatException in case the given array is unproper to construct a matrix */ public GIMatrix(int[][] array) { double[][] temp = new double[array.length][]; for (int i = 0; i < array.length; i++) { temp[i] = new double[array[i].length]; // line by line ... for (int j = 0; j < array[i].length; j++) temp[i][j] = array[i][j]; // converts ints to doubles } // verifyMatrixFormat(temp); this.array = temp; m = temp.length; n = temp[0].length; } // constructor Matrix(int[][]) /** * Class constructor. Uses an array of doubles to create a new Matrix object. The given array should * be properly instantiated as a matrix i.e. it must contain a fixed number of lines and columns, * otherwise an exception will be thrown. Array must be at leat 1x1. * * @param array an array of double objects (first index is the line, second is the column) * @exception BadMatrixFormatException in case the given array is unproper to construct a matrix */ public GIMatrix(double[][] array) throws BadMatrixFormatException { verifyMatrixFormat(array); double[][] temp = new double[array.length][]; for (int i = 0; i < array.length; i++) { temp[i] = new double[array[i].length]; // line by line ... for (int j = 0; j < array[i].length; j++) temp[i][j] = array[i][j]; } this.array = temp; m = array.length; n = array[0].length; } // constructor Matrix(double[][]) /** * Class constructor. Creates a new Matrix object with fixed dimensions. The matrix is * initialised to the "zero" matrix. * * @param line number of lines * @param col number of columns */ public GIMatrix(int line, int col) { array = new double[line][col]; for (int i = 0; i < line; i++) for (int j = 0; j < col; j++) array[i][j] = 0.0; m = line; n = col; } // constructor Matrix(int,int) /** * Class constructor. Copies an already existing Matrix object in a new Matrix object. * @param matrix a Matrix object */ public GIMatrix(GIMatrix matrix) { double[][] temp = new double[matrix.height()][]; for (int i = 0; i < matrix.height(); i++) { temp[i] = new double[matrix.width()]; // line by line ... for (int j = 0; j < matrix.width(); j++) { try { temp[i][j] = matrix.getValueAt(i,j); } catch (IndexOutOfBoundsException e) {} // never happens } } this.array = temp; m = array.length; n = array[0].length; } // constructor Matrix(Matrix) /** * Class constructor. Creates a new Matrix object using a table of matrices (an array of Matrix objects). * The given array should be properly instantiated i.e. it must contain a fixed number of lines and columns, * otherwise an exception will be thrown. * @param table an array of matrices * @exception BadMatrixFormatException if the table is not properly instantiated */ public GIMatrix(GIMatrix[][] table) throws BadMatrixFormatException { verifyTableFormat(table); m = n = 0; for (int i = 0; i < table.length; i++) m += table[i][0].height(); for (int j = 0; j < table[0].length; j++) n += table[0][j].width(); double[][] temp = new double[m][n]; int k = 0; // counters for matrices for (int i = 0; i < m; i++) { temp[i] = new double[n]; // line by line ... if (i == table[k][0].height()) k++; // last line of matrix reached int h = 0; for (int j = 0; j < n; j++) { if (j == table[k][h].width()) h++; // last column of matrix reached try { GIMatrix tempMatrix = table[k][h]; temp[i][j] = tempMatrix.getValueAt(i - k*tempMatrix.height(),j - h*tempMatrix.width()); } catch (IndexOutOfBoundsException e) {} // never happens } } this.array = temp; } // constructor Matrix(Matrix) /** * Returns the number of lines of the matrix. * @return the height of the matrix */ public int height() { return m; } // method heigth() /** * Returns the number of columns of the matrix. * @return the width of the matrix */ public int width() { return n; } // method width() /** * Returns the internal representation of the matrix, that is an array of double objects. * @return an array of double equivalent to the matrix */ public double[][] getArrayValue() { return array; } // method getArrayValue() /** * Resets the value of the matrix to the given array of double numbers * @param array an array of double objects (first index is the line, second is the column) * @exception BadMatrixFormatException in case the given array is unproper to construct a matrix */ public void setArrayValue(double[][] array) throws BadMatrixFormatException { verifyMatrixFormat(array); this.array = array; } // method setArrayValue(double[][]) /** * Returns the value of the given element. * @param i the line number * @param j the column number * @return the double at the given index in the Matrix * @exception IndexOutOfBoundsException if the given index is out of the matrix's range */ public double getValueAt(int i, int j) throws IndexOutOfBoundsException { if ( (i < 0)||(i >= m)||(j < 0)||(j >= n) ) throw new IndexOutOfBoundsException(); return array[i][j]; } // method getValueAt(int,int) /** * Sets the value of the element at the given index. * @param i the line number * @param j the column number * @param element the double to place at the given index in the Matrix * @exception IndexOutOfBoundsException if the given index is out of the matrix's range */ public void setValueAt(int i, int j, double element) throws IndexOutOfBoundsException { if ( (i < 0)||(i >= m)||(j < 0)||(j >= n) ) throw new IndexOutOfBoundsException(); array[i][j] = element; } // method setValueAt(int,int,double) /** * Returns the line-matrix at the given line index * @param i the line number * @return the specified line as a Matrix object * @exception IndexOutOfBoundsException if the given index is out of the matrix's range */ public GIMatrix getLine(int i) throws IndexOutOfBoundsException { if ( (i < 0)||(i >= m) ) throw new IndexOutOfBoundsException(); double[][] line = new double[1][n]; for (int k = 0; k < n; k++) line[0][k] = array[i][k]; try { return new GIMatrix(line); } // format is always OK anyway ... catch (BadMatrixFormatException e) { return null; } } // method getLine(int) /** * Returns the column-matrix at the given line index * @param j the column number * @return the specified column as a Matrix object * @exception IndexOutOfBoundsException if the given index is out of the matrix's range */ public GIMatrix getColumn(int j) throws IndexOutOfBoundsException { if ( (j < 0)||(j >= n) ) throw new IndexOutOfBoundsException(); double[][] column = new double[m][1]; for (int k = 0; k < m; k++) column[k][0] = array[k][j]; try { return new GIMatrix(column); } // format is always OK anyway ... catch (BadMatrixFormatException e) { return null; } } // method getColumn(int) /** * Sets the line of the matrix at the specified index to a new value. * @param i the line number * @param line the line to be placed at the specified index * @exception IndexOutOfBoundsException if the given index is out of the matrix's range * @exception BadMatrixFormatException in case the given Matrix is unproper to replace a line of this Matrix */ public void setLine(int i, GIMatrix line) throws IndexOutOfBoundsException, BadMatrixFormatException { if ( (i < 0)||(i >= m) ) throw new IndexOutOfBoundsException(); if ((line.height() != 1) || (line.width() != n)) throw new BadMatrixFormatException(); for (int k = 0; k < n; k++) array[i][k] = line.getValueAt(0,k); } // method setLine(int,Matrix) /** * Sets the column of the matrix at the specified index to a new value. * @param j the column number * @param column the colums to be placed at the specified index * @exception IndexOutOfBoundsException if the given index is out of the matrix's range * @exception BadMatrixFormatException in case the given Matrix is unproper to replace a column of this Matrix */ public void setColumn(int j, GIMatrix column) throws IndexOutOfBoundsException, BadMatrixFormatException { if ( (j < 0)||(j >= n) ) throw new IndexOutOfBoundsException(); if ((column.height() != m) || (column.width() != 1)) throw new BadMatrixFormatException(); for (int k = 0; k < m; k++) array[k][j] = column.getValueAt(k,0); } // method setColumn(int,Matrix) /** * Returns the identity matrix. * @param n the matrix's dimension (identity matrix is a square matrix) * @return the identity matrix of format nxn */ public static GIMatrix identity(int n) { double[][] identity = new double[n][n]; for (int i = 0; i < n; i++) { for (int j = 0; j < i; j++) identity[i][j] = 0.0; identity[i][i] = 1.0; for (int j = i+1; j < n; j++) identity[i][j] = 0.0; } try { return new GIMatrix(identity); } // format is always OK anyway ... catch (BadMatrixFormatException e) { return null; } } // method identity(int) /** * Returns a null matrix (with zeros everywhere) of given dimensions. * @param m number of lines * @param n number of columns * @return the zero (null) matrix of format mxn */ public static GIMatrix zero(int m, int n) { double[][] zero = new double[m][n]; for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) zero[i][j] = 0.0; try { return new GIMatrix(zero); } // format is always OK anyway ... catch (BadMatrixFormatException e) { return null; } } // method zero(int,int) /** * Verifies if two given matrix are equal or not. The matrix must be of the same size and dimensions, * otherwise an exception will be thrown. * @param matrix the Matrix object to be compared to * @return true if both matrix are equal element to element * @exception BadMatrixFormatException if the given matrix doesn't have the same dimensions as this one */ public boolean equals(GIMatrix matrix) throws BadMatrixFormatException { if ( (height() != matrix.height())||(width() != matrix.width()) ) throw new BadMatrixFormatException(); double[][] temp = matrix.getArrayValue(); for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) if (!(array[i][j]==temp[i][j])) return false; return true; } // method equals(Matrix) /** * Verifies if the matrix is square, that is if it has an equal number of lines and columns. * @return true if this matrix is square */ public boolean isSquare() { return (m == n); } // method isSquare() /** * Verifies if the matrix is symmetric, that is if the matrix is equal to it's transpose. * @return true if the matrix is symmetric * @exception BadMatrixFormatException if the matrix is not square */ public boolean isSymmetric() throws BadMatrixFormatException { if (m != n) throw new BadMatrixFormatException(); // the loop looks in the lower half of the matrix to find non-symetric elements for (int i = 1; i < m; i++) // starts at index 1 because index (0,0) always symmetric for (int j = 0; j < i; j++) if (!(array[i][j]==array[j][i])) return false; return true; // the matrix has passed the test } //method isSymmetric() // NOT OVER, LOOK MORE CAREFULLY FOR DEFINITION /** * Verifies if the matrix is antisymmetric, that is if the matrix is equal to the opposite of * it's transpose. * @return true if the matrix is antisymmetric * @exception BadMatrixFormatException if the matrix is not square */ public boolean isAntisymmetric() throws BadMatrixFormatException { if (m != n) throw new BadMatrixFormatException(); // the loop looks in the lower half of the matrix to find non-antisymetric elements for (int i = 0; i < m; i++) // not as isSymmetric() loop for (int j = 0; j <= i; j++) if (!(array[i][j]==-array[j][i])) return false; return true; // the matrix has passed the test } // method isAntisymmetric() /** * Verifies if the matrix is triangular superior or not. A triangular superior matrix has * zero (0) values everywhere under it's diagonal. * @return true if the matrix is triangular superior * @exception BadMatrixFormatException if the matrix is not square */ public boolean isTriangularSuperior() throws BadMatrixFormatException { if (m != n) throw new BadMatrixFormatException(); // the loop looks in the lower half of the matrix to find non-null elements for (int i = 1; i < m; i++) // starts at index 1 because index (0,0) is on the diagonal for (int j = 0; j < i; j++) if (!(array[i][j] == 0.0)) return false; return true; // the matrix has passed the test } // method isTriangularSuperior /** * Verifies if the matrix is triangular inferior or not. A triangular inferior matrix has * zero (0) values everywhere upper it's diagonal. * @return true if the matrix is triangular inferior * @exception BadMatrixFormatException if the matrix is not square */ public boolean isTriangularInferior() throws BadMatrixFormatException { if (m != n) throw new BadMatrixFormatException(); // the loop looks in the upper half of the matrix to find non-null elements for (int i = 1; i < m; i++) // starts at index 1 because index (0,0) is on the diagonal for (int j = i; j < n; j++) if (!(array[i][j] == 0.0)) return false; return true; // the matrix has passed the test } // method isTriangularInferior() /** * Verifies whether or not the matrix is diagonal. A diagonal matrix only has elements on its diagonal * and zeros (0) at every other index. The matrix must be square. * @return true if the matrix is diagonal * @exception BadMatrixFormatException if the matrix is not square */ public boolean isDiagonal() throws BadMatrixFormatException { if (m != n) throw new BadMatrixFormatException(); // the loop looks both halves of the matrix to find non-null elements for (int i = 1; i < m; i++) // starts at index 1 because index (0,0) must not be checked for (int j = 0; j < i; j++) if ( (!(array[i][j] == 0.0))||(!(array[j][i]== 0.0)) ) return false; // not null return true; } // method isDiagonal /** * Verifies if the matrix is invertible or not by asking for its determinant. * @return true if the matrix is invertible * @exception BadMatrixFormatException if the matrix is not square */ public boolean isInvertible() throws BadMatrixFormatException { if (m != n) throw new BadMatrixFormatException(); return (!(determinant() == 0)); // det != 0 } // method isInvertible() /** * Returns the transpose of this matrix. The transpose of a matrix A = {a(i,j)} is the matrix B = {b(i,j)} * such that b(i,j) = a(j,i) for every i,j i.e. it is the symetrical reflexion of the matrix along its * diagonal. The matrix must be square to use this method, otherwise an exception will be thrown. * @return the matrix's transpose as a Matrix object * @exception BadMatrixFormatException if the matrix is not square */ public GIMatrix inverse() throws MatrixNotInvertibleException { try { if (!isInvertible()) throw new MatrixNotInvertibleException(); } catch (BadMatrixFormatException e) { throw new MatrixNotInvertibleException(); } GIMatrix I = identity(n); // Creates an identity matrix of same dimensions GIMatrix table; try { GIMatrix[][] temp = {{this,I}}; table = new GIMatrix(temp); } catch (BadMatrixFormatException e) { return null; } // never happens table = table.GaussJordan(); // linear reduction method applied double[][] inv = new double[m][n]; for (int i = 0; i < m; i++) // extracts inverse matrix for (int j = n; j < 2*n; j++) { try { inv[i][j-n] = table.getValueAt(i,j); } catch (IndexOutOfBoundsException e) { return null; } // never happens } try { return new GIMatrix(inv); } catch (BadMatrixFormatException e) { return null; } // never happens... } // method inverse() /** * Gauss-Jordan algorithm. Returns the reduced-echeloned matrix of this matrix. The * algorithm has not yet been optimised but since it is quite simple, it should not be * a serious problem. * @return the reduced matrix */ public GIMatrix GaussJordan() { GIMatrix tempMatrix= new GIMatrix(this); try { int i = 0; int j = 0; int k = 0; boolean end = false; while ( (i < m) && (!end) ) { boolean allZero = true; // true if all elements under line i are null (zero) while (j < n) { // determination of the pivot for (k = i; k < m; k++) { if (!(tempMatrix.getValueAt(k,j)== 0.0)) { // if an element != 0 allZero = false; break; } } if (allZero) j++; else break; } if (j == n) end = true; else { if (k != i) tempMatrix = tempMatrix.invertLine(i,k); if (!(tempMatrix.getValueAt(i,j)== 1.0)) // if element != 1 tempMatrix = // A = L(i)(1/a(i,j))(A) tempMatrix.multiplyLine(i,1/tempMatrix.getValueAt(i,j)); for (int q = 0; q < m; q++) if (q != i) // A = L(q,i)(-a(q,j))(A) tempMatrix = tempMatrix.addLine(q,i,-tempMatrix.getValueAt(q,j)); } i++; } // normally here, r = i-1 return tempMatrix; } catch (IndexOutOfBoundsException e) { return null; } // never happens... well I hope ;) /* From: LEROUX, P. Algebre lineaire: une approche matricielle. Modulo Editeur, 1983. p. 75. (In French) */ } // method GaussJordan() /** * Returns the transpose of this matrix. The transpose of a matrix A = {a(i,j)} is the matrix B = {b(i,j)} * such that b(i,j) = a(j,i) for every i,j i.e. it is the symetrical reflexion of the matrix along its * diagonal. The matrix must be square to use this method, otherwise an exception will be thrown. * @return the matrix's transpose as a Matrix object * @exception BadMatrixFormatException if the matrix is not square */ public GIMatrix transpose() throws BadMatrixFormatException { if (m != n) throw new BadMatrixFormatException(); double[][] transpose = new double[array.length][array[0].length]; for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) transpose[i][j] = array[j][i]; return new GIMatrix(transpose); } // method transpose() /** * Returns a matrix containing all of the diagonal elements of this matrix and zero (0) everywhere * else. This matrix is called the diagonal of the matrix. * @return the diagonal of the matrix * @exception BadMatrixFormatException if the matrix is not square */ public GIMatrix diagonal() throws BadMatrixFormatException { if (m != n) throw new BadMatrixFormatException(); double[][] diagonal = new double[array.length][array[0].length];; for (int i = 0; i < m; i++) for (int j = 0; j < n; j++) { if (i == j) diagonal[i][j] = array[i][j]; else diagonal[i][j] = 0; } return new GIMatrix(diagonal); } // method diagonal() /** * Returns the resulting matrix of an elementary linear operation that consists of multiplying a * single line of the matrix by a constant. * @param i the line number * @param c the double constant that multiplies the line * @return the resulting Matrix object of the linear operation * @exception IndexOutOfBoundsException if the given index is out of the matrix's range */ public GIMatrix multiplyLine(int i, double c) throws IndexOutOfBoundsException { if ( (i < 0)||(i >= m) ) throw new IndexOutOfBoundsException(); double[][] temp = array; for (int k = 0; k < n; k++) temp[i][k] = c*temp[i][k]; // mutliply every member of the line by c try { return new GIMatrix(temp); } // format is always OK anyway ... catch (BadMatrixFormatException e) { return null; } } // method multiplyLine(int,int) /** * Returns the resulting matrix of an elementary linear operation that consists of inverting two lines. * @param i the first line number * @param j the second line number * @return the resulting Matrix object of the linear operation * @exception IndexOutOfBoundsException if the given index is out of the matrix's range */ public GIMatrix invertLine(int i, int j) throws IndexOutOfBoundsException { if ( (i < 0)||(i >= m)||(j < 0)||(j >= m) ) throw new IndexOutOfBoundsException(); double[][] temp = array; double[] tempLine = temp[j]; // temporary line temp[j] = temp[i]; temp[i] = tempLine; try { return new GIMatrix(temp); } // format is always OK anyway ... catch (BadMatrixFormatException e) { return null; } } // method invertLine(int,int) /** * Returns the resulting matrix of an elementary linear operation that consists of adding one line, * multiplied by some constant factor, to another line. * @param i the first line number * @param j the second line number (to be added to the first) * @param c the double constant that multiplies the first line * @return the resulting Matrix object of the linear operation * @exception IndexOutOfBoundsException if the given index is out of the matrix's range */ public GIMatrix addLine(int i, int j, double c) throws IndexOutOfBoundsException{ if ( (i < 0)||(i >= m)||(j < 0)||(j >= m) ) throw new IndexOutOfBoundsException(); double[][] temp = array; for (int k = 0; k < n; k++) temp[i][k] = temp[i][k]+c*temp[j][k]; // add multiplied element of i to element of j try { return new GIMatrix(temp); } // format is always OK anyway ... catch (BadMatrixFormatException e) { return null; } } // method addLine(int,int,double) /** * Addition from two matrices. */ public GIMatrix add(GIMatrix b) { if ((b==null) || (m!=b.m) || (n!=b.n)) return null; int i, j; GIMatrix result = new GIMatrix(m,n); for(i=0; ifollows this matrix in the multiplication, so for an example if the dimension of * the actual matrix is mxn, the dimension of the second one should be nxp in order for the multiplication * to be performed (otherwise an exception will be thrown) and the resulting matrix will have dimension mxp. * @param matrix the matrix following this one in the matricial multiplication * @return the resulting matrix of the matricial multiplication * @exception BadMatrixFormatException if the matrix passed in arguments has wrong dimensions */ public GIMatrix multiply(GIMatrix matrix) throws BadMatrixFormatException { if (n != matrix.height()) throw new BadMatrixFormatException(); // unsuitable dimensions int p = matrix.width(); double[][] temp = new double[m][p]; double[][] multiplied = matrix.getArrayValue(); for (int i = 0; i < m; i++) // line index of the first matrix for (int k = 0; k < p; k++) { // column index of the second matrix temp[i][k] = array[i][0]*multiplied[0][k]; // first multiplication for (int j = 1; j < n; j++) // sum of multiplications temp[i][k] = temp[i][k]+array[i][j]*multiplied[j][k]; } return new GIMatrix(temp); } // method multiply(Matrix) /** * Returns the determinant of this matrix. The matrix must be * square in order to use this method, otherwise an exception will be thrown. * Warning: this algorithm is very unefficient and takes too much time to compute * with large matrices. * @return the determinant of the matrix * @exception BadMatrixFormatException if the matrix is not square */ public double determinant() throws BadMatrixFormatException { if (m != n) throw new BadMatrixFormatException(); return det(array); // use of recursive method } // method determinant() // Method used for recursive determinant algorithm. Supposes the given array is square. private double det(double[][] mat) { if (mat.length == 1) return mat[0][0]; double temp = mat[0][0]*det(M(mat,0,0)); // (-1)^(0+0)*m[0][0]*det(M(i,j)) ... first assignation for (int k = 1; k < mat.length; k++) temp = temp+(det(M(mat,0,k))*((k % 2 == 0)?mat[0][k]:-mat[0][k])); // Note: ((0+k)%2 == 0)?1:-1 is equivalent to (-1)^(0+k) return temp; } // method det(double[][]) // Returns the minor of the array (supposed square) i.e. the array least its i-th line // and j-th column private double[][] M(double[][] mat, int i, int j) { double[][] temp = new double[mat.length-1][mat[0].length-1]; // "void minor" for (int k = 0; k < i; k++) { for (int h = 0; h < j; h++) temp[k][h] = mat[k][h]; for (int h = j+1; h < mat[0].length; h++) temp[k][h-1] = mat[k][h]; } for (int k = i+1; k < mat.length; k++) { for (int h = 0; h < j; h++) temp[k-1][h] = mat[k][h]; for (int h = j+1; h < mat[0].length; h++) temp[k-1][h-1] = mat[k][h]; } return temp; } // method M(double[][],int,int) /** * Returns the trace of this matrix, that is the sum of the elements of its diagonal. The matrix must be * square in order to use this method, otherwise an exception will be thrown. * @return the trace of the matrix * @exception BadMatrixFormatException if the matrix is not square */ public double trace() throws BadMatrixFormatException { if (m != n) throw new BadMatrixFormatException(); double trace = array[0][0]; for (int i = 1; i < m; i++) trace = trace+array[i][i]; return trace; } // method trace() // /** // * Returns the matrix as a String. // * The double numbers are printed using the form "p/q" or "a b/c" depending on the value of the boolean, // * and use a minimal number of spaces as specified. It is the user's responsibility to grant a number // * of spaces wide enough to get proper alignment. // * @see tatien.toolbox.double#toString // * @param simple must be true to get simple expression, false otherwise as specified // * @param spaces number of spaces // */ // public String print(boolean simple, int spaces) { // String print = ""; // for (int i = 0; i < m; i++) { // print = print + array[i][0].toString(simple,spaces); // for (int j = 1; j < n; j++) { // print = print + array[i][j].toString(simple,spaces); // } // print = print + "\n"; // } // return print; // } // method print() // Verifies if the matrix is of good format when calling a constructor or setArrayValue private void verifyMatrixFormat(double[][] testedMatrix) throws BadMatrixFormatException { if ( (testedMatrix.length == 0)||(testedMatrix[0].length == 0) ) throw new BadMatrixFormatException(); int noOfColumns = testedMatrix[0].length; for (int i = 1; i < testedMatrix.length; i++) if (testedMatrix[i].length != noOfColumns) throw new BadMatrixFormatException(); } // method verifyMatrixFormat(double[][]) // In the case of the implementation of a table i.e. an array of matrices, verifies if the table is proper. private void verifyTableFormat(GIMatrix[][] testedTable) throws BadMatrixFormatException { if ( (testedTable.length == 0)||(testedTable[0].length == 0) ) throw new BadMatrixFormatException(); int noOfColumns = testedTable[0].length; int currentHeigth, currentWidth; for (int i = 0; i < testedTable.length; i++) { // verifies correspondence of m's (heigth) if (testedTable[i].length != noOfColumns) throw new BadMatrixFormatException(); currentHeigth = testedTable[i][0].height(); for (int j = 1; j < testedTable[0].length; j++) if (testedTable[i][j].height() != currentHeigth) throw new BadMatrixFormatException(); } for (int j = 0; j < testedTable[0].length; j++) { // verifies correspondence of n's (width) currentWidth = testedTable[0][j].width(); for (int i = 1; i < testedTable.length; i++) if (testedTable[i][j].width() != currentWidth) throw new BadMatrixFormatException(); } } // method verifyTableFormat(Matrix[][]) } // class Matrix cdk-1.2.10/src/main/org/openscience/cdk/graph/invariant/HuLuIndexTool.java100644 0 0 22367 11570154753 23525 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 The Chemistry Development Kit (CDK) project * * 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. * * 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.graph.invariant; import org.openscience.cdk.AtomContainer; import org.openscience.cdk.exception.NoSuchAtomException; import org.openscience.cdk.graph.PathTools; import org.openscience.cdk.graph.invariant.exception.BadMatrixFormatException; import org.openscience.cdk.graph.invariant.exception.IndexOutOfBoundsException; import org.openscience.cdk.graph.matrix.ConnectionMatrix; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.tools.LoggingTool; import java.util.Iterator; /** * Collection of methods for the calculation of topological indices of a * molecular graph. * * @cdk.githash */ public class HuLuIndexTool { private final static LoggingTool logger = new LoggingTool(HuLuIndexTool.class); /** * Calculates the extended adjacency matrix index. * An implementation of the algorithm published in {@cdk.cite HU96}. * * @cdk.keyword EAID number */ public static double getEAIDNumber(AtomContainer atomContainer) throws NoSuchAtomException, BadMatrixFormatException,IndexOutOfBoundsException { boolean debug = false; GIMatrix matrix = new GIMatrix(getExtendedAdjacenyMatrix(atomContainer)); GIMatrix tempMatrix = matrix; GIMatrix fixedMatrix = matrix; for (int i = 2; i < atomContainer.getAtomCount(); i++) { tempMatrix = tempMatrix.multiply(fixedMatrix); matrix = matrix.add(tempMatrix); } for (int i = 0; i < atomContainer.getAtomCount(); i++) { matrix.setValueAt(i,i,matrix.getValueAt(i,i)+1); } double eaid = matrix.trace(); logger.debug("final matrix - the sum of the powers of EA matrix: "); displayMatrix(matrix.getArrayValue()); logger.debug("eaid number: "+ eaid); return eaid; } public static double[][] getExtendedAdjacenyMatrix(AtomContainer atomContainer) throws NoSuchAtomException { boolean debug = false; double[][] adjaMatrix = ConnectionMatrix.getMatrix(atomContainer); logger.debug("adjacency matrix: "); displayMatrix(adjaMatrix); double[] atomWeights = getAtomWeights(atomContainer); for (int i = 0; i < adjaMatrix.length; i++) { for (int j = 0; j < adjaMatrix.length; j++) { if (i==j) { if (atomContainer.getAtom(i).getSymbol()=="O") { adjaMatrix[i][j] = Math.sqrt(0.74)/6; } else { adjaMatrix[i][j] = Math.sqrt(0.74)/6; } } else { adjaMatrix[i][j] = (Math.sqrt(atomWeights[i]/atomWeights[j]) + Math.sqrt(atomWeights[j]/atomWeights[i])) * Math.sqrt(adjaMatrix[i][j])/6; } } } logger.debug("extended adjacency matrix: "); displayMatrix(adjaMatrix); return adjaMatrix; } public static double[] getAtomWeights(AtomContainer atomContainer) throws NoSuchAtomException { boolean debug = false; IAtom atom,headAtom,endAtom; int headAtomPosition,endAtomPosition; //int k = 0; double[] weightArray = new double[atomContainer.getAtomCount()]; double[][] adjaMatrix = ConnectionMatrix.getMatrix(atomContainer); int[][] apspMatrix = PathTools.computeFloydAPSP(adjaMatrix); int[] atomLayers = getAtomLayers(apspMatrix); int[] valenceSum; int[] interLayerBondSum; logger.debug("adjacency matrix: "); displayMatrix(adjaMatrix); logger.debug("all-pairs-shortest-path matrix: "); displayMatrix(apspMatrix); logger.debug("atom layers: "); displayArray(atomLayers); for (int i = 0; i < atomContainer.getAtomCount(); i++) { atom = atomContainer.getAtom(i); valenceSum = new int[atomLayers[i]]; for (int v = 0; v < valenceSum.length; v++) { valenceSum[v] = 0; } interLayerBondSum = new int[atomLayers[i]-1]; for (int v = 0; v < interLayerBondSum.length; v++) { interLayerBondSum[v] = 0; } //weightArray[k] = atom.getValenceElectronsCount() - atom.getHydrogenCount(); // method unfinished if(atom.getSymbol()=="O") weightArray[i] = 6 - atom.getHydrogenCount(); else weightArray[i] = 4 - atom.getHydrogenCount(); for (int j = 0; j < apspMatrix.length; j++) { if(atomContainer.getAtom(j).getSymbol()=="O") valenceSum[apspMatrix[j][i]] += 6 - atomContainer.getAtom(j).getHydrogenCount(); else valenceSum[apspMatrix[j][i]] += 4 - atomContainer.getAtom(j).getHydrogenCount(); } Iterator bonds = atomContainer.bonds().iterator(); while (bonds.hasNext()) { IBond bond = (IBond) bonds.next(); headAtom = bond.getAtom(0); endAtom = bond.getAtom(1); headAtomPosition = atomContainer.getAtomNumber(headAtom); endAtomPosition = atomContainer.getAtomNumber(endAtom); if (Math.abs(apspMatrix[i][headAtomPosition] - apspMatrix[i][endAtomPosition]) == 1) { int min = Math.min(apspMatrix[i][headAtomPosition],apspMatrix[i][endAtomPosition]); if (bond.getOrder() == IBond.Order.SINGLE) { interLayerBondSum[min] += 1; } else if (bond.getOrder() == IBond.Order.DOUBLE) { interLayerBondSum[min] += 2; } else if (bond.getOrder() == IBond.Order.TRIPLE) { interLayerBondSum[min] += 3; } else if (bond.getOrder() == IBond.Order.QUADRUPLE) { interLayerBondSum[min] += 4; } } } for (int j = 0; j < interLayerBondSum.length; j++) { weightArray[i] += interLayerBondSum[j] * valenceSum[j+1] * Math.pow(10, -(j+1)); } logger.debug("valence sum: "); displayArray(valenceSum); logger.debug("inter-layer bond sum: "); displayArray(interLayerBondSum); } logger.debug("weight array: "); displayArray(weightArray); return weightArray; } public static int[] getAtomLayers(int[][]apspMatrix) { int[] atomLayers = new int[apspMatrix.length]; for(int i = 0; i < apspMatrix.length; i++) { atomLayers[i] = 0; for(int j = 0; j < apspMatrix.length; j++) { if(atomLayers[i] < 1+ apspMatrix[j][i] ) atomLayers[i] = 1+ apspMatrix[j][i]; } } return atomLayers; } /** Lists a 2D double matrix to the System console */ public static void displayMatrix(double[][] matrix){ String line; for (int f = 0; f < matrix.length; f++) { line = ""; for (int g = 0; g < matrix.length; g++) { line += matrix[g][f] + " | "; } logger.debug(line); } } /** Lists a 2D int matrix to the System console */ public static void displayMatrix(int[][] matrix){ String line; for (int f = 0; f < matrix.length; f++) { line = ""; for (int g = 0; g < matrix.length; g++) { line += matrix[g][f] + " | "; } logger.debug(line); } } /** Lists a 1D array to the System console */ public static void displayArray(int[] array){ String line = ""; for (int f = 0; f < array.length; f++) { line += array[f] + " | "; } logger.debug(line); } /** Lists a 1D array to the System console */ public static void displayArray(double[] array){ String line = ""; for (int f = 0; f < array.length; f++) { line += array[f] + " | "; } logger.debug(line); } } cdk-1.2.10/src/main/org/openscience/cdk/graph/invariant/MorganNumbersTools.java100644 0 0 6514 11570154753 24576 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project * * 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. * * 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.graph.invariant; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; /** * Tool for calculating Morgan numbers {@cdk.cite MOR65}. * * @cdk.module standard * @cdk.githash * * @author shk3 * @cdk.created 2003-06-30 * @cdk.keyword Morgan number */ @TestClass("org.openscience.cdk.graph.invariant.MorganNumbersToolsTest") public class MorganNumbersTools { /** * Makes an array containing the morgan numbers of the atoms of atomContainer. * * @param atomContainer The atomContainer to analyse. * @return The morgan numbers value. */ @TestMethod("testGetMorganNumbers_IAtomContainer") public static long[] getMorganNumbers(IAtomContainer atomContainer) { long[] morganMatrix; long[] tempMorganMatrix; int N = atomContainer.getAtomCount(); morganMatrix = new long[N]; tempMorganMatrix = new long[N]; java.util.List atoms; for (int f = 0; f < N; f++) { morganMatrix[f] = atomContainer.getConnectedBondsCount(f); tempMorganMatrix[f] = atomContainer.getConnectedBondsCount(f); } for (int e = 0; e < N; e++) { for (int f = 0; f < N; f++) { morganMatrix[f] = 0; atoms = atomContainer.getConnectedAtomsList(atomContainer.getAtom(f)); for (IAtom atom : atoms) { morganMatrix[f] += tempMorganMatrix[atomContainer.getAtomNumber(atom)]; } } System.arraycopy(morganMatrix, 0, tempMorganMatrix, 0, N); } return tempMorganMatrix; } /** * Makes an array containing the morgan numbers+element symbol of the atoms of atomContainer. This method * puts the element symbol before the morgan number, useful for finding out how many different rests are connected to an atom. * * @param atomContainer The atomContainer to analyse. * @return The morgan numbers value. */ @TestMethod("testPhenylamine") public static String[] getMorganNumbersWithElementSymbol(IAtomContainer atomContainer) { long[] morgannumbers = getMorganNumbers(atomContainer); String[] morgannumberswithelement = new String[morgannumbers.length]; for (int i = 0; i < morgannumbers.length; i++) { morgannumberswithelement[i] = atomContainer.getAtom(i).getSymbol() + "-" + morgannumbers[i]; } return (morgannumberswithelement); } } cdk-1.2.10/src/main/org/openscience/cdk/graph/invariant/exception/BadMatrixFormatException.java100644 0 0 2146 11570154753 27674 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 The Chemistry Development Kit (CDK) project * * 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. * * 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.graph.invariant.exception; public class BadMatrixFormatException extends Exception { private static final long serialVersionUID = -4592379323522144603L; } cdk-1.2.10/src/main/org/openscience/cdk/graph/invariant/exception/IndexOutOfBoundsException.java100644 0 0 2146 11570154753 30047 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 The Chemistry Development Kit (CDK) project * * 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. * * 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.graph.invariant.exception; public class IndexOutOfBoundsException extends Exception { private static final long serialVersionUID = -1781128244202287777L; } cdk-1.2.10/src/main/org/openscience/cdk/graph/invariant/exception/MatrixNotInvertibleException.java100644 0 0 2151 11570154753 30615 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 The Chemistry Development Kit (CDK) project * * 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. * * 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.graph.invariant.exception; public class MatrixNotInvertibleException extends Exception { private static final long serialVersionUID = 8597172558566661068L; } cdk-1.2.10/src/main/org/openscience/cdk/graph/matrix/AdjacencyMatrix.java100644 0 0 5101 11570154753 23344 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project * * 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. * * 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.graph.matrix; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; /** * Calculator for a adjacency matrix representation of this AtomContainer. An * adjacency matrix is a matrix of quare NxN matrix, where N is the number of * atoms in the AtomContainer. The element i,j of the matrix is 1, if the i-th * and the j-th atom in the atomcontainer share a bond. Otherwise it is zero. * See {@cdk.cite TRI92}. * * @cdk.module core * @cdk.githash * @cdk.keyword adjacency matrix * * @author steinbeck * @cdk.created 2004-07-04 * @cdk.dictref blue-obelisk:calculateAdjecencyMatrix */ @TestClass("org.openscience.cdk.graph.matrix.AdjacencyMatrixTest") public class AdjacencyMatrix implements IGraphMatrix { /** * Returns the adjacency matrix for the given AtomContainer. * * @param container The AtomContainer for which the matrix is calculated * @return A adjacency matrix representating this AtomContainer */ @TestMethod("testGetMatrix_IAtomContainer") public static int[][] getMatrix(IAtomContainer container) { IBond bond; int indexAtom1; int indexAtom2; int[][] conMat = new int[container.getAtomCount()][container.getAtomCount()]; for (int f = 0; f < container.getBondCount(); f++){ bond = container.getBond(f); indexAtom1 = container.getAtomNumber(bond.getAtom(0)); indexAtom2 = container.getAtomNumber(bond.getAtom(1)); conMat[indexAtom1][indexAtom2] = 1; conMat[indexAtom2][indexAtom1] = 1; } return conMat; } } cdk-1.2.10/src/main/org/openscience/cdk/graph/matrix/ConnectionMatrix.java100644 0 0 5420 11570154753 23566 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project * * 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. * * 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.graph.matrix; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.tools.manipulator.BondManipulator; /** * Calculator for a connection matrix representation of this AtomContainer. An * adjacency matrix is a matrix of quare NxN matrix, where N is the number of * atoms in the AtomContainer. If the i-th and the j-th atom in the * atomcontainer share a bond, the element i,j in the matrix is set to the * bond order value. Otherwise it is zero. See {@cdk.cite TRI92}. * * @cdk.module standard * @cdk.githash * @cdk.keyword connection matrix * @cdk.dictref blue-obelisk:calculateConnectivityMatrix * * @author steinbeck * @cdk.created 2004-07-04 */ @TestClass("org.openscience.cdk.graph.matrix.ConnectionMatrixTest") public class ConnectionMatrix implements IGraphMatrix { /** * Returns the connection matrix representation of this AtomContainer. * * @param container The AtomContainer for which the matrix is calculated * @return A connection matrix representating this AtomContainer */ @TestMethod("testGetMatrix_IAtomContainer") public static double[][] getMatrix(IAtomContainer container) { IBond bond = null; int indexAtom1; int indexAtom2; double[][] conMat = new double[container.getAtomCount()][container.getAtomCount()]; for (int f = 0; f < container.getBondCount(); f++) { bond = container.getBond(f); indexAtom1 = container.getAtomNumber(bond.getAtom(0)); indexAtom2 = container.getAtomNumber(bond.getAtom(1)); conMat[indexAtom1][indexAtom2] = BondManipulator.destroyBondOrder(bond.getOrder()); conMat[indexAtom2][indexAtom1] = BondManipulator.destroyBondOrder(bond.getOrder()); } return conMat; } } cdk-1.2.10/src/main/org/openscience/cdk/graph/matrix/IGraphMatrix.java100644 0 0 2301 11570154753 22634 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project * * 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. * * 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.graph.matrix; /** * Interface describing a molecular graph matrix calculator. * * @cdk.module interfaces * @cdk.githash * @cdk.keyword graph matrix, molecular * * @author egonw * @cdk.created 2004-07-04 */ public interface IGraphMatrix { } cdk-1.2.10/src/main/org/openscience/cdk/graph/matrix/TopologicalMatrix.java100644 0 0 2006 11570154753 23740 0ustar 0 0 package org.openscience.cdk.graph.matrix; import org.openscience.cdk.graph.PathTools; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.graph.matrix.AdjacencyMatrix; /** * Calculator for a topological matrix representation of this AtomContainer. An * topological matrix is a matrix of quare NxN matrix, where N is the number of * atoms in the AtomContainer. The element i,j of the matrix is the distance between * two atoms in a molecule. * * @author federico * @cdk.githash * */ public class TopologicalMatrix implements IGraphMatrix { /** * Returns the topological matrix for the given AtomContainer. * * @param container The AtomContainer for which the matrix is calculated * @return A topological matrix representating this AtomContainer */ public static int[][] getMatrix(IAtomContainer container) { int[][]conMat = AdjacencyMatrix.getMatrix(container); int[][]TopolDistance = PathTools.computeFloydAPSP(conMat); return TopolDistance; } }cdk-1.2.10/src/main/org/openscience/cdk/graph/rebond/Bspt.java100644 0 0 32413 11570154753 21201 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2003-2007 Miguel Howard * * Contact: cdk-devel@lists.sf.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.graph.rebond; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import java.util.Enumeration; /** * BSP-Tree stands for Binary Space Partitioning Tree. * The tree partitions n-dimensional space (in our case 3) into little * boxes, facilitating searches for things which are *nearby*. * For some useful background info, search the web for "bsp tree faq". * Our application is somewhat simpler because we are storing points instead * of polygons. * *

We are working with three dimensions. For the purposes of the Bspt code * these dimensions are stored as 0, 1, or 2. Each node of the tree splits * along the next dimension, wrapping around to 0. *

 *    mySplitDimension = (parentSplitDimension + 1) % 3;
 * 
* A split value is stored in the node. Values which are <= splitValue are * stored down the left branch. Values which are >= splitValue are stored * down the right branch. When this happens, the search must proceed down * both branches. * Planar and crystaline substructures can generate values which are == along * one dimension. * *

To get a good picture in your head, first think about it in one dimension, * points on a number line. The tree just partitions the points. * Now think about 2 dimensions. The first node of the tree splits the plane * into two rectangles along the x dimension. The second level of the tree * splits the subplanes (independently) along the y dimension into smaller * rectangles. The third level splits along the x dimension. * In three dimensions, we are doing the same thing, only working with * 3-d boxes. * *

Three enumerators are provided *

    *
  • enumNear(Bspt.Tuple center, double distance)
    * returns all the points contained in of all the boxes which are within * distance from the center. *
  • enumSphere(Bspt.Tuple center, double distance)
    * returns all the points which are contained within the sphere (inclusive) * defined by center + distance *
  • enumHemiSphere(Bspt.Tuple center, double distance)
    * same as sphere, but only the points which are greater along the * x dimension *
* * @author Miguel Howard * @cdk.created 2003-05 * * @cdk.module standard * @cdk.githash * @cdk.keyword rebonding * @cdk.keyword Binary Space Partitioning Tree * @cdk.keyword join-the-dots */ @TestClass("org.openscience.cdk.graph.rebond.BsptTest") public final class Bspt { private final static int leafCount = 4; private final static int stackDepth = 64; /* this corresponds to the max height of the tree */ int dimMax; Element eleRoot; /* static double distance(int dim, Tuple t1, Tuple t2) { return Math.sqrt(distance2(dim, t1, t2)); } static double distance2(int dim, Tuple t1, Tuple t2) { double distance2 = 0.0; while (--dim >= 0) { double distT = t1.getDimValue(dim) - t2.getDimValue(dim); distance2 += distT*distT; } return distance2; } */ public Bspt(int dimMax) { this.dimMax = dimMax; this.eleRoot = new Leaf(); } public void addTuple(Tuple tuple) { if (! eleRoot.addTuple(tuple)) { eleRoot = new Node(0, dimMax, (Leaf) eleRoot); if (! eleRoot.addTuple(tuple)) throw new Error("Bspt.addTuple() failed"); } } @TestMethod("testToString") public String toString() { return eleRoot.toString(); } protected void dump() { eleRoot.dump(0); } protected Enumeration enumeration() { return new EnumerateAll(); } class EnumerateAll implements Enumeration { Node[] stack; int sp; int i; Leaf leaf; EnumerateAll() { stack = new Node[stackDepth]; sp = 0; Element ele = eleRoot; while (ele instanceof Node) { Node node = (Node) ele; if (sp == stackDepth) throw new Error("Bspt.EnumerateAll tree stack overflow"); stack[sp++] = node; ele = node.eleLE; } leaf = (Leaf)ele; i = 0; } public boolean hasMoreElements() { return (i < leaf.count) || (sp > 0); } public Object nextElement() { if (i == leaf.count) { // logger.debug("-->" + stack[sp-1].splitValue); Element ele = stack[--sp].eleGE; while (ele instanceof Node) { Node node = (Node) ele; stack[sp++] = node; ele = node.eleLE; } leaf = (Leaf)ele; i = 0; } return leaf.tuples[i++]; } } protected Enumeration enumNear(Tuple center, double distance) { return new EnumerateNear(center, distance); } class EnumerateNear implements Enumeration { Node[] stack; int sp; int i; Leaf leaf; double distance; Tuple center; EnumerateNear(Tuple center, double distance) { this.distance = distance; this.center = center; stack = new Node[stackDepth]; sp = 0; Element ele = eleRoot; while (ele instanceof Node) { Node node = (Node) ele; if (center.getDimValue(node.dim) - distance <= node.splitValue) { if (sp == stackDepth) throw new Error("Bspt.EnumerateNear tree stack overflow"); stack[sp++] = node; ele = node.eleLE; } else { ele = node.eleGE; } } leaf = (Leaf)ele; i = 0; } public boolean hasMoreElements() { if (i < leaf.count) return true; if (sp == 0) return false; Element ele = stack[--sp]; while (ele instanceof Node) { Node node = (Node) ele; if (center.getDimValue(node.dim) + distance < node.splitValue) { if (sp == 0) return false; ele = stack[--sp]; } else { ele = node.eleGE; while (ele instanceof Node) { Node nodeLeft = (Node) ele; stack[sp++] = nodeLeft; ele = nodeLeft.eleLE; } } } leaf = (Leaf)ele; i = 0; return true; } public Object nextElement() { return leaf.tuples[i++]; } } protected EnumerateSphere enumSphere(Tuple center, double distance) { return new EnumerateSphere(center, distance, false); } protected EnumerateSphere enumHemiSphere(Tuple center, double distance) { return new EnumerateSphere(center, distance, true); } class EnumerateSphere implements Enumeration { Node[] stack; int sp; int i; Leaf leaf; double distance; double distance2; Tuple center; double centerValues[]; double foundDistance2; // the dist squared of a found Element; // when set, only the hemisphere sphere .GT. or .EQ. the point // (on the first dim) is returned boolean tHemisphere; EnumerateSphere(Tuple center, double distance, boolean tHemisphere) { this.distance = distance; this.distance2 = distance*distance; this.center = center; this.tHemisphere = tHemisphere; centerValues = new double[dimMax]; for (int dim = dimMax; --dim >= 0; ) centerValues[dim] = center.getDimValue(dim); stack = new Node[stackDepth]; sp = 0; Element ele = eleRoot; while (ele instanceof Node) { Node node = (Node) ele; if (center.getDimValue(node.dim) - distance <= node.splitValue) { if (sp == stackDepth) throw new Error("Bspt.EnumerateSphere tree stack overflow"); stack[sp++] = node; ele = node.eleLE; } else { ele = node.eleGE; } } leaf = (Leaf)ele; i = 0; } private boolean isWithin(Tuple t) { double dist2; double distT; distT = t.getDimValue(0) - centerValues[0]; if (tHemisphere && distT < 0) { return false; } dist2 = distT * distT; if (dist2 > distance2) { return false; } for (int dim = dimMax; --dim > 0; ) { distT = t.getDimValue(dim) - centerValues[dim]; dist2 += distT*distT; if (dist2 > distance2) { return false; } } this.foundDistance2 = dist2; return true; } public boolean hasMoreElements() { while (true) { for ( ; i < leaf.count; ++i) if (isWithin(leaf.tuples[i])) return true; if (sp == 0) return false; Element ele = stack[--sp]; while (ele instanceof Node) { Node node = (Node) ele; if (center.getDimValue(node.dim) + distance < node.splitValue) { if (sp == 0) return false; ele = stack[--sp]; } else { ele = node.eleGE; while (ele instanceof Node) { Node nodeLeft = (Node) ele; stack[sp++] = nodeLeft; ele = nodeLeft.eleLE; } } } leaf = (Leaf)ele; i = 0; } } public Object nextElement() { return leaf.tuples[i++]; } public double foundDistance2() { return foundDistance2; } } public interface Tuple { public double getDimValue(int dim); } interface Element { boolean addTuple(Tuple tuple); void dump(int level); boolean isLeafWithSpace(); } class Node implements Element { Element eleLE; int dim; int dimMax; double splitValue; Element eleGE; Node(int dim, int dimMax, Leaf leafLE) { this.eleLE = leafLE; this.dim = dim; this.dimMax = dimMax; this.splitValue = leafLE.getSplitValue(dim); this.eleGE = new Leaf(leafLE, dim, splitValue); } public boolean addTuple(Tuple tuple) { if (tuple.getDimValue(dim) < splitValue) { if (eleLE.addTuple(tuple)) return true; eleLE = new Node((dim + 1) % dimMax, dimMax, (Leaf)eleLE); return eleLE.addTuple(tuple); } if (tuple.getDimValue(dim) > splitValue) { if (eleGE.addTuple(tuple)) return true; eleGE = new Node((dim + 1) % dimMax, dimMax, (Leaf)eleGE); return eleGE.addTuple(tuple); } if (eleLE.isLeafWithSpace()) eleLE.addTuple(tuple); else if (eleGE.isLeafWithSpace()) eleGE.addTuple(tuple); else if (eleLE instanceof Node) eleLE.addTuple(tuple); else if (eleGE instanceof Node) eleGE.addTuple(tuple); else { eleLE = new Node((dim + 1) % dimMax, dimMax, (Leaf)eleLE); return eleLE.addTuple(tuple); } return true; } public String toString() { return eleLE.toString() + dim + ":" + splitValue + "\n" + eleGE.toString(); } public void dump(int level) { System.out.println(""); eleLE.dump(level + 1); for (int i = 0; i < level; ++i) System.out.print("-"); System.out.println(">" + splitValue); eleGE.dump(level + 1); } public boolean isLeafWithSpace() { return false; } } class Leaf implements Element { int count; Tuple[] tuples; Leaf() { count = 0; tuples = new Tuple[leafCount]; } Leaf(Leaf leaf, int dim, double splitValue) { this(); for (int i = leafCount; --i >= 0; ) { Tuple tuple = leaf.tuples[i]; double value = tuple.getDimValue(dim); if (value > splitValue || (value == splitValue && ((i & 1) == 1))) { leaf.tuples[i] = null; tuples[count++] = tuple; } } int dest = 0; for (int src = 0; src < leafCount; ++src) if (leaf.tuples[src] != null) leaf.tuples[dest++] = leaf.tuples[src]; leaf.count = dest; if (count == 0) tuples[leafCount] = null; // explode } public double getSplitValue(int dim) { if (count != leafCount) tuples[leafCount] = null; return (tuples[0].getDimValue(dim) + tuples[leafCount - 1].getDimValue(dim)) / 2; } public String toString() { return "leaf:" + count + "\n"; } public boolean addTuple(Tuple tuple) { if (count == leafCount) return false; tuples[count++] = tuple; return true; } public void dump(int level) { for (int i = 0; i < count; ++i) { Tuple t = tuples[i]; for (int j = 0; j < level; ++j) System.out.print("."); for (int dim = 0; dim < dimMax-1; ++dim) System.out.print("" + t.getDimValue(dim) + ","); System.out.println("" + t.getDimValue(dimMax - 1)); } } public boolean isLeafWithSpace() { return count < leafCount; } } } cdk-1.2.10/src/main/org/openscience/cdk/graph/rebond/Point.java100644 0 0 3154 11570154753 21342 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2003-2007 Miguel Howard * * Contact: cdk-devel@lists.sf.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.graph.rebond; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; /** * @author Miguel Howard * @cdk.created 2003-05 * @cdk.module standard * @cdk.githash */ @TestClass("org.openscience.cdk.graph.rebond.PointTest") public class Point implements Bspt.Tuple { double x; double y; double z; public Point(double x, double y, double z) { this.x = x; this.y = y; this.z = z; } @TestMethod("testGetDimValue_int") public double getDimValue(int dim) { if (dim == 0) return x; if (dim == 1) return y; return z; } @TestMethod("testToString") public String toString() { return "<" + x + "," + y + "," + z + ">"; } } cdk-1.2.10/src/main/org/openscience/cdk/graph/rebond/RebondTool.java100644 0 0 13250 11570154753 22336 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2003-2007 Miguel Howard * * 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 org.openscience.cdk.graph.rebond; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; import java.util.Iterator; /** * Provides tools to rebond a molecule from 3D coordinates only. * The algorithm uses an efficient algorithm using a * Binary Space Partitioning Tree (Bspt). It requires that the * atom types are configured such that the covalent bond radii * for all atoms are set. The AtomTypeFactory can be used for this. * * @cdk.keyword rebonding * @cdk.keyword bond, recalculation * @cdk.dictref blue-obelisk:rebondFrom3DCoordinates * * @author Miguel Howard * @cdk.created 2003-05-23 * @cdk.module standard * @cdk.githash * * @see org.openscience.cdk.graph.rebond.Bspt */ @TestClass("org.openscience.cdk.graph.rebond.RebondToolTest") public class RebondTool { private double maxCovalentRadius; private double minBondDistance; private double bondTolerance; private Bspt bspt; public RebondTool(double maxCovalentRadius, double minBondDistance, double bondTolerance) { this.maxCovalentRadius = maxCovalentRadius; this.bondTolerance = bondTolerance; this.minBondDistance = minBondDistance; this.bspt = null; } /** * Rebonding using a Binary Space Partition Tree. Note, that any bonds * defined will be deleted first. It assumes the unit of 3D space to * be 1 Âle;ngstrom. */ @TestMethod("testRebond_IAtomContainer") public void rebond(IAtomContainer container) throws CDKException { container.removeAllBonds(); maxCovalentRadius = 0.0; // construct a new binary space partition tree bspt = new Bspt(3); Iterator atoms = container.atoms().iterator(); while (atoms.hasNext()) { IAtom atom = atoms.next(); double myCovalentRadius = atom.getCovalentRadius(); if (myCovalentRadius == 0.0) { throw new CDKException("Atom(s) does not have covalentRadius defined."); } if (myCovalentRadius > maxCovalentRadius) maxCovalentRadius = myCovalentRadius; TupleAtom tupleAtom = new TupleAtom(atom); bspt.addTuple(tupleAtom); } // rebond all atoms atoms = container.atoms().iterator(); while (atoms.hasNext()) { bondAtom(container, (IAtom)atoms.next()); } } /** * Rebonds one atom by looking up nearby atom using the binary space partition tree. */ private void bondAtom(IAtomContainer container, IAtom atom) { double myCovalentRadius = atom.getCovalentRadius(); double searchRadius = myCovalentRadius + maxCovalentRadius + bondTolerance; Point tupleAtom = new Point(atom.getPoint3d().x, atom.getPoint3d().y, atom.getPoint3d().z); for (Bspt.EnumerateSphere e = bspt.enumHemiSphere(tupleAtom, searchRadius); e.hasMoreElements(); ) { IAtom atomNear = ((TupleAtom)e.nextElement()).getAtom(); if (atomNear != atom && container.getBond(atom, atomNear) == null) { boolean bonded = isBonded(myCovalentRadius, atomNear.getCovalentRadius(), e.foundDistance2()); if (bonded) { IBond bond = atom.getBuilder().newBond(atom, atomNear, IBond.Order.SINGLE); container.addBond(bond); } } } } /** * Returns the bond order for the bond. At this moment, it only returns * 0 or 1, but not 2 or 3, or aromatic bond order. */ private boolean isBonded(double covalentRadiusA, double covalentRadiusB, double distance2) { double maxAcceptable = covalentRadiusA + covalentRadiusB + bondTolerance; double maxAcceptable2 = maxAcceptable * maxAcceptable; double minBondDistance2 = this.minBondDistance*this.minBondDistance; if (distance2 < minBondDistance2) return false; return distance2 <= maxAcceptable2; } class TupleAtom implements Bspt.Tuple { IAtom atom; TupleAtom(IAtom atom) { this.atom = atom; } public double getDimValue(int dim) { if (dim == 0) return atom.getPoint3d().x; if (dim == 1) return atom.getPoint3d().y; return atom.getPoint3d().z; } public IAtom getAtom() { return this.atom; } public String toString() { return ("<" + atom.getPoint3d().x + "," + atom.getPoint3d().y + "," + atom.getPoint3d().z + ">"); } } } cdk-1.2.10/src/main/org/openscience/cdk/inchi/InChIGenerator.java100644 0 0 40102 11570154753 21604 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2006-2007 Sam Adams * * 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. * * 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.inchi; import net.sf.jniinchi.*; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.IsotopeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomParity; import org.openscience.cdk.interfaces.IBond; import javax.vecmath.Point2d; import javax.vecmath.Point3d; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; /** *

This class generates the IUPAC International Chemical Identifier (InChI) for * a CDK IAtomContainer. It places calls to a JNI wrapper for the InChI C++ library. * *

If the atom container has 3D coordinates for all of its atoms then they * will be used, otherwise 2D coordinates will be used if available. * *

Spin multiplicities and some aspects of stereochemistry are not * currently handled completely. * *

Example usage

* * // Generate factory - throws CDKException if native code does not load
* InChIGeneratorFactory factory = new InChIGeneratorFactory();
* // Get InChIGenerator
* InChIGenerator gen = factory.getInChIGenerator(container);
*
* INCHI_RET ret = gen.getReturnStatus();
* if (ret == INCHI_RET.WARNING) {
* // InChI generated, but with warning message
* System.out.println("InChI warning: " + gen.getMessage());
* } else if (ret != INCHI_RET.OKAY) {
* // InChI generation failed
* throw new CDKException("InChI failed: " + ret.toString()
* + " [" + gen.getMessage() + "]");
* }
*
* String inchi = gen.getInchi();
* String auxinfo = gen.getAuxInfo();
*

* TODO: distinguish between singlet and undefined spin multiplicity
* TODO: double bond and allene parities
* TODO: problem recognising bond stereochemistry
*
* * @author Sam Adams * * @cdk.module inchi * @cdk.githash */ @TestClass("org.openscience.cdk.inchi.InChIGeneratorTest") public class InChIGenerator { protected JniInchiInput input; protected JniInchiOutput output; /** * AtomContainer instance refers to. */ protected IAtomContainer atomContainer; /** *

Constructor. Generates InChI from CDK AtomContainer. * *

Reads atoms, bonds etc from atom container and converts to format * InChI library requires, then calls the library. * * @param atomContainer AtomContainer to generate InChI for. * @throws org.openscience.cdk.exception.CDKException if there is an * error during InChI generation */ @TestClass("testGetInchiFromChlorineAtom,testGetInchiFromLithiumIontestGetInchiFromChlorine37Atom") protected InChIGenerator(IAtomContainer atomContainer) throws CDKException { try { input = new JniInchiInput(""); generateInchiFromCDKAtomContainer(atomContainer); } catch (JniInchiException jie) { throw new CDKException("InChI generation failed: " + jie.getMessage(), jie); } } /** *

Constructor. Generates InChI from CDK AtomContainer. * *

Reads atoms, bonds etc from atom container and converts to format * InChI library requires, then calls the library. * * @param atomContainer AtomContainer to generate InChI for. * @param options Space delimited string of options to pass to InChI library. * Each option may optionally be preceded by a command line * switch (/ or -). * @throws CDKException */ protected InChIGenerator(IAtomContainer atomContainer, String options) throws CDKException { try { input = new JniInchiInput(options); generateInchiFromCDKAtomContainer(atomContainer); } catch (JniInchiException jie) { throw new CDKException("InChI generation failed: " + jie.getMessage(), jie); } } /** *

Constructor. Generates InChI from CDK AtomContainer. * *

Reads atoms, bonds etc from atom container and converts to format * InChI library requires, then calls the library. * * @param atomContainer AtomContainer to generate InChI for. * @param options List of INCHI_OPTION. * @throws CDKException */ protected InChIGenerator(IAtomContainer atomContainer, List options) throws CDKException { try { input = new JniInchiInput(options); generateInchiFromCDKAtomContainer(atomContainer); } catch (JniInchiException jie) { throw new CDKException("InChI generation failed: " + jie.getMessage(), jie); } } /** *

Reads atoms, bonds etc from atom container and converts to format * InChI library requires, then places call for the library to generate * the InChI. * * @param atomContainer AtomContainer to generate InChI for. * @throws CDKException */ private void generateInchiFromCDKAtomContainer(IAtomContainer atomContainer) throws CDKException { this.atomContainer = atomContainer; Iterator atoms = atomContainer.atoms().iterator(); // Check for 3d coordinates boolean all3d = true; boolean all2d = true; while (atoms.hasNext()) { IAtom atom = (IAtom)atoms.next(); if (atom.getPoint3d() == null) { all3d = false; } if (atom.getPoint2d() == null) { all2d = false; } } // Process atoms IsotopeFactory ifact = null; try { ifact = IsotopeFactory.getInstance(atomContainer.getBuilder()); } catch (Exception e) { // Do nothing } Map atomMap = new HashMap(); atoms = atomContainer.atoms().iterator(); while (atoms.hasNext()) { IAtom atom = atoms.next(); // Get coordinates // Use 3d if possible, otherwise 2d or none double x, y, z; if (all3d) { Point3d p = atom.getPoint3d(); x = p.x; y = p.y; z = p.z; } else if (all2d) { Point2d p = atom.getPoint2d(); x = p.x; y = p.y; z = 0.0; } else { x = 0.0; y = 0.0; z = 0.0; } // Chemical element symbol String el = atom.getSymbol(); // Generate InChI atom JniInchiAtom iatom = input.addAtom(new JniInchiAtom(x, y, z, el)); atomMap.put(atom, iatom); // Check if charged int charge = atom.getFormalCharge(); if (charge != 0) { iatom.setCharge(charge); } // Check whether isotopic Integer isotopeNumber = atom.getMassNumber(); if (isotopeNumber != CDKConstants.UNSET && ifact != null) { IAtom isotope = atomContainer.getBuilder().newAtom(el); ifact.configure(isotope); if (isotope.getMassNumber().intValue() == isotopeNumber.intValue()) { isotopeNumber = 0; } } if (isotopeNumber != CDKConstants.UNSET) { iatom.setIsotopicMass(isotopeNumber); } // Check for implicit hydrogens // atom.getHydrogenCount() returns number of implict hydrogens, not // total number // Ref: Posting to cdk-devel list by Egon Willighagen 2005-09-17 Integer implicitH = atom.getHydrogenCount(); if (implicitH == CDKConstants.UNSET) implicitH = 0; if (implicitH != 0) { iatom.setImplicitH(implicitH); } // Check if radical int count = atomContainer.getConnectedSingleElectronsCount(atom); if (count == 0) { // TODO - how to check whether singlet or undefined multiplicity } else if (count == 1) { iatom.setRadical(INCHI_RADICAL.DOUBLET); } else if (count == 2) { iatom.setRadical(INCHI_RADICAL.TRIPLET); } else { throw new CDKException("Unrecognised radical type"); } } // Process bonds Iterator bonds = atomContainer.bonds().iterator(); while (bonds.hasNext()) { IBond bond = bonds.next(); // Assumes 2 centre bond JniInchiAtom at0 = (JniInchiAtom) atomMap.get(bond.getAtom(0)); JniInchiAtom at1 = (JniInchiAtom) atomMap.get(bond.getAtom(1)); // Get bond order INCHI_BOND_TYPE order; IBond.Order bo = bond.getOrder(); if (bond.getFlag(CDKConstants.ISAROMATIC)) { order = INCHI_BOND_TYPE.ALTERN; } else if (bo == CDKConstants.BONDORDER_SINGLE) { order = INCHI_BOND_TYPE.SINGLE; } else if (bo == CDKConstants.BONDORDER_DOUBLE) { order = INCHI_BOND_TYPE.DOUBLE; } else if (bo == CDKConstants.BONDORDER_TRIPLE) { order = INCHI_BOND_TYPE.TRIPLE; } else { throw new CDKException("Failed to generate InChI: Unsupported bond type"); } // Create InChI bond JniInchiBond ibond = new JniInchiBond(at0, at1, order); input.addBond(ibond); // Check for bond stereo definitions int stereo = bond.getStereo(); // No stereo definition if (stereo == CDKConstants.STEREO_BOND_NONE) { ibond.setStereoDefinition(INCHI_BOND_STEREO.NONE); } // Bond ending (fat end of wedge) below the plane else if (stereo == CDKConstants.STEREO_BOND_DOWN) { ibond.setStereoDefinition(INCHI_BOND_STEREO.SINGLE_1DOWN); } // Bond ending (fat end of wedge) above the plane else if (stereo == CDKConstants.STEREO_BOND_UP) { ibond.setStereoDefinition(INCHI_BOND_STEREO.SINGLE_1UP); } // Bond starting (pointy end of wedge) below the plane else if (stereo == CDKConstants.STEREO_BOND_DOWN_INV) { ibond.setStereoDefinition(INCHI_BOND_STEREO.SINGLE_2DOWN); } // Bond starting (pointy end of wedge) above the plane else if (stereo == CDKConstants.STEREO_BOND_UP_INV) { ibond.setStereoDefinition(INCHI_BOND_STEREO.SINGLE_2UP); } // Bond with undefined stereochemistry else if (stereo == CDKConstants.STEREO_BOND_UNDEFINED) { if (order == INCHI_BOND_TYPE.SINGLE) { ibond.setStereoDefinition(INCHI_BOND_STEREO.SINGLE_1EITHER); } else if (order == INCHI_BOND_TYPE.DOUBLE) { ibond.setStereoDefinition(INCHI_BOND_STEREO.DOUBLE_EITHER); } } } // Process atom parities (tetrahedral InChI Stereo0D Parities) atoms = atomContainer.atoms().iterator(); while (atoms.hasNext()) { IAtom atom = atoms.next(); IAtomParity parity = atomContainer.getAtomParity(atom); if (parity != null) { IAtom[] surroundingAtoms = parity.getSurroundingAtoms(); int sign = parity.getParity(); JniInchiAtom atC = (JniInchiAtom) atomMap.get(atom); JniInchiAtom at0 = (JniInchiAtom) atomMap.get(surroundingAtoms[0]); JniInchiAtom at1 = (JniInchiAtom) atomMap.get(surroundingAtoms[1]); JniInchiAtom at2 = (JniInchiAtom) atomMap.get(surroundingAtoms[2]); JniInchiAtom at3 = (JniInchiAtom) atomMap.get(surroundingAtoms[3]); INCHI_PARITY p = INCHI_PARITY.UNKNOWN; if (sign > 0) { p = INCHI_PARITY.EVEN; } else if (sign < 0) { p = INCHI_PARITY.ODD; } else { throw new CDKException("Atom parity of zero"); } input.addStereo0D(new JniInchiStereo0D(atC, at0, at1, at2, at3, INCHI_STEREOTYPE.TETRAHEDRAL, p)); } } try { output = JniInchiWrapper.getInchi(input); } catch (JniInchiException jie) { throw new CDKException("Failed to generate InChI: " + jie.getMessage(), jie); } } /** * Gets return status from InChI process. OKAY and WARNING indicate * InChI has been generated, in all other cases InChI generation * has failed. */ @TestMethod("testGetInchiFromLandDAlanine3D,testGetInchiEandZ12Dichloroethene2D") public INCHI_RET getReturnStatus() { return(output.getReturnStatus()); } /** * Gets generated InChI string. */ @TestMethod("testGetInchiEandZ12Dichloroethene2D,testGetInchiFromEthyne,testGetInchiFromEthene") public String getInchi() { return(output.getInchi()); } /** * Gets generated InChIKey string. */ @TestMethod("testGetInchiFromEthane") public String getInchiKey() throws CDKException { JniInchiOutputKey key; try { key = JniInchiWrapper.getInChIKey(output.getInchi()); if (key.getReturnStatus() == INCHI_KEY.OK) { return key.getKey(); } else { throw new CDKException("Error while creating InChIKey: " + key.getReturnStatus()); } } catch (JniInchiException exception) { throw new CDKException("Error while creating InChIKey: " + exception.getMessage(), exception); } } /** * Gets auxillary information. */ public String getAuxInfo() { return(output.getAuxInfo()); } /** * Gets generated (error/warning) messages. */ public String getMessage() { return(output.getMessage()); } /** * Gets generated log. */ public String getLog() { return(output.getLog()); } } cdk-1.2.10/src/main/org/openscience/cdk/inchi/InChIGeneratorFactory.java100644 0 0 14072 11570154753 23143 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2006-2007 Sam Adams * * 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. * * 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.inchi; import net.sf.jniinchi.JniInchiWrapper; import net.sf.jniinchi.LoadNativeLibraryException; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IChemObjectBuilder; import java.util.List; /** *

Factory providing access to InChIGenerator and InChIToStructure. See those * classes for examples of use. These methods make use of the JNI-InChI library. * *

InChI/Structure interconversion is implemented in this way so that we can * check whether or not the native code required is available. If the native * code cannot be loaded a CDKException will be thrown when the constructor * is called. The most common problem is that the native code is not in the * the correct location. Java searches the locations in the PATH environmental * variable, under Windows, and LD_LIBRARY_PATH under Linux, so the JNI-InChI * native libraries must be in one of these locations. If the JNI-InChI jar file * is being used and either the current working directory, or '.' are contained * in PATH of LD_LIBRARY_PATH then the native code should be placed * automatically. If the native files are in the correct location but fail to * load, then they may need to be recompiled for your system. See: *

    *
  • http://sourceforge.net/projects/jni-inchi *
  • http://www.iupac.org/inchi/ *
* * @author Sam Adams * * @cdk.module inchi * @cdk.githash */ public class InChIGeneratorFactory { /** *

Constructor for InChIGeneratorFactory. Ensures that native code * required for InChI/Structure interconversion is available, otherwise * throws CDKException. * * @throws CDKException if unable to load native code */ public InChIGeneratorFactory() throws CDKException { try { JniInchiWrapper.loadLibrary(); } catch (LoadNativeLibraryException lnle) { throw new CDKException("Unable to load native code; " + lnle.getMessage(), lnle); } } /** * Gets InChI generator for CDK IAtomContainer. * * @param container AtomContainer to generate InChI for. * @return the InChI generator object * @throws CDKException if the generator cannot be instantiated */ public InChIGenerator getInChIGenerator(IAtomContainer container) throws CDKException { return(new InChIGenerator(container)); } /** * Gets InChI generator for CDK IAtomContainer. * * @param container AtomContainer to generate InChI for. * @param options String of options for InChI generation. * @return the InChI generator object * @throws CDKException if the generator cannot be instantiated */ public InChIGenerator getInChIGenerator(IAtomContainer container, String options) throws CDKException { return(new InChIGenerator(container, options)); } /** * Gets InChI generator for CDK IAtomContainer. * * @param container AtomContainer to generate InChI for. * @param options List of options (net.sf.jniinchi.INCHI_OPTION) for InChI generation. * @return the InChI generator object * @throws CDKException if the generator cannot be instantiated */ public InChIGenerator getInChIGenerator(IAtomContainer container, List options) throws CDKException { return(new InChIGenerator(container, options)); } /** * Gets structure generator for an InChI string. * * @param inchi InChI to generate structure from. * @param builder the builder to use * @return the InChI structure generator object * @throws CDKException if the generator cannot be instantiated */ public InChIToStructure getInChIToStructure(String inchi, IChemObjectBuilder builder) throws CDKException { return(new InChIToStructure(inchi, builder)); } /** *

Gets structure generator for an InChI string. * * @param inchi InChI to generate structure from. * @param builder the builder to employ * @param options String of options for structure generation. * @return the InChI structure generator object * @throws CDKException if the generator cannot be instantiated */ public InChIToStructure getInChIToStructure(String inchi, IChemObjectBuilder builder, String options) throws CDKException { return(new InChIToStructure(inchi, builder, options)); } /** *

Gets structure generator for an InChI string. * * @param inchi InChI to generate structure from. * @param options List of options (net.sf.jniinchi.INCHI_OPTION) for structure generation. * @param builder the builder to employ * @return the InChI structure generator object * @throws CDKException if the generator cannot be instantiated */ public InChIToStructure getInChIToStructure(String inchi, IChemObjectBuilder builder, List options) throws CDKException { return(new InChIToStructure(inchi, builder, options)); } } cdk-1.2.10/src/main/org/openscience/cdk/inchi/InChIToStructure.java100644 0 0 26317 11570154753 22175 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2006-2007 Sam Adams * * 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. * * 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.inchi; import net.sf.jniinchi.*; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomParity; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObjectBuilder; import java.util.HashMap; import java.util.List; import java.util.Map; /** *

This class generates a CDK IAtomContainer from an InChI string. It places * calls to a JNI wrapper for the InChI C++ library. * *

The generated IAtomContainer will have all 2D and 3D coordinates set to 0.0, * but may have atom parities set. Double bond and allene stereochemistry are * not currently recorded. * *

Example usage

* * // Generate factory - throws CDKException if native code does not load
* InChIGeneratorFactory factory = new InChIGeneratorFactory();
* // Get InChIToStructure
* InChIToStructure intostruct = factory.getInChIToStructure(
* inchi, DefaultChemObjectBuilder.getInstance()
* );
*
* INCHI_RET ret = intostruct.getReturnStatus();
* if (ret == INCHI_RET.WARNING) {
* // Structure generated, but with warning message
* System.out.println("InChI warning: " + intostruct.getMessage());
* } else if (ret != INCHI_RET.OKAY) {
* // Structure generation failed
* throw new CDKException("Structure generation failed failed: " + ret.toString()
* + " [" + intostruct.getMessage() + "]");
* }
*
* IAtomContainer container = intostruct.getAtomContainer();
*

* * @author Sam Adams * * @cdk.module inchi * @cdk.githash */ public class InChIToStructure { protected JniInchiInputInchi input; protected JniInchiOutputStructure output; protected IAtomContainer molecule; /** * Constructor. Generates CDK AtomContainer from InChI. * @param inchi * @throws CDKException */ protected InChIToStructure(String inchi, IChemObjectBuilder builder) throws CDKException { try { input = new JniInchiInputInchi(inchi, ""); } catch (JniInchiException jie) { throw new CDKException("Failed to convert InChI to molecule: " + jie.getMessage(), jie); } generateAtomContainerFromInchi(builder); } /** * Constructor. Generates CMLMolecule from InChI. * @param inchi * @param options * @throws CDKException */ protected InChIToStructure(String inchi, IChemObjectBuilder builder, String options) throws CDKException { try { input = new JniInchiInputInchi(inchi, options); } catch (JniInchiException jie) { throw new CDKException("Failed to convert InChI to molecule: " + jie.getMessage(), jie); } generateAtomContainerFromInchi(builder); } /** * Constructor. Generates CMLMolecule from InChI. * @param inchi * @param options * @throws CDKException */ protected InChIToStructure(String inchi, IChemObjectBuilder builder, List options) throws CDKException { try { input = new JniInchiInputInchi(inchi, options); } catch (JniInchiException jie) { throw new CDKException("Failed to convert InChI to molecule: " + jie.getMessage()); } generateAtomContainerFromInchi(builder); } /** * Gets structure from InChI, and converts InChI library data structure * into an IAtomContainer. * * @throws CDKException */ protected void generateAtomContainerFromInchi(IChemObjectBuilder builder) throws CDKException { try { output = JniInchiWrapper.getStructureFromInchi(input); } catch (JniInchiException jie) { throw new CDKException("Failed to convert InChI to molecule: " + jie.getMessage(), jie); } //molecule = new AtomContainer(); molecule = builder.newAtomContainer(); Map inchiCdkAtomMap = new HashMap(); for (int i = 0; i < output.getNumAtoms(); i ++) { JniInchiAtom iAt = output.getAtom(i); IAtom cAt = builder.newAtom(); inchiCdkAtomMap.put(iAt, cAt); cAt.setID("a" + i); cAt.setSymbol(iAt.getElementType()); // Ignore coordinates - all zero int charge = iAt.getCharge(); if (charge != 0) { cAt.setFormalCharge(charge); } // hydrogenCount contains number of implict hydrogens, not // total number // Ref: Posting to cdk-devel list by Egon Willighagen 2005-09-17 int numH = iAt.getImplicitH(); if (numH != 0) { cAt.setHydrogenCount(numH); } molecule.addAtom(cAt); } for (int i = 0; i < output.getNumBonds(); i ++) { JniInchiBond iBo = output.getBond(i); IBond cBo = builder.newBond(); IAtom atO = inchiCdkAtomMap.get(iBo.getOriginAtom()); IAtom atT = inchiCdkAtomMap.get(iBo.getTargetAtom()); IAtom[] atoms = new IAtom[2]; atoms[0] = atO; atoms[1] = atT; cBo.setAtoms(atoms); INCHI_BOND_TYPE type = iBo.getBondType(); if (type == INCHI_BOND_TYPE.SINGLE) { cBo.setOrder(CDKConstants.BONDORDER_SINGLE); } else if (type == INCHI_BOND_TYPE.DOUBLE) { cBo.setOrder(CDKConstants.BONDORDER_DOUBLE); } else if (type == INCHI_BOND_TYPE.TRIPLE) { cBo.setOrder(CDKConstants.BONDORDER_TRIPLE); } else if (type == INCHI_BOND_TYPE.ALTERN) { cBo.setFlag(CDKConstants.ISAROMATIC, true); } else { throw new CDKException("Unknown bond type: " + type); } INCHI_BOND_STEREO stereo = iBo.getBondStereo(); // No stereo definition if (stereo == INCHI_BOND_STEREO.NONE) { cBo.setStereo(CDKConstants.STEREO_BOND_NONE); } // Bond ending (fat end of wedge) below the plane else if (stereo == INCHI_BOND_STEREO.SINGLE_1DOWN) { cBo.setStereo(CDKConstants.STEREO_BOND_DOWN); } // Bond ending (fat end of wedge) above the plane else if (stereo == INCHI_BOND_STEREO.SINGLE_1UP) { cBo.setStereo(CDKConstants.STEREO_BOND_UP); } // Bond starting (pointy end of wedge) below the plane else if (stereo == INCHI_BOND_STEREO.SINGLE_2DOWN) { cBo.setStereo(CDKConstants.STEREO_BOND_DOWN_INV); } // Bond starting (pointy end of wedge) above the plane else if (stereo == INCHI_BOND_STEREO.SINGLE_2UP) { cBo.setStereo(CDKConstants.STEREO_BOND_UP_INV); } // Bond with undefined stereochemistry else if (stereo == INCHI_BOND_STEREO.SINGLE_1EITHER || stereo == INCHI_BOND_STEREO.DOUBLE_EITHER) { cBo.setStereo(CDKConstants.STEREO_BOND_UNDEFINED); } molecule.addBond(cBo); } for (int i = 0; i < output.getNumStereo0D(); i ++) { JniInchiStereo0D stereo0d = output.getStereo0D(i); if (stereo0d.getStereoType() == INCHI_STEREOTYPE.TETRAHEDRAL) { JniInchiAtom central = stereo0d.getCentralAtom(); JniInchiAtom[] neighbours = stereo0d.getNeighbors(); IAtom atC = (IAtom) inchiCdkAtomMap.get(central); IAtom at0 = (IAtom) inchiCdkAtomMap.get(neighbours[0]); IAtom at1 = (IAtom) inchiCdkAtomMap.get(neighbours[1]); IAtom at2 = (IAtom) inchiCdkAtomMap.get(neighbours[2]); IAtom at3 = (IAtom) inchiCdkAtomMap.get(neighbours[3]); int sign; if (stereo0d.getParity() == INCHI_PARITY.ODD) { sign = -1; } else if (stereo0d.getParity() == INCHI_PARITY.EVEN) { sign = +1; } else { // CDK Only supports parities of + or - continue; } IAtomParity parity = builder.newAtomParity(atC, at0, at1, at2, at3, sign); molecule.addAtomParity(parity); } else { // TODO - other types of atom parity - double bond, etc } } } /** * Returns generated molecule. * @return An AtomContainer object */ public IAtomContainer getAtomContainer() { return(molecule); } /** * Gets return status from InChI process. OKAY and WARNING indicate * InChI has been generated, in all other cases InChI generation * has failed. */ public INCHI_RET getReturnStatus() { return(output.getReturnStatus()); } /** * Gets generated (error/warning) messages. */ public String getMessage() { return(output.getMessage()); } /** * Gets generated log. */ public String getLog() { return(output.getLog()); } /** *

Returns warning flags, see INCHIDIFF in inchicmp.h. * *

[x][y]: *
x=0 => Reconnected if present in InChI otherwise Disconnected/Normal *
x=1 => Disconnected layer if Reconnected layer is present *
y=1 => Main layer or Mobile-H *
y=0 => Fixed-H layer */ public long[][] getWarningFlags() { return(output.getWarningFlags()); } } cdk-1.2.10/src/main/org/openscience/cdk/index/CASNumber.java100644 0 0 7145 11570154753 20571 0ustar 0 0 /* * $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.index; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import java.util.regex.Matcher; import java.util.regex.Pattern; /** * Tools to work with CAS registry numbers. * *

References: *

*

* * @author Egon Willighagen * @cdk.githash * @author Nathanaël "M.Le_maudit" Mazuir * * @see CAS website * * @cdk.created 2003-06-30 * @cdk.keyword CAS number * @cdk.require java1.4+ */ @TestClass("org.openscience.cdk.index.CASNumberTest") public class CASNumber { /** * Checks whether the registry number is valid. * * @param casNumber the CAS number to validate * @cdk.keyword CAS number * @cdk.keyword validation * @return true if a valid CAS number, false otherwise */ @TestMethod("testInvalidCheckDigits,testValidNumbers") public static boolean isValid(String casNumber) { boolean overall = true; /* * check format */ String format = "^(\\d+)-(\\d\\d)-(\\d)$"; Pattern pattern = Pattern.compile(format); Matcher matcher = pattern.matcher(casNumber); overall = overall && matcher.matches(); if (matcher.matches()) { /* * check number */ String part1 = matcher.group(1); String part2 = matcher.group(2); String part3 = matcher.group(3); int part1value = Integer.parseInt(part1); if (part1value < 50) { overall = false; // CAS numbers start at 50-00-0 } else { int digit = CASNumber.calculateCheckDigit(part1, part2); overall = overall && (digit == Integer.parseInt(part3)); } } return overall; } private static int calculateCheckDigit(String part1, String part2) { int total = 0; total = total + 1*Integer.parseInt(part2.substring(1,2)); total = total + 2*Integer.parseInt(part2.substring(0,1)); int length = part1.length(); for (int i=0; i * * 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. * * 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.interfaces; /** * Class defining an adduct object in a MolecularFormula. It maintains * a list of list IMolecularFormula.

* * Examples: *

    *
  • [C2H4O2+Na]+
  • *
* * @cdk.module interfaces * @author miguelrojasch * @cdk.created 2007-11-20 * @cdk.keyword molecular formula */ public interface IAdductFormula extends IMolecularFormulaSet{ /** * Checks a set of Nodes for the occurrence of the isotope in the * adduct formula from a particular isotope. It returns 0 if the does not exist. * * @param isotope The IIsotope to look for * @return The occurrence of this isotope in this adduct * @see #getIsotopeCount() */ public int getIsotopeCount(IIsotope isotope); /** * Checks a set of Nodes for the number of different isotopes in the * adduct formula. * * @return The the number of different isotopes in this adduct formula * @see #getIsotopeCount(IIsotope) */ public int getIsotopeCount(); /** * Returns an Iterator for looping over all isotopes in this adduct formula. * * @return An Iterator with the isotopes in this adduct formula */ public Iterable isotopes(); /** * Returns the partial charge of this Adduct. If the charge * has not been set the return value is Double.NaN. * * @return the charge of this Adduct * * @see #setCharge */ public Integer getCharge(); /** * True, if the AdductFormula contains the given IIsotope object. * * @param isotope The IIsotope this AdductFormula is searched for * @return True, if the AdductFormula contains the given isotope object */ public boolean contains(IIsotope isotope); /** * Sets the partial charge of this adduct formula. * * @param charge The partial charge * * @see #getCharge */ public void setCharge(Integer charge) ; /** * Clones this IAdductFormula object and its content. * * @return The cloned object */ public Object clone() throws CloneNotSupportedException ; /** * Returns a ChemObjectBuilder for the data classes that extend * this class. * * @return The IChemObjectBuilder matching this IChemObject */ public IChemObjectBuilder getBuilder(); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IAminoAcid.java100644 0 0 4436 11570154753 21763 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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 org.openscience.cdk.interfaces; /** * A AminoAcid is Monomer which stores additional amino acid specific * informations, like the N-terminus atom. * * @cdk.module interfaces * @cdk.githash * * @author Egon Willighagen * @cdk.created 2005-12-05 * @cdk.keyword amino acid */ public interface IAminoAcid extends IMonomer { /** * Retrieves the N-terminus atom. * * @return The Atom that is the N-terminus * * @see #addNTerminus(IAtom) */ public IAtom getNTerminus(); /** * Add an Atom and makes it the N-terminus atom. * * @param atom The Atom that is the N-terminus * * @see #getNTerminus */ public void addNTerminus(IAtom atom); /** * Retrieves the C-terminus atom. * * @return The Atom that is the C-terminus * * @see #addCTerminus(IAtom) */ public IAtom getCTerminus(); /** * Add an Atom and makes it the C-terminus atom. * * @param atom The Atom that is the C-terminus * * @see #getCTerminus */ public void addCTerminus(IAtom atom); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IAtom.java100644 0 0 7501 11570154753 21033 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; import javax.vecmath.Point2d; import javax.vecmath.Point3d; /** * Represents the idea of an chemical atom. * * @cdk.module interfaces * * @author egonw * @cdk.created 2005-08-24 * @cdk.keyword atom * @cdk.githash */ public interface IAtom extends IAtomType { /** * Sets the partial charge of this atom. * * @param charge The partial charge * @see #getCharge */ public void setCharge(Double charge); /** * Returns the partial charge of this atom. * * @return the charge of this atom * @see #setCharge */ public Double getCharge(); /** * Sets the implicit hydrogen count of this atom. * * @param hydrogenCount The number of hydrogen atoms bonded to this atom. * @see #getHydrogenCount */ public void setHydrogenCount(Integer hydrogenCount); /** * Returns the implicit hydrogen count of this atom. * * @return The hydrogen count of this atom. * @see #setHydrogenCount */ public Integer getHydrogenCount(); /** * Sets a point specifying the location of this * atom in a 2D space. * * @param point2d A point in a 2D plane * @see #getPoint2d */ public void setPoint2d(Point2d point2d); /** * Sets a point specifying the location of this * atom in 3D space. * * @param point3d A point in a 3-dimensional space * @see #getPoint3d */ public void setPoint3d(Point3d point3d); /** * Sets a point specifying the location of this * atom in a Crystal unit cell. * * @param point3d A point in a 3d fractional unit cell space * @see #getFractionalPoint3d * @see org.openscience.cdk.Crystal */ public void setFractionalPoint3d(Point3d point3d); /** * Sets the stereo parity for this atom. * * @param stereoParity The stereo parity for this atom * @see org.openscience.cdk.CDKConstants for predefined values. * @see #getStereoParity */ public void setStereoParity(Integer stereoParity); /** * Returns a point specifying the location of this * atom in a 2D space. * * @return A point in a 2D plane. Null if unset. * @see #setPoint2d */ public Point2d getPoint2d(); /** * Returns a point specifying the location of this * atom in a 3D space. * * @return A point in 3-dimensional space. Null if unset. * @see #setPoint3d */ public Point3d getPoint3d(); /** * Returns a point specifying the location of this * atom in a Crystal unit cell. * * @return A point in 3d fractional unit cell space. Null if unset. * @see #setFractionalPoint3d * @see org.openscience.cdk.CDKConstants for predefined values. */ public Point3d getFractionalPoint3d(); /** * Returns the stereo parity of this atom. It uses the predefined values * found in CDKConstants. * * @return The stereo parity for this atom * @see org.openscience.cdk.CDKConstants * @see #setStereoParity */ public Integer getStereoParity(); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IAtomContainer.java100644 0 0 44040 11570154753 22715 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; import org.openscience.cdk.interfaces.IBond.Order; import java.util.List; /** * Base class for all chemical objects that maintain a list of Atoms and * ElectronContainers.

* * Looping over all IBonds in the IAtomContainer * is typically done like: *

 *  for (IBond bond : atomContainer.bonds()) {
 *    // do something
 *  }
 *  
* If you do need an explicit Iterator then use *
 * Iterator bondIter = atomContainer.bonds().iterator();
 * 
* * @cdk.module interfaces * @cdk.githash * * @author steinbeck * @cdk.created 2000-10-02 */ public interface IAtomContainer extends IChemObject, IChemObjectListener { /** * Adds an AtomParity to this container. If a parity is already given for the * affected Atom, it is overwritten. * * @param parity The new AtomParity for this container * @see #getAtomParity */ public void addAtomParity(IAtomParity parity); /** * Returns the atom parity for the given Atom. If no parity is associated * with the given Atom, it returns null. * * @param atom Atom for which the parity must be returned * @return The AtomParity for the given Atom, or null if that Atom does * not have an associated AtomParity * @see #addAtomParity */ public IAtomParity getAtomParity(IAtom atom); /** * Sets the array of atoms of this AtomContainer. * * @param atoms The array of atoms to be assigned to this AtomContainer * @see #atoms */ public void setAtoms(IAtom[] atoms); /** * Sets the array of bonds of this AtomContainer. * * @param bonds The array of bonds to be assigned to * this AtomContainer * @see #bonds */ public void setBonds(IBond[] bonds); /** * Set the atom at position number in [0,..]. * * @param number The position of the atom to be set. * @param atom The atom to be stored at position number * @see #getAtom */ public void setAtom(int number, IAtom atom); /** * Get the atom at position number in [0,..]. * * @param number The position of the atom to be retrieved. * @return The atom number * @see #setAtom */ public IAtom getAtom(int number); /** * Get the bond at position number in [0,..]. * *@param number The position of the bond to be retrieved. *@return The bond number */ public IBond getBond(int number); /** * Get the lone pair at position number in [0,..]. * *@param number The position of the LonePair to be retrieved. *@return The lone pair number */ public ILonePair getLonePair(int number); /** * Get the single electron at position number in [0,..]. * *@param number The position of the SingleElectron to be retrieved. *@return The single electron number */ public ISingleElectron getSingleElectron(int number); /** * Returns an Iterable for looping over all atoms in this container. * *@return An Iterable with the atoms in this container */ public Iterable atoms(); /** * Returns an Iterable for looping over all bonds in this container. * *@return An Iterable with the bonds in this container */ public Iterable bonds(); /** * Returns an Iterable for looping over all lone pairs in this container. * *@return An Iterable with the lone pairs in this container */ public Iterable lonePairs(); /** * Returns an Iterable for looping over all single electrons in this container. * *@return An Iterable with the single electrons in this container */ public Iterable singleElectrons(); /** * Returns an Iterable for looping over all electron containers in this container. * *@return An Iterable with the electron containers in this container */ public Iterable electronContainers(); /** * Returns the atom at position 0 in the container. * *@return The atom at position 0 . */ public IAtom getFirstAtom(); /** * Returns the atom at the last position in the container. * *@return The atom at the last position */ public IAtom getLastAtom(); /** * Returns the position of a given atom in the atoms array. It returns -1 if * the atom atom does not exist. * *@param atom The atom to be sought *@return The Position of the atom in the atoms array in [0,..]. */ public int getAtomNumber(IAtom atom); /** * Returns the position of the bond between two given atoms in the * electronContainers array. It returns -1 if the bond does not exist. * *@param atom1 The first atom *@param atom2 The second atom *@return The Position of the bond between a1 and a2 in the * electronContainers array. */ public int getBondNumber(IAtom atom1, IAtom atom2); /** * Returns the position of a given bond in the electronContainers array. It * returns -1 if the bond does not exist. * *@param bond The bond to be sought *@return The Position of the bond in the electronContainers array in [0,..]. */ public int getBondNumber(IBond bond); /** * Returns the position of a given lone pair in the lone pair array. * It returns -1 if the lone pair does not exist. * * @param lonePair The lone pair to be sought * @return The Position of the lone pair in the array.. */ public int getLonePairNumber(ILonePair lonePair); /** * Returns the position of a given single electron in the single electron array. * It returns -1 if the single electron does not exist. * * @param singleElectron The single electron to be sought * @return The Position of the single electron in the array. */ public int getSingleElectronNumber(ISingleElectron singleElectron); /** * Returns the ElectronContainer at position number in the * container. * *@param number The position of the ElectronContainer to be returned. *@return The ElectronContainer at position number. *@see #addElectronContainer(IElectronContainer) */ public IElectronContainer getElectronContainer(int number); /** * Returns the bond that connectes the two given atoms. * * @param atom1 The first atom * @param atom2 The second atom * @return The bond that connectes the two atoms */ public IBond getBond(IAtom atom1, IAtom atom2); /** * Returns the number of Atoms in this Container. * *@return The number of Atoms in this Container */ public int getAtomCount(); /** * Returns the number of Bonds in this Container. * *@return The number of Bonds in this Container */ public int getBondCount(); /** * Returns the number of LonePairs in this Container. * *@return The number of LonePairs in this Container */ public int getLonePairCount(); /** * Returns the number of the single electrons in this container. * * @return The number of SingleElectron objects of this AtomContainer */ public int getSingleElectronCount(); /** * Returns the number of ElectronContainers in this Container. * * @return The number of ElectronContainers in this Container */ public int getElectronContainerCount(); /** * Returns an ArrayList of all atoms connected to the given atom. * *@param atom The atom the bond partners are searched of. *@return The ArrayList with the connected atoms */ public List getConnectedAtomsList(IAtom atom); /** * Returns an ArrayList of all Bonds connected to the given atom. * *@param atom The atom the connected bonds are searched of *@return The ArrayList with connected atoms */ public List getConnectedBondsList(IAtom atom); /** * Returns the array of lone pairs connected to an atom. * *@param atom The atom for which to get lone pairs *@return The array of LonePairs of this AtomContainer */ public List getConnectedLonePairsList(IAtom atom); /** * Returns an array of all SingleElectron connected to the given atom. * *@param atom The atom on which the single electron is located *@return The array of SingleElectron of this AtomContainer */ public List getConnectedSingleElectronsList(IAtom atom); /** * Returns an ArrayList of all electronContainers connected to the given atom. * *@param atom The atom the connected electronContainers are searched of *@return The ArrayList with the connected atoms */ public List getConnectedElectronContainersList(IAtom atom); /** * Returns the number of atoms connected to the given atom. * *@param atom The atom the number of bond partners are searched of. *@return The the size of connected atoms */ public int getConnectedAtomsCount(IAtom atom); /** * Returns the number of Bonds for a given Atom. * *@param atom The atom *@return The number of Bonds for this atom */ public int getConnectedBondsCount(IAtom atom); /** * Returns the number of connected atoms (degree) to the given atom. * *@param atomnumber The atomnumber the degree is searched for *@return The number of connected atoms (degree) */ public int getConnectedBondsCount(int atomnumber); /** * Returns the number of LonePairs for a given Atom. * *@param atom The atom *@return The number of LonePairs for this atom */ public int getConnectedLonePairsCount(IAtom atom); /** * Returns the sum of the SingleElectron for a given Atom. * *@param atom The atom on which the single electron is located *@return The array of SingleElectron of this AtomContainer */ public int getConnectedSingleElectronsCount(IAtom atom); /** * Returns the sum of the bond orders for a given Atom. * * @param atom The atom * @return The number of bondorders for this atom */ public double getBondOrderSum(IAtom atom); /** * Returns the maximum bond order that this atom currently has in the context * of this AtomContainer. * * @param atom The atom * @return The maximum bond order that this atom currently has */ public Order getMaximumBondOrder(IAtom atom); /** * Returns the minimum bond order that this atom currently has in the context * of this AtomContainer. * *@param atom The atom *@return The minimim bond order that this atom currently has */ public Order getMinimumBondOrder(IAtom atom); /** * Adds all atoms and electronContainers of a given atomcontainer to this * container. * *@param atomContainer The atomcontainer to be added */ public void add(IAtomContainer atomContainer); /** * Adds an atom to this container. * *@param atom The atom to be added to this container */ public void addAtom(IAtom atom); /** * Adds a Bond to this AtomContainer. * *@param bond The bond to added to this container */ public void addBond(IBond bond); /** * Adds a lone pair to this AtomContainer. * *@param lonePair The LonePair to added to this container */ public void addLonePair(ILonePair lonePair); /** * Adds a single electron to this AtomContainer. * *@param singleElectron The SingleElectron to added to this container */ public void addSingleElectron(ISingleElectron singleElectron); /** * Adds a ElectronContainer to this AtomContainer. * *@param electronContainer The ElectronContainer to added to this container */ public void addElectronContainer(IElectronContainer electronContainer); /** * Removes all atoms and electronContainers of a given atomcontainer from this * container. * *@param atomContainer The atomcontainer to be removed */ public void remove(IAtomContainer atomContainer); /** * Removes the atom at the given position from the AtomContainer. Note that * the electronContainers are unaffected: you also have to take care of * removing all electronContainers to this atom from the container manually. * *@param position The position of the atom to be removed. */ public void removeAtom(int position); /** * Removes the given atom from the AtomContainer. Note that the * electronContainers are unaffected: you also have to take care of removeing * all electronContainers to this atom from the container. * *@param atom The atom to be removed */ public void removeAtom(IAtom atom); /** * Removes the bond at the given position from the AtomContainer. * *@param position The position of the bond to be removed. */ public IBond removeBond(int position); /** * Removes the bond that connects the two given atoms. * * @param atom1 The first atom * @param atom2 The second atom * @return The bond that connectes the two atoms */ public IBond removeBond(IAtom atom1, IAtom atom2); /** * Removes the bond from this container. * * @param bond The bond to be removed. */ public void removeBond(IBond bond); /** * Removes the lone pair at the given position from the AtomContainer. * * @param position The position of the LonePair to be removed. * @return The removed ILonePair. */ public ILonePair removeLonePair(int position); /** * Removes the lone pair from the AtomContainer. * * @param lonePair The LonePair to be removed. */ public void removeLonePair(ILonePair lonePair); /** * Removes the single electron at the given position from the AtomContainer. * * @param position The position of the SingleElectron to be removed. * @return The removed ISingleElectron */ public ISingleElectron removeSingleElectron(int position); /** * Removes the single electron from the AtomContainer. * * @param singleElectron The SingleElectron to be removed. */ public void removeSingleElectron(ISingleElectron singleElectron); /** * Removes the bond at the given position from this container. * * @param position The position of the bond in the electronContainers array * @return the IElectronContainer that was removed */ public IElectronContainer removeElectronContainer(int position); /** * Removes this ElectronContainer from this container. * * @param electronContainer The electronContainer to be removed */ public void removeElectronContainer(IElectronContainer electronContainer); /** * Removes the given atom and all connected electronContainers from the * AtomContainer. * *@param atom The atom to be removed */ public void removeAtomAndConnectedElectronContainers(IAtom atom); /** * Removes all atoms and bond from this container. */ public void removeAllElements(); /** * Removes electronContainers from this container. */ public void removeAllElectronContainers(); /** * Removes all Bonds from this container. */ public void removeAllBonds(); /** * Adds a bond to this container. * *@param atom1 Id of the first atom of the Bond in [0,..] *@param atom2 Id of the second atom of the Bond in [0,..] *@param order Bondorder *@param stereo Stereochemical orientation */ public void addBond(int atom1, int atom2, IBond.Order order, int stereo); /** * Adds a bond to this container. * *@param atom1 Id of the first atom of the Bond in [0,..] *@param atom2 Id of the second atom of the Bond in [0,..] *@param order Bondorder */ public void addBond(int atom1, int atom2, IBond.Order order); /** * Adds a LonePair to this Atom. * *@param atomID The atom number to which the LonePair is added in [0,..] */ public void addLonePair(int atomID); /** * Adds a SingleElectron to this Atom. * *@param atomID The atom number to which the SingleElectron is added in [0,..] */ public void addSingleElectron(int atomID); /** * True, if the AtomContainer contains the given atom object. * *@param atom the atom this AtomContainer is searched for *@return True, if the AtomContainer contains the given atom object */ public boolean contains(IAtom atom); /** * True, if the AtomContainer contains the given bond object. * *@param bond the bond this AtomContainer is searched for *@return True, if the AtomContainer contains the given bond object */ public boolean contains(IBond bond); /** * True, if the AtomContainer contains the given LonePair object. * *@param lonePair the LonePair this AtomContainer is searched for *@return True, if the AtomContainer contains the given LonePair object */ public boolean contains(ILonePair lonePair); /** * True, if the AtomContainer contains the given SingleElectron object. * *@param singleElectron the SingleElectron this AtomContainer is searched for *@return True, if the AtomContainer contains the given SingleElectron object */ public boolean contains(ISingleElectron singleElectron); /** * True, if the AtomContainer contains the given ElectronContainer object. * *@param electronContainer ElectronContainer that is searched for *@return True, if the AtomContainer contains the given bond object */ public boolean contains(IElectronContainer electronContainer); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IAtomContainerSet.java100644 0 0 12367 11570154753 23400 0ustar 0 0 /* * $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; /** * A set of AtomContainers. * * @author egonw * @cdk.module interfaces * @cdk.githash */ public interface IAtomContainerSet extends IChemObject { /** * Adds an atomContainer to this container. * * @param atomContainer The atomContainer to be added to this container */ public void addAtomContainer(IAtomContainer atomContainer); /** * Removes an AtomContainer from this container. * * @param atomContainer The atomContainer to be removed from this container */ public void removeAtomContainer(IAtomContainer atomContainer); /** * Removes all AtomContainer from this container. */ public void removeAllAtomContainers(); /** * Removes an AtomContainer from this container. * * @param pos The position of the AtomContainer to be removed from this container */ public void removeAtomContainer(int pos); /** * Replace the AtomContainer at a specific position (array has to be large enough). * * @param position position in array for AtomContainer * @param container the replacement AtomContainer */ public void replaceAtomContainer(int position, IAtomContainer container); /** * Sets the coefficient of a AtomContainer to a given value. * * @param container The AtomContainer for which the multiplier is set * @param multiplier The new multiplier for the AtomContatiner * @return true if multiplier has been set * @see #getMultiplier(IAtomContainer) */ public boolean setMultiplier(IAtomContainer container, Double multiplier); /** * Sets the coefficient of a AtomContainer to a given value. * * @param position The position of the AtomContainer for which the multiplier is * set in [0,..] * @param multiplier The new multiplier for the AtomContatiner at * position * @see #getMultiplier(int) */ public void setMultiplier(int position, Double multiplier); /** * Returns an array of double with the stoichiometric coefficients * of the products. * * @return The multipliers for the AtomContainer's in this set * @see #setMultipliers */ public Double[] getMultipliers(); /** * Sets the multipliers of the AtomContainers. * * @param newMultipliers The new multipliers for the AtomContainers in this set * @return true if multipliers have been set. * @see #getMultipliers */ public boolean setMultipliers(Double[] newMultipliers); /** * Adds an atomContainer to this container with the given * multiplier. * * @param atomContainer The atomContainer to be added to this container * @param multiplier The multiplier of this atomContainer */ public void addAtomContainer(IAtomContainer atomContainer, double multiplier); /** * Adds all atomContainers in the AtomContainerSet to this container. * * @param atomContainerSet The AtomContainerSet */ public void add(IAtomContainerSet atomContainerSet); /** * Get an Iterable for this AtomContainerSet. * * @return A new Iterable for this AtomContainerSet. */ public Iterable atomContainers(); /** * Returns the AtomContainer at position number in the * container. * * @param number The position of the AtomContainer to be returned. * @return The AtomContainer at position number . */ public IAtomContainer getAtomContainer(int number); /** * Returns the multiplier for the AtomContainer at position number in the * container. * * @param number The position of the multiplier of the AtomContainer to be returned. * @return The multiplier for the AtomContainer at position number . * @see #setMultiplier(int, Double) */ public Double getMultiplier(int number); /** * Returns the multiplier of the given AtomContainer. * * @param container The AtomContainer for which the multiplier is given * @return -1, if the given molecule is not a container in this set * @see #setMultiplier(IAtomContainer, Double) */ public Double getMultiplier(IAtomContainer container); /** * Returns the number of AtomContainers in this Container. * * @return The number of AtomContainers in this Container */ public int getAtomContainerCount(); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IAtomParity.java100644 0 0 4107 11570154753 22223 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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 org.openscience.cdk.interfaces; /** * Represents the concept of an atom parity identifying the stereochemistry * around an atom, given four neighbouring atoms. * * @cdk.module interfaces * @cdk.githash * * @author egonw * @cdk.created 2005-08-24 * @cdk.keyword atom parity * @cdk.keyword stereochemistry */ public interface IAtomParity extends Cloneable { /** * Returns the atom for which this parity is defined. * * @return The atom for which this parity is defined */ public IAtom getAtom(); /** * Returns the four atoms that define the stereochemistry for * this parity. * * @return The four atoms that define the stereochemistry for * this parity */ public IAtom[] getSurroundingAtoms(); /** * Returns the parity value. * * @return The parity value */ public int getParity(); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IAtomType.java100644 0 0 11543 11570154753 21716 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; /** * The base class for atom types. Atom types are typically used to describe the * behaviour of an atom of a particular element in different environment like * sp3 hybridized carbon C3, etc., in some molecular modelling * applications. * * @cdk.module interfaces * @cdk.githash * * @author egonw * @cdk.created 2005-08-24 * * @cdk.keyword atom, type */ public interface IAtomType extends IIsotope { public enum Hybridization { S, SP1, // linear SP2, // trigonal planar (single pi-electron in pz) SP3, // tetrahedral PLANAR3, // trigonal planar (lone pair in pz) SP3D1, // trigonal planar SP3D2, // octahedral SP3D3, // pentagonal bipyramid SP3D4, // square antiprim?? SP3D5 // tricapped trigonal prism } /** * Sets the if attribute of the AtomType object. * * @param identifier The new AtomTypeID value. Null if unset. * @see #getAtomTypeName */ public void setAtomTypeName(String identifier); /** * Sets the MaxBondOrder attribute of the AtomType object. * * @param maxBondOrder The new MaxBondOrder value * @see #getMaxBondOrder */ public void setMaxBondOrder(IBond.Order maxBondOrder); /** * Sets the the exact bond order sum attribute of the AtomType object. * * @param bondOrderSum The new bondOrderSum value * @see #getBondOrderSum */ public void setBondOrderSum(Double bondOrderSum); /** * Gets the id attribute of the AtomType object. * * @return The id value * @see #setAtomTypeName */ public String getAtomTypeName(); /** * Gets the MaxBondOrder attribute of the AtomType object. * * @return The MaxBondOrder value * @see #setMaxBondOrder */ public IBond.Order getMaxBondOrder(); /** * Gets the bondOrderSum attribute of the AtomType object. * * @return The bondOrderSum value * @see #setBondOrderSum */ public Double getBondOrderSum(); /** * Sets the formal charge of this atom. * * @param charge The formal charge * @see #getFormalCharge */ public void setFormalCharge(Integer charge); /** * Returns the formal charge of this atom. * * @return the formal charge of this atom * @see #setFormalCharge */ public Integer getFormalCharge(); /** * Sets the formal neighbour count of this atom. * * @param count The neighbour count * @see #getFormalNeighbourCount */ public void setFormalNeighbourCount(Integer count); /** * Returns the formal neighbour count of this atom. * * @return the formal neighbour count of this atom * @see #setFormalNeighbourCount */ public Integer getFormalNeighbourCount(); /** * Sets the hybridization of this atom. * * @param hybridization The hybridization * @see #getHybridization */ public void setHybridization(Hybridization hybridization); /** * Returns the hybridization of this atom. * * @return the hybridization of this atom * @see #setHybridization */ public Hybridization getHybridization(); /** * Sets the covalent radius for this AtomType. * * @param radius The covalent radius for this AtomType * @see #getCovalentRadius */ public void setCovalentRadius(Double radius); /** * Returns the covalent radius for this AtomType. * * @return The covalent radius for this AtomType * @see #setCovalentRadius */ public Double getCovalentRadius(); /** * Sets the the exact electron valency of the AtomType object. * * @param valency The new valency value * @see #getValency() */ public void setValency(Integer valency); /** * Gets the the exact electron valency of the AtomType object. * * @return The valency value * @see #setValency(Integer) */ public Integer getValency(); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IBioPolymer.java100644 0 0 10366 11570154753 22237 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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 org.openscience.cdk.interfaces; import java.util.Collection; import java.util.Map; /** * A BioPolymer is a subclass of a Polymer which is supposed to store * additional informations about the Polymer which are connected to BioPolymers. * * @cdk.module interfaces * @cdk.githash * * @author Edgar Luttmann * @cdk.created 2001-08-06 * * @cdk.keyword polymer * @cdk.keyword biopolymer */ public interface IBioPolymer extends IPolymer { /** * Adds the atom oAtom without specifying a Monomer or a Strand. Therefore the * atom to this AtomContainer, but not to a certain Strand or Monomer (intended * e.g. for HETATMs). * * @param oAtom The atom to add */ public void addAtom(IAtom oAtom); /** * Adds the atom oAtom to a specified Strand, whereas the Monomer is unspecified. Hence * the atom will be added to a Monomer of type UNKNOWN in the specified Strand. * * @param oAtom The atom to add * @param oStrand The strand the atom belongs to */ public void addAtom(IAtom oAtom, IStrand oStrand); /** * Adds the atom to a specified Strand and a specified Monomer. * * @param oAtom The atom to add * @param oMonomer The monomer the atom belongs to * @param oStrand The strand the atom belongs to */ public void addAtom(IAtom oAtom, IMonomer oMonomer, IStrand oStrand); /** * Return the number of monomers present in BioPolymer. * * @return number of monomers */ public int getMonomerCount(); /** * Retrieve a Monomer object by specifying its name. * *

You have to specify the strand to enable * monomers with the same name in different strands. There is at least one such case: every * strand contains a monomer called "". * * @param monName The name of the monomer to look for * @param strandName The name of the strand to look for * @return The Monomer object which was asked for */ public IMonomer getMonomer(String monName, String strandName); /** * Returns a collection of the names of all Monomers in this * BioPolymer. * * @return a Collection of all the monomer names. */ public Collection getMonomerNames(); /** * Return the number of strands present in the BioPolymer. * * @return number of strands */ public int getStrandCount(); /** * Retrieve a Monomer object by specifying its name. * * @param cName The name of the monomer to look for * @return The Monomer object which was asked for */ public IStrand getStrand(String cName); /** * Returns a collection of the names of all Strands in this * BioPolymer. * * @return a Collection of all the strand names. */ public Collection getStrandNames(); /** * Removes a particular strand, specified by its name. * * @param name The name of the strand to remove */ public void removeStrand(String name); /** * Returns a Map containing the strands in the Polymer. * * @return hashtable containing the strands in the Polymer */ public Map getStrands(); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IBond.java100644 0 0 11760 11570154753 21037 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; import javax.vecmath.Point2d; import javax.vecmath.Point3d; /** * Implements the concept of a covalent bond between two or more atoms. A bond is * considered to be a number of electrons connecting two ore more atoms. *type filter text * @cdk.module interfaces * @cdk.githash * * @author egonw * @cdk.created 2005-08-24 * @cdk.keyword bond * @cdk.keyword atom * @cdk.keyword electron */ public interface IBond extends IElectronContainer { public enum Order { SINGLE, DOUBLE, TRIPLE, QUADRUPLE } /** * Returns the Iterable to atoms making up this bond. * *@return An Iterable to atoms participating in this bond *@see #setAtoms */ public Iterable atoms(); /** * Sets the array of atoms making up this bond. * * @param atoms An array of atoms that forms this bond * @see #atoms */ public void setAtoms(IAtom[] atoms); /** * Returns the number of Atoms in this Bond. * * @return The number of Atoms in this Bond */ public int getAtomCount(); /** * Returns an Atom from this bond. * * @param position The position in this bond where the atom is * @return The atom at the specified position * @see #setAtom */ public IAtom getAtom(int position); /** * Returns the atom connected to the given atom. * * @param atom The atom the bond partner is searched of * @return the connected atom or null if the given atom is not part of the bond */ public IAtom getConnectedAtom(IAtom atom); /** * Returns all the atoms in the bond connected to the given atom. * * @param atom The atoms the bond partner is searched of * @return the connected atoms or null if the given atom is not part of the bond */ public IAtom[] getConnectedAtoms(IAtom atom); /** * Returns true if the given atom participates in this bond. * * @param atom The atom to be tested if it participates in this bond * @return true if the atom participates in this bond */ public boolean contains(IAtom atom); /** * Sets an Atom in this bond. * * @param atom The atom to be set * @param position The position in this bond where the atom is to be inserted * @see #getAtom */ public void setAtom(IAtom atom, int position); /** * Returns the bond order of this bond. * * @return The bond order of this bond * @see org.openscience.cdk.CDKConstants org.openscience.cdk.CDKConstants * for predefined values. * @see #setOrder */ public Order getOrder(); /** * Sets the bond order of this bond. * * @param order The bond order to be assigned to this bond * @see org.openscience.cdk.CDKConstants for predefined values. * @see #getOrder */ public void setOrder(Order order); /** * Returns the stereo descriptor for this bond. * * @return The stereo descriptor for this bond * @see #setStereo * @see org.openscience.cdk.CDKConstants for predefined values. */ public int getStereo(); /** * Sets the stereo descriptor for this bond. * * @param stereo The stereo descriptor to be assigned to this bond. * @see #getStereo * @see org.openscience.cdk.CDKConstants for predefined values. */ public void setStereo(int stereo); /** * Returns the geometric 2D center of the bond. * * @return The geometric 2D center of the bond */ public Point2d get2DCenter(); /** * Returns the geometric 3D center of the bond. * * @return The geometric 3D center of the bond */ public Point3d get3DCenter(); /** * Compares a bond with this bond. * * @param object Object of type Bond * @return Return true, if the bond is equal to this bond */ public boolean compare(Object object); /** * Checks whether a bond is connected to another one. * This can only be true if the bonds have an Atom in common. * * @param bond The bond which is checked to be connect with this one * @return True, if the bonds share an atom, otherwise false */ public boolean isConnectedTo(IBond bond); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IChemFile.java100644 0 0 4614 11570154753 21611 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; /** * An {@link IChemObject} containing a number of ChemSequences. This is supposed to be the * top level container, which can contain all the concepts stored in a chemical * document * * @author egonw * @cdk.module interfaces * @cdk.githash */ public interface IChemFile extends IChemObject { /** * Adds an {@link IChemSequence} to this container. * * @param chemSequence The chemSequence to be added to this container * @see #chemSequences */ public void addChemSequence(IChemSequence chemSequence); /** * Removes the IChemSequence at the given position from this container. * * @param pos Position of the IChemSequence to remove * @see #chemSequences */ public void removeChemSequence(int pos); /** * Returns the {@link Iterable} to ChemSequences of this container. * *@return The {@link Iterable} to ChemSequences of this container *@see #addChemSequence */ public Iterable chemSequences(); /** * Returns the ChemSequence at position number in the container. * * @param number The position of the ChemSequence to be returned. * @return The ChemSequence at position number. * @see #addChemSequence */ public IChemSequence getChemSequence(int number); /** * Returns the number of ChemSequences in this Container. * * @return The number of ChemSequences in this Container */ public int getChemSequenceCount(); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IChemModel.java100644 0 0 5271 11570154753 21772 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; /** * An object containig multiple MoleculeSet and * the other lower level concepts like rings, sequences, * fragments, etc. * * @cdk.module interfaces * @cdk.githash */ public interface IChemModel extends IChemObject { /** * Returns the MoleculeSet of this ChemModel. * * @return The MoleculeSet of this ChemModel * @see #setMoleculeSet */ public IMoleculeSet getMoleculeSet(); /** * Sets the MoleculeSet of this ChemModel. * * @param setOfMolecules the content of this model * @see #getMoleculeSet */ public void setMoleculeSet(IMoleculeSet setOfMolecules); /** * Returns the RingSet of this ChemModel. * * @return the ringset of this model * @see #setRingSet */ public IRingSet getRingSet(); /** * Sets the RingSet of this ChemModel. * * @param ringSet the content of this model * @see #getRingSet */ public void setRingSet(IRingSet ringSet); /** * Gets the Crystal contained in this ChemModel. * * @return The crystal in this model * @see #setCrystal */ public ICrystal getCrystal(); /** * Sets the Crystal contained in this ChemModel. * * @param crystal the Crystal to store in this model * @see #getCrystal */ public void setCrystal(ICrystal crystal); /** * Gets the ReactionSet contained in this ChemModel. * * @return The ReactionSet in this model * @see #setReactionSet */ public IReactionSet getReactionSet(); /** * Sets the ReactionSet contained in this ChemModel. * * @param sor the ReactionSet to store in this model * @see #getReactionSet */ public void setReactionSet(IReactionSet sor); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IChemObject.java100644 0 0 14443 11570154753 22161 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; import java.util.Map; /** * The base class for all chemical objects in this cdk. It provides methods for * adding listeners and for their notification of events, as well a a hash * table for administration of physical or chemical properties * *@author egonw * @cdk.githash *@cdk.module interfaces */ public interface IChemObject extends Cloneable { /** * Use this to add yourself to this IChemObject as a listener. In order to do * so, you must implement the ChemObjectListener Interface. * * @param col the ChemObjectListener * @see #removeListener */ public void addListener(IChemObjectListener col); /** * Returns the number of ChemObjectListeners registered with this object. * * @return the number of registered listeners. */ public int getListenerCount(); /** * Use this to remove a ChemObjectListener from the ListenerList of this * IChemObject. It will then not be notified of change in this object anymore. * * @param col The ChemObjectListener to be removed * @see #addListener */ public void removeListener(IChemObjectListener col); /** * Set a flag to use or not use notification. By default it should be set * to true. * * @param bool if true, then notification messages are sent. * @see #getNotification() */ public void setNotification(boolean bool); /** * Returns the flag that indicates whether notification messages are sent around. * * @return true if messages are sent. * @see #setNotification(boolean) */ public boolean getNotification(); /** * This should be triggered by an method that changes the content of an object * to that the registered listeners can react to it. */ public void notifyChanged(); /** * This should be triggered by an method that changes the content of an object * to that the registered listeners can react to it. This is a version of * notifyChanged() which allows to propagate a change event while preserving * the original origin. * * @param evt A ChemObjectChangeEvent pointing to the source of where * the change happend */ public void notifyChanged(IChemObjectChangeEvent evt); /** * Sets a property for a IChemObject. * * @param description An object description of the property (most likely a * unique string) * @param property An object with the property itself * @see #getProperty * @see #removeProperty */ public void setProperty(Object description, Object property); /** * Removes a property for a IChemObject. * * @param description The object description of the property (most likely a * unique string) * @see #setProperty * @see #getProperty */ public void removeProperty(Object description); /** * Returns a property for the IChemObject. * * @param description An object description of the property (most likely a * unique string) * @return The object containing the property. Returns null if * propert is not set. * @see #setProperty * @see #removeProperty */ public Object getProperty(Object description); /** * Returns a Map with the IChemObject's properties. * *@return The object's properties as an Map *@see #setProperties */ public Map getProperties(); /** * Returns the identifier (ID) of this object. * * @return a String representing the ID value * @see #setID */ public String getID(); /** * Sets the identifier (ID) of this object. * * @param identifier a String representing the ID value * @see #getID */ public void setID(String identifier); /** * Sets the value of some flag. * * @param flag_type Flag to set * @param flag_value Value to assign to flag * @see #getFlag */ public void setFlag(int flag_type, boolean flag_value); /** * Returns the value of some flag. * * @param flag_type Flag to retrieve the value of * @return true if the flag flag_type is set * @see #setFlag */ public boolean getFlag(int flag_type); /** * Sets the properties of this object. * * @param properties a Map specifying the property values * @see #getProperties */ public void setProperties(Map properties); /** * Sets the whole set of flags. * * @param flagsNew the new flags. * @see #getFlags */ public void setFlags(boolean[] flagsNew); /** * Returns the whole set of flags. * * @return the flags. * @see #setFlags */ public boolean[] getFlags(); /** * Returns a one line description of this IChemObject. * * @return a String representation of this object */ public String toString(); /** * Returns a deep clone of this IChemObject. * * @return Object the clone of this IChemObject. * @throws CloneNotSupportedException if the IChemObject cannot be cloned */ public Object clone() throws CloneNotSupportedException; /** * Returns a ChemObjectBuilder for the data classes that extend * this class. * * @return The IChemObjectBuilder matching this IChemObject */ public IChemObjectBuilder getBuilder(); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IChemObjectBuilder.java100644 0 0 52177 11570154753 23476 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; import org.openscience.cdk.interfaces.IBond.Order; import javax.vecmath.Point3d; /** * A helper class to instantiate a IChemObject for a specific implementation. * * @author egonw * @cdk.module interfaces * @cdk.githash */ public interface IChemObjectBuilder { /** * Constructs an completely unset IAminoAcid. * * @return IAminoAcid implementation defined for this IChemObjectBuilder */ public IAminoAcid newAminoAcid(); /** * Constructs an completely unset IAtom. * * @return IAtom implementation defined for this IChemObjectBuilder */ public IAtom newAtom(); /** * Constructs an IAtom from a String containing an element symbol. * * @param element The IElement from which the Atom should be constructed * @return IAtom implementation defined for this IChemObjectBuilder */ public IAtom newAtom(IElement element); /** * Constructs an IAtom from a String containing an element symbol. * * @param elementSymbol The String describing the element for the Atom * @return IAtom implementation defined for this IChemObjectBuilder */ public IAtom newAtom(String elementSymbol); /** * Constructs an IAtom from an Element and a Point2d. * * @param elementSymbol The Element * @param point2d The Point * @return IAtom implementation defined for this IChemObjectBuilder */ public IAtom newAtom(String elementSymbol, javax.vecmath.Point2d point2d); /** * Constructs an IAtom from an Element and a Point3d. * * @param elementSymbol The symbol of the atom * @param point3d The 3D coordinates of the atom * @return IAtom implementation defined for this IChemObjectBuilder */ public IAtom newAtom(String elementSymbol, javax.vecmath.Point3d point3d); /** * Constructs an empty IAtomContainer. * * @return IAtomContainer implementation defined for this IChemObjectBuilder */ public IAtomContainer newAtomContainer(); /** * Constructs an empty IAtomContainer that will contain a certain number of * atoms and electronContainers. It will set the starting array lengths to the * defined values, but will not create any IAtom or IElectronContainer's. * * @param atomCount Number of atoms to be in this container * @param bondCount Number of bonds to be in this container * @param lonePairCount Number of lone pairs to be in this container * @param singleElectronCount Number of single electrons to be in this * container * * @return IAtomContainer implementation defined for * this IChemObjectBuilder */ public IAtomContainer newAtomContainer(int atomCount, int bondCount, int lonePairCount, int singleElectronCount); /** * Constructs an IAtomContainer with a copy of the atoms and electronContainers * of another IAtomContainer (A shallow copy, i.e., with the same objects as in * the original IAtomContainer). * * @param container An AtomContainer to copy the atoms and electronContainers from * @return IAtomContainer implementation defined for this IChemObjectBuilder */ public IAtomContainer newAtomContainer(IAtomContainer container); /** * Constructs an IAtomParity. * * @param centralAtom Atom for which the parity is defined * @param first First Atom of four that define the stereochemistry * @param second Second Atom of four that define the stereochemistry * @param third Third Atom of four that define the stereochemistry * @param fourth Fourth Atom of four that define the stereochemistry * @param parity +1 or -1, defining the parity * @return IAtomParity implementation defined for this IChemObjectBuilder */ public IAtomParity newAtomParity(IAtom centralAtom, IAtom first, IAtom second, IAtom third, IAtom fourth, int parity); /** * Constructor for the IAtomType object. * * @param elementSymbol Symbol of the atom * @return IAtomType implementation defined for this IChemObjectBuilder */ public IAtomType newAtomType(String elementSymbol); /** * Constructor for the IAtomType object. * * @param identifier An id for this atom type, like C3 for sp3 carbon * @param elementSymbol The element symbol identifying the element to which this atom type applies * @return IAtomType implementation defined for this IChemObjectBuilder */ public IAtomType newAtomType(String identifier, String elementSymbol); /** * Constructs an IAtomType from a String containing an element symbol. * * @param element The IElement from which the AtomType should be constructed * @return IAtomType implementation defined for this IChemObjectBuilder */ public IAtomType newAtomType(IElement element); /** * Contructs a new IBioPolymer to store the IStrands. * * @return IBioPolymer implementation defined for this IChemObjectBuilder */ public IBioPolymer newBioPolymer(); /** * Constructs an IPDBAtom from a IElement. * * @param element The Element for the PDBAtom * @return IPDBAtom implementation defined for this IChemObjectBuilder */ public IPDBAtom newPDBAtom(IElement element); /** * Constructs an IPDBAtom from a String containing an element symbol. * * @param symbol The String describing the element for the PDBAtom * @return IPDBAtom implementation defined for this IChemObjectBuilder */ public IPDBAtom newPDBAtom(String symbol); /** * Constructs an IPDBAtom from an Element and a Point3d. * * @param elementSymbol The symbol of the atom * @param point3d The 3D coordinates of the atom * @return IPDBAtom implementation defined for this IChemObjectBuilder */ public IPDBAtom newPDBAtom(String elementSymbol, Point3d point3d); /** * Contructs a new IPDBPolymer to store the IStrands. * * @return IPDBPolymer implementation defined for this IChemObjectBuilder */ public IPDBPolymer newPDBPolymer(); /** * Constructs an IPDBStructure. * * @return IPDBStructure implementation defined for this IChemObjectBuilder */ public IPDBStructure newPDBStructure(); /** * Constructs an IPDBMonomer. * * @return IPDBMonomer implementation defined for this IChemObjectBuilder */ public IPDBMonomer newPDBMonomer(); /** * Constructs an empty IBond. * * @return IBond implementation defined for this IChemObjectBuilder */ public IBond newBond(); /** * Constructs a IBond with a single bond order.. * * @param atom1 the first IAtom in the bond * @param atom2 the second IAtom in the bond * @return IBond implementation defined for this IChemObjectBuilder */ public IBond newBond(IAtom atom1, IAtom atom2); /** * Constructs a IBond with a given order. * * @param atom1 the first IAtom in the bond * @param atom2 the second IAtom in the bond * @param order the bond order * @return IBond implementation defined for this IChemObjectBuilder */ public IBond newBond(IAtom atom1, IAtom atom2, Order order); /** * Constructs a IBond with a given order and stereo orientation from an array * of atoms. * * @param atom1 the first Atom in the bond * @param atom2 the second Atom in the bond * @param order the bond order * @param stereo a descriptor the stereochemical orientation of this bond * @return IBond implementation defined for this IChemObjectBuilder */ public IBond newBond(IAtom atom1, IAtom atom2, Order order, int stereo); /** * Constrcts a IBond with multiple atoms and undefined order and orientation. * * @param atoms The atoms constituting the bond * @return IBond implementation defined for this IChemObjectBuilder */ public IBond newBond(IAtom[] atoms); /** * Constrcts a IBond with multiple atoms and defined order and undefined orientation. * * @param atoms The atoms constituting the bond * @param order The order for this bond * @return IBond implementation defined for this IChemObjectBuilder */ public IBond newBond(IAtom[] atoms, Order order); /** * Constructs an empty IChemFile. * * @return IChemFile implementation defined for this IChemObjectBuilder */ public IChemFile newChemFile(); /** * Constructs an new IChemModel with a null IMoleculeSet. * * @return IChemModel implementation defined for this IChemObjectBuilder */ public IChemModel newChemModel(); /** * Constructs an new IChemObject. * * @return IChemObject implementation defined for this IChemObjectBuilder */ public IChemObject newChemObject(); /** * Constructs an new IChemObject from an existing one. * * @param object THe source object * @return IChemObject implementation defined for this IChemObjectBuilder */ public IChemObject newChemObject(IChemObject object); /** * Constructs an empty IChemSequence. * * @return IChemSequence implementation defined for this IChemObjectBuilder */ public IChemSequence newChemSequence(); /** * Constructs a new ICrystal with zero length cell axis. * * @return ICrystal implementation defined for this IChemObjectBuilder */ public ICrystal newCrystal(); /** * Constructs a new ICrystal with zero length cell axis * and adds the atoms in the IAtomContainer as cell content. * * @param container the IAtomContainer providing the atoms and bonds * @return ICrystal implementation defined for this IChemObjectBuilder */ public ICrystal newCrystal(IAtomContainer container); /** * Constructs an empty IElectronContainer. * * @return IElectronContainer implementation defined for this IChemObjectBuilder */ public IElectronContainer newElectronContainer(); /** * Constructs an empty IElement. * * @return IElement implementation defined for this IChemObjectBuilder */ public IElement newElement(); /** * Constructs an empty IElement from an existing IElement. * * @param element The IElement from which the Element should be constructed * @return IElement implementation defined for this IChemObjectBuilder */ public IElement newElement(IElement element); /** * Constructs an IElement with a given element symbol. * * @param symbol The element symbol that this element should have. * @return IElement implementation defined for this IChemObjectBuilder */ public IElement newElement(String symbol); /** * Constructs an IElement with a given element symbol, * atomic number and atomic mass. * * @param symbol The element symbol of this element. * @param atomicNumber The atomicNumber of this element. * @return IElement implementation defined for this IChemObjectBuilder */ public IElement newElement(String symbol, int atomicNumber); /** * Constructor for the IIsotope object. * * @param elementSymbol The element symbol, "O" for oxygen, etc. * @return IIsotope implementation defined for this IChemObjectBuilder */ public IIsotope newIsotope(String elementSymbol); /** * Constructs an IIsotope object from an existing IIsotope. * * @param element The IElement from which the Isotope should be constructed * @return IIsotope implementation defined for this IChemObjectBuilder */ public IIsotope newIsotope(IElement element); /** * Constructor for the IIsotope object. * * @param atomicNumber The atomic number of the isotope * @param elementSymbol The element symbol, "O" for oxygen, etc. * @param massNumber The atomic mass of the isotope, 16 for oxygen, e.g. * @param exactMass The exact mass of the isotope, be a little more explicit here :-) * @param abundance The natural abundance of the isotope * @return IIsotope implementation defined for this IChemObjectBuilder */ public IIsotope newIsotope(int atomicNumber, String elementSymbol, int massNumber, double exactMass, double abundance); /** * Constructor for the IIsotope object. * * @param atomicNumber The atomic number of the isotope, 8 for oxygen * @param elementSymbol The element symbol, "O" for oxygen, etc. * @param exactMass The exact mass of the isotope, be a little more explicit here :-) * @param abundance The natural abundance of the isotope * @return IIsotope implementation defined for this IChemObjectBuilder */ public IIsotope newIsotope(int atomicNumber, String elementSymbol, double exactMass, double abundance); /** * Constructor for the IIsotope object. * * @param elementSymbol The element symbol, "O" for oxygen, etc. * @param massNumber The atomic mass of the isotope, 16 for oxygen, e.g. * @return IIsotope implementation defined for this IChemObjectBuilder */ public IIsotope newIsotope(String elementSymbol, int massNumber); /** * Constructs an unconnected ILonePair. * * @return ILonePair implementation defined for this IChemObjectBuilder */ public ILonePair newLonePair(); /** * Constructs an ILonePair on an IAtom. * * @param atom IAtom to which this lone pair is connected * @return ILonePair implementation defined for this IChemObjectBuilder */ public ILonePair newLonePair(IAtom atom); /** * Creates a directional IMapping between IChemObject's. * * @param objectOne object which is being mapped * @param objectTwo object to which is being mapped * @return IMapping implementation defined for this IChemObjectBuilder */ public IMapping newMapping(IChemObject objectOne, IChemObject objectTwo); /** * Creates an IMolecule without any IAtoms and IBonds. * * @return IMolecule implementation defined for this IChemObjectBuilder */ public IMolecule newMolecule(); /** * Constructor for the IMolecule object. The parameters define the * initial capacity of the arrays. * * @param atomCount init capacity of IAtom array * @param bondCount init capacity of IElectronContainer array * @param lonePairCount init capacity of ILonePair array * @param singleElectronCount init capacity of ISingleElectron array * @return IMolecule implementation defined for this IChemObjectBuilder */ public IMolecule newMolecule(int atomCount, int bondCount, int lonePairCount, int singleElectronCount); /** * Constructs an IMolecule with * a shallow copy of the atoms and bonds of an IAtomContainer. * * @param container An IMolecule to copy the atoms and bonds from * @return IMolecule implementation defined for this IChemObjectBuilder */ public IMolecule newMolecule(IAtomContainer container); /** * Constructs a new IMonomer. * * @return IMonomer implementation defined for this IChemObjectBuilder */ public IMonomer newMonomer (); /** * Constructs a new IPolymer to store the IMonomers. * * @return IPolymer implementation defined for this IChemObjectBuilder */ public IPolymer newPolymer(); /** * Constructs an empty, forward IReaction. * * @return IReaction implementation defined for this IChemObjectBuilder */ public IReaction newReaction(); /** * Constructs an empty IRing. * * @return IRing implementation defined for this IChemObjectBuilder */ public IRing newRing(); /** * Constructs a IRing from an IAtomContainer. * * @param container IAtomContainer to create the IRing from * @return IRing implementation defined for this IChemObjectBuilder */ public IRing newRing(IAtomContainer container); /** * Constructs a ring that will have a certain number of atoms of the given elements. * * @param ringSize The number of atoms and bonds the ring will have * @param elementSymbol The element of the atoms the ring will have * @return IRing implementation defined for this IChemObjectBuilder */ public IRing newRing(int ringSize, String elementSymbol); /** * Constructs an empty IRing that will have a certain size. * * @param ringSize The size (number of atoms) the ring will have * @return IRing implementation defined for this IChemObjectBuilder */ public IRing newRing(int ringSize); /** * Constructs an empty IRingSet. * * @return IRingSet implementation defined for this IChemObjectBuilder */ public IRingSet newRingSet(); /** * Constructs an empty IAtomContainerSet. * * @return IAtomContainerSet implementation defined for this IChemObjectBuilder */ public IAtomContainerSet newAtomContainerSet(); /** * Constructs an empty IMoleculeSet. * * @return IMoleculeSet implementation defined for this IChemObjectBuilder */ public IMoleculeSet newMoleculeSet(); /** * Constructs an empty IReactionSet. * * @return IReactionSet implementation defined for this IChemObjectBuilder */ public IReactionSet newReactionSet(); /** * Constructs an empty IReactionScheme. * * @return IReactionScheme implementation defined for this IChemObjectBuilder */ public IReactionScheme newReactionScheme(); /** * Constructs an single electron orbital with an associated IAtom. * * @return ISingleElectron implementation defined for this IChemObjectBuilder */ public ISingleElectron newSingleElectron(); /** * Constructs an single electron orbital on an IAtom. * * @param atom The atom to which the single electron belongs. * @return ISingleElectron implementation defined for this IChemObjectBuilder */ public ISingleElectron newSingleElectron(IAtom atom); /** * Contructs a new IStrand. * * @return IStrand implementation defined for this IChemObjectBuilder */ public IStrand newStrand(); /** * Constructs an empty IPseudoAtom. * * @return IPseudoAtom implementation defined for this IChemObjectBuilder */ public IPseudoAtom newPseudoAtom(); /** * Constructs an IPseudoAtom from a label. * * @param label The String describing the PseudoAtom * @return IPseudoAtom implementation defined for this IChemObjectBuilder */ public IPseudoAtom newPseudoAtom(String label); /** * Constructs an IPseudoAtom from an existing IAtom object. * * @param element The IElement from which the PseudoAtom should be constructed * @return IPseudoAtom implementation defined for this IChemObjectBuilder */ public IPseudoAtom newPseudoAtom(IElement element); /** * Constructs an IPseudoAtom from a label and a Point3d. * * @param label The String describing the IPseudoAtom * @param point3d The 3D coordinates of the IPseudoAtom * @return IPseudoAtom implementation defined for this IChemObjectBuilder */ public IPseudoAtom newPseudoAtom(String label, javax.vecmath.Point3d point3d); /** * Constructs an IPseudoAtom from a label and a Point2d. * * @param label The String describing the IPseudoAtom * @param point2d The 2D coordinates of the IPseudoAtom * @return IPseudoAtom implementation defined for this IChemObjectBuilder */ public IPseudoAtom newPseudoAtom(String label, javax.vecmath.Point2d point2d); /** * Constructs a IFragmentAtom. * * @return a fragment atom */ public IFragmentAtom newFragmentAtom(); public IMolecularFormula newMolecularFormula(); public IMolecularFormulaSet newMolecularFormulaSet(); public IMolecularFormulaSet newMolecularFormulaSet(IMolecularFormula formula); public IAdductFormula newAdductFormula(); public IAdductFormula newAdductFormula(IMolecularFormula formula); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IChemObjectChangeEvent.java100644 0 0 3041 11570154753 24241 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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 org.openscience.cdk.interfaces; /** * Event fired by CDK IChemObject classes to their registered listeners * in case something changed within them. * * @cdk.module interfaces * @cdk.githash */ public interface IChemObjectChangeEvent { /** * IChemObject that fired the event. * * @return the source of the event */ public Object getSource(); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IChemObjectListener.java100644 0 0 3301 11570154753 23636 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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 org.openscience.cdk.interfaces; /** * Classes implementing this interface must implement this method * such that they react appropriately to changes in the object they * are interested in. * * @cdk.module interfaces * @cdk.githash */ public interface IChemObjectListener { /** * Called by objects to notify objects that implemented this interface * and registered with them as ChemObjectListeners. * * @param event a ChemObjectChangeEvent object */ public void stateChanged(IChemObjectChangeEvent event); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IChemSequence.java100644 0 0 4474 11570154753 22506 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; /** * A sequence of ChemModels, which can, for example, be used to * store the course of a reaction. Each state of the reaction would be * stored in one ChemModel. * * @cdk.module interfaces * @cdk.githash * * @cdk.keyword animation * @cdk.keyword reaction */ public interface IChemSequence extends IChemObject { /** * Adds an chemModel to this container. * * @param chemModel The chemModel to be added to this container * @see #getChemModel */ public void addChemModel(IChemModel chemModel); /** * Remove a ChemModel from this ChemSequence. * * @param pos The position of the ChemModel to be removed. */ public void removeChemModel(int pos); /** * Returns an Iterable to ChemModels in this container. * * @return The Iterable to ChemModels in this container * @see #addChemModel */ public Iterable chemModels(); /** * Returns the ChemModel at position number in the * container. * * @param number The position of the ChemModel to be returned. * @return The ChemModel at position number. * @see #addChemModel */ public IChemModel getChemModel(int number); /** * Returns the number of ChemModels in this Container. * * @return The number of ChemModels in this Container */ public int getChemModelCount(); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/ICrystal.java100644 0 0 7420 11570154753 21554 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; import javax.vecmath.Vector3d; /** * Class representing a molecular crystal. * The crystal is described with molecules in fractional * coordinates and three cell axes: a,b and c. * *

The crystal is designed to store only the asymetric atoms. * Though this is not enforced, it is assumed by all methods. * * @cdk.module interfaces * @cdk.githash * * @cdk.keyword crystal */ public interface ICrystal extends IAtomContainer { /** * Adds the atoms in the AtomContainer as cell content. Symmetry related * atoms should not be added unless P1 space group is used. */ public void add(IAtomContainer container); /** * Adds the atom to the crystal. Symmetry related atoms should * not be added unless P1 space group is used. */ public void addAtom(IAtom atom); /** * Sets the A unit cell axes in carthesian coordinates in a * eucledian space. * * @param newAxis the new A axis * @see #getA */ public void setA(Vector3d newAxis); /** * Gets the A unit cell axes in carthesian coordinates * as a three element double array. * * @return a Vector3D representing the A axis * @see #setA */ public Vector3d getA(); /** * Sets the B unit cell axes in carthesian coordinates. * * @param newAxis the new B axis * @see #getB */ public void setB(Vector3d newAxis); /** * Gets the B unit cell axes in carthesian coordinates * as a three element double array. * * @return a Vector3D representing the B axis * @see #setB */ public Vector3d getB(); /** * Sets the C unit cell axes in carthesian coordinates. * * @param newAxis the new C axis * @see #getC */ public void setC(Vector3d newAxis); /** * Gets the C unit cell axes in carthesian coordinates * as a three element double array. * * @return a Vector3D representing the C axis * @see #setC */ public Vector3d getC(); /** * Gets the space group of this crystal. * * @return the space group of this crystal structure * @see #setSpaceGroup */ public String getSpaceGroup(); /** * Sets the space group of this crystal. * * @param group the space group of this crystal structure * @see #getSpaceGroup */ public void setSpaceGroup(String group); /** * Gets the number of asymmetric parts in the unit cell. * * @return the number of assymetric parts in the unit cell * @see #setZ */ public Integer getZ(); /** * Sets the number of assymmetric parts in the unit cell. * * @param value the number of assymetric parts in the unit cell * @see #getZ */ public void setZ(Integer value); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IElectronContainer.java100644 0 0 3140 11570154753 23544 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; /** * Base class for entities containing electrons, like bonds, orbitals, lone-pairs. * * @cdk.module interfaces * @cdk.githash * * @cdk.keyword electron */ public interface IElectronContainer extends IChemObject { /** * Returns the number of electrons in this electron container. * * @return The number of electrons in this electron container. * @see #setElectronCount */ public Integer getElectronCount(); /** * Sets the number of electrons in this electron container. * * @param electronCount The number of electrons in this electron container. * @see #getElectronCount */ public void setElectronCount(Integer electronCount); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IElement.java100644 0 0 4602 11570154753 21523 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; /** * Implements the idea of an element in the periodic table. * * @cdk.module interfaces * @cdk.githash * @cdk.keyword element * @cdk.keyword atomic number * @cdk.keyword number, atomic */ public interface IElement extends IChemObject { /** * Returns the atomic number of this element. * *

Once instantiated all field not filled by passing parameters * to the constructor are null. Elements can be configured by using * the IsotopeFactory.configure() method: *

	 *   Element element = new Element("C");
	 *   IsotopeFactory if = IsotopeFactory.getInstance(element.getBuilder());
	 *   if.configure(element);
	 * 
*

* * @return The atomic number of this element * * @see #setAtomicNumber */ public Integer getAtomicNumber(); /** * Sets the atomic number of this element. * * @param atomicNumber The atomic mass to be assigned to this element * * @see #getAtomicNumber */ public void setAtomicNumber(Integer atomicNumber); /** * Returns the element symbol of this element. * * @return The element symbol of this element. Null if unset. * * @see #setSymbol */ public String getSymbol(); /** * Sets the element symbol of this element. * * @param symbol The element symbol to be assigned to this atom * * @see #getSymbol */ public void setSymbol(String symbol); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IFragmentAtom.java100644 0 0 4005 11570154753 22513 0ustar 0 0 /* $Revision$ $Author$$Date$ * * Copyright (C) 2007 Egon Willighagen * * 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 org.openscience.cdk.interfaces; /** * Class to represent an IPseudoAtom which embeds an IAtomContainer. Very much * like the MDL molfile Group concept. * * @cdk.module interfaces * @cdk.githash * * @author egonw */ public interface IFragmentAtom extends IPseudoAtom { /** * Helper method to indicate that the method should be drawn fully, and not * just the abbreviated form. * * @return true, if it should be considered in expended form */ public boolean isExpanded(); public void setExpanded(boolean bool); /** * Returns the fully expended form of the IFragmentAtom. * * @return the fully expanded form as an IAtomContainer object */ public IAtomContainer getFragment(); /** * Sets the fully expended form of the IFragmentAtom. * * @param fragment The fragment */ public void setFragment(IAtomContainer fragment); }cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IIsotope.java100644 0 0 5064 11570154753 21557 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; /** * Used to store and retrieve data of a particular isotope. * * @cdk.module interfaces * @cdk.githash * * @author egonw * @cdk.created 2005-08-24 * @cdk.keyword isotope * @cdk.keyword mass number * @cdk.keyword number, mass */ public interface IIsotope extends IElement { /** * Sets the NaturalAbundance attribute of the Isotope object. * * @param naturalAbundance The new NaturalAbundance value * * @see #getNaturalAbundance */ public void setNaturalAbundance(Double naturalAbundance); /** * Sets the ExactMass attribute of the Isotope object. * * @param exactMass The new ExactMass value * * @see #getExactMass */ public void setExactMass(Double exactMass); /** * Gets the NaturalAbundance attribute of the Isotope object. * Returns null when unconfigured. * * @return The NaturalAbundance value * * @see #setNaturalAbundance */ public Double getNaturalAbundance(); /** * Gets the ExactMass attribute of the Isotope object. * Returns null when unconfigured. * * @return The ExactMass value * * @see #setExactMass */ public Double getExactMass(); /** * Returns the atomic mass of this element. * Returns null when unconfigured. * * @return The atomic mass of this element * * @see #setMassNumber(Integer) */ public Integer getMassNumber(); /** * Sets the atomic mass of this element. * * @param massNumber The atomic mass to be assigned to this element * * @see #getMassNumber */ public void setMassNumber(Integer massNumber); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/ILonePair.java100644 0 0 3407 11570154753 21645 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; /** * A LonePair is an orbital primarily located with one Atom, containing * two electrons. * * @cdk.module interfaces * @cdk.githash * * @cdk.keyword orbital * @cdk.keyword lone-pair */ public interface ILonePair extends IElectronContainer { /** * Returns the associated Atom. * * @return the associated Atom. * @see #setAtom */ public IAtom getAtom(); /** * Sets the associated Atom. * * @param atom the Atom this lone pair will be associated with * @see #getAtom */ public void setAtom(IAtom atom); /** * Returns true if the given atom participates in this lone pair. * * @param atom The atom to be tested if it participates in this bond * @return true if this lone pair is associated with the atom */ public boolean contains(IAtom atom); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IMapping.java100644 0 0 3122 11570154753 21521 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Kai Hartmann * * 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. * * 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.interfaces; /** * Represents a mapping of two atoms. * * @cdk.module interfaces * @cdk.githash * @author kaihartmann * @cdk.created 2006-02-15 */ public interface IMapping extends IChemObject { /** * Returns an {@link Iterable} to the two IChemObjects. * * @return An {@link Iterable} to two IChemObjects that define the mapping */ public Iterable relatedChemObjects(); /** * Retrieve the first or second of the related IChemObjects. * * @param pos The position of the IChemObject. * @return The IChemObject to retrieve. */ public IChemObject getChemObject(int pos); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IMolecularFormula.java100644 0 0 14222 11570154753 23422 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2007 Miguel Rojasch * * 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. * * 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.interfaces; import java.util.Map; /** * Class defining a molecular formula object. It maintains * a list of IISotope.

* * Examples: *

    *
  • [C5H5]-
  • *
  • C6H6
  • *
  • 12C513CH6
  • *
* * @cdk.module interfaces * @author miguelrojasch * @cdk.created 2007-11-20 * @cdk.keyword molecular formula */ public interface IMolecularFormula{ /** * Adds an molecularFormula to this MolecularFormula. * * @param formula The molecularFormula to be added to this chemObject */ public IMolecularFormula add(IMolecularFormula formula); /** * Adds an Isotope to this MolecularFormula one time. * * @param isotope The isotope to be added to this MolecularFormula * @see #addIsotope(IIsotope, int) */ public IMolecularFormula addIsotope(IIsotope isotope); /** * Adds an Isotope to this MolecularFormula in a number of occurrences. * * @param isotope The isotope to be added to this MolecularFormula * @param count The number of occurrences to add * @see #addIsotope(IIsotope) */ public IMolecularFormula addIsotope(IIsotope isotope, int count); /** * Checks a set of Nodes for the occurrence of the isotope in the * IMolecularFormula from a particular isotope. It returns 0 if the does not exist. * * @param isotope The IIsotope to look for * @return The occurrence of this isotope in this IMolecularFormula * @see #getIsotopeCount() */ public int getIsotopeCount(IIsotope isotope); /** * Returns an {@link Iterable} for looping over all isotopes in this IMolecularFormula. * * @return An {@link Iterable} with the isotopes in this IMolecularFormula */ public Iterable isotopes(); /** * Checks a set of Nodes for the number of different isotopes in the * IMolecularFormula. * * @return The the number of different isotopes in this IMolecularFormula * @see #getIsotopeCount(IIsotope) */ public int getIsotopeCount(); /** * True, if the MolecularFormula contains the given IIsotope object. Not * the instance. The method looks for other isotopes which has the same * symbol, natural abundance and exact mass. * * @param isotope The IIsotope this IMolecularFormula is searched for * @return True, if the IMolecularFormula contains the given isotope object */ public boolean contains(IIsotope isotope); /** * Removes the given isotope from the MolecularFormula. * * @param isotope The IIsotope to be removed */ public void removeIsotope(IIsotope isotope); /** * Removes all isotopes of this molecular formula. */ public void removeAllIsotopes(); /** * Sets the partial charge of this IMolecularFormula. * * @param charge The partial charge * * @see #getCharge */ public void setCharge(Integer charge) ; /** * Returns the partial charge of this IMolecularFormula. If the charge * has not been set the return value is Double.NaN. * * @return the charge of this IMolecularFormula * * @see #setCharge */ public Integer getCharge(); /** * Clones this MolecularFormula object and its content. * * @return The cloned object */ public Object clone() throws CloneNotSupportedException ; /** * Sets a property for a IChemObject. I should * integrate into ChemObject. * *@param description An object description of the property (most likely a * unique string) *@param property An object with the property itself *@see #getProperty *@see #removeProperty */ public void setProperty(Object description, Object property); /** * Removes a property for a IChemObject. I should * integrate into ChemObject. * *@param description The object description of the property (most likely a * unique string) *@see #setProperty *@see #getProperty */ public void removeProperty(Object description); /** * Returns a property for the IChemObject. I should * integrate into ChemObject. * *@param description An object description of the property (most likely a * unique string) *@return The object containing the property. Returns null if * property is not set. *@see #setProperty *@see #removeProperty */ public Object getProperty(Object description); /** * Returns a Map with the IChemObject's properties.I should * integrate into ChemObject. * *@return The object's properties as an Hashtable *@see #setProperties */ public Map getProperties(); /** * Sets the properties of this object.I should * integrate into ChemObject. * *@param properties a Hashtable specifying the property values *@see #getProperties */ public void setProperties(Map properties); /** * Returns a ChemObjectBuilder for the data classes that extend * this class. * * @return The IChemObjectBuilder matching this IChemObject */ public IChemObjectBuilder getBuilder(); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IMolecularFormulaSet.java100644 0 0 7511 11570154753 24061 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2007 Miguel Rojasch * * 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. * * 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.interfaces; /** * Class defining a molecular formula object. It maintains * a list of list IMoleculaFormula.

* * Examples: *

    *
  • [C5H5]-
  • *
  • C6H6
  • *
  • 12C513CH6
  • *
* * @cdk.module interfaces * @author miguelrojasch * @cdk.created 2007-11-20 * @cdk.keyword molecular formula */ public interface IMolecularFormulaSet { /** * Adds all molecularFormulas in the MolecularFormulaSet to this chemObject. * * @param formulaSet The MolecularFormulaSet */ public void add(IMolecularFormulaSet formulaSet); /** * Adds an IMolecularFormula to this chemObject. * * @param formula The IMolecularFormula to be added to this chemObject */ public void addMolecularFormula(IMolecularFormula formula); /** * * Returns the IMolecularFormula at position number in the * chemObject. * * @param position The position of the MolecularFormula to be returned. * @return The IMolecularFormula at position number . */ public IMolecularFormula getMolecularFormula(int position); /** * Returns the array of IMolecularFormula of this chemObject. * * @return The array of IMolecularFormulas of this chemObject * * @see #addMolecularFormula(IMolecularFormula) */ public Iterable molecularFormulas(); /** * Returns the number of MolecularFormulas in this IMolecularFormulaSet. * * @return The number of MolecularFormulas in this IMolecularFormulaSet */ public int size(); /** * True, if the IMolecularFormulaSet contains the given IMolecularFormula object. * * @param formula The IMolecularFormula this IMolecularFormulaSet is searched for * @return True, if the IMolecularFormulaSet contains the given formula object */ public boolean contains(IMolecularFormula formula); /** * Removes the given IMolecularFormula from the IMolecularFormulaSet. * * @param formula The IMolecularFormula to be removed */ public void removeMolecularFormula(IMolecularFormula formula); /** * Removes the IMolecularFormula at the given position from the IMolecularFormulaSet. * * @param position The position of the IMolecularFormula to be removed. */ public void removeMolecularFormula(int position); /** * Removes all IMolecularFormula of this IMolecularFormulaSet. */ public void removeAllMolecularFormulas(); /** * Clones this IMolecularFormulaSet object and its content. * * @return The cloned object */ public Object clone() throws CloneNotSupportedException ; /** * Returns a ChemObjectBuilder for the data classes that extend * this class. * * @return The IChemObjectBuilder matching this IChemObject */ public IChemObjectBuilder getBuilder(); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IMolecule.java100644 0 0 2167 11570154753 21703 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; /** * Represents a set of Molecules. * * @cdk.module interfaces * @cdk.githash * @author egonw * @cdk.created 2005-08-25 */ public interface IMolecule extends IAtomContainer { } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IMoleculeSet.java100644 0 0 4714 11570154753 22357 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; /** * Represents a set of Molecules. * * @cdk.module interfaces * @cdk.githash * @author egonw * @cdk.created 2005-08-25 */ public interface IMoleculeSet extends IAtomContainerSet { /** * Adds an IMolecule to this container. * * @param molecule The molecule to be added to this container */ public void addMolecule(IMolecule molecule); /** * Adds all molecules in the MoleculeSet to this container. * * @param moleculeSet The MoleculeSet to add */ public void add(IMoleculeSet moleculeSet); /** * Sets the molecules in the IMoleculeSet, removing previously added * IMolecule's. * * @param molecules New set of molecules * @see #molecules() */ public void setMolecules(IMolecule[] molecules); /** * Returns the array of Molecules of this container. * * @return The array of Molecules of this container * @see #setMolecules(IMolecule[]) */ public Iterable molecules(); /** * Returns the Molecule at position number in the * container. * * @param number The position of the Molecule to be returned. * @return The Molecule at position number . */ public IMolecule getMolecule(int number); /** * Returns the number of Molecules in this Container. * * @return The number of Molecules in this Container */ public int getMoleculeCount(); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IMonomer.java100644 0 0 4315 11570154753 21547 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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 org.openscience.cdk.interfaces; /** * A Monomer is an AtomContainer which stores additional monomer specific * informations for a group of Atoms. * * @cdk.module interfaces * @cdk.githash * * @author Edgar Luttmann * @cdk.created 2001-08-06 * * @cdk.keyword monomer */ public interface IMonomer extends IAtomContainer { /** * Retrieve the monomer name. * * @return The name of the Monomer object * @see #setMonomerName */ public String getMonomerName(); /** * Retrieve the monomer type. * * @return The type of the Monomer object * @see #setMonomerType */ public String getMonomerType(); /** * Set the name of the Monomer object. * * @param cMonomerName The new name for this monomer * @see #getMonomerName */ public void setMonomerName(String cMonomerName); /** * Set the type of the Monomer object. * * @param cMonomerType The new type for this monomer * @see #getMonomerType */ public void setMonomerType(String cMonomerType); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IPDBAtom.java100644 0 0 12345 11570154753 21403 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Miguel Rojas * * 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. * * 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.interfaces; /** * A PDBAtom is a subclass of a Atom which is supposed to store * additional informations about the Atom * * @cdk.module interfaces * @cdk.githash * * @author Miguel Rojas * @cdk.created 2006-11-20 * * @cdk.keyword pdbpolymer */ public interface IPDBAtom extends IAtom { /** * get one entire line from the PDB entry file which describe the IPDBAtom. * It consists of 80 columns. * * @return a String with all information */ public String getRecord(); /** * set one entire line from the PDB entry file which describe the IPDBAtom. * It consists of 80 columns. * * @param newRecord A String with all information */ public void setRecord(String newRecord); /** * get the Temperature factor of this atom. * * @return the Temperature factor of this atom */ public Double getTempFactor(); /** * set the Temperature factor of this atom. * * @param newTempFactor the Temperature factor of this atom */ public void setTempFactor(Double newTempFactor); /** * get the Residue name of this atom. * * @return the Residue name of this atom */ public String getResName(); /** * set the Residue name of this atom. * * @param newResName the Residue name of this atom */ public void setResName(String newResName); /** * get Code for insertion of residues of this atom. * * @return the Code for insertion of residues of this atom */ public String getICode(); /** * set the Code for insertion of residues of this atom. * * @param newICode the Code for insertion of residues of this atom */ public void setICode(String newICode); /** * get the Atom name of this atom. * * @return the Atom name of this atom */ public String getName(); /** * set the Atom name of this atom. * * @param newName the Atom name of this atom */ public void setName(String newName); /** * get the Chain identifier of this atom. * * @return the Chain identifier of this atom */ public String getChainID(); /** * set the Chain identifier of this atom. * * @param newChainID the Chain identifier of this atom */ public void setChainID(String newChainID); /** * get the Alternate location indicator of this atom. * * @return the Alternate location indicator of this atom */ public String getAltLoc(); /** * set the Alternate location indicator of this atom. * * @param newAltLoc the Alternate location indicator of this atom */ public void setAltLoc(String newAltLoc); /** * get the Segment identifier, left-justified of this atom. * * @return the Segment identifier, left-justified of this atom */ public String getSegID(); /** * set the Segment identifier, left-justified of this atom. * * @param newSegID the Segment identifier, left-justified of this atom */ public void setSegID(String newSegID); /** * get the Atom serial number of this atom. * * @return the Atom serial number of this atom */ public Integer getSerial(); /** * set the Atom serial number of this atom. * * @param newSerial the Atom serial number of this atom */ public void setSerial(Integer newSerial); /** * get the Residue sequence number of this atom. * * @return the Residue sequence number of this atom */ public String getResSeq(); /** * set the Residue sequence number of this atom. * * @param newResSeq the Residue sequence number of this atom */ public void setResSeq(String newResSeq); public Boolean getOxt(); public void setOxt(Boolean newOxt); public Boolean getHetAtom(); public void setHetAtom(Boolean newHetAtom); /** * get the Occupancy of this atom. * * @return the Occupancy of this atom */ public Double getOccupancy(); /** * set the Occupancy of this atom. * * @param newOccupancy the Occupancy of this atom */ public void setOccupancy(Double newOccupancy); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IPDBMonomer.java100644 0 0 4221 11570154753 22071 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2006-2007 Miguel Rojas * * 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. * * 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.interfaces; /** * Represents the idea of an protein monomer as found in PDB files. * * @cdk.module interfaces * @cdk.githash * * @author Miguel Rojas * @cdk.created 2006-11-20 * * @cdk.keyword pdbpolymer */ public interface IPDBMonomer extends IMonomer { /** * Sets the ICode of this monomer. * * @param newICode the I code of this monomer */ public void setICode(String newICode); /** * Gets the ICode of this monomer. * * @return the ICode of this monomer */ public String getICode(); /** * Sets the Chain ID of this monomer. * * @param newChainID the Chain ID of this monomer */ public void setChainID(String newChainID); /** * Gets the Chain ID of this monomer. * * @return the Chain ID of this monomer */ public String getChainID(); /** * Gets the sequence identifier of this monomer. * * @return the sequence identifier of this monomer */ public String getResSeq(); /** * Sets the sequence identifier of this monomer. * * @param newResSeq the new sequence identifier of this monomer */ public void setResSeq(String newResSeq); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IPDBPolymer.java100644 0 0 5131 11570154753 22105 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Miguel Rojas * * 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 org.openscience.cdk.interfaces; import java.util.Collection; /** * A PDBPolymer is a subclass of a BioPolymer which is supposed to store * additional informations about the BioPolymer which are connected to BioPolymers. * * @cdk.module interfaces * @cdk.githash * * @author Miguel Rojas * @cdk.created 2006-11-20 * * @cdk.keyword polymer * @cdk.keyword biopolymer * @cdk.keyword pdbpolymer */ public interface IPDBPolymer extends IBioPolymer { /** * Adds the atom oAtom without specifying a Monomer or a Strand. Therefore the * atom to this AtomContainer, but not to a certain Strand or Monomer (intended * e.g. for HETATMs). * * @param oAtom The atom to add */ public void addAtom(IPDBAtom oAtom); /** * Adds the atom to a specified Strand and a specified Monomer. * * @param oAtom The atom to add * @param oMonomer The monomer the atom belongs to * @param oStrand The strand the atom belongs to */ public void addAtom(IPDBAtom oAtom, IMonomer oMonomer, IStrand oStrand); /** * Adds the PDBStructure structure a this PDBPolymer. * * @param structure The PDBStructure to add */ public void addStructure(IPDBStructure structure); /** * Returns a Collection containing the PDBStructure in the PDBPolymer. * * @return Collection containing the PDBStructure in the PDBPolymer */ public Collection getStructures(); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IPDBStructure.java100644 0 0 7755 11570154753 22474 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Miguel Rojas * * 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. * * 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.interfaces; /** * Represents the idea of an chemical structure. * * @cdk.module interfaces * @cdk.githash * * @author Miguel Rojas * @cdk.created 2006-11-20 * * @cdk.keyword pdbpolymer */ public interface IPDBStructure{ /** * get the ending Chain identifier of this structure. * * @return the ending Chain identifier of this structure */ public Character getEndChainID(); /** * set the ending Chain identifier of this structure. * * @param endChainID the ending Chain identifier of this structure */ public void setEndChainID(Character endChainID); /** * get the ending Code for insertion of residues of this structure. * * @return the ending Code for insertion of residues of this structure */ public Character getEndInsertionCode(); /** * set the ending Code for insertion of residues of this structure. * * @param endInsertionCode the ending Code for insertion of residues of this structure */ public void setEndInsertionCode(Character endInsertionCode); /** * get the ending sequence number of this structure. * * @return the ending sequence number of this structure */ public Integer getEndSequenceNumber(); /** * set the ending sequence number of this structure. * * @param endSequenceNumber the ending sequence number of this structure */ public void setEndSequenceNumber(Integer endSequenceNumber); /** * get start Chain identifier of this structure. * * @return the start Chain identifier of this structure */ public Character getStartChainID(); /** * set the start Chain identifier of this structure. * * @param startChainID the start Chain identifier of this structure */ public void setStartChainID(Character startChainID); /** * get start Code for insertion of residues of this structure. * * @return the start Code for insertion of residues of this structure */ public Character getStartInsertionCode(); /** * set the start Chain identifier of this structure. * * @param startInsertionCode the start Chain identifier of this structure */ public void setStartInsertionCode(Character startInsertionCode); /** * get the start sequence number of this structure. * * @return the start sequence number of this structure */ public Integer getStartSequenceNumber(); /** * set the start sequence number of this structure. * * @param startSequenceNumber the start sequence number of this structure */ public void setStartSequenceNumber(Integer startSequenceNumber); /** * get Structure Type of this structure. * * @return the Structure Type of this structure */ public String getStructureType(); /** * set the Structure Type of this structure. * * @param structureType the Structure Type of this structure */ public void setStructureType(String structureType); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IPolymer.java100644 0 0 5363 11570154753 21566 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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 org.openscience.cdk.interfaces; import java.util.Collection; /** * Subclass of Molecule to store Polymer specific attributes that a Polymer has. * * @cdk.module interfaces * @cdk.githash * * @author Edgar Luttmann * @author Martin Eklund * @cdk.created 2001-08-06 * @cdk.keyword polymer */ public interface IPolymer extends IMolecule { /** * Adds the atom oAtom without specifying a Monomer. Therefore the * atom to this AtomContainer, but not to a certain Monomer (intended * e.g. for HETATMs). * * @param oAtom The atom to add */ public void addAtom(IAtom oAtom); /** * Adds the atom oAtom to a specified Monomer. * * @param oAtom The atom to add * @param oMonomer The monomer the atom belongs to */ public void addAtom(IAtom oAtom, IMonomer oMonomer); /** * Return the number of monomers present in the Polymer. * * @return number of monomers */ public int getMonomerCount(); /** * Retrieve a Monomer object by specifying its name. * * @param cName The name of the monomer to look for * @return The Monomer object which was asked for */ public IMonomer getMonomer(String cName); /** * Returns a collection of the names of all Monomers in this * polymer. * * @return a Collection of all the monomer names. */ public Collection getMonomerNames(); /** * Removes a particular monomer, specified by its name. * * @param name The name of the monomer to be removed */ public void removeMonomer(String name); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IPseudoAtom.java100644 0 0 3515 11570154753 22214 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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 org.openscience.cdk.interfaces; /** * Represents the idea of a non-chemical atom-like entity, like Me, * R, X, Phe, His, etc. * *

This should be replaced by the mechanism explained in RFC #8. * * @cdk.module interfaces * @cdk.githash * * @see IAtom */ public interface IPseudoAtom extends IAtom { /** * Returns the label of this PseudoAtom. * * @return The label for this PseudoAtom * @see #setLabel */ public String getLabel(); /** * Sets the label of this PseudoAtom. * * @param label The new label for this PseudoAtom * @see #getLabel */ public void setLabel(String label); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IReaction.java100644 0 0 21744 11570154753 21724 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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 org.openscience.cdk.interfaces; /** * Represents the idea of a chemical reaction. The reaction consists of * a set of reactants and a set of products. * *

The class mostly represents abstract reactions, such as 2D diagrams, * and is not intended to represent reaction trajectories. Such can better * be represented with a ChemSequence. * * @cdk.module interfaces * @cdk.githash * * @author Egon Willighagen * @cdk.created 2003-02-13 * @cdk.keyword reaction */ public interface IReaction extends IChemObject { public enum Direction { /** Reaction equilibrium which is (almost) fully on the product side. Often denoted with a forward arrow. */ FORWARD, /** Reaction equilibrium which is (almost) fully on the reactant side. Often denoted with a backward arrow. */ BACKWARD, /** Reaction equilibrium state. Often denoted by a double arrow. */ BIDIRECTIONAL } /** * Returns the number of reactants in this reaction. * * @return The number of reactants in this reaction */ public int getReactantCount(); /** * Returns the number of products in this reaction. * * @return The number of products in this reaction */ public int getProductCount(); /** * Returns a IMoleculeSet containing the reactants in this reaction. * * @return A IMoleculeSet containing the reactants in this reaction * @see #setReactants */ public IMoleculeSet getReactants(); /** * Assigns a IMoleculeSet to the reactants in this reaction. * * @param reactants The new set of reactants * @see #getReactants */ public void setReactants(IMoleculeSet reactants); /** * Returns a IMoleculeSet containing the products of this reaction. * * @return A IMoleculeSet containing the products in this reaction * @see #setProducts */ public IMoleculeSet getProducts(); /** * Assigns a IMoleculeSet to the products of this reaction. * * @param products The new set of products * @see #getProducts */ public void setProducts(IMoleculeSet products); /** * Returns a IMoleculeSet containing the agents in this reaction. * * @return A IMoleculeSet containing the agents in this reaction * @see #addAgent */ public IMoleculeSet getAgents(); /** * Returns the mappings between the reactant and the product side. * * @return An {@link Iterable} to the Mappings. * @see #addMapping */ public Iterable mappings(); /** * Adds a reactant to this reaction. * * @param reactant Molecule added as reactant to this reaction * @see #getReactants */ public void addReactant(IMolecule reactant); /** * Adds an agent to this reaction. * * @param agent Molecule added as agent to this reaction * @see #getAgents */ public void addAgent(IMolecule agent); /** * Adds a reactant to this reaction with a stoichiometry coefficient. * * @param reactant Molecule added as reactant to this reaction * @param coefficient Stoichiometry coefficient for this molecule * @see #getReactants */ public void addReactant(IMolecule reactant, Double coefficient); /** * Adds a product to this reaction. * * @param product Molecule added as product to this reaction * @see #getProducts */ public void addProduct(IMolecule product); /** * Adds a product to this reaction. * * @param product Molecule added as product to this reaction * @param coefficient Stoichiometry coefficient for this molecule * @see #getProducts */ public void addProduct(IMolecule product, Double coefficient); /** * Returns the stoichiometry coefficient of the given reactant. * * @param reactant Reactant for which the coefficient is returned. * @return -1, if the given molecule is not a product in this Reaction * @see #setReactantCoefficient */ public Double getReactantCoefficient(IMolecule reactant); /** * Returns the stoichiometry coefficient of the given product. * * @param product Product for which the coefficient is returned. * @return -1, if the given molecule is not a product in this Reaction * @see #setProductCoefficient */ public Double getProductCoefficient(IMolecule product); /** * Sets the coefficient of a a reactant to a given value. * * @param reactant Reactant for which the coefficient is set * @param coefficient The new coefficient for the given reactant * @return true if Molecule has been found and stoichiometry has been set. * @see #getReactantCoefficient */ public boolean setReactantCoefficient(IMolecule reactant, Double coefficient); /** * Sets the coefficient of a a product to a given value. * * @param product Product for which the coefficient is set * @param coefficient The new coefficient for the given product * @return true if Molecule has been found and stoichiometry has been set. * @see #getProductCoefficient */ public boolean setProductCoefficient(IMolecule product, Double coefficient); /** * Returns an array of double with the stoichiometric coefficients * of the reactants. * * @return An array of double's containing the coefficients of the reactants * @see #setReactantCoefficients */ public Double[] getReactantCoefficients(); /** * Returns an array of double with the stoichiometric coefficients * of the products. * * @return An array of double's containing the coefficients of the products * @see #setProductCoefficients */ public Double[] getProductCoefficients(); /** * Sets the coefficients of the reactants. * * @param coefficients An array of double's containing the coefficients of the reactants * @return true if coefficients have been set. * @see #getReactantCoefficients */ public boolean setReactantCoefficients(Double[] coefficients); /** * Sets the coefficient of the products. * * @param coefficients An array of double's containing the coefficients of the products * @return true if coefficients have been set. * @see #getProductCoefficients */ public boolean setProductCoefficients(Double[] coefficients); /** * Sets the direction of the reaction. * * @param direction The new reaction direction * @see #getDirection */ public void setDirection(IReaction.Direction direction); /** * Returns the {@link IReaction.Direction} of the reaction. * * @return The direction of this reaction (FORWARD, BACKWARD or BIDIRECTIONAL). * @see #setDirection(Direction) */ public IReaction.Direction getDirection(); /** * Adds a mapping between the reactant and product side to this * Reaction. * * @param mapping Mapping to add. * @see #mappings */ public void addMapping(IMapping mapping); /** * Removes a mapping between the reactant and product side to this * Reaction. * * @param pos Position of the Mapping to remove. * @see #mappings */ public void removeMapping(int pos); /** * Retrieves a mapping between the reactant and product side to this * Reaction. * * @param pos Position of Mapping to get. */ public IMapping getMapping(int pos); /** * Get the number of mappings between the reactant and product side to this * Reaction. * * @return Number of stored Mappings. */ public int getMappingCount(); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IReactionScheme.java100644 0 0 4551 11570154753 23026 0ustar 0 0 /* * $RCSfile$ * $Author: egonw $ * $Date: 2006-03-29 10:27:08 +0200 (Wed, 29 Mar 2006) $ * $Revision: 5855 $ * * Copyright (C) 2006-2007 Miguel Rojas * * 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. * * 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.interfaces; /** * Classes that implement this interface of a scheme. * This is designed to contain a set of reactions which are linked in * some way but without hard coded semantics. * * @author miguelrojasch * @cdk.module interfaces */ public interface IReactionScheme extends IReactionSet{ /** * Add a scheme of reactions. * * @param reactScheme The IReactionScheme to include */ public void add(IReactionScheme reactScheme); /** * Returns an Iterable for looping over all IMolecularScheme * in this ReactionScheme. * * @return An Iterable with the IMolecularScheme in this ReactionScheme */ public Iterable reactionSchemes(); /** * Returns the number of ReactionScheme in this Scheme. * * @return The number of ReactionScheme in this Scheme */ public int getReactionSchemeCount(); /** * Removes all IReactionScheme from this chemObject. */ public void removeAllReactionSchemes(); /** * Removes an IReactionScheme from this chemObject. * * @param scheme The IReactionScheme to be removed from this chemObject */ public void removeReactionScheme(IReactionScheme scheme); /** * Clones this IReactionScheme object and its content. * * @return The cloned object */ public Object clone() throws CloneNotSupportedException ; } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IReactionSet.java100644 0 0 4576 11570154753 22364 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; /** * A set of reactions, for example those taking part in a reaction. * * @cdk.module interfaces * @cdk.githash * * @cdk.keyword reaction */ public interface IReactionSet extends IChemObject { /** * Adds an reaction to this container. * * @param reaction The reaction to be added to this container */ public void addReaction(IReaction reaction); /** * Remove a reaction from this set. * * @param pos The position of the reaction to be removed. */ public void removeReaction(int pos); /** * Returns the Reaction at position number in the * container. * * @param number The position of the Reaction to be returned * @return The Reaction at position number */ public IReaction getReaction(int number); /** * Returns the {@link Iterable} over Reactions of this container. * * @return The {@link Iterable} over Reactions of this container */ public Iterable reactions(); /** * Returns the number of Reactions in this Container. * * @return The number of Reactions in this Container */ public int getReactionCount(); /** * Removes all reactions from this set. */ public void removeAllReactions(); /** * Removes all instances of a reaction from this IReactionSet. * * @param relevantReaction */ public void removeReaction(IReaction relevantReaction); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IRing.java100644 0 0 4134 11570154753 21031 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; /** * Class representing a ring structure in a molecule. * A ring is a linear sequence of * N atoms interconnected to each other by covalent bonds, * such that atom i (1 < i < N) is bonded to * atom i-1 and atom i + 1 and atom 1 is bonded to atom N and atom 2. * * @cdk.module interfaces * @cdk.githash * * @cdk.keyword ring */ public interface IRing extends IAtomContainer { /** * Returns the number of atoms/bonds in this ring. * * @return The number of atoms/bonds in this ring */ public int getRingSize(); /** * Returns the next bond in order, relative to a given bond and atom. * Example: Let the ring be composed of 0-1, 1-2, 2-3 and 3-0. * A request getNextBond(1-2, 2) will return Bond 2-3. * * @param bond A bond for which an atom from a consecutive bond is sought * @param atom A atom from the bond above to assign a search direction * @return The next bond in the order given by the above assignment */ public IBond getNextBond(IBond bond, IAtom atom); /** * Returns the sum of all bond orders in the ring. * * @return the sum of all bond orders in the ring */ public int getBondOrderSum(); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IRingSet.java100644 0 0 5227 11570154753 21511 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; /** * Maintains a set of Ring objects. * * @cdk.module interfaces * @cdk.githash * * @cdk.keyword ring, set of */ public interface IRingSet extends IAtomContainerSet { /** * Returns a vector of all rings that this bond is part of. * * @param bond The bond to be checked * @return A vector of all rings that this bond is part of */ public IRingSet getRings(IBond bond); /** * Returns a vector of all rings that this atom is part of. * * @param atom The atom to be checked * @return A vector of all rings that this bond is part of */ public IRingSet getRings(IAtom atom); /** * Returns all the rings in the RingSet that share * one or more atoms with a given ring. * * @param ring A ring with which all return rings must share one or more atoms * @return All the rings that share one or more atoms with a given ring. */ public IRingSet getConnectedRings(IRing ring); /** * Adds all rings of another RingSet if they are not allready part of this ring set. * * If you want to add a single ring to the set use {@link #addAtomContainer(org.openscience.cdk.interfaces.IAtomContainer)} * * @param ringSet the ring set to be united with this one. */ public void add(IRingSet ringSet); /** * True, if at least one of the rings in the ringset contains * the given atom. * * @param atom IAtom to check * @return true, if the ringset contains the atom */ public boolean contains(IAtom atom); /** * True, if this set contains the IAtomContainer. * * @param container IAtomContainer to check * @return true, if the ringset contains the container */ public boolean contains(IAtomContainer container); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/ISingleElectron.java100644 0 0 4144 11570154753 23050 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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. * * 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.interfaces; /** * A Single Electron is an orbital which is occupied by only one electron. * A radical in CDK is represented by an AtomContainer that contains an Atom * and a SingleElectron type ElectronContainer: *

 *   AtomContainer radical = new AtomContainer();
 *   Atom carbon = new Atom("C");
 *   carbon.setImplicitHydrogens(3);
 *   radical.addElectronContainer(new SingleElectron(carbon));
 * 
* * @cdk.module interfaces * @cdk.githash * * @cdk.keyword radical * @cdk.keyword electron, unpaired */ public interface ISingleElectron extends IElectronContainer { /** * Returns the associated Atom. * * @return the associated Atom. * @see #setAtom */ public IAtom getAtom(); /** * Sets the associated Atom. * * @param atom the Atom this SingleElectron will be associated with * @see #getAtom */ public void setAtom(IAtom atom); /** * Returns true if the given atom participates in this SingleElectron. * * @param atom The atom to be tested if it participates in this bond * @return true if this SingleElectron is associated with the atom */ public boolean contains(IAtom atom); } cdk-1.2.10/src/main/org/openscience/cdk/interfaces/IStrand.java100644 0 0 7045 11570154753 21371 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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 org.openscience.cdk.interfaces; import java.util.Collection; import java.util.Map; /** * A Strand is an AtomContainer which stores additional strand specific * informations for a group of Atoms. * * @cdk.module interfaces * @cdk.githash * @cdk.created 2004-12-20 * @author Martin Eklund */ public interface IStrand extends IAtomContainer { /** * Retrieve the strand name. * * @return The name of the Strand object * @see #setStrandName(String) */ public String getStrandName(); /** * Retrieve the strand type. * * @return The type of the Strand object * @see #setStrandType(String) */ public String getStrandType(); /** * Set the name of the Strand object. * * @param cStrandName The new name for this strand * @see #getStrandName() */ public void setStrandName(String cStrandName); /** * Set the type of the Strand object. * * @param cStrandType The new type for this strand * @see #getStrandType() */ public void setStrandType(String cStrandType); /** * Adds the atom oAtom without specifying a Monomer or a Strand. Therefore the * atom gets added to a Monomer of type UNKNOWN in a Strand of type UNKNOWN. * * @param oAtom The atom to add */ public void addAtom(IAtom oAtom); /** * Adds the atom oAtom to a specific Monomer. * * @param oAtom The atom to add * @param oMonomer The monomer the atom belongs to */ public void addAtom(IAtom oAtom, IMonomer oMonomer); /** * Return the number of monomers present in the Strand. * * @return number of monomers */ public int getMonomerCount(); /** * Retrieve a Monomer object by specifying its name. * * @param cName The name of the monomer to look for * @return The Monomer object which was asked for */ public IMonomer getMonomer(String cName); /** * Returns a collection of the names of all Monomers in this * polymer. * * @return a Collection of all the monomer names. */ public Collection getMonomerNames(); /** * Removes a particular monomer, specified by its name. * * @param name The name of the monomer to remove */ public void removeMonomer(String name); /** * Returns the monomers in this strand. * * @return Map containing the monomers in the strand. */ public Map getMonomers(); } cdk-1.2.10/src/main/org/openscience/cdk/io/CDKSourceCodeWriter.java100644 0 0 23136 11570154753 22102 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2003-2007 Egon Willighagen * * 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 org.openscience.cdk.io; import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.StringWriter; import java.io.Writer; import java.util.Iterator; import javax.vecmath.Point2d; import javax.vecmath.Point3d; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IPseudoAtom; import org.openscience.cdk.io.formats.CDKSourceCodeFormat; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.setting.BooleanIOSetting; import org.openscience.cdk.io.setting.IOSetting; import org.openscience.cdk.tools.DataFeatures; import org.openscience.cdk.tools.IDCreator; import org.openscience.cdk.tools.LoggingTool; /** * Converts a Molecule into CDK source code that would build the same * molecule. It's typical use is: *
 * StringWriter stringWriter = new StringWriter();
 * ChemObjectWriter writer = new CDKSourceCodeWriter(stringWriter);
 * writer.write((Molecule)molecule);
 * writer.close();
 * System.out.print(stringWriter.toString());
 * 
* * @cdk.module io * @cdk.githash * * @author Egon Willighagen * @cdk.created 2003-10-01 * * @cdk.keyword file format, CDK source code */ @TestClass("org.openscience.cdk.io.CDKSourceCodeWriterTest") public class CDKSourceCodeWriter extends DefaultChemObjectWriter { private BufferedWriter writer; private LoggingTool logger; private BooleanIOSetting write2DCoordinates; private BooleanIOSetting write3DCoordinates; /** * Constructs a new CDKSourceCodeWriter. * * @param out The Writer to write to */ public CDKSourceCodeWriter(Writer out) { logger = new LoggingTool(this); initIOSettings(); try { setWriter(out); } catch (Exception exc) { } } public CDKSourceCodeWriter(OutputStream out) { this(new OutputStreamWriter(out)); } public CDKSourceCodeWriter() { this(new StringWriter()); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return CDKSourceCodeFormat.getInstance(); } public void setWriter(Writer out) throws CDKException { if (out instanceof BufferedWriter) { writer = (BufferedWriter)out; } else { writer = new BufferedWriter(out); } } public void setWriter(OutputStream output) throws CDKException { setWriter(new OutputStreamWriter(output)); } /** * Flushes the output and closes this object. */ @TestMethod("testClose") public void close() throws IOException { writer.flush(); writer.close(); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i atoms = molecule.atoms().iterator(); while (atoms.hasNext()) { IAtom atom = (IAtom)atoms.next(); writeAtom(atom); writer.write(" mol.addAtom(" + atom.getID() + ");"); writer.newLine(); } } private void writeBonds(IAtomContainer molecule) throws Exception { Iterator bonds = molecule.bonds().iterator(); while (bonds.hasNext()) { IBond bond = (IBond) bonds.next(); writeBond(bond); writer.write(" mol.addBond(" + bond.getID() + ");"); writer.newLine(); } } public void writeMolecule(IMolecule molecule) throws Exception { writer.write("{"); writer.newLine(); writer.write(" IMolecule mol = new Molecule();"); writer.newLine(); IDCreator.createIDs(molecule); writeAtoms(molecule); writeBonds(molecule); writer.write("}"); writer.newLine(); } public void writeAtomContainer(IAtomContainer molecule) throws Exception { writer.write("{"); writer.newLine(); writer.write(" IAtomContainer mol = new AtomContainer();"); writer.newLine(); IDCreator.createIDs(molecule); writeAtoms(molecule); writeBonds(molecule); writer.write("}"); writer.newLine(); } public void writeAtom(IAtom atom) throws Exception { if (atom instanceof IPseudoAtom) { writer.write(" IPseudoAtom " + atom.getID() + " = mol.getBuilder().newPseudoAtom();"); writer.newLine(); writer.write(" atom.setLabel(\"" + ((IPseudoAtom)atom).getLabel() + "\");"); writer.newLine(); } else { writer.write(" IAtom " + atom.getID() + " = mol.getBuilder().newAtom(\"" + atom.getSymbol() + "\");"); writer.newLine(); } if (atom.getFormalCharge() != null) { writer.write(" " + atom.getID() + ".setFormalCharge(" + atom.getFormalCharge() + ");"); writer.newLine(); } if (write2DCoordinates.isSet() && atom.getPoint2d() != null) { Point2d p2d = atom.getPoint2d(); writer.write(" " + atom.getID() + ".setPoint2d(new Point2d(" + p2d.x + ", " + p2d.y + "));"); writer.newLine(); } if (write3DCoordinates.isSet() && atom.getPoint3d() != null) { Point3d p3d = atom.getPoint3d(); writer.write(" " + atom.getID() + ".setPoint3d(new Point3d(" + p3d.x + ", " + p3d.y + ", " + p3d.z + "));"); writer.newLine(); } } public void writeBond(IBond bond) throws Exception { writer.write(" IBond " + bond.getID() + " = mol.getBuilder().newBond(" + bond.getAtom(0).getID() + ", " + bond.getAtom(1).getID() + ", IBond.Order." + bond.getOrder() + ");"); writer.newLine(); } public int getSupportedDataFeatures() { return DataFeatures.HAS_2D_COORDINATES | DataFeatures.HAS_3D_COORDINATES | DataFeatures.HAS_GRAPH_REPRESENTATION | DataFeatures.HAS_ATOM_ELEMENT_SYMBOL; } public int getRequiredDataFeatures() { return DataFeatures.HAS_GRAPH_REPRESENTATION | DataFeatures.HAS_ATOM_ELEMENT_SYMBOL; } private void initIOSettings() { write2DCoordinates = new BooleanIOSetting("write2DCoordinates", IOSetting.LOW, "Should 2D coordinates be added?", "true"); write3DCoordinates = new BooleanIOSetting("write3DCoordinates", IOSetting.LOW, "Should 3D coordinates be added?", "true"); } private void customizeJob() { fireIOSettingQuestion(write2DCoordinates); fireIOSettingQuestion(write3DCoordinates); } public IOSetting[] getIOSettings() { IOSetting[] settings = new IOSetting[2]; settings[0] = write2DCoordinates; settings[1] = write3DCoordinates; return settings; } } cdk-1.2.10/src/main/org/openscience/cdk/io/CIFReader.java100644 0 0 42671 11570154753 20061 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.io; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.util.StringTokenizer; import javax.vecmath.Point3d; import javax.vecmath.Vector3d; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.ICrystal; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.geometry.CrystalGeometryTools; import org.openscience.cdk.io.formats.CIFFormat; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.tools.LoggingTool; /** * This is not a reader for the CIF and mmCIF crystallographic formats. * It is able, however, to extract some content from such files. * It's very ad hoc, not written * using any dictionary. So please complain if something is not working. * In addition, the things it does read are considered experimental. * *

The CIF example on the IUCR website has been tested, as well as Crambin (1CRN) * in the PDB database. * * @cdk.module io * @cdk.githash * * @cdk.keyword file format, CIF * @cdk.keyword file format, mmCIF * * @author E.L. Willighagen * @cdk.created 2003-10-12 */ @TestClass("org.openscience.cdk.io.CIFReaderTest") public class CIFReader extends DefaultChemObjectReader { private BufferedReader input; private LoggingTool logger; private ICrystal crystal = null; // cell parameters private double a = 0.0; private double b = 0.0; private double c = 0.0; private double alpha = 0.0; private double beta = 0.0; private double gamma = 0.0; /** * Create an CIF like file reader. * * @param input source of CIF data */ public CIFReader(Reader input) { this.input = new BufferedReader(input); this.logger = new LoggingTool(this); } public CIFReader(InputStream input) { this(new InputStreamReader(input)); } public CIFReader() { this(new StringReader("")); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return CIFFormat.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader reader) throws CDKException { this.input = new BufferedReader(input); } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class testClass) { Class[] interfaces = testClass.getInterfaces(); for (int i=0; i 0 && line.charAt(0) != '#') { line = input.readLine().trim(); } } private void processAtomLoopBlock(String firstLine) throws IOException { int atomLabel = -1; // -1 means not found in this block int atomSymbol = -1; int atomFractX = -1; int atomFractY = -1; int atomFractZ = -1; int atomRealX = -1; int atomRealY = -1; int atomRealZ = -1; String line = firstLine.trim(); int headerCount = 0; boolean hasParsableInformation = false; while (line != null && line.charAt(0) == '_') { headerCount++; if (line.equals("_atom_site_label") || line.equals("_atom_site_label_atom_id")) { atomLabel = headerCount; hasParsableInformation = true; logger.info("label found in col: " + atomLabel); } else if (line.startsWith("_atom_site_fract_x")) { atomFractX = headerCount; hasParsableInformation = true; logger.info("frac x found in col: " + atomFractX); } else if (line.startsWith("_atom_site_fract_y")) { atomFractY = headerCount; hasParsableInformation = true; logger.info("frac y found in col: " + atomFractY); } else if (line.startsWith("_atom_site_fract_z")) { atomFractZ = headerCount; hasParsableInformation = true; logger.info("frac z found in col: " + atomFractZ); } else if (line.equals("_atom_site.Cartn_x")) { atomRealX = headerCount; hasParsableInformation = true; logger.info("cart x found in col: " + atomRealX); } else if (line.equals("_atom_site.Cartn_y")) { atomRealY = headerCount; hasParsableInformation = true; logger.info("cart y found in col: " + atomRealY); } else if (line.equals("_atom_site.Cartn_z")) { atomRealZ = headerCount; hasParsableInformation = true; logger.info("cart z found in col: " + atomRealZ); } else if (line.equals("_atom_site.type_symbol")) { atomSymbol = headerCount; hasParsableInformation = true; logger.info("type_symbol found in col: " + atomSymbol); } else { logger.warn("Ignoring atom loop block field: " + line); } line = input.readLine().trim(); } if (hasParsableInformation == false ) { logger.info("No parsable info found"); skipUntilEmptyOrCommentLine(line); } else { // now that headers are parsed, read the data while(line != null && line.length() > 0 && line.charAt(0) != '#') { logger.debug("new row"); StringTokenizer tokenizer = new StringTokenizer(line); if (tokenizer.countTokens() < headerCount) { logger.warn("Column count mismatch; assuming continued on next line"); logger.debug("Found #expected, #found: " + headerCount + ", " + tokenizer.countTokens()); tokenizer = new StringTokenizer(line + input.readLine()); } int colIndex = 0; // process one row IAtom atom = crystal.getBuilder().newAtom("C"); Point3d frac = new Point3d(); Point3d real = new Point3d(); boolean hasFractional = false; boolean hasCartesian = false; while (tokenizer.hasMoreTokens()) { colIndex++; String field = tokenizer.nextToken(); logger.debug("Parsing col,token: " + colIndex + "=" + field); if (colIndex == atomLabel) { if (atomSymbol == -1) { // no atom symbol found, use label String element = extractFirstLetters(field); atom.setSymbol(element); } atom.setID(field); } else if (colIndex == atomFractX) { hasFractional = true; frac.x = parseIntoDouble(field); } else if (colIndex == atomFractY) { hasFractional = true; frac.y = parseIntoDouble(field); } else if (colIndex == atomFractZ) { hasFractional = true; frac.z = parseIntoDouble(field); } else if (colIndex == atomSymbol) { atom.setSymbol(field); } else if (colIndex == atomRealX) { hasCartesian = true; logger.debug("Adding x3: " + parseIntoDouble(field)); real.x = parseIntoDouble(field); } else if (colIndex == atomRealY) { hasCartesian = true; logger.debug("Adding y3: " + parseIntoDouble(field)); real.y = parseIntoDouble(field); } else if (colIndex == atomRealZ) { hasCartesian = true; logger.debug("Adding x3: " + parseIntoDouble(field)); real.z = parseIntoDouble(field); } } if (hasCartesian) { Vector3d a = crystal.getA(); Vector3d b = crystal.getB(); Vector3d c = crystal.getC(); frac = CrystalGeometryTools.cartesianToFractional(a, b, c, real); atom.setFractionalPoint3d(frac); } if (hasFractional) { atom.setFractionalPoint3d(frac); } logger.debug("Adding atom: " + atom); crystal.addAtom(atom); // look up next row line = input.readLine().trim(); } } } /** * Process double in the format: '.071(1)'. */ private double parseIntoDouble(String value) { double returnVal = 0.0; if (value.charAt(0) == '.') value = "0" + value; int bracketIndex = value.indexOf("("); if (bracketIndex != -1) { value = value.substring(0, bracketIndex); } try { returnVal = Double.parseDouble(value); } catch (Exception exception) { logger.error("Could not parse double string: " + value); } return returnVal; } private String extractFirstLetters(String value) { StringBuffer result = new StringBuffer(); for (int i=0; i * * 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 org.openscience.cdk.io; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.util.HashMap; import java.util.Map; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.io.cml.CMLErrorHandler; import org.openscience.cdk.io.cml.CMLHandler; import org.openscience.cdk.io.cml.CMLResolver; import org.openscience.cdk.io.cml.ICMLModule; import org.openscience.cdk.io.formats.CMLFormat; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.tools.LoggingTool; import org.xml.sax.InputSource; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; import org.xml.sax.XMLReader; /** * Reads a molecule in CML 1.x and 2.0 format. * CML is an XML based application {@cdk.cite PMR99}, and this Reader * applies the method described in {@cdk.cite WIL01}. * * @author Egon L. Willighagen * @cdk.created 2001-02-01 * @cdk.module io * @cdk.githash * @cdk.keyword file format, CML * @cdk.bug 1544406 */ @TestClass("org.openscience.cdk.io.CMLReaderTest") public class CMLReader extends DefaultChemObjectReader { private XMLReader parser; private InputStream input; private String url; private Map userConventions = new HashMap(); private LoggingTool logger; /** * Reads CML from an java.io.InputStream, for example the FileInputStream. * * @param input InputStream type input */ public CMLReader(InputStream input) { this.input = input; init(); } public CMLReader() { this(new ByteArrayInputStream(new byte[0])); } public void registerConvention(String convention, ICMLModule conv) { userConventions.put(convention, conv); } /** * Define this CMLReader to take the input from a java.io.Reader * class. Possible readers are (among others) StringReader and FileReader. * * @param url String url which points to the file to be read */ public CMLReader(String url) { this.init(); this.url = url; } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return CMLFormat.getInstance(); } /** * This method must not be used; XML reading requires the use of an InputStream. * Use setReader(InputStream) instead. */ @TestMethod("testSetReader_Reader") public void setReader(Reader reader) throws CDKException { throw new CDKException("Invalid method call; use SetReader(InputStream) instead."); } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { this.input = input; } private void init() { logger = new LoggingTool(this); url = ""; // make sure it is not null boolean success = false; // If JAXP is prefered (comes with Sun JVM 1.4.0 and higher) if (!success) { try { javax.xml.parsers.SAXParserFactory spf = javax.xml.parsers.SAXParserFactory.newInstance(); spf.setNamespaceAware(true); javax.xml.parsers.SAXParser saxParser = spf.newSAXParser(); parser = saxParser.getXMLReader(); logger.info("Using JAXP/SAX XML parser."); success = true; } catch (Exception e) { logger.warn("Could not instantiate JAXP/SAX XML reader: ", e.getMessage()); logger.debug(e); } } // Aelfred is first alternative. if (!success) { try { parser = (XMLReader)this.getClass().getClassLoader(). loadClass("gnu.xml.aelfred2.XmlReader"). newInstance(); logger.info("Using Aelfred2 XML parser."); success = true; } catch (Exception e) { logger.warn("Could not instantiate Aelfred2 XML reader!"); logger.debug(e); } } // Xerces is second alternative if (!success) { try { parser = (XMLReader)this.getClass().getClassLoader(). loadClass("org.apache.xerces.parsers.SAXParser"). newInstance(); logger.info("Using Xerces XML parser."); success = true; } catch (Exception e) { logger.warn("Could not instantiate Xerces XML reader!"); logger.debug(e); } } if (!success) { logger.error("Could not instantiate any XML parser!"); } } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i * Stefan Kuhn * Miguel Rojas-Cherto * * 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 org.openscience.cdk.io; import java.io.FileWriter; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.StringWriter; import java.io.Writer; import java.util.ArrayList; import java.util.List; import nu.xom.Attribute; import nu.xom.Document; import nu.xom.Element; import nu.xom.Serializer; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.ICrystal; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.interfaces.IPDBPolymer; import org.openscience.cdk.interfaces.IReaction; import org.openscience.cdk.interfaces.IReactionScheme; import org.openscience.cdk.interfaces.IReactionSet; import org.openscience.cdk.io.cml.CustomSerializer; import org.openscience.cdk.io.formats.CMLFormat; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.setting.BooleanIOSetting; import org.openscience.cdk.io.setting.IOSetting; import org.openscience.cdk.io.setting.StringIOSetting; import org.openscience.cdk.libio.cml.Convertor; import org.openscience.cdk.libio.cml.ICMLCustomizer; import org.openscience.cdk.tools.LoggingTool; /** * Serializes a {@link IMoleculeSet} or a {@link IMolecule} object to CML 2 code. * Chemical Markup Language is an XML-based file format {@cdk.cite PMR99}. * Output can be redirected to other Writer objects like {@link StringWriter} * and {@link FileWriter}. An example: * *

 *   StringWriter output = new StringWriter();
 *   boolean makeFragment = true;
 *   CMLWriter cmlwriter = new CMLWriter(output, makeFragment);
 *   cmlwriter.write(molecule);
 *   cmlwriter.close();
 *   String cmlcode = output.toString();
 * 
* *

Output to a file called "molecule.cml" can done with: * *

 *   FileWriter output = new FileWriter("molecule.cml");
 *   CMLWriter cmlwriter = new CMLWriter(output);
 *   cmlwriter.write(molecule);
 *   cmlwriter.close();
 * 
* *

For atoms it outputs: coordinates, element type and formal charge. * For bonds it outputs: order, atoms (2, or more) and wedges. * * @cdk.module libiocml * @cdk.githash * @cdk.builddepends xom-1.0.jar * @cdk.depends jumbo50.jar * @cdk.require java1.5+ * @cdk.bug 1565563 * * @see java.io.FileWriter * @see java.io.StringWriter * * @author Egon Willighagen * * @cdk.keyword file format, CML */ @TestClass("org.openscience.cdk.io.CMLWriterTest") public class CMLWriter extends DefaultChemObjectWriter { private OutputStream output; private Writer writer; private BooleanIOSetting cmlIds; private BooleanIOSetting namespacedOutput; private StringIOSetting namespacePrefix; private BooleanIOSetting schemaInstanceOutput; private StringIOSetting instanceLocation; private BooleanIOSetting indent; private BooleanIOSetting xmlDeclaration; private LoggingTool logger; private List customizers = null; /** * Constructs a new CMLWriter class. Output will be stored in the Writer * class given as parameter. The CML code will be valid CML code with a * XML header. Only one object can be stored. * * @param out Writer to redirect the output to. */ public CMLWriter(Writer out) { this.writer = out; output = new OutputStream() { public void write(int anInt) throws IOException { writer.write(anInt); } }; logger = new LoggingTool(this); initIOSettings(); } public CMLWriter(OutputStream output) { this.output = output; writer = null; logger = new LoggingTool(this); initIOSettings(); } public CMLWriter() { this(new StringWriter()); } public void registerCustomizer(ICMLCustomizer customizer) { if (customizers == null) customizers = new ArrayList(); customizers.add(customizer); logger.info("Loaded Customizer: ", customizer.getClass().getName()); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return CMLFormat.getInstance(); } public void setWriter(Writer writer) throws CDKException { this.writer = writer; } public void setWriter(OutputStream output) throws CDKException { //TODO dont know what the intention here is, but without this line it is not working... this.output = output; setWriter(new OutputStreamWriter(output)); } /** * Flushes the output and closes this object */ @TestMethod("testClose") public void close() throws IOException { output.close(); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i0) ? namespacePrefix.getSetting() : null ); // adding the customizer if (customizers != null) { for (ICMLCustomizer customizer : customizers) { convertor.registerCustomizer(customizer); } } // now convert the object Element root = null; if (object instanceof IPDBPolymer) { root = convertor.cdkPDBPolymerToCMLMolecule((IPDBPolymer)object); } else if (object instanceof IMolecule) { root = convertor.cdkMoleculeToCMLMolecule((IMolecule)object); } else if (object instanceof ICrystal) { root = convertor.cdkCrystalToCMLMolecule((ICrystal)object); } else if (object instanceof IAtom) { root = convertor.cdkAtomToCMLAtom(null, (IAtom)object); } else if (object instanceof IBond) { root = convertor.cdkBondToCMLBond((IBond)object); } else if (object instanceof IReaction) { root = convertor.cdkReactionToCMLReaction((IReaction)object); } else if (object instanceof IReactionScheme){ root = convertor.cdkReactionSchemeToCMLReactionSchemeAndMoleculeList((IReactionScheme)object); } else if (object instanceof IReactionSet) { root = convertor.cdkReactionSetToCMLReactionList((IReactionSet)object); } else if (object instanceof IMoleculeSet) { root = convertor.cdkMoleculeSetToCMLList((IMoleculeSet)object); } else if (object instanceof IChemSequence) { root = convertor.cdkChemSequenceToCMLList((IChemSequence)object); } else if (object instanceof IChemModel) { root = convertor.cdkChemModelToCMLList((IChemModel)object); } else if (object instanceof IAtomContainer) { root = convertor.cdkAtomContainerToCMLMolecule((IAtomContainer)object); } else if (object instanceof IChemFile) { root = convertor.cdkChemFileToCMLList((IChemFile)object); } Document doc = new Document(root); try { Serializer serializer = null; if (xmlDeclaration.isSet()) { serializer = new Serializer(output, "ISO-8859-1"); } else { serializer = new CustomSerializer(output, "ISO-8859-1"); } if (indent.isSet()) { logger.info("Indenting XML output"); serializer.setIndent(2); } if (schemaInstanceOutput.isSet()) { root.addNamespaceDeclaration("xsi", "http://www.w3.org/2001/XMLSchema-instance"); root.addAttribute(new Attribute( "xsi:schemaLocation=", "http://www.w3.org/2001/XMLSchema-instance", "http://www.xml-cml.org/schema/cml2/core " + instanceLocation.getSetting() )); } serializer.write(doc); } catch (Exception exception) { throw new CDKException("Could not write XML output: " + exception.getMessage(), exception); } } private void initIOSettings() { cmlIds = new BooleanIOSetting("CMLIDs", IOSetting.LOW, "Should the output use CML identifiers?", "true"); namespacedOutput = new BooleanIOSetting("NamespacedOutput", IOSetting.LOW, "Should the output use namespaced output?", "true"); namespacePrefix = new StringIOSetting("NamespacePrefix", IOSetting.LOW, "What should the namespace prefix be? [empty is no prefix]", ""); schemaInstanceOutput = new BooleanIOSetting("SchemaInstance", IOSetting.LOW, "Should the output use the Schema-Instance attribute?", "false"); instanceLocation = new StringIOSetting("InstanceLocation", IOSetting.LOW, "Where is the schema found?", ""); indent = new BooleanIOSetting("Indenting", IOSetting.LOW, "Should the output be indented?", "true"); xmlDeclaration = new BooleanIOSetting("XMLDeclaration", IOSetting.LOW, "Should the output contain an XML declaration?", "true"); } private void customizeJob() { fireIOSettingQuestion(cmlIds); fireIOSettingQuestion(namespacedOutput); if (namespacedOutput.isSet()) { fireIOSettingQuestion(namespacePrefix); } fireIOSettingQuestion(schemaInstanceOutput); if (schemaInstanceOutput.isSet()) { fireIOSettingQuestion(instanceLocation); } fireIOSettingQuestion(indent); fireIOSettingQuestion(xmlDeclaration); } public IOSetting[] getIOSettings() { IOSetting[] settings = new IOSetting[7]; settings[0] = cmlIds; settings[1] = namespacedOutput; settings[2] = namespacePrefix; settings[3] = schemaInstanceOutput; settings[4] = instanceLocation; settings[5] = indent; settings[6] = xmlDeclaration; return settings; } } cdk-1.2.10/src/main/org/openscience/cdk/io/CTXReader.java100644 0 0 16610 11570154753 20110 0ustar 0 0 /* $RCSfile: $ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2006-2007 Egon Willighagen * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.io; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.Symbols; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.*; import org.openscience.cdk.io.formats.CTXFormat; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.manipulator.BondManipulator; import java.io.*; /** * Reader that extracts information from the IDENT, NAME, ATOMS and BONDS * blocks in CTX files. * * @cdk.module io * @cdk.githash */ @TestClass("org.openscience.cdk.io.CTXReaderTest") public class CTXReader extends DefaultChemObjectReader { private BufferedReader input; private LoggingTool logger; private IChemFile file; public CTXReader() { logger = new LoggingTool(this); file = null; } public CTXReader(Reader input) { this(); if (input instanceof BufferedReader) { this.input = (BufferedReader)input; } else { this.input = new BufferedReader(input); } } public CTXReader(InputStream input) { this(new InputStreamReader(input)); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return CTXFormat.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader reader) throws CDKException { if (reader instanceof BufferedReader) { this.input = (BufferedReader)reader; } else { this.input = new BufferedReader(reader); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i 1 && line.charAt(0) == ' ' && line.charAt(1) == '/'); } @TestMethod("testClose") public void close() throws IOException { input.close(); } } cdk-1.2.10/src/main/org/openscience/cdk/io/CrystClustReader.java100644 0 0 22575 11570154753 21600 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2004-2007 Egon Willighagen * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.io; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.geometry.CrystalGeometryTools; import org.openscience.cdk.interfaces.*; import org.openscience.cdk.io.formats.CrystClustFormat; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.math.FortranFormat; import org.openscience.cdk.tools.LoggingTool; import javax.vecmath.Point3d; import javax.vecmath.Vector3d; import java.io.*; /** * @cdk.module extra * @cdk.githash */ @TestClass("org.openscience.cdk.io.CrystClustReaderTest") public class CrystClustReader extends DefaultChemObjectReader { private BufferedReader input; private LoggingTool logger; public CrystClustReader() { logger = new LoggingTool(this); } public CrystClustReader(Reader input) { this(); if (input instanceof BufferedReader) { this.input = (BufferedReader)input; } else { this.input = new BufferedReader(input); } } public CrystClustReader(InputStream input) { this(new InputStreamReader(input)); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return CrystClustFormat.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader reader) throws CDKException { if (reader instanceof BufferedReader) { this.input = (BufferedReader)reader; } else { this.input = new BufferedReader(reader); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i * * 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. * * 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.io; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.exception.UnsupportedChemObjectException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.ICrystal; import org.openscience.cdk.io.formats.CrystClustFormat; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.tools.LoggingTool; import javax.vecmath.Vector3d; import java.io.*; //import org.openscience.cdk.tools.LoggingTool; /** * Rather stupid file format used for storing crystal information. * * @author Egon Willighagen * @cdk.created 2004-01-01 * * @cdk.module extra * @cdk.githash */ @TestClass("org.openscience.cdk.io.CrystClustWriterTest") public class CrystClustWriter extends DefaultChemObjectWriter { private BufferedWriter writer; private LoggingTool logger; /** * Constructs a new CrystClustWriter class. Output will be stored in the Writer * class given as parameter. * * @param out Writer to redirect the output to. */ public CrystClustWriter(Writer out) { logger = new LoggingTool(this); try { if (out instanceof BufferedWriter) { writer = (BufferedWriter)out; } else { writer = new BufferedWriter(out); } } catch (Exception exc) { logger.debug(exc.toString()); } } public CrystClustWriter(OutputStream output) { this(new OutputStreamWriter(output)); } public CrystClustWriter() { this(new StringWriter()); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return CrystClustFormat.getInstance(); } public void setWriter(Writer out) throws CDKException { if (out instanceof BufferedWriter) { writer = (BufferedWriter)out; } else { writer = new BufferedWriter(out); } } public void setWriter(OutputStream output) throws CDKException { setWriter(new OutputStreamWriter(output)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (Class anInterface : interfaces) { if (ICrystal.class.equals(anInterface)) return true; if (IChemSequence.class.equals(anInterface)) return true; } return false; } /** * Serializes the IChemObject to CrystClust format and redirects it to the output Writer. * * @param object A Molecule of MoleculeSet object */ public void write(IChemObject object) throws UnsupportedChemObjectException { if (object instanceof ICrystal) { writeCrystal((ICrystal)object); } else if (object instanceof IChemSequence) { writeChemSequence((IChemSequence)object); } else { throw new UnsupportedChemObjectException("This object type is not supported."); } } /** * Flushes the output and closes this object */ @TestMethod("testClose") public void close() throws IOException { writer.close(); } // Private procedures private void writeChemSequence(IChemSequence cs) throws UnsupportedChemObjectException { int count = cs.getChemModelCount(); for (int i=0; i < count; i++) { writeln("frame: " + (i+1)); writeCrystal(cs.getChemModel(i).getCrystal()); } } /** * Writes a single frame to the Writer. * *

Format: *

     *            line      data
     *           -------    --------------------------
     *              1       spacegroup
     *            2,3,4     cell parameter: a
     *            5,6,7                     b
     *            8,9,10                    c
     *             11       number of atoms
     *             12       number of asym. units
     *            13-16     atomtype: charge, atomcoord x, y, z
     *            17-20     idem second atom
     *            21-24     idem third atom etc
     * 
* * @param crystal the Crystal to serialize */ private void writeCrystal(ICrystal crystal) { String sg = crystal.getSpaceGroup(); if ("P 2_1 2_1 2_1".equals(sg)) { writeln("P 21 21 21 (1)"); } else { writeln("P 1 (1)"); } // output unit cell axes writeVector3d(crystal.getA()); writeVector3d(crystal.getB()); writeVector3d(crystal.getC()); // output number of atoms int noatoms = crystal.getAtomCount(); write(Integer.toString(noatoms)); writeln(""); // output number of asym. units (Z) if (sg.equals("P1")) { writeln("1"); } else { // duno writeln("1"); } // output atoms for (int i = 0; i < noatoms; i++) { // output atom sumbol IAtom atom = crystal.getAtom(i); write(atom.getSymbol()); write(":"); // output atom charge writeln(Double.toString(atom.getCharge())); // output coordinates writeln(Double.toString(atom.getPoint3d().x)); writeln(Double.toString(atom.getPoint3d().y)); writeln(Double.toString(atom.getPoint3d().z)); } } private void write(String s) { try { writer.write(s); } catch (IOException e) { System.err.println("CMLWriter IOException while printing \"" + s + "\":" + e.toString()); } } private void writeln(String s) { try { writer.write(s); writer.newLine(); } catch (IOException e) { System.err.println("CMLWriter IOException while printing \"" + s + "\":" + e.toString()); } } private void writeVector3d(Vector3d vector) { write(Double.toString(vector.x)); writeln(""); write(Double.toString(vector.y)); writeln(""); write(Double.toString(vector.z)); writeln(""); } } cdk-1.2.10/src/main/org/openscience/cdk/io/DefaultChemObjectReader.java100644 0 0 5756 11570154753 22753 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2002-2007 The Jmol Development Team * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.io; import java.util.ArrayList; import java.util.List; import org.openscience.cdk.io.listener.IChemObjectIOListener; import org.openscience.cdk.io.listener.IReaderListener; import org.openscience.cdk.io.setting.IOSetting; /** * Abstract class that ChemObjectReader's can implement to have it * take care of basic stuff, like managing the ReaderListeners. * * @cdk.module io * @cdk.githash */ public abstract class DefaultChemObjectReader implements ISimpleChemObjectReader { /** * An event to be sent to listeners when a frame is read. */ private ReaderEvent frameReadEvent = null; protected IChemObjectReader.Mode mode = IChemObjectReader.Mode.RELAXED; /** * Holder of reader event listeners. */ private List listenerList = new ArrayList(2); public void addChemObjectIOListener(IChemObjectIOListener listener) { listenerList.add(listener); } public void removeChemObjectIOListener(IChemObjectIOListener listener) { listenerList.remove(listener); } /* Extra convenience methods */ /** * Sends a frame read event to the registered ReaderListeners. */ protected void fireFrameRead() { for (int i = 0; i < listenerList.size(); ++i) { IChemObjectIOListener listener = listenerList.get(i); if (listener instanceof IReaderListener) { // Lazily create the event: if (frameReadEvent == null) { frameReadEvent = new ReaderEvent(this); } ((IReaderListener)listener).frameRead(frameReadEvent); } } } protected void fireIOSettingQuestion(IOSetting setting) { for (int i = 0; i < listenerList.size(); ++i) { IChemObjectIOListener listener = listenerList.get(i); listener.processIOSettingQuestion(setting); } } public IOSetting[] getIOSettings() { return new IOSetting[0]; } public void setReaderMode(ISimpleChemObjectReader.Mode mode) { this.mode = mode; } } cdk-1.2.10/src/main/org/openscience/cdk/io/DefaultChemObjectWriter.java100644 0 0 4036 11570154753 23013 0ustar 0 0 /* $Revision$ $Author$$Date$ * * Copyright (C) 2002-2007 The Jmol Development Team * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.io; import java.util.ArrayList; import java.util.List; import org.openscience.cdk.io.listener.IChemObjectIOListener; import org.openscience.cdk.io.setting.IOSetting; /** * Abstract class that ChemObjectReader's can implement to have it * take care of basic stuff, like managing the ReaderListeners. * * @cdk.module io * @cdk.githash */ public abstract class DefaultChemObjectWriter implements IChemObjectWriter { /** * Holder of reader event listeners. */ private List listenerList = new ArrayList(); public void addChemObjectIOListener(IChemObjectIOListener listener) { listenerList.add(listener); } public void removeChemObjectIOListener(IChemObjectIOListener listener) { listenerList.remove(listener); } protected void fireIOSettingQuestion(IOSetting setting) { for (int i = 0; i < listenerList.size(); ++i) { IChemObjectIOListener listener = listenerList.get(i); listener.processIOSettingQuestion(setting); } } public IOSetting[] getIOSettings() { return new IOSetting[0]; } } cdk-1.2.10/src/main/org/openscience/cdk/io/FormatFactory.java100644 0 0 21235 11570154753 21106 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2001-2007 Bradley A. Smith * 2003-2009 Egon Willighagen * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.io; import java.io.BufferedReader; import java.io.CharArrayReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.io.formats.IChemFormat; import org.openscience.cdk.io.formats.IChemFormatMatcher; import org.openscience.cdk.io.formats.XYZFormat; /** * A factory for recognizing chemical file formats. Formats * of GZiped files can be detected too. * * A typical example is: *
 *   StringReader stringReader = new StringReader("<molecule/>");
 *   IChemFormat format = new FormatFactory().guessFormat(stringReader);
 * 
* * @cdk.module ioformats * @cdk.githash * * @author Egon Willighagen * @author Bradley A. Smith */ @TestClass("org.openscience.cdk.io.FormatFactoryTest") public class FormatFactory { private final static String IO_FORMATS_LIST = "io-formats.set"; private int headerLength; private static List formats = null; /** * Constructs a ReaderFactory which tries to detect the format in the * first 65536 chars. */ public FormatFactory() { this(65536); } /** * Constructs a ReaderFactory which tries to detect the format in the * first given number of chars. * * @param headerLength length of the header in number of chars */ public FormatFactory(int headerLength) { this.headerLength = headerLength; loadFormats(); } private void loadFormats() { if (formats == null) { formats = new ArrayList(); try { BufferedReader reader = new BufferedReader(new InputStreamReader( this.getClass().getClassLoader().getResourceAsStream(IO_FORMATS_LIST) )); int formatCount = 0; while (reader.ready()) { // load them one by one String formatName = reader.readLine(); formatCount++; try { Class formatClass = this.getClass().getClassLoader().loadClass(formatName); Method getinstanceMethod = formatClass.getMethod("getInstance", new Class[0]); IChemFormatMatcher format = (IChemFormatMatcher)getinstanceMethod.invoke(null, new Object[0]); formats.add(format); } catch (ClassNotFoundException exception) { } catch (Exception exception) { } } } catch (Exception exception) { } } } /** * Registers a format for detection. */ public void registerFormat(IChemFormatMatcher format) { formats.add(format); } /** * Returns the list of recognizable formats. * * @return {@link List} of {@link IChemFormat}s. */ public List getFormats(){ return formats; } /** * Creates a String of the Class name of the IChemObject reader * for this file format. The input is read line-by-line * until a line containing an identifying string is * found. * *

The ReaderFactory detects more formats than the CDK * has Readers for. * *

This method is not able to detect the format of gziped files. * Use guessFormat(InputStream) instead for such files. * * @throws IOException if an I/O error occurs * @throws IllegalArgumentException if the input is null * * @see #guessFormat(InputStream) */ public IChemFormat guessFormat(Reader input) throws IOException { if (input == null) { throw new IllegalArgumentException("input cannot be null"); } // make a copy of the header char[] header = new char[this.headerLength]; if (!input.markSupported()) { throw new IllegalArgumentException("input must support mark"); } input.mark(this.headerLength); input.read(header, 0, this.headerLength); input.reset(); BufferedReader buffer = new BufferedReader(new CharArrayReader(header)); /* Search file for a line containing an identifying keyword */ String line = null; int lineNumber = 1; while ((line = buffer.readLine()) != null) { for (int i=0; iExpected behaviour: *
The "GamessReader" object is able to read GAMESS output log file format. * *

Limitations:
This reader was developed from a small set of * example log files, and therefore, is not guaranteed to properly read all * GAMESS output. If you have problems, please contact the author of this code, * not the developers of GAMESS. * * * * *

Implementation *
Available feature(s): *

    *
  • Molecular coordinates: Each set of coordinates is added to the ChemFile in the order they are found.
  • *
* Unavailable feature(s): *
    * * * *
  • Energies: They are associated with the previously read set of coordinates.
  • *
  • Normal coordinates of vibrations: They are associated with the previously read set of coordinates.
  • *
* * * *

References: *
GAMESS is a * quantum chemistry program by Gordon research group atIowa State University. * * @cdk.module extra * @cdk.githash * @cdk.keyword Gamess * @cdk.keyword file format * @cdk.keyword output * @cdk.keyword log file * * @author Bradley A. Smith * * */ //TODO Update class comments with appropriate information. //TODO Update "see" tag with reference to GamessWriter when it will be implemented. //TODO Update "author" tag with appropriate information. @TestClass("org.openscience.cdk.io.GamessReaderTest") public class GamessReader extends DefaultChemObjectReader { /** * Boolean constant used to specify that the coordinates are given in Bohr units. */ public static final boolean BOHR_UNIT = true; /** * Double constant that contains the convertion factor from Bohr unit to * Ångstrom unit. */ //TODO Check the accuracy of this comment. public static final double BOHR_TO_ANGSTROM = 0.529177249; /** * Boolean constant used to specify that the coordinates are given in Ångstrom units. */ public static final boolean ANGSTROM_UNIT = false; /** * The "BufferedReader" object used to read data from the "file system" file. * * @see org.openscience.cdk.io.GamessReader#GamessReader(Reader) */ //TODO Improve field comment. //TODO Answer the question : When is it opened and when is it closed? private BufferedReader input; /** * Constructs a new "GamessReader" object given a "Reader" object as input. * *

The "Reader" object may be an instantiable object from the "Reader" * hierarchy. *
For more detail about the "Reader" objects that are really accepted * by this "GamessReader" see accepts(IChemObject) method * documentation. * * @param inputReader The "Reader" object given as input parameter. * * @see #accepts(Class) * @see java.io.Reader * */ public GamessReader(Reader inputReader) { this.input = new BufferedReader(inputReader); } public GamessReader(InputStream input) { this(new InputStreamReader(input)); } public GamessReader() { this(new StringReader("")); } /* (non-Javadoc) (Javadoc is automaticly inherited from the link below) * @see org.openscience.cdk.io.ChemObjectIO#accepts(org.openscience.cdk.ChemObject) */ //TODO Update comment with appropriate information to comply Constructor's documentation. @TestMethod("testGetFormat") public IResourceFormat getFormat() { return GamessFormat.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader reader) throws CDKException { this.input = new BufferedReader(input); } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; ithis.input.readLine() instruction. * * @see org.openscience.cdk.io.GamessReader#input */ //TODO Answer the question : Is this method's name appropriate (given the fact that it do not read a ChemFile object, but return it)? private IChemFile readChemFile(IChemFile file) throws IOException { IChemSequence sequence = file.getBuilder().newChemSequence(); // TODO Answer the question : Is this line needed ? IChemModel model = file.getBuilder().newChemModel(); // TODO Answer the question : Is this line needed ? IMoleculeSet moleculeSet = file.getBuilder().newMoleculeSet(); model.setMoleculeSet(moleculeSet); //TODO Answer the question : Should I do this? sequence.addChemModel(model); //TODO Answer the question : Should I do this? file.addChemSequence(sequence); //TODO Answer the question : Should I do this? String currentReadLine = this.input.readLine(); while (this.input.ready() == true && (currentReadLine != null)) { /* * There are 2 types of coordinate sets: * - bohr coordinates sets (if statement) * - angstr???m coordinates sets (else statement) */ if (currentReadLine.indexOf("COORDINATES (BOHR)") >= 0) { /* * The following line do no contain data, so it is ignored. */ this.input.readLine(); moleculeSet.addMolecule(this.readCoordinates( file.getBuilder().newMolecule(), GamessReader.BOHR_UNIT )); //break; //<- stops when the first set of coordinates is found. } else if (currentReadLine.indexOf(" COORDINATES OF ALL ATOMS ARE (ANGS)") >= 0) { /* * The following 2 lines do no contain data, so it are ignored. */ this.input.readLine(); this.input.readLine(); moleculeSet.addMolecule(this.readCoordinates( file.getBuilder().newMolecule(), GamessReader.ANGSTROM_UNIT )); //break; //<- stops when the first set of coordinates is found. } currentReadLine = this.input.readLine(); } return file; } /** * Reads a set of coordinates from the "file system" file through the use of * the "input" field, scales coordinate to angstr???m unit, builds each atom with * the right associated coordinates, builds a new molecule with these atoms * and returns the complete molecule. * *

Implementation: *
Dummy atoms are ignored. * * @param coordinatesUnits The unit in which coordinates are given. * * @throws IOException may be thrown by the "input" object. * * @see org.openscience.cdk.io.GamessReader#input */ //TODO Update method comments with appropriate information. private IMolecule readCoordinates(IMolecule molecule, boolean coordinatesUnits) throws IOException { /* * Coordinates must all be given in angstr???ms. */ double unitScaling = GamessReader.scalesCoordinatesUnits(coordinatesUnits); String retrievedLineFromFile; while (this.input.ready() == true) { retrievedLineFromFile = this.input.readLine(); /* * A coordinate set is followed by an empty line, so when this line * is reached, there are no more coordinates to add to the current set. */ if ((retrievedLineFromFile == null) || (retrievedLineFromFile.trim().length() == 0)) { break; } int atomicNumber; String atomicSymbol; //StringReader sr = new StringReader(retrievedLineFromFile); StreamTokenizer token = new StreamTokenizer(new StringReader(retrievedLineFromFile)); /* * The first token is ignored. It contains the atomic symbol and may * be concatenated with a number. */ token.nextToken(); if (token.nextToken() == StreamTokenizer.TT_NUMBER) { atomicNumber = (int) token.nval; atomicSymbol = this.identifyAtomicSymbol(atomicNumber); /* * Dummy atoms are assumed to be given with an atomic number set * to zero. We will do not add them to the molecule. */ if (atomicNumber == 0) { continue; } } else { throw new IOException("Error reading coordinates"); } /* * Atom's coordinates are stored in an array. */ double[] coordinates = new double[3]; for (int i = 0; i < coordinates.length; i++) { if (token.nextToken() == StreamTokenizer.TT_NUMBER) { coordinates[i] = token.nval * unitScaling; } else { throw new IOException("Error reading coordinates"); } } IAtom atom = molecule.getBuilder().newAtom(atomicSymbol, new Point3d(coordinates[0],coordinates[1],coordinates[2])); molecule.addAtom(atom); } return molecule; } /** * Identifies the atomic symbol of an atom given its default atomic number. * *

Implementation: *
This is not a definitive method. It will probably be replaced with a * more appropriate one. Be advised that as it is not a definitive version, * it only recognise atoms from Hydrogen (1) to Argon (18). * * @param atomicNumber The atomic number of an atom. * * @return The Symbol corresponding to the atom or "null" is the atom was not recognised. */ //TODO Update method comments with appropriate information. private String identifyAtomicSymbol(int atomicNumber) { String symbol; switch (atomicNumber) { case 1: symbol = "H"; break; case 2: symbol = "He"; break; case 3: symbol = "Li"; break; case 4: symbol = "Be"; break; case 5: symbol = "B"; break; case 6: symbol = "C"; break; case 7: symbol = "N"; break; case 8: symbol = "O"; break; case 9: symbol = "F"; break; case 10: symbol = "Ne"; break; case 11: symbol = "Na"; break; case 12: symbol = "Mg"; break; case 13: symbol = "Al"; break; case 14: symbol = "Si"; break; case 15: symbol = "P"; break; case 16: symbol = "S"; break; case 17: symbol = "Cl"; break; case 18: symbol = "Ar"; break; default: symbol = null; break; } return symbol; } /** * Scales coordinates to Ångström unit if they are given in Bohr unit. * If coordinates are already given in Ångström unit, then no modifications * are performed. * * @param coordinatesUnits BOHR_UNIT if coordinates are given in Bohr unit and ANGSTROM_UNIT * if they are given in Ångström unit. * * @return The scaling convertion factor: 1 if no scaling is needed and BOHR_TO_ANGSTROM if scaling has to be performed. * * @see org.openscience.cdk.PhysicalConstants#BOHR_TO_ANGSTROM * @see org.openscience.cdk.io.GamessReader#BOHR_UNIT * @see org.openscience.cdk.io.GamessReader#ANGSTROM_UNIT */ //TODO Update method comments with appropriate information. private static double scalesCoordinatesUnits(boolean coordinatesUnits) { if (coordinatesUnits == GamessReader.BOHR_UNIT) { return PhysicalConstants.BOHR_TO_ANGSTROM; } else { //condition is: (coordinatesUnits == GamessReader.ANGTROM_UNIT) return (double) 1; } } /* (non-Javadoc) (Javadoc is automaticly inherited from the link below) * @see org.openscience.cdk.io.ChemObjectIO#close() */ //TODO Answer the question : What are all concerned ressources ? @TestMethod("testClose") public void close() throws IOException { /* * Closes the BufferedReader used to read the file content. */ input.close(); } }cdk-1.2.10/src/main/org/openscience/cdk/io/Gaussian03Reader.java100644 0 0 42644 11570154753 21375 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2002-2003 Bradley A. Smith * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.io; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StreamTokenizer; import java.io.StringReader; import javax.vecmath.Point3d; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.IsotopeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.io.formats.Gaussian03Format; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.tools.LoggingTool; /** * A reader for Gaussian03 output. * Gaussian 03 is a quantum chemistry program * by Gaussian, Inc. (http://www.gaussian.com/). * *

Molecular coordinates, energies, and normal coordinates of * vibrations are read. Each set of coordinates is added to the * ChemFile in the order they are found. Energies and vibrations * are associated with the previously read set of coordinates. * *

This reader was developed from a small set of * example output files, and therefore, is not guaranteed to * properly read all Gaussian03 output. If you have problems, * please contact the author of this code, not the developers * of Gaussian03. * *

This code was adaptated by Jonathan from Gaussian98Reader written by * Bradley, and ported to CDK by Egon. * * @author Jonathan C. Rienstra-Kiracofe * @author Bradley A. Smith * @author Egon Willighagen * @cdk.module io * @cdk.githash */ public class Gaussian03Reader extends DefaultChemObjectReader { private BufferedReader input; private LoggingTool logger; public Gaussian03Reader(Reader reader) { input = new BufferedReader(reader); logger = new LoggingTool(this); } public Gaussian03Reader(InputStream input) { this(new InputStreamReader(input)); } public Gaussian03Reader() { this(new StringReader("")); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return Gaussian03Format.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader reader) throws CDKException { this.input = new BufferedReader(input); } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { if (IChemFile.class.equals(interfaces[i])) return true; if (IChemSequence.class.equals(interfaces[i])) return true; } return false; } public IChemObject read(IChemObject object) throws CDKException { if (object instanceof IChemSequence) { return readChemSequence((IChemSequence) object); } else if (object instanceof IChemFile) { return readChemFile((IChemFile) object); } else { throw new CDKException("Object " + object.getClass().getName() + " is not supported"); } } @TestMethod("testClose") public void close() throws IOException { input.close(); } private IChemFile readChemFile(IChemFile chemFile) throws CDKException { IChemSequence sequence = readChemSequence(chemFile.getBuilder().newChemSequence()); chemFile.addChemSequence(sequence); return chemFile; } private IChemSequence readChemSequence(IChemSequence sequence) throws CDKException { IChemModel model = null; try { String line = input.readLine(); //String levelOfTheory = null; // Find first set of coordinates while (input.ready() && (line != null)) { if (line.indexOf("Standard orientation:") >= 0) { // Found a set of coordinates model = sequence.getBuilder().newChemModel(); try { readCoordinates(model); } catch (IOException exception) { throw new CDKException("Error while reading coordinates: " + exception.toString(), exception); } break; } line = input.readLine(); } if (model != null) { // Read all other data line = input.readLine(); while (input.ready() && (line != null)) { if (line.indexOf("Standard orientation:") >= 0) { // Found a set of coordinates // Add current frame to file and create a new one. sequence.addChemModel(model); fireFrameRead(); model = sequence.getBuilder().newChemModel(); readCoordinates(model); } else if (line.indexOf("SCF Done:") >= 0) { // Found an energy model.setProperty("org.openscience.cdk.io.Gaussian03Reaer:SCF Done", line.trim()); } else if (line.indexOf("Harmonic frequencies") >= 0) { // Found a set of vibrations // try { // readFrequencies(model); // } catch (IOException exception) { // throw new CDKException("Error while reading frequencies: " + exception.toString(), exception); // } } else if (line.indexOf("Mulliken atomic charges") >= 0) { readPartialCharges(model); } else if (line.indexOf("Magnetic shielding") >= 0) { // Found NMR data // try { // readNMRData(model, line); // } catch (IOException exception) { // throw new CDKException("Error while reading NMR data: " + exception.toString(), exception); // } } else if (line.indexOf("GINC") >= 0) { // Found calculation level of theory //levelOfTheory = parseLevelOfTheory(line); // FIXME: is doing anything with it? } line = input.readLine(); } // Add current frame to file sequence.addChemModel(model); fireFrameRead(); } } catch (IOException exception) { throw new CDKException("Error while reading general structure: " + exception.toString(), exception); } return sequence; } /** * Reads a set of coordinates into ChemModel. * * @param model the destination ChemModel * @throws IOException if an I/O error occurs */ private void readCoordinates(IChemModel model) throws CDKException, IOException { IAtomContainer container = model.getBuilder().newAtomContainer(); String line = input.readLine(); line = input.readLine(); line = input.readLine(); line = input.readLine(); while (input.ready()) { line = input.readLine(); if ((line == null) || (line.indexOf("-----") >= 0)) { break; } int atomicNumber = 0; StringReader sr = new StringReader(line); StreamTokenizer token = new StreamTokenizer(sr); token.nextToken(); // ignore first token if (token.nextToken() == StreamTokenizer.TT_NUMBER) { atomicNumber = (int) token.nval; if (atomicNumber == 0) { // Skip dummy atoms. Dummy atoms must be skipped // if frequencies are to be read because Gaussian // does not report dummy atoms in frequencies, and // the number of atoms is used for reading frequencies. continue; } } else { throw new IOException("Error reading coordinates"); } token.nextToken(); // ignore third token double x = 0.0; double y = 0.0; double z = 0.0; if (token.nextToken() == StreamTokenizer.TT_NUMBER) { x = token.nval; } else { throw new IOException("Error reading coordinates"); } if (token.nextToken() == StreamTokenizer.TT_NUMBER) { y = token.nval; } else { throw new IOException("Error reading coordinates"); } if (token.nextToken() == StreamTokenizer.TT_NUMBER) { z = token.nval; } else { throw new IOException("Error reading coordinates"); } String symbol = "Du"; try { symbol = IsotopeFactory.getInstance(model.getBuilder()).getElementSymbol(atomicNumber); } catch (Exception exception) { throw new CDKException("Could not determine element symbol!", exception); } IAtom atom = model.getBuilder().newAtom(symbol); atom.setPoint3d(new Point3d(x, y, z)); container.addAtom(atom); } IMoleculeSet moleculeSet = model.getBuilder().newMoleculeSet(); moleculeSet.addMolecule(model.getBuilder().newMolecule(container)); model.setMoleculeSet(moleculeSet); } /** * Reads partial atomic charges and add the to the given ChemModel. */ private void readPartialCharges(IChemModel model) throws CDKException, IOException { logger.info("Reading partial atomic charges"); IMoleculeSet moleculeSet = model.getMoleculeSet(); IMolecule molecule = moleculeSet.getMolecule(0); String line = input.readLine(); // skip first line after "Total atomic charges" while (input.ready()) { line = input.readLine(); logger.debug("Read charge block line: " + line); if ((line == null) || (line.indexOf("Sum of Mulliken charges") >= 0)) { logger.debug("End of charge block found"); break; } StringReader sr = new StringReader(line); StreamTokenizer tokenizer = new StreamTokenizer(sr); if (tokenizer.nextToken() == StreamTokenizer.TT_NUMBER) { int atomCounter = (int) tokenizer.nval; tokenizer.nextToken(); // ignore the symbol double charge = 0.0; if (tokenizer.nextToken() == StreamTokenizer.TT_NUMBER) { charge = (double) tokenizer.nval; logger.debug("Found charge for atom " + atomCounter + ": " + charge); } else { throw new CDKException("Error while reading charge: expected double."); } IAtom atom = molecule.getAtom(atomCounter - 1); atom.setCharge(charge); } } } /** * Reads a set of vibrations into ChemModel. * * @param model the destination ChemModel * @throws IOException if an I/O error occurs */ // private void readFrequencies(IChemModel model) throws IOException { /* This is yet to be ported. Vibrations don't exist yet in CDK. String line = input.readLine(); line = input.readLine(); line = input.readLine(); line = input.readLine(); line = input.readLine(); while ((line != null) && line.startsWith(" Frequencies --")) { Vector currentVibs = new Vector(); StringReader vibValRead = new StringReader(line.substring(15)); StreamTokenizer token = new StreamTokenizer(vibValRead); while (token.nextToken() != StreamTokenizer.TT_EOF) { Vibration vib = new Vibration(Double.toString(token.nval)); currentVibs.addElement(vib); } line = input.readLine(); // skip "Red. masses" line = input.readLine(); // skip "Rfc consts" line = input.readLine(); // skip "IR Inten" while (!line.startsWith(" Atom AN")) { // skip all lines upto and including the " Atom AN" line line = input.readLine(); // skip } for (int i = 0; i < frame.getAtomCount(); ++i) { line = input.readLine(); StringReader vectorRead = new StringReader(line); token = new StreamTokenizer(vectorRead); token.nextToken(); // ignore first token token.nextToken(); // ignore second token for (int j = 0; j < currentVibs.size(); ++j) { double[] v = new double[3]; if (token.nextToken() == StreamTokenizer.TT_NUMBER) { v[0] = token.nval; } else { throw new IOException("Error reading frequency"); } if (token.nextToken() == StreamTokenizer.TT_NUMBER) { v[1] = token.nval; } else { throw new IOException("Error reading frequency"); } if (token.nextToken() == StreamTokenizer.TT_NUMBER) { v[2] = token.nval; } else { throw new IOException("Error reading frequency"); } ((Vibration) currentVibs.elementAt(j)).addAtomVector(v); } } for (int i = 0; i < currentVibs.size(); ++i) { frame.addVibration((Vibration) currentVibs.elementAt(i)); } line = input.readLine(); line = input.readLine(); line = input.readLine(); } */ // } /** * Reads NMR nuclear shieldings. */ // private void readNMRData(IChemModel model, String labelLine) throws IOException { /* FIXME: this is yet to be ported. CDK does not have shielding stuff. // Determine label for properties String label; if (labelLine.indexOf("Diamagnetic") >= 0) { label = "Diamagnetic Magnetic shielding (Isotropic)"; } else if (labelLine.indexOf("Paramagnetic") >= 0) { label = "Paramagnetic Magnetic shielding (Isotropic)"; } else { label = "Magnetic shielding (Isotropic)"; } int atomIndex = 0; for (int i = 0; i < frame.getAtomCount(); ++i) { String line = input.readLine().trim(); while (line.indexOf("Isotropic") < 0) { if (line == null) { return; } line = input.readLine().trim(); } StringTokenizer st1 = new StringTokenizer(line); // Find Isotropic label while (st1.hasMoreTokens()) { if (st1.nextToken().equals("Isotropic")) { break; } } // Find Isotropic value while (st1.hasMoreTokens()) { if (st1.nextToken().equals("=")) { break; } } double shielding = Double.valueOf(st1.nextToken()).doubleValue(); NMRShielding ns1 = new NMRShielding(label, shielding); ((org.openscience.jmol.Atom)frame.getAtomAt(atomIndex)).addProperty(ns1); ++atomIndex; } */ // } /** * Select the theory and basis set from the first archive line. */ /*private String parseLevelOfTheory(String line) { StringTokenizer st1 = new StringTokenizer(line, "\\"); // Must contain at least 6 tokens if (st1.countTokens() < 6) { return null; } // Skip first four tokens for (int i = 0; i < 4; ++i) { st1.nextToken(); } return st1.nextToken() + "/" + st1.nextToken(); }*/ } cdk-1.2.10/src/main/org/openscience/cdk/io/Gaussian98Reader.java100644 0 0 50670 11570154753 21411 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2002-2003 Bradley A. Smith * Copyright (C) 2003-2007 Egon Willighagen * Copyright (C) 2003-2007 Christoph Steinbeck * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.io; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StreamTokenizer; import java.io.StringReader; import java.util.List; import java.util.StringTokenizer; import javax.vecmath.Point3d; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.IsotopeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.io.formats.Gaussian98Format; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.setting.BooleanIOSetting; import org.openscience.cdk.io.setting.IOSetting; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.manipulator.ChemModelManipulator; /** * A reader for Gaussian98 output. Gaussian 98 is a quantum chemistry program * by Gaussian, Inc. (http://www.gaussian.com/). *

*

Molecular coordinates, energies, and normal coordinates of vibrations are * read. Each set of coordinates is added to the ChemFile in the order they are * found. Energies and vibrations are associated with the previously read set * of coordinates. *

*

This reader was developed from a small set of example output files, and * therefore, is not guaranteed to properly read all Gaussian98 output. If you * have problems, please contact the author of this code, not the developers of * Gaussian98. * * @author Bradley A. Smith * @author Egon Willighagen * @author Christoph Steinbeck * @cdk.module io * @cdk.githash */ @TestClass("org.openscience.cdk.io.Gaussian98ReaderTest") public class Gaussian98Reader extends DefaultChemObjectReader { private BufferedReader input; private LoggingTool logger; private int atomCount = 0; private String lastRoute = ""; /** * Customizable setting */ private BooleanIOSetting readOptimizedStructureOnly; /** * Constructor for the Gaussian98Reader object */ public Gaussian98Reader() { this(new StringReader("")); } public Gaussian98Reader(InputStream input) { this(new InputStreamReader(input)); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return Gaussian98Format.getInstance(); } /** * Sets the reader attribute of the Gaussian98Reader object * * @param input The new reader value * @throws CDKException Description of the Exception */ @TestMethod("testSetReader_Reader") public void setReader(Reader input) throws CDKException { if (input instanceof BufferedReader) { this.input = (BufferedReader) input; } else { this.input = new BufferedReader(input); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } /** * Create an Gaussian98 output reader. * * @param input source of Gaussian98 data */ public Gaussian98Reader(Reader input) { logger = new LoggingTool(this); if (input instanceof BufferedReader) { this.input = (BufferedReader) input; } else { this.input = new BufferedReader(input); } initIOSettings(); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { if (IChemFile.class.equals(interfaces[i])) return true; } Class superClass = classObject.getSuperclass(); if (superClass != null) return this.accepts(superClass); return false; } public IChemObject read(IChemObject object) throws CDKException { customizeJob(); if (object instanceof IChemFile) { IChemFile file = (IChemFile) object; try { file = readChemFile(file); } catch (IOException exception) { throw new CDKException( "Error while reading file: " + exception.toString(), exception ); } return file; } else { throw new CDKException("Reading of a " + object.getClass().getName() + " is not supported."); } } @TestMethod("testClose") public void close() throws IOException { input.close(); } /** * Read the Gaussian98 output. * * @return a ChemFile with the coordinates, energies, and * vibrations. * @throws IOException if an I/O error occurs * @throws CDKException Description of the Exception */ private IChemFile readChemFile(IChemFile chemFile) throws CDKException, IOException { IChemSequence sequence = chemFile.getBuilder().newChemSequence(); IChemModel model = null; String line = input.readLine(); String levelOfTheory; String description; int modelCounter = 0; // Find first set of coordinates by skipping all before "Standard orientation" while (input.ready() && (line != null)) { if (line.indexOf("Standard orientation:") >= 0) { // Found a set of coordinates model = chemFile.getBuilder().newChemModel(); readCoordinates(model); break; } line = input.readLine(); } if (model != null) { // Read all other data line = input.readLine().trim(); while (input.ready() && (line != null)) { if (line.indexOf("#") == 0) { // Found the route section // Memorizing this for the description of the chemmodel lastRoute = line; modelCounter = 0; } else if (line.indexOf("Standard orientation:") >= 0) { // Found a set of coordinates // Add current frame to file and create a new one. if (!readOptimizedStructureOnly.isSet()) { sequence.addChemModel(model); } else { logger.info("Skipping frame, because I was told to do"); } fireFrameRead(); model = chemFile.getBuilder().newChemModel(); modelCounter++; readCoordinates(model); } else if (line.indexOf("SCF Done:") >= 0) { // Found an energy model.setProperty(CDKConstants.REMARK, line.trim()); } else if (line.indexOf("Harmonic frequencies") >= 0) { // Found a set of vibrations // readFrequencies(frame); } else if (line.indexOf("Total atomic charges") >= 0) { readPartialCharges(model); } else if (line.indexOf("Magnetic shielding") >= 0) { // Found NMR data readNMRData(model, line); } else if (line.indexOf("GINC") >= 0) { // Found calculation level of theory levelOfTheory = parseLevelOfTheory(line); logger.debug("Level of Theory for this model: " + levelOfTheory); description = lastRoute + ", model no. " + modelCounter; model.setProperty(CDKConstants.DESCRIPTION, description); } else { //logger.debug("Skipping line: " + line); } line = input.readLine(); } // Add last frame to file sequence.addChemModel(model); fireFrameRead(); } chemFile.addChemSequence(sequence); return chemFile; } /** * Reads a set of coordinates into ChemFrame. * * @param model Description of the Parameter * @throws IOException if an I/O error occurs * @throws CDKException Description of the Exception */ private void readCoordinates(IChemModel model) throws CDKException, IOException { IMoleculeSet moleculeSet = model.getBuilder().newMoleculeSet(); IMolecule molecule = model.getBuilder().newMolecule(); String line = input.readLine(); line = input.readLine(); line = input.readLine(); line = input.readLine(); while (input.ready()) { line = input.readLine(); if ((line == null) || (line.indexOf("-----") >= 0)) { break; } int atomicNumber; StringReader sr = new StringReader(line); StreamTokenizer token = new StreamTokenizer(sr); token.nextToken(); // ignore first token if (token.nextToken() == StreamTokenizer.TT_NUMBER) { atomicNumber = (int) token.nval; if (atomicNumber == 0) { // Skip dummy atoms. Dummy atoms must be skipped // if frequencies are to be read because Gaussian // does not report dummy atoms in frequencies, and // the number of atoms is used for reading frequencies. continue; } } else { throw new CDKException("Error while reading coordinates: expected integer."); } token.nextToken(); // ignore third token double x; double y; double z; if (token.nextToken() == StreamTokenizer.TT_NUMBER) { x = token.nval; } else { throw new IOException("Error reading x coordinate"); } if (token.nextToken() == StreamTokenizer.TT_NUMBER) { y = token.nval; } else { throw new IOException("Error reading y coordinate"); } if (token.nextToken() == StreamTokenizer.TT_NUMBER) { z = token.nval; } else { throw new IOException("Error reading z coordinate"); } String symbol = "Du"; try { symbol = IsotopeFactory.getInstance(model.getBuilder()).getElementSymbol(atomicNumber); } catch (Exception exception) { throw new CDKException("Could not determine element symbol!", exception); } IAtom atom = model.getBuilder().newAtom(symbol); atom.setPoint3d(new Point3d(x, y, z)); molecule.addAtom(atom); } /* * this is the place where we store the atomcount to * be used as a counter in the nmr reading */ atomCount = molecule.getAtomCount(); moleculeSet.addMolecule(molecule); model.setMoleculeSet(moleculeSet); } /** * Reads partial atomic charges and add the to the given ChemModel. * * @param model Description of the Parameter * @throws CDKException Description of the Exception * @throws IOException Description of the Exception */ private void readPartialCharges(IChemModel model) throws CDKException, IOException { logger.info("Reading partial atomic charges"); IMoleculeSet moleculeSet = model.getMoleculeSet(); IMolecule molecule = moleculeSet.getMolecule(0); String line = input.readLine(); // skip first line after "Total atomic charges" while (input.ready()) { line = input.readLine(); logger.debug("Read charge block line: " + line); if ((line == null) || (line.indexOf("Sum of Mulliken charges") >= 0)) { logger.debug("End of charge block found"); break; } StringReader sr = new StringReader(line); StreamTokenizer tokenizer = new StreamTokenizer(sr); if (tokenizer.nextToken() == StreamTokenizer.TT_NUMBER) { int atomCounter = (int) tokenizer.nval; tokenizer.nextToken(); // ignore the symbol double charge; if (tokenizer.nextToken() == StreamTokenizer.TT_NUMBER) { charge = tokenizer.nval; logger.debug("Found charge for atom " + atomCounter + ": " + charge); } else { throw new CDKException("Error while reading charge: expected double."); } IAtom atom = molecule.getAtom(atomCounter - 1); atom.setCharge(charge); } } } /** * Reads a set of vibrations into ChemFrame. * *@param model Description of the Parameter *@exception IOException if an I/O error occurs */ // private void readFrequencies(IChemModel model) throws IOException // { /* * FIXME: this is yet to be ported * String line; * line = input.readLine(); * line = input.readLine(); * line = input.readLine(); * line = input.readLine(); * line = input.readLine(); * while ((line != null) && line.startsWith(" Frequencies --")) { * Vector currentVibs = new Vector(); * StringReader vibValRead = new StringReader(line.substring(15)); * StreamTokenizer token = new StreamTokenizer(vibValRead); * while (token.nextToken() != StreamTokenizer.TT_EOF) { * Vibration vib = new Vibration(Double.toString(token.nval)); * currentVibs.addElement(vib); * } * line = input.readLine(); * line = input.readLine(); * line = input.readLine(); * line = input.readLine(); * line = input.readLine(); * line = input.readLine(); * for (int i = 0; i < frame.getAtomCount(); ++i) { * line = input.readLine(); * StringReader vectorRead = new StringReader(line); * token = new StreamTokenizer(vectorRead); * token.nextToken(); * / ignore first token * token.nextToken(); * / ignore second token * for (int j = 0; j < currentVibs.size(); ++j) { * double[] v = new double[3]; * if (token.nextToken() == StreamTokenizer.TT_NUMBER) { * v[0] = token.nval; * } else { * throw new IOException("Error reading frequency"); * } * if (token.nextToken() == StreamTokenizer.TT_NUMBER) { * v[1] = token.nval; * } else { * throw new IOException("Error reading frequency"); * } * if (token.nextToken() == StreamTokenizer.TT_NUMBER) { * v[2] = token.nval; * } else { * throw new IOException("Error reading frequency"); * } * ((Vibration) currentVibs.elementAt(j)).addAtomVector(v); * } * } * for (int i = 0; i < currentVibs.size(); ++i) { * frame.addVibration((Vibration) currentVibs.elementAt(i)); * } * line = input.readLine(); * line = input.readLine(); * line = input.readLine(); * } */ // } /** * Reads NMR nuclear shieldings. */ private void readNMRData(IChemModel model, String labelLine) throws CDKException { List containers = ChemModelManipulator.getAllAtomContainers(model); if (containers.size() == 0) { // nothing to store the results into return; } // otherwise insert in the first AC IAtomContainer ac = (IAtomContainer)containers.get(0); // Determine label for properties String label; if (labelLine.indexOf("Diamagnetic") >= 0) { label = "Diamagnetic Magnetic shielding (Isotropic)"; } else if (labelLine.indexOf("Paramagnetic") >= 0) { label = "Paramagnetic Magnetic shielding (Isotropic)"; } else { label = "Magnetic shielding (Isotropic)"; } int atomIndex = 0; for (int i = 0; i < atomCount; ++i) { try { String line = input.readLine().trim(); while (line.indexOf("Isotropic") < 0) { if (line == null) { return; } line = input.readLine().trim(); } StringTokenizer st1 = new StringTokenizer(line); // Find Isotropic label while (st1.hasMoreTokens()) { if (st1.nextToken().equals("Isotropic")) { break; } } // Find Isotropic value while (st1.hasMoreTokens()) { if (st1.nextToken().equals("=")) break; } double shielding = Double.valueOf(st1.nextToken()).doubleValue(); logger.info("Type of shielding: " + label); ac.getAtom(atomIndex).setProperty(CDKConstants.ISOTROPIC_SHIELDING, new Double(shielding)); ++atomIndex; } catch (Exception exc) { logger.debug("failed to read line from gaussian98 file where I expected one."); } } } /** * Select the theory and basis set from the first archive line. * * @param line Description of the Parameter * @return Description of the Return Value */ private String parseLevelOfTheory(String line) { StringBuffer summary = new StringBuffer(); summary.append(line); try { do { line = input.readLine().trim(); summary.append(line); } while (!(line.indexOf("@") >= 0)); } catch (Exception exc) { logger.debug("syntax problem while parsing summary of g98 section: "); logger.debug(exc); } logger.debug("parseLoT(): " + summary.toString()); StringTokenizer st1 = new StringTokenizer(summary.toString(), "\\"); // Must contain at least 6 tokens if (st1.countTokens() < 6) { return null; } // Skip first four tokens for (int i = 0; i < 4; ++i) { st1.nextToken(); } return st1.nextToken() + "/" + st1.nextToken(); } private void initIOSettings() { readOptimizedStructureOnly = new BooleanIOSetting("ReadOptimizedStructureOnly", IOSetting.LOW, "Should I only read the optimized structure from a geometry optimization?", "false"); } private void customizeJob() { fireIOSettingQuestion(readOptimizedStructureOnly); } /** * Gets the iOSettings attribute of the Gaussian98Reader object * *@return The iOSettings value */ public IOSetting[] getIOSettings() { IOSetting[] settings = new IOSetting[1]; settings[0] = readOptimizedStructureOnly; return settings; } } cdk-1.2.10/src/main/org/openscience/cdk/io/GhemicalMMReader.java100644 0 0 30312 11570154753 21410 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2002-2003 The Jmol Development Team * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.io; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.util.StringTokenizer; import javax.vecmath.Point3d; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.IsotopeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.io.formats.GhemicalMMFormat; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.tools.LoggingTool; /** * Reads Ghemical ( * http://www.uku.fi/~thassine/ghemical/) * molecular mechanics (*.mm1gp) files. * * @cdk.module io * @cdk.githash * * @author Egon Willighagen */ @TestClass("org.openscience.cdk.io.GhemicalMMReaderTest") public class GhemicalMMReader extends DefaultChemObjectReader { private LoggingTool logger = null; private BufferedReader input = null; public GhemicalMMReader(Reader input) { this.logger = new LoggingTool(this); this.input = new BufferedReader(input); } public GhemicalMMReader(InputStream input) { this(new InputStreamReader(input)); } public GhemicalMMReader() { this(new StringReader("")); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return GhemicalMMFormat.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader input) throws CDKException { if (input instanceof BufferedReader) { this.input = (BufferedReader)input; } else { this.input = new BufferedReader(input); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testClose") public void close() { } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.io; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.io.formats.HINFormat; import org.openscience.cdk.io.formats.IResourceFormat; import javax.vecmath.Point3d; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; /** * Reads an object from HIN formated input. * * @cdk.module io * @cdk.githash * * @author Rajarshi Guha * @cdk.created 2004-01-27 * * @cdk.keyword file format, HIN */ @TestClass("org.openscience.cdk.io.HINReaderTest") public class HINReader extends DefaultChemObjectReader { private BufferedReader input; /** * Construct a new reader from a Reader type object * * @param input reader from which input is read */ public HINReader(Reader input) { this.input = new BufferedReader(input); } public HINReader(InputStream input) { this(new InputStreamReader(input)); } public HINReader() { this(new StringReader("")); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return HINFormat.getInstance(); } @TestMethod("testClose") public void close() throws IOException { input.close(); } @TestMethod("testSetReader_Reader") public void setReader(Reader input) throws CDKException { if (input instanceof BufferedReader) { this.input = (BufferedReader)input; } else { this.input = new BufferedReader(input); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (Class anInterface : interfaces) { if (IChemFile.class.equals(anInterface)) return true; } Class superClass = classObject.getSuperclass(); if (superClass != null) return this.accepts(superClass); return false; } /** * Reads the content from a HIN input. It can only return a * IChemObject of type ChemFile * * @param object class must be of type ChemFile * * @see org.openscience.cdk.ChemFile */ public IChemObject read(IChemObject object) throws CDKException { if (object instanceof IChemFile) { return readChemFile((IChemFile)object); } else { throw new CDKException("Only supported is reading of ChemFile objects."); } } private String getMolName( String line) { if (line == null) return(""); StringTokenizer st = new StringTokenizer(line," "); int ntok = st.countTokens(); String[] toks = new String[ ntok ]; for (int j = 0; j < ntok; j++) { toks[j] = st.nextToken(); } if (toks.length == 3) return(toks[2]); else return(""); } /** * Private method that actually parses the input to read a ChemFile * object. In its current state it is able to read all the molecules * (if more than one is present) in the specified HIN file. These are * placed in a MoleculeSet object which in turn is placed in a ChemModel * which in turn is placed in a ChemSequence object and which is finally * placed in a ChemFile object and returned to the user. * * @return A ChemFile containing the data parsed from input. */ private IChemFile readChemFile(IChemFile file) { IChemSequence chemSequence = file.getBuilder().newChemSequence(); IChemModel chemModel = file.getBuilder().newChemModel(); IMoleculeSet setOfMolecules = file.getBuilder().newMoleculeSet(); String info; StringTokenizer tokenizer; try { String line; // read in header info while (true) { line = input.readLine(); if (line.startsWith("mol")) { info = getMolName(line); break; } } // start the actual molecule data - may be multiple molecule line = input.readLine(); while(true) { if (line == null) break; // end of file if (line.startsWith(";")) continue; // comment line if (line.startsWith("mol")) { info = getMolName(line); line = input.readLine(); } IMolecule m = file.getBuilder().newMolecule(); m.setProperty(CDKConstants.TITLE ,info); // Each element of cons is an ArrayList of length 3 which stores // the start and end indices and bond order of each bond // found in the HIN file. Before adding bonds we need to reduce // the number of bonds so as not to count the same bond twice List> cons = new ArrayList>(); // read data for current molecule int atomSerial = 0; while (true) { if (line == null || line.contains("endmol")) { break; } if (line.startsWith(";")) continue; // comment line tokenizer = new StringTokenizer(line, " "); int ntoken = tokenizer.countTokens(); String[] toks = new String[ ntoken ]; for (int i = 0; i < ntoken; i++) toks[i] = tokenizer.nextToken(); String sym = toks[3]; double charge = Double.parseDouble(toks[6]); double x = Double.parseDouble(toks[7]); double y = Double.parseDouble(toks[8]); double z = Double.parseDouble(toks[9]); int nbond = Integer.parseInt(toks[10]); IAtom atom = file.getBuilder().newAtom(sym, new Point3d(x,y,z)); atom.setCharge(charge); IBond.Order bo = IBond.Order.SINGLE; for (int j = 11; j < (11+nbond*2); j += 2) { int s = Integer.parseInt(toks[j]) - 1; // since atoms start from 1 in the file char bt = toks[j+1].charAt(0); switch(bt) { case 's': bo = IBond.Order.SINGLE; break; case 'd': bo = IBond.Order.DOUBLE; break; case 't': bo = IBond.Order.TRIPLE; break; case 'a': bo = IBond.Order.QUADRUPLE; break; } List ar = new ArrayList(3); ar.add(atomSerial); ar.add(s); ar.add(bo); cons.add( ar ); } m.addAtom(atom); atomSerial++; line = input.readLine(); } // now just store all the bonds we have for (List ar : cons) { IAtom s = m.getAtom((Integer) ar.get(0)); IAtom e = m.getAtom((Integer) ar.get(1)); IBond.Order bo = (IBond.Order) ar.get(2); if (!isConnected(m, s, e)) m.addBond(file.getBuilder().newBond(s, e, bo)); } setOfMolecules.addMolecule(m); // we may not get a 'mol N' immediately since // the aromaticring keyword might be present // and doesn't seem to be located within the molecule // block while (true) { line = input.readLine(); if (line == null || line.startsWith("mol")) break; } } // got all the molecule in the HIN file (hopefully!) chemModel.setMoleculeSet(setOfMolecules); chemSequence.addChemModel(chemModel); file.addChemSequence(chemSequence); } catch (IOException e) { // FIXME: should make some noise now file = null; } return file; } private boolean isConnected(IAtomContainer atomContainer, IAtom atom1, IAtom atom2) { for (IBond bond : atomContainer.bonds()) { if (bond.contains(atom1) && bond.contains(atom2)) return true; } return false; } } cdk-1.2.10/src/main/org/openscience/cdk/io/HINWriter.java100644 0 0 17154 11570154753 20146 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.io; import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.StringWriter; import java.io.Writer; import java.util.Iterator; import javax.vecmath.Point3d; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.io.formats.HINFormat; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.tools.LoggingTool; /** * Writer that outputs in the HIN format. * * @author Rajarshi Guha * @cdk.module io * @cdk.githash * @cdk.created 2004-01-27 */ @TestClass("org.openscience.cdk.io.HINWriterTest") public class HINWriter extends DefaultChemObjectWriter { private BufferedWriter writer; /** * Constructor. * * @param out the stream to write the HIN file to. */ public HINWriter(Writer out) { LoggingTool logger = new LoggingTool(this); try { if (out instanceof BufferedWriter) { writer = (BufferedWriter) out; } else { writer = new BufferedWriter(out); } } catch (Exception exc) { logger.debug(exc.toString()); } } public HINWriter(OutputStream output) { this(new OutputStreamWriter(output)); } public HINWriter() { this(new StringWriter()); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return HINFormat.getInstance(); } public void setWriter(Writer out) throws CDKException { if (out instanceof BufferedWriter) { writer = (BufferedWriter) out; } else { writer = new BufferedWriter(out); } } public void setWriter(OutputStream output) throws CDKException { setWriter(new OutputStreamWriter(output)); } /** * Flushes the output and closes this object. */ @TestMethod("testClose") public void close() throws IOException { writer.close(); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i = 0; i < interfaces.length; i++) { if (IMolecule.class.equals(interfaces[i])) return true; if (IMoleculeSet.class.equals(interfaces[i])) return true; } return false; } public void write(IChemObject object) throws CDKException { if (object instanceof IMolecule) { try { IMoleculeSet som = object.getBuilder().newMoleculeSet(); som.addMolecule((IMolecule) object); writeMolecule(som); } catch (Exception ex) { throw new CDKException("Error while writing HIN file: " + ex.getMessage(), ex); } } else if (object instanceof IMoleculeSet) { try { writeMolecule((IMoleculeSet) object); } catch (IOException ex) { // } } else { throw new CDKException("HINWriter only supports output of Molecule or SetOfMolecule classes."); } } /** * writes all the molecules supplied in a MoleculeSet class to * a single HIN file. You can also supply a single Molecule object * as well * * @param som the set of molecules to write */ private void writeMolecule(IMoleculeSet som) throws IOException { //int na = 0; //String info = ""; String sym; double chrg; //boolean writecharge = true; for (int molnum = 0; molnum < som.getMoleculeCount(); molnum++) { IMolecule mol = som.getMolecule(molnum); try { String molname = "mol " + (molnum + 1) + " " + mol.getProperty(CDKConstants.TITLE); writer.write(molname, 0, molname.length()); writer.newLine(); // Loop through the atoms and write them out: java.util.Iterator atoms = mol.atoms().iterator(); int i = 0; while (atoms.hasNext()) { IAtom atom = (IAtom)atoms.next(); String line = "atom "; sym = atom.getSymbol(); chrg = atom.getCharge(); Point3d point = atom.getPoint3d(); line = line + Integer.toString(i + 1) + " - " + sym + " ** - " + Double.toString(chrg) + " " + Double.toString(point.x) + " " + Double.toString(point.y) + " " + Double.toString(point.z) + " "; String buf = ""; int ncon = 0; Iterator bonds = mol.bonds().iterator(); while (bonds.hasNext()) { IBond bond = (IBond)bonds.next(); if (bond.contains(atom)) { // current atom is in the bond so lets get the connected atom IAtom connectedAtom = bond.getConnectedAtom(atom); IBond.Order bondOrder = bond.getOrder(); int serial; String bondType = ""; // get the serial no for this atom serial = mol.getAtomNumber(connectedAtom); if (bondOrder == IBond.Order.SINGLE) bondType = "s"; else if (bondOrder == IBond.Order.DOUBLE) bondType = "d"; else if (bondOrder == IBond.Order.TRIPLE) bondType = "t"; else if (bond.getFlag(CDKConstants.ISAROMATIC)) bondType = "a"; buf = buf + Integer.toString(serial + 1) + " " + bondType + " "; ncon++; } } line = line + " " + Integer.toString(ncon) + " " + buf; writer.write(line, 0, line.length()); writer.newLine(); i++; } String buf = "endmol " + (molnum + 1); writer.write(buf, 0, buf.length()); writer.newLine(); } catch (IOException e) { throw e; } } } } cdk-1.2.10/src/main/org/openscience/cdk/io/IChemObjectIO.java100644 0 0 6362 11570154753 20656 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 1997-2008 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.io; import java.io.IOException; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.listener.IChemObjectIOListener; import org.openscience.cdk.io.setting.IOSetting; /** * This class is the interface that all IO readers should implement. * Programs need only care about this interface for any kind of IO. * Currently, database IO and file IO is supported. * *

The easiest way to implement a new {@link IChemObjectReader} is to * subclass the {@link DefaultChemObjectReader}. * * @cdk.module io * @cdk.githash * * @see DefaultChemObjectReader * * @author Egon Willighagen **/ public interface IChemObjectIO { /** * Returns the {@link IResourceFormat} class for this IO class. */ public IResourceFormat getFormat(); /** * Returns whether the given {@link IChemObject} can be read or written. * * @param classObject {@link IChemObject} of which is tested if it can be handled. * @return true, if the {@link IChemObject} can be handled. */ public boolean accepts(Class classObject); /** * Closes this IChemObjectIO's resources. * * @throws throws an {@link IOException} when the wrapper IO class cannot be closed. */ @TestMethod("testClose") public void close() throws IOException; /** * Returns an array of {@link IOSetting}s defined by this IChemObjectIO class. * * @return the {@link IOSetting}s for this class. */ public IOSetting[] getIOSettings(); /** * Adds a {@link IChemObjectIOListener} to this IChemObjectIO. * * @param listener the reader listener to add. */ public void addChemObjectIOListener(IChemObjectIOListener listener); /** * Removes a {@link IChemObjectIOListener} from this IChemObjectIO. * * @param listener the listener to be removed. */ public void removeChemObjectIOListener(IChemObjectIOListener listener); } cdk-1.2.10/src/main/org/openscience/cdk/io/IChemObjectReader.java100644 0 0 4332 11570154753 21544 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2000-2007 Egon Willighagen * * 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 org.openscience.cdk.io; import java.io.InputStream; import java.io.Reader; import org.openscience.cdk.exception.CDKException; /** * This class is the interface that all IO readers should implement. * * @cdk.module io * @cdk.githash * * @author Egon Willighagen **/ public interface IChemObjectReader extends IChemObjectIO { public enum Mode { /** Only fail on serious format problems */ RELAXED, /** Fail on any format problem */ STRICT } /** * Sets the Reader from which this ChemObjectReader should read * the contents. */ public void setReader(Reader reader) throws CDKException; /** * Sets the InputStream from which this ChemObjectReader should read * the contents. */ public void setReader(InputStream reader) throws CDKException; /** * Sets the reader mode. If Mode.STRICT, then the reader will fail on * any problem in the format of the read file, instead of trying to * recover from that. * * @param mode */ public void setReaderMode(Mode mode); } cdk-1.2.10/src/main/org/openscience/cdk/io/IChemObjectWriter.java100644 0 0 4561 11570154753 21622 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.io; import java.io.OutputStream; import java.io.Writer; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IChemObject; /** * This class is the interface that all IO writers should implement. * Programs need only care about this interface for any kind of IO. * *

Currently, database IO and file IO is supported. Internet IO is * expected. * * @cdk.module io * @cdk.githash * * @version $Date$ */ public interface IChemObjectWriter extends IChemObjectIO { /** * Writes the content of "object" to output * * @param object the object of which the content is outputed * * @exception CDKException is thrown if the output * does not support the data in the object */ public void write(IChemObject object) throws CDKException; /** * Sets the Writer from which this ChemObjectWriter should write * the contents. */ public void setWriter(Writer writer) throws CDKException; /** * Sets the OutputStream from which this ChemObjectWriter should write * the contents. */ public void setWriter(OutputStream writer) throws CDKException; } cdk-1.2.10/src/main/org/openscience/cdk/io/INChIPlainTextReader.java100644 0 0 16252 11570154753 22177 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.io; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.util.StringTokenizer; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.io.formats.INChIPlainTextFormat; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.inchi.INChIContentProcessorTool; /** * Reads the content of a IUPAC/NIST Chemical Identifier (INChI) plain text * document. This reader parses output generated with INChI 1.12beta like: *

 * 
 * Input_File: "E:\Program Files\INChI\inchi-samples\Figure04.mol"
 * 
 * Structure: 1
 * INChI=1.12Beta/C6H6/c1-2-4-6-5-3-1/h1-6H
 * AuxInfo=1.12Beta/0/N:1,2,3,4,5,6/E:(1,2,3,4,5,6)/rA:6CCCCCC/rB:s1;d1;d2;s3;s4d5;/rC:5.6378,-4.0013,0;5.6378,-5.3313,0;4.4859,-3.3363,0;4.4859,-5.9963,0;3.3341,-4.0013,0;3.3341,-5.3313,0;
 * 
* * @cdk.module extra * @cdk.githash * * @author Egon Willighagen * @cdk.created 2004-08-01 * * @cdk.keyword file format, INChI * @cdk.keyword chemical identifier * @cdk.require java1.4+ * * @see org.openscience.cdk.io.INChIReader */ @TestClass("org.openscience.cdk.io.INChIPlainTextReaderTest") public class INChIPlainTextReader extends DefaultChemObjectReader { private BufferedReader input; private INChIContentProcessorTool inchiTool; /** * Construct a INChI reader from a Reader object. * * @param input the Reader with the content */ public INChIPlainTextReader(Reader input) { this.init(); setReader(input); inchiTool = new INChIContentProcessorTool(); } public INChIPlainTextReader(InputStream input) { this(new InputStreamReader(input)); } public INChIPlainTextReader() { this(new StringReader("")); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return INChIPlainTextFormat.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader input) { if (input instanceof BufferedReader) { this.input = (BufferedReader)input; } else { this.input = new BufferedReader(input); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } /** * Initializes this reader. */ private void init() {} @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; iThe elements that are read are given in the INChIHandler class. * * @cdk.module extra * @cdk.githash * * @author Egon Willighagen * @cdk.created 2004-05-17 * * @cdk.keyword file format, INChI * @cdk.keyword chemical identifier * @cdk.require java1.4+ * * @see org.openscience.cdk.io.inchi.INChIHandler */ @TestClass("org.openscience.cdk.io.INChIReaderTest") public class INChIReader extends DefaultChemObjectReader { private XMLReader parser; private InputStream input; private LoggingTool logger; /** * Construct a INChI reader from a InputStream object. * * @param input the InputStream with the content */ public INChIReader(InputStream input) { this.input = input; init(); } public INChIReader() { this(new ByteArrayInputStream(new byte[0])); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return INChIFormat.getInstance(); } /** * This method must not be used; XML reading requires the use of an InputStream. * Use setReader(InputStream) instead. */ @TestMethod("testSetReader_Reader") public void setReader(Reader reader) throws CDKException { throw new CDKException("Invalid method call; use SetReader(InputStream) instead."); } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { this.input = input; } /** * Initializes this reader. */ private void init() { logger = new LoggingTool(this); boolean success = false; // If JAXP is prefered (comes with Sun JVM 1.4.0 and higher) if (!success) { try { javax.xml.parsers.SAXParserFactory spf = javax.xml.parsers.SAXParserFactory.newInstance(); spf.setNamespaceAware(true); javax.xml.parsers.SAXParser saxParser = spf.newSAXParser(); parser = saxParser.getXMLReader(); logger.info("Using JAXP/SAX XML parser."); success = true; } catch (Exception e) { logger.warn("Could not instantiate JAXP/SAX XML reader!"); logger.debug(e); } } // Aelfred is first alternative. if (!success) { try { parser = (XMLReader)this.getClass().getClassLoader(). loadClass("gnu.xml.aelfred2.XmlReader"). newInstance(); logger.info("Using Aelfred2 XML parser."); success = true; } catch (Exception e) { logger.warn("Could not instantiate Aelfred2 XML reader!"); logger.debug(e); } } // Xerces is second alternative if (!success) { try { parser = (XMLReader)this.getClass().getClassLoader(). loadClass("org.apache.xerces.parsers.SAXParser"). newInstance(); logger.info("Using Xerces XML parser."); success = true; } catch (Exception e) { logger.warn("Could not instantiate Xerces XML reader!"); logger.debug(e); } } if (!success) { logger.error("Could not instantiate any XML parser!"); } } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i * * 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 org.openscience.cdk.io; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IChemObject; /** * This class is the interface that all IO readers should implement. * Programs need only care about this interface for any kind of IO. * Currently, database IO and file IO is supported. * *

The easiest way to implement a new ChemObjectReader is to * subclass the DefaultChemObjectReader. * *

I don't know how this should be enforced, but a Reader should * also provide an empty constructor so that ClassLoader/getInstance() * can be used to instantiate a ChemObjectReader. * * @cdk.module io * @cdk.githash * * @see DefaultChemObjectReader * * @author Egon Willighagen **/ public interface ISimpleChemObjectReader extends IChemObjectReader { /** * Reads an IChemObject of type "object" from input. The constructor * of the actual implementation may take a Reader as input to get * a very flexible reader that can read from string, files, etc. * * @param object the type of object to return * @return returns an object of that contains the content (or * part) of the input content * * @exception CDKException it is thrown if * the type of information is not available from * the input **/ public IChemObject read(IChemObject object) throws CDKException; } cdk-1.2.10/src/main/org/openscience/cdk/io/MDLRXNReader.java100644 0 0 37511 11570154753 20461 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.io; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.util.Iterator; import java.util.StringTokenizer; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IReaction; import org.openscience.cdk.interfaces.IReactionSet; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.MDLRXNFormat; import org.openscience.cdk.tools.LoggingTool; /** * Reads a molecule from an MDL RXN file {@cdk.cite DAL92}. * * @cdk.module io * @cdk.githash * * @author Egon Willighagen * @cdk.created 2003-07-24 * * @cdk.keyword file format, MDL RXN */ @TestClass("org.openscience.cdk.io.MDLRXNReaderTest") public class MDLRXNReader extends DefaultChemObjectReader { BufferedReader input = null; private LoggingTool logger = null; /** * Contructs a new MDLReader that can read Molecule from a given Reader. * * @param in The Reader to read from */ public MDLRXNReader(Reader in) { this(in, Mode.RELAXED); } public MDLRXNReader(Reader in, Mode mode) { logger = new LoggingTool(this); if (in instanceof BufferedReader) { input = (BufferedReader)in; } else { input = new BufferedReader(in); } super.mode = mode; } public MDLRXNReader(InputStream input) { this(input, Mode.RELAXED); } public MDLRXNReader(InputStream input, Mode mode) { this(new InputStreamReader(input), mode); } public MDLRXNReader() { this(new StringReader("")); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return MDLRXNFormat.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader input) throws CDKException { if (input instanceof BufferedReader) { this.input = (BufferedReader)input; } else { this.input = new BufferedReader(input); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i' String fieldName = null; if (str.startsWith("> ")) { // ok, should extract the field name str.substring(2); // String content = int index = str.indexOf("<"); if (index != -1) { int index2 = str.substring(index).indexOf(">"); if (index2 != -1) { fieldName = str.substring(index+1,index+index2); } } // end skip all other lines while ((line = input.readLine()) != null && line.startsWith(">")) { logger.debug("data header line: ", line); } } if (line == null) { throw new CDKException("Expecting data line here, but found null!"); } String data = line; while ((line = input.readLine()) != null && line.trim().length() > 0) { if (line.equals("$$$$")) { logger.error("Expecting data line here, but found end of molecule: ", line); break; } logger.debug("data line: ", line); data += line; // preserve newlines, unless the line is exactly 80 chars; in that case it // is assumed to continue on the next line. See MDL documentation. if (line.length() < 80) data += System.getProperty("line.separator"); } if (fieldName != null) { logger.info("fieldName, data: ", fieldName, ", ", data); r.setProperty(fieldName, data); } } } } } catch (CDKException cdkexc) { throw cdkexc; } catch (Exception exception) { String error = "Error while parsing SDF"; logger.error(error); logger.debug(exception); throw new CDKException(error, exception); } return setOfReactions; } /** * Read a Reaction from a file in MDL RXN format * * @return The Reaction that was read from the MDL file. */ private IReaction readReaction(IChemObjectBuilder builder) throws CDKException { logger.debug("Reading new reaction"); int linecount = 0; IReaction reaction = builder.newReaction(); try { input.readLine(); // first line should be $RXN input.readLine(); // second line input.readLine(); // third line input.readLine(); // fourth line } catch (IOException exception) { logger.debug(exception); throw new CDKException("Error while reading header of RXN file", exception); } int reactantCount = 0; int productCount = 0; try { String countsLine = input.readLine(); linecount++; if (countsLine == null) { return null; } logger.debug("Line " + linecount + ": " + countsLine); if (countsLine.startsWith("$$$$")) { logger.debug("File is empty, returning empty reaction"); return reaction; } /* this line contains the number of reactants and products */ StringTokenizer tokenizer = new StringTokenizer(countsLine); reactantCount = Integer.valueOf(tokenizer.nextToken()).intValue(); logger.info("Expecting " + reactantCount + " reactants in file"); productCount = Integer.valueOf(tokenizer.nextToken()).intValue(); logger.info("Expecting " + productCount + " products in file"); } catch (Exception exception) { logger.debug(exception); throw new CDKException("Error while counts line of RXN file", exception); } // now read the reactants try { for (int i=1; i<=reactantCount; i++) { StringBuffer molFile = new StringBuffer(); input.readLine(); // announceMDLFileLine String molFileLine = ""; do { molFileLine = input.readLine(); molFile.append(molFileLine); molFile.append(System.getProperty("line.separator")); } while (!molFileLine.equals("M END")); // read MDL molfile content MDLReader reader = new MDLReader( new StringReader(molFile.toString())); IMolecule reactant = (IMolecule)reader.read( builder.newMolecule() ); // add reactant reaction.addReactant(reactant); } } catch (CDKException exception) { // rethrow exception from MDLReader throw exception; } catch (Exception exception) { logger.debug(exception); throw new CDKException("Error while reading reactant", exception); } // now read the products try { for (int i=1; i<=productCount; i++) { StringBuffer molFile = new StringBuffer(); input.readLine(); // String announceMDLFileLine = String molFileLine = ""; do { molFileLine = input.readLine(); molFile.append(molFileLine); molFile.append(System.getProperty("line.separator")); } while (!molFileLine.equals("M END")); // read MDL molfile content MDLReader reader = new MDLReader( new StringReader(molFile.toString()), super.mode ); IMolecule product = (IMolecule)reader.read( builder.newMolecule()); // add reactant reaction.addProduct(product); } } catch (CDKException exception) { // rethrow exception from MDLReader throw exception; } catch (Exception exception) { logger.debug(exception); throw new CDKException("Error while reading products", exception); } // now try to map things, if wanted logger.info("Reading atom-atom mapping from file"); // distribute all atoms over two AtomContainer's IAtomContainer reactingSide = builder.newAtomContainer(); Iterator molecules = reaction.getReactants().molecules().iterator(); while (molecules.hasNext()) { reactingSide.add((IMolecule)molecules.next()); } IAtomContainer producedSide = builder.newAtomContainer(); molecules = reaction.getProducts().molecules().iterator(); while (molecules.hasNext()) { producedSide.add((IMolecule)molecules.next()); } // map the atoms int mappingCount = 0; // IAtom[] reactantAtoms = reactingSide.getAtoms(); // IAtom[] producedAtoms = producedSide.getAtoms(); for (int i=0; i * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.io; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.util.StringTokenizer; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IReaction; import org.openscience.cdk.interfaces.IReactionSet; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.MDLRXNV3000Format; import org.openscience.cdk.io.setting.IOSetting; import org.openscience.cdk.tools.LoggingTool; /** * Class that implements the new MDL mol format introduced in August 2002. * The overall syntax is compatible with the old format, but I consider * the format completely different, and thus implemented a separate Reader * for it. * * @cdk.module io * @cdk.githash * * @author Egon Willighagen * @cdk.created 2003-10-05 * * @cdk.keyword MDL V3000 * @cdk.require java1.4+ */ @TestClass("org.openscience.cdk.io.MDLRXNV3000ReaderTest") public class MDLRXNV3000Reader extends DefaultChemObjectReader { BufferedReader input = null; private LoggingTool logger = null; public MDLRXNV3000Reader(Reader in) { this(in, Mode.RELAXED); } public MDLRXNV3000Reader(Reader in, Mode mode) { logger = new LoggingTool(this); if (in instanceof BufferedReader) { input = (BufferedReader)in; } else { input = new BufferedReader(in); } initIOSettings(); super.mode = mode; } public MDLRXNV3000Reader(InputStream input) { this(input, Mode.RELAXED); } public MDLRXNV3000Reader(InputStream input, Mode mode) { this(new InputStreamReader(input), mode); } public MDLRXNV3000Reader() { this(new StringReader("")); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return MDLRXNV3000Format.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader input) throws CDKException { if (input instanceof BufferedReader) { this.input = (BufferedReader)input; } else { this.input = new BufferedReader(input); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i * MDLRXNWriter writer = new MDLRXNWriter(new FileWriter(new File("output.mol"))); * writer.write((Molecule)molecule); * writer.close(); * * * See {@cdk.cite DAL92}. * * @cdk.module io * @cdk.githash * * @cdk.keyword file format, MDL RXN file */ @TestClass("org.openscience.cdk.io.MDLRXNReaderTest") public class MDLRXNWriter extends DefaultChemObjectWriter { private BufferedWriter writer; private LoggingTool logger; private int reactionNumber; public Map rdFields=null; /** * Contructs a new MDLWriter that can write an array of * Molecules to a Writer. * * @param out The Writer to write to */ public MDLRXNWriter(Writer out){ logger = new LoggingTool(this); try { if (out instanceof BufferedWriter) { writer = (BufferedWriter)out; } else { writer = new BufferedWriter(out); } } catch (Exception exc) { } this.reactionNumber = 1; } /** * Contructs a new MDLWriter that can write an array of * Molecules to a given OutputStream. * * @param output The OutputStream to write to */ public MDLRXNWriter(OutputStream output){ this(new OutputStreamWriter(output)); } public MDLRXNWriter(){ this(new StringWriter()); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return MDLFormat.getInstance(); } public void setWriter(Writer out) throws CDKException { if (out instanceof BufferedWriter) { writer = (BufferedWriter)out; } else { writer = new BufferedWriter(out); } } public void setWriter(OutputStream output) throws CDKException { setWriter(new OutputStreamWriter(output)); } /** * Here you can set a map which will be used to build rd fields in the file. * The entries will be translated to rd fields like this:
* > <key>
* > value
* empty line
* * @param map The map to be used, map of String-String pairs */ public void setRdFields(Map map){ rdFields = map; } /** * Flushes the output and closes this object. */ @TestMethod("testClose") public void close() throws IOException { writer.close(); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i it = reactions.reactions().iterator();it.hasNext();){ writeReaction(it.next()); } } /** * Writes a Reaction to an OutputStream in MDL sdf format. * * @param reaction A Reaction that is written to an OutputStream */ private void writeReaction(IReaction reaction) throws CDKException { int reactantCount = reaction.getReactantCount(); int productCount = reaction.getProductCount(); if (reactantCount <= 0 || productCount <= 0) { throw new CDKException("Either no reactants or no products present."); } try { // taking care of the $$$$ signs: // we do not write such a sign at the end of the first reaction, thus we have to write on BEFORE the second reaction if(reactionNumber == 2) { writer.write("$$$$"); writer.newLine(); } writer.write("$RXN"); writer.newLine(); // reaction name String line = (String)reaction.getProperty(CDKConstants.TITLE); if(line == null) line = ""; if(line.length() > 80) line = line.substring(0,80); writer.write(line); writer.newLine(); // user/program/date&time/reaction registry no. line writer.newLine(); // comment line line = (String)reaction.getProperty(CDKConstants.REMARK); if(line == null) line = ""; if(line.length() > 80) line = line.substring(0,80); writer.write(line); writer.newLine(); line = ""; line += formatMDLInt(reactantCount, 3); line += formatMDLInt(productCount, 3); writer.write(line); writer.newLine(); writeMoleculeSet(reaction.getReactants()); writeMoleculeSet(reaction.getProducts()); //write sdfields, if any if(rdFields!=null){ Set set = rdFields.keySet(); Iterator iterator = set.iterator(); while (iterator.hasNext()) { Object element = iterator.next(); writer.write("> <"+(String)element+">"); writer.newLine(); writer.write(rdFields.get(element).toString()); writer.newLine(); writer.newLine(); } } // taking care of the $$$$ signs: // we write such a sign at the end of all except the first molecule if(reactionNumber != 1) { writer.write("$$$$"); writer.newLine(); } reactionNumber++; } catch (IOException ex) { logger.error(ex.getMessage()); logger.debug(ex); throw new CDKException("Exception while writing MDL file: " + ex.getMessage(), ex); } } /** * Writes a MoleculeSet to an OutputStream for the reaction. * * @param som The MoleculeSet that is written to an OutputStream */ private void writeMoleculeSet(IMoleculeSet som) throws IOException, CDKException { for (int i = 0; i < som.getMoleculeCount(); i++) { IMolecule mol = som.getMolecule(i); for (int j = 0; j < som.getMultiplier(i); j++) { StringWriter sw = new StringWriter(); writer.write("$MOL"); writer.newLine(); MDLWriter mdlwriter = null; try { mdlwriter = new MDLWriter(sw); } catch (Exception ex) { logger.error(ex.getMessage()); logger.debug(ex); throw new CDKException("Exception while creating MDLWriter: " + ex.getMessage(), ex); } mdlwriter.write(mol); writer.write(sw.toString()); } } } /** * Formats an int to fit into the connectiontable and changes it * to a String. * * @param i The int to be formated * @param l Length of the String * @return The String to be written into the connectiontable */ private String formatMDLInt(int i, int l) { String s = "", fs = ""; NumberFormat nf = NumberFormat.getNumberInstance(Locale.ENGLISH); nf.setParseIntegerOnly(true); nf.setMinimumIntegerDigits(1); nf.setMaximumIntegerDigits(l); nf.setGroupingUsed(false); s = nf.format(i); l = l - s.length(); for (int f = 0; f < l; f++) fs += " "; fs += s; return fs; } } cdk-1.2.10/src/main/org/openscience/cdk/io/MDLReader.java100644 0 0 55446 11570154753 20100 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 1997-2007 Christoph Steinbeck * * 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 org.openscience.cdk.io; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.util.Iterator; import javax.vecmath.Point2d; import javax.vecmath.Point3d; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.IsotopeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.IIsotope; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.interfaces.IPseudoAtom; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.MDLFormat; import org.openscience.cdk.io.setting.BooleanIOSetting; import org.openscience.cdk.io.setting.IOSetting; import org.openscience.cdk.tools.LoggingTool; /** * Reads a molecule from the original MDL MOL or SDF file {@cdk.cite DAL92}. An SD files * is read into a {@link IChemSequence} of {@link IChemModel}'s. Each ChemModel will contain one * Molecule. If the MDL molfile contains a property block, the {@link MDLV2000Reader} should be * used. * *

If all z coordinates are 0.0, then the xy coordinates are taken as * 2D, otherwise the coordinates are read as 3D. * *

The title of the MOL file is read and can be retrieved with: *

 *   molecule.getProperty(CDKConstants.TITLE);
 * 
* * @cdk.module io * @cdk.githash * * @author steinbeck * @author Egon Willighagen * @cdk.created 2000-10-02 * @cdk.keyword file format, MDL molfile * @cdk.keyword file format, SDF * * @see org.openscience.cdk.io.MDLV2000Reader */ @TestClass("org.openscience.cdk.io.MDLReaderTest") public class MDLReader extends DefaultChemObjectReader { BufferedReader input = null; private LoggingTool logger = null; private BooleanIOSetting forceReadAs3DCoords; public MDLReader() { this(new StringReader("")); } /** * Constructs a new MDLReader that can read Molecule from a given InputStream. * *@param in The InputStream to read from */ public MDLReader(InputStream in) { this(in, Mode.RELAXED); } public MDLReader(InputStream in, Mode mode) { this(new InputStreamReader(in)); super.mode = mode; } /** * Constructs a new MDLReader that can read Molecule from a given Reader. * * @param in The Reader to read from */ public MDLReader(Reader in) { this(in, Mode.RELAXED); } public MDLReader(Reader in, Mode mode) { super.mode = mode; logger = new LoggingTool(this); input = new BufferedReader(in); initIOSettings(); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return MDLFormat.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader input) throws CDKException { if (input instanceof BufferedReader) { this.input = (BufferedReader)input; } else { this.input = new BufferedReader(input); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i' String fieldName = null; if (str.startsWith("> ")) { // ok, should extract the field name str.substring(2); // String content = int index = str.indexOf("<"); if (index != -1) { int index2 = str.substring(index).indexOf(">"); if (index2 != -1) { fieldName = str.substring( index+1, index+index2 ); } } // end skip all other lines while ((line = input.readLine()) != null && line.startsWith(">")) { logger.debug("data header line: ", line); } } if (line == null) { throw new CDKException("Expecting data line here, but found null!"); } String data = line; while ((line = input.readLine()) != null && line.trim().length() > 0) { if (line.equals("$$$$")) { logger.error("Expecting data line here, but found end of molecule: ", line); break; } logger.debug("data line: ", line); data += line; // preserve newlines, unless the line is exactly 80 chars; in that case it // is assumed to continue on the next line. See MDL documentation. if (line.length() < 80) data += System.getProperty("line.separator"); } if (fieldName != null) { logger.info("fieldName, data: ", fieldName, ", ", data); m.setProperty(fieldName, data); } } } } } catch (CDKException cdkexc) { throw cdkexc; } catch (Exception exception) { String error = "Error while parsing SDF"; logger.error(error); logger.debug(exception); throw new CDKException(error, exception); } try { input.close(); } catch (Exception exc) { String error = "Error while closing file: " + exc.getMessage(); logger.error(error); throw new CDKException(error, exc); } chemFile.addChemSequence(chemSequence); return chemFile; } /** * Read a Molecule from a file in MDL sd format * *@return The Molecule that was read from the MDL file. */ private IMolecule readMolecule(IMolecule molecule) throws CDKException { logger.debug("Reading new molecule"); int linecount = 0; int atoms = 0; int bonds = 0; int atom1 = 0; int atom2 = 0; int order = 0; int stereo = 0; int RGroupCounter=1; int Rnumber=0; String [] rGroup=null; double x = 0.0; double y = 0.0; double z = 0.0; double totalX = 0.0; double totalY = 0.0; double totalZ = 0.0; //int[][] conMat = new int[0][0]; //String help; IAtom atom; String line = ""; try { IsotopeFactory isotopeFactory = IsotopeFactory.getInstance(molecule.getBuilder()); logger.info("Reading header"); line = input.readLine(); linecount++; if (line == null) { return null; } logger.debug("Line " + linecount + ": " + line); if (line.startsWith("$$$$")) { logger.debug("File is empty, returning empty molecule"); return molecule; } if (line.length() > 0) { molecule.setProperty(CDKConstants.TITLE, line); } line = input.readLine(); linecount++; logger.debug("Line " + linecount + ": " + line); line = input.readLine(); linecount++; logger.debug("Line " + linecount + ": " + line); if (line.length() > 0) { molecule.setProperty(CDKConstants.REMARK, line); } logger.info("Reading rest of file"); line = input.readLine(); linecount++; logger.debug("Line " + linecount + ": " + line); if (mode == Mode.STRICT) { if (line.contains("V2000") || line.contains("v2000")) { throw new CDKException("This file must be read with the MDLV2000Reader."); } if (line.contains("V3000") || line.contains("v3000")) { throw new CDKException("This file must be read with the MDLV3000Reader."); } } atoms = Integer.valueOf(line.substring(0,3).trim()).intValue(); logger.debug("Atomcount: " + atoms); bonds = Integer.valueOf(line.substring(3,6).trim()).intValue(); logger.debug("Bondcount: " + bonds); // read ATOM block logger.info("Reading atom block"); for (int f = 0; f < atoms; f++) { line = input.readLine(); linecount++; x = new Double(line.substring( 0,10).trim()).doubleValue(); y = new Double(line.substring(10,20).trim()).doubleValue(); z = new Double(line.substring(20,30).trim()).doubleValue(); // *all* values should be zero, not just the sum totalX += Math.abs(x); totalY += Math.abs(y); totalZ += Math.abs(z); logger.debug("Coordinates: " + x + "; " + y + "; " + z); String element = line.substring(31,34).trim(); logger.debug("Atom type: ", element); if (isotopeFactory.isElement(element)) { atom = isotopeFactory.configure(molecule.getBuilder().newAtom(element)); } else if ("A".equals(element)) { atom = molecule.getBuilder().newPseudoAtom(element); } else if ("Q".equals(element)) { atom = molecule.getBuilder().newPseudoAtom(element); } else if ("*".equals(element)) { atom = molecule.getBuilder().newPseudoAtom(element); } else if ("LP".equals(element)) { atom = molecule.getBuilder().newPseudoAtom(element); } else if ("L".equals(element)) { atom = molecule.getBuilder().newPseudoAtom(element); } else if (element.length() > 0 && element.charAt(0) == 'R'){ logger.debug("Atom ", element, " is not an regular element. Creating a PseudoAtom."); //check if the element is R rGroup=element.split("^R"); if (rGroup.length >1){ try{ Rnumber=Integer.parseInt(rGroup[(rGroup.length-1)]); RGroupCounter=Rnumber; }catch(Exception ex){ Rnumber=RGroupCounter; RGroupCounter++; } element="R"+Rnumber; } atom = molecule.getBuilder().newPseudoAtom(element); } else { if (mode == ISimpleChemObjectReader.Mode.STRICT) { throw new CDKException("Invalid element type. Must be an existing element, or one in: A, Q, L, LP, *."); } atom = molecule.getBuilder().newPseudoAtom(element); } // store as 3D for now, convert to 2D (if totalZ == 0.0) later atom.setPoint3d(new Point3d(x, y, z)); // parse further fields String massDiffString = line.substring(34,36).trim(); logger.debug("Mass difference: ", massDiffString); if (!(atom instanceof IPseudoAtom)) { try { int massDiff = Integer.parseInt(massDiffString); if (massDiff != 0) { IIsotope major = IsotopeFactory.getInstance(molecule.getBuilder()).getMajorIsotope(element); atom.setAtomicNumber(major.getAtomicNumber() + massDiff); } } catch (Exception exception) { logger.error("Could not parse mass difference field"); } } else { logger.error("Cannot set mass difference for a non-element!"); } String chargeCodeString = line.substring(36,39).trim(); logger.debug("Atom charge code: ", chargeCodeString); int chargeCode = Integer.parseInt(chargeCodeString); if (chargeCode == 0) { // uncharged species } else if (chargeCode == 1) { atom.setFormalCharge(+3); } else if (chargeCode == 2) { atom.setFormalCharge(+2); } else if (chargeCode == 3) { atom.setFormalCharge(+1); } else if (chargeCode == 4) { } else if (chargeCode == 5) { atom.setFormalCharge(-1); } else if (chargeCode == 6) { atom.setFormalCharge(-2); } else if (chargeCode == 7) { atom.setFormalCharge(-3); } try { // read the mmm field as position 61-63 String reactionAtomIDString = line.substring(60,63).trim(); logger.debug("Parsing mapping id: ", reactionAtomIDString); try { int reactionAtomID = Integer.parseInt(reactionAtomIDString); if (reactionAtomID != 0) { atom.setID(reactionAtomIDString); } } catch (Exception exception) { logger.error("Mapping number ", reactionAtomIDString, " is not an integer."); logger.debug(exception); } } catch (Exception exception) { // older mol files don't have all these fields... logger.warn("A few fields are missing. Older MDL MOL file?"); } //shk3: This reads shifts from after the molecule. I don't think this is an official format, but I saw it frequently 80=>78 for alk if(line.length()>=78){ double shift=Double.parseDouble(line.substring(69,80).trim()); atom.setProperty("first shift",new Double(shift)); } if(line.length()>=87){ double shift=Double.parseDouble(line.substring(79,87).trim()); atom.setProperty("second shift",new Double(shift)); } molecule.addAtom(atom); } // convert to 2D, if totalZ == 0 if (totalX == 0.0 && totalY == 0.0 && totalZ == 0.0) { logger.info("All coordinates are 0.0"); for (IAtom atomToUpdate : molecule.atoms()) { atomToUpdate.setPoint3d(null); } } else if (totalZ == 0.0 && !forceReadAs3DCoords.isSet()) { logger.info("Total 3D Z is 0.0, interpreting it as a 2D structure"); Iterator atomsToUpdate = molecule.atoms().iterator(); while (atomsToUpdate.hasNext()) { IAtom atomToUpdate = (IAtom)atomsToUpdate.next(); Point3d p3d = atomToUpdate.getPoint3d(); atomToUpdate.setPoint2d(new Point2d(p3d.x, p3d.y)); atomToUpdate.setPoint3d(null); } } // read BOND block logger.info("Reading bond block"); for (int f = 0; f < bonds; f++) { line = input.readLine(); linecount++; atom1 = java.lang.Integer.valueOf(line.substring(0,3).trim()).intValue(); atom2 = java.lang.Integer.valueOf(line.substring(3,6).trim()).intValue(); order = java.lang.Integer.valueOf(line.substring(6,9).trim()).intValue(); if (line.length() > 12) { stereo = java.lang.Integer.valueOf(line.substring(9,12).trim()).intValue(); } else { logger.warn("Missing expected stereo field at line: " + line); } if (logger.isDebugEnabled()) { logger.debug("Bond: " + atom1 + " - " + atom2 + "; order " + order); } if (stereo == 1) { // MDL up bond stereo = CDKConstants.STEREO_BOND_UP; } else if (stereo == 6) { // MDL down bond stereo = CDKConstants.STEREO_BOND_DOWN; } else if (stereo == 4) { //MDL bond undefined stereo = CDKConstants.STEREO_BOND_UNDEFINED; } // interpret CTfile's special bond orders IAtom a1 = molecule.getAtom(atom1 - 1); IAtom a2 = molecule.getAtom(atom2 - 1); IBond newBond = null; if (order == 1) { newBond = molecule.getBuilder().newBond(a1, a2, IBond.Order.SINGLE, stereo); } else if (order == 2) { newBond = molecule.getBuilder().newBond(a1, a2, IBond.Order.DOUBLE, stereo); } else if (order == 3) { newBond = molecule.getBuilder().newBond(a1, a2, IBond.Order.TRIPLE, stereo); } else if (order == 4) { // aromatic bond newBond = molecule.getBuilder().newBond(a1, a2, IBond.Order.SINGLE, stereo); // mark both atoms and the bond as aromatic newBond.setFlag(CDKConstants.ISAROMATIC, true); a1.setFlag(CDKConstants.ISAROMATIC, true); a2.setFlag(CDKConstants.ISAROMATIC, true); } molecule.addBond(newBond); } } catch (Exception exception) { exception.printStackTrace(); String error = "Error while parsing line " + linecount + ": " + line + " -> " + exception.getMessage(); logger.error(error); logger.debug(exception); throw new CDKException(error, exception); } return molecule; } @TestMethod("testClose") public void close() throws IOException { input.close(); } private void initIOSettings() { forceReadAs3DCoords = new BooleanIOSetting("ForceReadAs3DCoordinates", IOSetting.LOW, "Should coordinates always be read as 3D?", "false"); } public void customizeJob() { fireIOSettingQuestion(forceReadAs3DCoords); } public IOSetting[] getIOSettings() { IOSetting[] settings = new IOSetting[1]; settings[0] = forceReadAs3DCoords; return settings; } } cdk-1.2.10/src/main/org/openscience/cdk/io/MDLV2000Reader.java100644 0 0 101257 11570154753 20540 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 1997-2007 Christoph Steinbeck * * 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 org.openscience.cdk.io; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.util.Iterator; import java.util.List; import java.util.StringTokenizer; import javax.vecmath.Point2d; import javax.vecmath.Point3d; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.IsotopeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.IIsotope; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.interfaces.IPseudoAtom; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.MDLV2000Format; import org.openscience.cdk.io.setting.BooleanIOSetting; import org.openscience.cdk.io.setting.IOSetting; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.manipulator.AtomContainerManipulator; /** * Reads a molecule from an MDL MOL or SDF file {@cdk.cite DAL92}. An SD files * is read into a {@link IChemSequence} of {@link IChemModel}'s. Each IChemModel will contain one * Molecule. * *

From the Atom block it reads atomic coordinates, element types and * formal charges. From the Bond block it reads the bonds and the orders. * Additionally, it reads 'M CHG', 'G ', 'M RAD' and 'M ISO' lines from the * property block. * *

If all z coordinates are 0.0, then the xy coordinates are taken as * 2D, otherwise the coordinates are read as 3D. * *

The title of the MOL file is read and can be retrieved with: *

 *   molecule.getProperty(CDKConstants.TITLE);
 * 
* *

RGroups which are saved in the MDL molfile as R#, are renamed according to their appearance, * e.g. the first R# is named R1. With PseudAtom.getLabel() "R1" is returned (instead of R#). * This is introduced due to the SAR table generation procedure of Scitegics PipelinePilot. * * @cdk.module io * @cdk.githash * * @author steinbeck * @author Egon Willighagen * @cdk.created 2000-10-02 * @cdk.keyword file format, MDL molfile * @cdk.keyword file format, SDF * @cdk.bug 1587283 */ @TestClass("org.openscience.cdk.io.MDLV2000ReaderTest") public class MDLV2000Reader extends DefaultChemObjectReader { BufferedReader input = null; private LoggingTool logger = null; private BooleanIOSetting forceReadAs3DCoords; private BooleanIOSetting interpretHydrogenIsotopes; public MDLV2000Reader() { this(new StringReader("")); } /** * Constructs a new MDLReader that can read Molecule from a given InputStream. * *@param in The InputStream to read from */ public MDLV2000Reader(InputStream in) { this(new InputStreamReader(in)); } public MDLV2000Reader(InputStream in, Mode mode) { this(new InputStreamReader(in), mode); } /** * Contructs a new MDLReader that can read Molecule from a given Reader. * *@param in The Reader to read from */ public MDLV2000Reader(Reader in) { this(in, Mode.RELAXED); } public MDLV2000Reader(Reader in, Mode mode) { logger = new LoggingTool(this); input = new BufferedReader(in); initIOSettings(); super.mode = mode; } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return MDLV2000Format.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader input) throws CDKException { if (input instanceof BufferedReader) { this.input = (BufferedReader)input; } else { this.input = new BufferedReader(input); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i' String fieldName = null; if (str.startsWith("> ")) { // ok, should extract the field name str.substring(2); // String content = int index = str.indexOf("<"); if (index != -1) { int index2 = str.substring(index).indexOf(">"); if (index2 != -1) { fieldName = str.substring( index+1, index+index2 ); } } // end skip all other lines while ((line = input.readLine()) != null && line.startsWith(">")) { logger.debug("data header line: ", line); } } if (line == null) { throw new CDKException("Expecting data line here, but found null!"); } StringBuilder data = new StringBuilder(); data.append(line); while ((line = input.readLine()) != null && line.trim().length() > 0) { if (line.equals("$$$$")) { logger.error("Expecting data line here, but found end of molecule: ", line); break; } logger.debug("data line: ", line); data.append(line); // preserve newlines, unless the line is exactly 80 chars; in that case it // is assumed to continue on the next line. See MDL documentation. if (line.length() < 80) data.append(System.getProperty("line.separator")); } if (fieldName != null) { logger.info("fieldName, data: ", fieldName, ", ", data); m.setProperty(fieldName, data.toString()); } } } } } catch (CDKException cdkexc) { throw cdkexc; } catch (Exception exception) { String error = "Error while parsing SDF"; logger.error(error); logger.debug(exception); throw new CDKException(error, exception); } try { input.close(); } catch (Exception exc) { String error = "Error while closing file: " + exc.getMessage(); logger.error(error); throw new CDKException(error, exc); } chemFile.addChemSequence(chemSequence); return chemFile; } /** * Read a Molecule from a file in MDL sd format * *@return The Molecule that was read from the MDL file. */ private IMolecule readMolecule(IMolecule molecule) throws CDKException { logger.debug("Reading new molecule"); int linecount = 0; int atoms = 0; int bonds = 0; int atom1 = 0; int atom2 = 0; int order = 0; int stereo = 0; int RGroupCounter=1; int Rnumber=0; String [] rGroup=null; double x = 0.0; double y = 0.0; double z = 0.0; double totalX = 0.0; double totalY = 0.0; double totalZ = 0.0; //int[][] conMat = new int[0][0]; //String help; IAtom atom; String line = ""; try { IsotopeFactory isotopeFactory = IsotopeFactory.getInstance(molecule.getBuilder()); logger.info("Reading header"); line = input.readLine(); linecount++; if (line == null) { return null; } logger.debug("Line " + linecount + ": " + line); if (line.startsWith("$$$$")) { logger.debug("File is empty, returning empty molecule"); return molecule; } if (line.length() > 0) { molecule.setProperty(CDKConstants.TITLE, line); } line = input.readLine(); linecount++; logger.debug("Line " + linecount + ": " + line); line = input.readLine(); linecount++; logger.debug("Line " + linecount + ": " + line); if (line.length() > 0) { molecule.setProperty(CDKConstants.REMARK, line); } logger.info("Reading rest of file"); line = input.readLine(); linecount++; logger.debug("Line " + linecount + ": " + line); // if the line is empty we hav a problem - either a malformed // molecule entry or just extra new lines at the end of the file if (line.length() == 0) { // read till the next $$$$ or EOF while (true) { line = input.readLine(); linecount++; if (line == null) { return null; } if (line.startsWith("$$$$")) { return molecule; // an empty molecule } } } if (mode == Mode.STRICT) { if (line.contains("V3000") || line.contains("v3000")) { throw new CDKException("This file must be read with the MDLV3000Reader."); } else if (!line.contains("V2000") && !line.contains("v2000")) { throw new CDKException("This file must be read with the MDLReader."); } } atoms = Integer.parseInt(line.substring(0, 3).trim()); logger.debug("Atomcount: " + atoms); bonds = Integer.parseInt(line.substring(3, 6).trim()); logger.debug("Bondcount: " + bonds); // read ATOM block logger.info("Reading atom block"); for (int f = 0; f < atoms; f++) { line = input.readLine(); linecount++; x = Double.parseDouble(line.substring(0, 10).trim()); y = Double.parseDouble(line.substring(10, 20).trim()); z = Double.parseDouble(line.substring(20, 30).trim()); // *all* values should be zero, not just the sum totalX += Math.abs(x); totalY += Math.abs(y); totalZ += Math.abs(z); logger.debug("Coordinates: " + x + "; " + y + "; " + z); String element = line.substring(31,34).trim(); logger.debug("Atom type: ", element); if (isotopeFactory.isElement(element)) { atom = isotopeFactory.configure(molecule.getBuilder().newAtom(element)); } else if ("A".equals(element)) { atom = molecule.getBuilder().newPseudoAtom(element); } else if ("Q".equals(element)) { atom = molecule.getBuilder().newPseudoAtom(element); } else if ("*".equals(element)) { atom = molecule.getBuilder().newPseudoAtom(element); } else if ("LP".equals(element)) { atom = molecule.getBuilder().newPseudoAtom(element); } else if ("L".equals(element)) { atom = molecule.getBuilder().newPseudoAtom(element); } else if (element.length() > 0 && element.charAt(0) == 'R'){ logger.debug("Atom ", element, " is not an regular element. Creating a PseudoAtom."); //check if the element is R rGroup=element.split("^R"); if (rGroup.length >1){ try{ Rnumber= Integer.valueOf(rGroup[(rGroup.length - 1)]); RGroupCounter=Rnumber; }catch(Exception ex){ Rnumber=RGroupCounter; RGroupCounter++; } element="R"+Rnumber; } atom = molecule.getBuilder().newPseudoAtom(element); } else { if (mode == ISimpleChemObjectReader.Mode.STRICT) { throw new CDKException("Invalid element type. Must be an existing element, or one in: A, Q, L, LP, *."); } atom = molecule.getBuilder().newPseudoAtom(element); } // store as 3D for now, convert to 2D (if totalZ == 0.0) later atom.setPoint3d(new Point3d(x, y, z)); // parse further fields String massDiffString = line.substring(34,36).trim(); logger.debug("Mass difference: ", massDiffString); if (!(atom instanceof IPseudoAtom)) { try { int massDiff = Integer.parseInt(massDiffString); if (massDiff != 0) { IIsotope major = IsotopeFactory.getInstance(molecule.getBuilder()).getMajorIsotope(element); atom.setMassNumber(major.getMassNumber() + massDiff); } } catch (Exception exception) { logger.error("Could not parse mass difference field"); } } else { logger.error("Cannot set mass difference for a non-element!"); } String chargeCodeString = line.substring(36,39).trim(); logger.debug("Atom charge code: ", chargeCodeString); int chargeCode = Integer.parseInt(chargeCodeString); if (chargeCode == 0) { // uncharged species } else if (chargeCode == 1) { atom.setFormalCharge(+3); } else if (chargeCode == 2) { atom.setFormalCharge(+2); } else if (chargeCode == 3) { atom.setFormalCharge(+1); } else if (chargeCode == 4) { } else if (chargeCode == 5) { atom.setFormalCharge(-1); } else if (chargeCode == 6) { atom.setFormalCharge(-2); } else if (chargeCode == 7) { atom.setFormalCharge(-3); } try { // read the mmm field as position 61-63 String reactionAtomIDString = line.substring(60,63).trim(); logger.debug("Parsing mapping id: ", reactionAtomIDString); try { int reactionAtomID = Integer.parseInt(reactionAtomIDString); if (reactionAtomID != 0) { atom.setID(reactionAtomIDString); } } catch (Exception exception) { logger.error("Mapping number ", reactionAtomIDString, " is not an integer."); logger.debug(exception); } } catch (Exception exception) { // older mol files don't have all these fields... logger.warn("A few fields are missing. Older MDL MOL file?"); } //shk3: This reads shifts from after the molecule. I don't think this is an official format, but I saw it frequently 80=>78 for alk if(line.length()>=78){ double shift=Double.parseDouble(line.substring(69,80).trim()); atom.setProperty("first shift", shift); } if(line.length()>=87){ double shift=Double.parseDouble(line.substring(79,87).trim()); atom.setProperty("second shift", shift); } molecule.addAtom(atom); } // convert to 2D, if totalZ == 0 if (totalX == 0.0 && totalY == 0.0 && totalZ == 0.0) { logger.info("All coordinates are 0.0"); for (IAtom atomToUpdate : molecule.atoms()) { atomToUpdate.setPoint3d(null); } } else if (totalZ == 0.0 && !forceReadAs3DCoords.isSet()) { logger.info("Total 3D Z is 0.0, interpreting it as a 2D structure"); Iterator atomsToUpdate = molecule.atoms().iterator(); while (atomsToUpdate.hasNext()) { IAtom atomToUpdate = atomsToUpdate.next(); Point3d p3d = atomToUpdate.getPoint3d(); if (p3d != null) { atomToUpdate.setPoint2d(new Point2d(p3d.x, p3d.y)); atomToUpdate.setPoint3d(null); } } } // read BOND block logger.info("Reading bond block"); for (int f = 0; f < bonds; f++) { line = input.readLine(); linecount++; atom1 = Integer.parseInt(line.substring(0, 3).trim()); atom2 = Integer.parseInt(line.substring(3, 6).trim()); order = Integer.parseInt(line.substring(6, 9).trim()); if (line.length() >= 12) { if (line.length() > 12) { stereo = Integer.parseInt(line.substring(9, 12).trim()); } else { stereo = Integer.parseInt(line.substring(9).trim()); } } else { logger.warn("Missing expected stereo field at line: " + line); } if (logger.isDebugEnabled()) { logger.debug("Bond: " + atom1 + " - " + atom2 + "; order " + order); } if (stereo == 1) { // MDL up bond stereo = CDKConstants.STEREO_BOND_UP; } else if (stereo == 6) { // MDL down bond stereo = CDKConstants.STEREO_BOND_DOWN; } else if (stereo == 4) { //MDL bond undefined stereo = CDKConstants.STEREO_BOND_UNDEFINED; } // interpret CTfile's special bond orders IAtom a1 = molecule.getAtom(atom1 - 1); IAtom a2 = molecule.getAtom(atom2 - 1); IBond newBond = null; if (order == 1) { newBond = molecule.getBuilder().newBond(a1, a2, IBond.Order.SINGLE, stereo); } else if (order == 2) { newBond = molecule.getBuilder().newBond(a1, a2, IBond.Order.DOUBLE, stereo); } else if (order == 3) { newBond = molecule.getBuilder().newBond(a1, a2, IBond.Order.TRIPLE, stereo); } else if (order == 4) { // aromatic bond newBond = molecule.getBuilder().newBond(a1, a2, IBond.Order.SINGLE, stereo); // mark both atoms and the bond as aromatic newBond.setFlag(CDKConstants.ISAROMATIC, true); a1.setFlag(CDKConstants.ISAROMATIC, true); a2.setFlag(CDKConstants.ISAROMATIC, true); } molecule.addBond(newBond); } // read PROPERTY block logger.info("Reading property block"); while (true) { line = input.readLine(); linecount++; if (line == null) { throw new CDKException("The expected property block is missing!"); } if (line.startsWith("M END")) break; boolean lineRead = false; if (line.startsWith("M CHG")) { // FIXME: if this is encountered for the first time, all // atom charges should be set to zero first! int infoCount = Integer.parseInt(line.substring(6,9).trim()); StringTokenizer st = new StringTokenizer(line.substring(9)); for (int i=1; i <= infoCount; i++) { String token = st.nextToken(); int atomNumber = Integer.parseInt(token.trim()); token = st.nextToken(); int charge = Integer.parseInt(token.trim()); molecule.getAtom(atomNumber - 1).setFormalCharge(charge); } } else if (line.matches("^A \\d+")) { // Reads the pseudo atom property from the mol file // The atom number of the to replaced atom int aliasAtomNumber = Integer.parseInt(line.replaceFirst("^A ", "")) - RGroupCounter; line = input.readLine(); linecount++; String[] aliasArray = line.split("\\\\"); // name of the alias atom like R1 odr R2 etc. String alias = ""; for (int i = 0; i < aliasArray.length; i++) { alias += aliasArray[i]; } IAtom aliasAtom = molecule.getAtom(aliasAtomNumber); IAtom newPseudoAtom = molecule.getBuilder().newPseudoAtom(alias); if(aliasAtom.getPoint2d() != null) { newPseudoAtom.setPoint2d(aliasAtom.getPoint2d()); } if(aliasAtom.getPoint3d() != null) { newPseudoAtom.setPoint3d(aliasAtom.getPoint3d()); } molecule.addAtom(newPseudoAtom); List bondsOfAliasAtom = molecule.getConnectedBondsList(aliasAtom); for (int i = 0; i < bondsOfAliasAtom.size(); i++) { IBond bondOfAliasAtom = bondsOfAliasAtom.get(i); IAtom connectedToAliasAtom = bondOfAliasAtom.getConnectedAtom(aliasAtom); IBond newBond = bondOfAliasAtom.getBuilder().newBond(); newBond.setAtoms(new IAtom[] {connectedToAliasAtom, newPseudoAtom}); newBond.setOrder(bondOfAliasAtom.getOrder()); molecule.addBond(newBond); molecule.removeBond(aliasAtom, connectedToAliasAtom); } molecule.removeAtom(aliasAtom); RGroupCounter++; } else if (line.startsWith("M ISO")) { try { String countString = line.substring(6,10).trim(); int infoCount = Integer.parseInt(countString); StringTokenizer st = new StringTokenizer(line.substring(10)); for (int i=1; i <= infoCount; i++) { int atomNumber = Integer.parseInt(st.nextToken().trim()); int absMass = Integer.parseInt(st.nextToken().trim()); if (absMass != 0) { IAtom isotope = molecule.getAtom(atomNumber - 1); isotope.setMassNumber(absMass); } } } catch (NumberFormatException exception) { String error = "Error (" + exception.getMessage() + ") while parsing line " + linecount + ": " + line + " in property block."; logger.error(error); throw new CDKException("NumberFormatException in isotope information on line: " + line, exception); } } else if (line.startsWith("M RAD")) { try { String countString = line.substring(6,9).trim(); int infoCount = Integer.parseInt(countString); StringTokenizer st = new StringTokenizer(line.substring(9)); for (int i=1; i <= infoCount; i++) { int atomNumber = Integer.parseInt(st.nextToken().trim()); int spinMultiplicity = Integer.parseInt(st.nextToken().trim()); if (spinMultiplicity > 1) { IAtom radical = molecule.getAtom(atomNumber - 1); for (int j=2; j <= spinMultiplicity; j++) { // 2 means doublet -> one unpaired electron // 3 means triplet -> two unpaired electron molecule.addSingleElectron(molecule.getBuilder().newSingleElectron(radical)); } } } } catch (NumberFormatException exception) { String error = "Error (" + exception.getMessage() + ") while parsing line " + linecount + ": " + line + " in property block."; logger.error(error); throw new CDKException("NumberFormatException in radical information on line: " + line, exception); } } else if (line.startsWith("G ")) { try { String atomNumberString = line.substring(3,6).trim(); int atomNumber = Integer.parseInt(atomNumberString); //String whatIsThisString = line.substring(6,9).trim(); String atomName = input.readLine(); // convert Atom into a PseudoAtom IAtom prevAtom = molecule.getAtom(atomNumber - 1); IPseudoAtom pseudoAtom = molecule.getBuilder().newPseudoAtom(atomName); if (prevAtom.getPoint2d() != null) { pseudoAtom.setPoint2d(prevAtom.getPoint2d()); } if (prevAtom.getPoint3d() != null) { pseudoAtom.setPoint3d(prevAtom.getPoint3d()); } AtomContainerManipulator.replaceAtomByAtom(molecule, prevAtom, pseudoAtom); } catch (NumberFormatException exception) { String error = "Error (" + exception.toString() + ") while parsing line " + linecount + ": " + line + " in property block."; logger.error(error); throw new CDKException("NumberFormatException in group information on line: " + line, exception); } } if (!lineRead) { logger.warn("Skipping line in property block: ", line); } } } catch (CDKException exception) { String error = "Error while parsing line " + linecount + ": " + line + " -> " + exception.getMessage(); logger.error(error); logger.debug(exception); throw exception; } catch (Exception exception) { exception.printStackTrace(); String error = "Error while parsing line " + linecount + ": " + line + " -> " + exception.getMessage(); logger.error(error); logger.debug(exception); throw new CDKException(error, exception); } if (interpretHydrogenIsotopes.isSet()) { fixHydrogenIsotopes(molecule); } return molecule; } private void fixHydrogenIsotopes(IMolecule molecule) { Iterator atoms = molecule.atoms().iterator(); while (atoms.hasNext()) { IAtom atom = atoms.next(); if (atom instanceof IPseudoAtom) { IPseudoAtom pseudo = (IPseudoAtom)atom; Integer massNumber = atom.getMassNumber(); if ("D".equals(pseudo.getLabel()) && massNumber != null && massNumber == 2) { IAtom newAtom = molecule.getBuilder().newAtom(atom); newAtom.setSymbol("H"); AtomContainerManipulator.replaceAtomByAtom(molecule, atom, newAtom); } else if ("T".equals(pseudo.getLabel()) && massNumber != null && massNumber == 3) { IAtom newAtom = molecule.getBuilder().newAtom(atom); newAtom.setSymbol("H"); AtomContainerManipulator.replaceAtomByAtom(molecule, atom, newAtom); } } } } @TestMethod("testClose") public void close() throws IOException { input.close(); } private void initIOSettings() { forceReadAs3DCoords = new BooleanIOSetting("ForceReadAs3DCoordinates", IOSetting.LOW, "Should coordinates always be read as 3D?", "false"); interpretHydrogenIsotopes = new BooleanIOSetting("InterpretHydrogenIsotopes", IOSetting.LOW, "Should D and T be interpreted as hydrogen isotopes?", "true"); } public void customizeJob() { fireIOSettingQuestion(forceReadAs3DCoords); fireIOSettingQuestion(interpretHydrogenIsotopes); } public IOSetting[] getIOSettings() { IOSetting[] settings = new IOSetting[2]; settings[0] = forceReadAs3DCoords; settings[1] = interpretHydrogenIsotopes; return settings; } } cdk-1.2.10/src/main/org/openscience/cdk/io/MDLV3000Reader.java100644 0 0 60730 11570154753 20521 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2006-2008 Egon Willighagen * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.io; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.vecmath.Point2d; import javax.vecmath.Point3d; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.IsotopeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IPseudoAtom; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.MDLV3000Format; import org.openscience.cdk.io.setting.IOSetting; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.manipulator.BondManipulator; /** * Class that implements the MDL mol V3000 format. This reader reads the * element symbol and 2D or 3D coordinates from the ATOM block. * * @cdk.module io * @cdk.githash * * @author Egon Willighagen * @cdk.created 2006 * * @cdk.keyword MDL molfile V3000 * @cdk.require java1.4+ */ @TestClass("org.openscience.cdk.io.MDLV3000ReaderTest") public class MDLV3000Reader extends DefaultChemObjectReader { BufferedReader input = null; private LoggingTool logger = null; private Pattern keyValueTuple; private Pattern keyValueTuple2; private int lineNumber; public MDLV3000Reader(Reader in) { this(in, Mode.RELAXED); } public MDLV3000Reader(Reader in, Mode mode) { logger = new LoggingTool(this); input = new BufferedReader(in); initIOSettings(); super.mode = mode; /* compile patterns */ keyValueTuple = Pattern.compile("\\s*(\\w+)=([^\\s]*)(.*)"); // e.g. CHG=-1 keyValueTuple2 = Pattern.compile("\\s*(\\w+)=\\(([^\\)]*)\\)(.*)"); // e.g. ATOMS=(1 31) lineNumber = 0; } public MDLV3000Reader(InputStream input) { this(input, Mode.RELAXED); } public MDLV3000Reader(InputStream input, Mode mode) { this(new InputStreamReader(input), mode); } public MDLV3000Reader() { this(new StringReader("")); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return MDLV3000Format.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader input) throws CDKException { if (input instanceof BufferedReader) { this.input = (BufferedReader)input; } else { this.input = new BufferedReader(input); } lineNumber = 0; } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i 0) { if (line1.startsWith("M V30")) { // no header return line1; } readData.setProperty(CDKConstants.TITLE, line1); } readLine(); String line3 = readLine(); if (line3.length() > 0) readData.setProperty(CDKConstants.COMMENT, line3); String line4 = readLine(); if (!line4.contains("3000")) { throw new CDKException("This file is not a MDL V3000 molfile."); } return readLine(); } /** * Reads the atoms, coordinates and charges. * *

IMPORTANT: it does not support the atom list and its negation! */ public void readAtomBlock(IAtomContainer readData) throws CDKException { logger.info("Reading ATOM block"); IsotopeFactory isotopeFactory; try { isotopeFactory = IsotopeFactory.getInstance(readData.getBuilder()); } catch (IOException exception) { throw new CDKException("Could not initiate the IsotopeFactory.", exception); } int RGroupCounter = 1; int Rnumber = 0; String[] rGroup = null; boolean foundEND = false; while (isReady() && !foundEND) { String command = readCommand(readLine()); if ("END ATOM".equals(command)) { // FIXME: should check whether 3D is really 2D foundEND = true; } else { logger.debug("Parsing atom from: " + command); IAtom atom = readData.getBuilder().newAtom(); StringTokenizer tokenizer = new StringTokenizer(command); // parse the index try { atom.setID(tokenizer.nextToken()); } catch (Exception exception) { String error = "Error while parsing atom index"; logger.error(error); logger.debug(exception); throw new CDKException(error, exception); } // parse the element String element = tokenizer.nextToken(); if (isotopeFactory.isElement(element)) { atom = isotopeFactory.configure(readData.getBuilder().newAtom(element)); } else if ("A".equals(element)) { atom = readData.getBuilder().newPseudoAtom(element); } else if ("Q".equals(element)) { atom = readData.getBuilder().newPseudoAtom(element); } else if ("*".equals(element)) { atom = readData.getBuilder().newPseudoAtom(element); } else if ("LP".equals(element)) { atom = readData.getBuilder().newPseudoAtom(element); } else if ("L".equals(element)) { atom = readData.getBuilder().newPseudoAtom(element); } else if (element.length() > 0 && element.charAt(0) == 'R'){ logger.debug("Atom ", element, " is not an regular element. Creating a PseudoAtom."); //check if the element is R rGroup = element.split("^R"); if (rGroup.length > 1){ try{ Rnumber = Integer.valueOf(rGroup[(rGroup.length-1)]).intValue(); RGroupCounter=Rnumber; }catch(Exception ex){ Rnumber=RGroupCounter; RGroupCounter++; } element="R"+Rnumber; } atom = readData.getBuilder().newPseudoAtom(element); } else { if (mode == ISimpleChemObjectReader.Mode.STRICT) { throw new CDKException("Invalid element type. Must be an existing element, or one in: A, Q, L, LP, *."); } atom = readData.getBuilder().newPseudoAtom(element); } // parse atom coordinates (in Angstrom) try { String xString = tokenizer.nextToken(); String yString = tokenizer.nextToken(); String zString = tokenizer.nextToken(); double x = Double.parseDouble(xString); double y = Double.parseDouble(yString); double z = Double.parseDouble(zString); atom.setPoint3d(new Point3d(x, y, z)); atom.setPoint2d(new Point2d(x, y)); // FIXME: dirty! } catch (Exception exception) { String error = "Error while parsing atom coordinates"; logger.error(error); logger.debug(exception); throw new CDKException(error, exception); } // atom-atom mapping String mapping = tokenizer.nextToken(); if (!mapping.equals("0")) { logger.warn("Skipping atom-atom mapping: " + mapping); } // else: default 0 is no mapping defined // the rest are key value things if (command.indexOf("=") != -1) { Map options = parseOptions(exhaustStringTokenizer(tokenizer)); Iterator keys = options.keySet().iterator(); while (keys.hasNext()) { String key = keys.next(); String value = options.get(key); try { if (key.equals("CHG")) { int charge = Integer.parseInt(value); if (charge != 0) { // zero is no charge specified atom.setFormalCharge(charge); } } else { logger.warn("Not parsing key: " + key); } } catch (Exception exception) { String error = "Error while parsing key/value " + key + "=" + value + ": " + exception.getMessage(); logger.error(error); logger.debug(exception); throw new CDKException(error, exception); } } } // store atom readData.addAtom(atom); logger.debug("Added atom: " + atom); } } } /** * Reads the bond atoms, order and stereo configuration. */ public void readBondBlock(IAtomContainer readData) throws CDKException { logger.info("Reading BOND block"); boolean foundEND = false; while (isReady() && !foundEND) { String command = readCommand(readLine()); if ("END BOND".equals(command)) { foundEND = true; } else { logger.debug("Parsing bond from: " + command); StringTokenizer tokenizer = new StringTokenizer(command); IBond bond = readData.getBuilder().newBond(); // parse the index try { String indexString = tokenizer.nextToken(); bond.setID(indexString); } catch (Exception exception) { String error = "Error while parsing bond index"; logger.error(error); logger.debug(exception); throw new CDKException(error, exception); } // parse the order try { String orderString = tokenizer.nextToken(); int order = Integer.parseInt(orderString); if (order >= 4) { logger.warn("Query order types are not supported (yet). File a bug if you need it"); } else { bond.setOrder(BondManipulator.createBondOrder((double)order)); } } catch (Exception exception) { String error = "Error while parsing bond index"; logger.error(error); logger.debug(exception); throw new CDKException(error, exception); } // parse index atom 1 try { String indexAtom1String = tokenizer.nextToken(); int indexAtom1 = Integer.parseInt(indexAtom1String); IAtom atom1 = readData.getAtom(indexAtom1 -1); bond.setAtom(atom1, 0); } catch (Exception exception) { String error = "Error while parsing index atom 1 in bond"; logger.error(error); logger.debug(exception); throw new CDKException(error, exception); } // parse index atom 2 try { String indexAtom2String = tokenizer.nextToken(); int indexAtom2 = Integer.parseInt(indexAtom2String); IAtom atom2 = readData.getAtom(indexAtom2 -1); bond.setAtom(atom2, 1); } catch (Exception exception) { String error = "Error while parsing index atom 2 in bond"; logger.error(error); logger.debug(exception); throw new CDKException(error, exception); } // the rest are key=value fields if (command.indexOf("=") != -1) { Map options = parseOptions(exhaustStringTokenizer(tokenizer)); Iterator keys = options.keySet().iterator(); while (keys.hasNext()) { String key = keys.next(); String value = options.get(key); try { if (key.equals("CFG")) { int configuration = Integer.parseInt(value); if (configuration == 0) { bond.setStereo(CDKConstants.STEREO_BOND_NONE); } else if (configuration == 1) { bond.setStereo(CDKConstants.STEREO_BOND_UP); } else if (configuration == 2) { bond.setStereo(CDKConstants.STEREO_BOND_UNDEFINED); } else if (configuration == 3) { bond.setStereo(CDKConstants.STEREO_BOND_DOWN); } } else { logger.warn("Not parsing key: " + key); } } catch (Exception exception) { String error = "Error while parsing key/value " + key + "=" + value + ": " + exception.getMessage(); logger.error(error); logger.debug(exception); throw new CDKException(error, exception); } } } // storing bond readData.addBond(bond); logger.debug("Added bond: " + bond); } } } /** * Reads labels. */ public void readSGroup(IAtomContainer readData) throws CDKException { boolean foundEND = false; while (isReady() && !foundEND) { String command = readCommand(readLine()); if ("END SGROUP".equals(command)) { foundEND = true; } else { logger.debug("Parsing Sgroup line: " + command); StringTokenizer tokenizer = new StringTokenizer(command); // parse the index String indexString = tokenizer.nextToken(); logger.warn("Skipping external index: " + indexString); // parse command type String type = tokenizer.nextToken(); // parse the external index String externalIndexString = tokenizer.nextToken(); logger.warn("Skipping external index: " + externalIndexString); // the rest are key=value fields Map options = new Hashtable(); if (command.indexOf("=") != -1) { options = parseOptions(exhaustStringTokenizer(tokenizer)); } // now interpret line if (type.startsWith("SUP")) { Iterator keys = options.keySet().iterator(); int atomID = -1; String label = ""; while (keys.hasNext()) { String key = keys.next(); String value = options.get(key); try { if (key.equals("ATOMS")) { StringTokenizer atomsTokenizer = new StringTokenizer(value); Integer.parseInt(atomsTokenizer.nextToken()); // should be 1, int atomCount = atomID = Integer.parseInt(atomsTokenizer.nextToken()); } else if (key.equals("LABEL")) { label = value; } else { logger.warn("Not parsing key: " + key); } } catch (Exception exception) { String error = "Error while parsing key/value " + key + "=" + value + ": " + exception.getMessage(); logger.error(error); logger.debug(exception); throw new CDKException(error, exception); } if (atomID != -1 && label.length() > 0) { IAtom atom = readData.getAtom(atomID-1); if (!(atom instanceof IPseudoAtom)) { atom = readData.getBuilder().newPseudoAtom(atom); } ((IPseudoAtom)atom).setLabel(label); readData.setAtom(atomID-1, atom); } } } else { logger.warn("Skipping unrecognized SGROUP type: " + type); } } } } /** * Reads the command on this line. If the line is continued on the next, that * part is added. * * @return Returns the command on this line. */ private String readCommand(String line) throws CDKException { if (line.startsWith("M V30 ")) { String command = line.substring(7); if (command.endsWith("-")) { command = command.substring(0, command.length()-1); command += readCommand(readLine()); } return command; } else { throw new CDKException("Could not read MDL file: unexpected line: " + line); } } private Map parseOptions(String string) throws CDKException { Map keyValueTuples = new Hashtable(); while (string.length() >= 3) { logger.debug("Matching remaining option string: " + string); Matcher tuple1Matcher = keyValueTuple2.matcher(string); if (tuple1Matcher.matches()) { String key = tuple1Matcher.group(1); String value = tuple1Matcher.group(2); string = tuple1Matcher.group(3); logger.debug("Found key: " + key); logger.debug("Found value: " + value); keyValueTuples.put(key, value); } else { Matcher tuple2Matcher = keyValueTuple.matcher(string); if (tuple2Matcher.matches()) { String key = tuple2Matcher.group(1); String value = tuple2Matcher.group(2); string = tuple2Matcher.group(3); logger.debug("Found key: " + key); logger.debug("Found value: " + value); keyValueTuples.put(key, value); } else { logger.warn("Quiting; could not parse: " + string + "."); string = ""; } } } return keyValueTuples; } public String exhaustStringTokenizer(StringTokenizer tokenizer) { StringBuffer buffer = new StringBuffer(); buffer.append(" "); while (tokenizer.hasMoreTokens()) { buffer.append(tokenizer.nextToken()); buffer.append(" "); } return buffer.toString(); } public String readLine() throws CDKException { String line = null; try { line = input.readLine(); lineNumber++; logger.debug("read line " + lineNumber + ":", line); } catch (Exception exception) { String error = "Unexpected error while reading file: " + exception.getMessage(); logger.error(error); logger.debug(exception); throw new CDKException(error, exception); } return line; } public boolean isReady() throws CDKException { try { return input.ready(); } catch (Exception exception) { String error = "Unexpected error while reading file: " + exception.getMessage(); logger.error(error); logger.debug(exception); throw new CDKException(error, exception); } } @TestMethod("testAccepts") public boolean accepts(IChemObject object) { if (object instanceof IMolecule) { return true; } return false; } @TestMethod("testClose") public void close() throws IOException { input.close(); } private void initIOSettings() { } public IOSetting[] getIOSettings() { return new IOSetting[0]; } } cdk-1.2.10/src/main/org/openscience/cdk/io/MDLWriter.java100644 0 0 36171 11570154753 20144 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 1997-2007 The Chemistry Development Kit (CDK) project * 2009 Egon Willighagen * * 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 org.openscience.cdk.io; import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.StringWriter; import java.io.Writer; import java.text.NumberFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Iterator; import java.util.Locale; import java.util.TimeZone; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.IsotopeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IPseudoAtom; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.MDLFormat; import org.openscience.cdk.io.setting.BooleanIOSetting; import org.openscience.cdk.io.setting.IOSetting; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.manipulator.ChemFileManipulator; /** * Writes MDL molfiles, which contains a single molecule. * For writing a MDL molfile you can this code: *

 * MDLWriter writer = new MDLWriter(new FileWriter(new File("output.mol")));
 * writer.write((Molecule)molecule);
 * writer.close();
 * 
* * See {@cdk.cite DAL92}. * * @cdk.module io * @cdk.githash * @cdk.keyword file format, MDL molfile */ @TestClass("org.openscience.cdk.io.MDLWriterTest") public class MDLWriter extends DefaultChemObjectWriter { private final static LoggingTool logger = new LoggingTool(MDLWriter.class); private BooleanIOSetting forceWriteAs2DCoords; private BufferedWriter writer; /** * Constructs a new MDLWriter that can write an {@link IMolecule} * to the MDL molfile format. * * @param out The Writer to write to */ public MDLWriter(Writer out) { if (out instanceof BufferedWriter) { writer = (BufferedWriter)out; } else { writer = new BufferedWriter(out); } initIOSettings(); } /** * Constructs a new MDLWriter that can write an {@link IMolecule} * to a given OutputStream. * * @param output The OutputStream to write to */ public MDLWriter(OutputStream output) { this(new OutputStreamWriter(output)); } public MDLWriter() { this(new StringWriter()); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return MDLFormat.getInstance(); } public void setWriter(Writer out) throws CDKException { if (out instanceof BufferedWriter) { writer = (BufferedWriter)out; } else { writer = new BufferedWriter(out); } } public void setWriter(OutputStream output) throws CDKException { setWriter(new OutputStreamWriter(output)); } /** * Flushes the output and closes this object. */ @TestMethod("testClose") public void close() throws IOException { writer.close(); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i80) title=title.substring(0,80); writer.write(title); writer.newLine(); /* From CTX spec * This line has the format: * IIPPPPPPPPMMDDYYHHmmddSSssssssssssEEEEEEEEEEEERRRRRR * (FORTRAN: A2<--A8--><---A10-->A2I2<--F10.5-><---F12.5--><-I6-> ) * User's first and last initials (l), program name (P), * date/time (M/D/Y,H:m), dimensional codes (d), scaling factors (S, s), * energy (E) if modeling program input, internal registry number (R) * if input through MDL form. * A blank line can be substituted for line 2. */ writer.write(" CDK "); writer.write(new SimpleDateFormat("M/d/y,H:m",Locale.US).format( Calendar.getInstance(TimeZone.getDefault()).getTime()) ); writer.newLine(); String comment = (String)container.getProperty(CDKConstants.REMARK); if (comment == null) comment = ""; if(comment.length()>80) comment=comment.substring(0,80); writer.write(comment); writer.newLine(); // write Counts line line += formatMDLInt(container.getAtomCount(), 3); line += formatMDLInt(container.getBondCount(), 3); line += " 0 0 0 0 0 0 0 0999 V2000"; writer.write(line); writer.newLine(); // write Atom block for (int f = 0; f < container.getAtomCount(); f++) { IAtom atom = container.getAtom(f); line = ""; if (atom.getPoint3d() != null && !forceWriteAs2DCoords.isSet()) { line += formatMDLFloat((float) atom.getPoint3d().x); line += formatMDLFloat((float) atom.getPoint3d().y); line += formatMDLFloat((float) atom.getPoint3d().z) + " "; } else if (atom.getPoint2d() != null) { line += formatMDLFloat((float) atom.getPoint2d().x); line += formatMDLFloat((float) atom.getPoint2d().y); line += " 0.0000 "; } else { // if no coordinates available, then output a number // of zeros line += formatMDLFloat((float)0.0); line += formatMDLFloat((float)0.0); line += formatMDLFloat((float)0.0) + " "; } if(container.getAtom(f) instanceof IPseudoAtom){ //according to http://www.google.co.uk/url?sa=t&ct=res&cd=2&url=http%3A%2F%2Fwww.mdl.com%2Fdownloads%2Fpublic%2Fctfile%2Fctfile.pdf&ei=MsJjSMbjAoyq1gbmj7zCDQ&usg=AFQjCNGaJSvH4wYy4FTXIaQ5f7hjoTdBAw&sig2=eSfruNOSsdMFdlrn7nhdAw an R group is written as R# if(((IPseudoAtom) container.getAtom(f)).getLabel().equals("R")) line += "R#"; else line += formatMDLString(((IPseudoAtom) container.getAtom(f)).getLabel(), 3); }else{ line += formatMDLString(container.getAtom(f).getSymbol(), 3); } line += " 0 0 0 0 0 0 0 0 0 0 0 0"; writer.write(line); writer.newLine(); } // write Bond block Iterator bonds = container.bonds().iterator(); while (bonds.hasNext()) { IBond bond = (IBond) bonds.next(); if (bond.getAtomCount() != 2) { logger.warn("Skipping bond with more/less than two atoms: " + bond); } else { if (bond.getStereo() == CDKConstants.STEREO_BOND_UP_INV || bond.getStereo() == CDKConstants.STEREO_BOND_DOWN_INV) { // turn around atom coding to correct for inv stereo line = formatMDLInt(container.getAtomNumber(bond.getAtom(1)) + 1,3); line += formatMDLInt(container.getAtomNumber(bond.getAtom(0)) + 1,3); } else { line = formatMDLInt(container.getAtomNumber(bond.getAtom(0)) + 1,3); line += formatMDLInt(container.getAtomNumber(bond.getAtom(1)) + 1,3); } line += formatMDLInt((int)bond.getOrder().ordinal()+1,3); line += " "; switch(bond.getStereo()){ case CDKConstants.STEREO_BOND_UP: line += "1"; break; case CDKConstants.STEREO_BOND_UP_INV: line += "1"; break; case CDKConstants.STEREO_BOND_DOWN: line += "6"; break; case CDKConstants.STEREO_BOND_DOWN_INV: line += "6"; break; default: line += "0"; } line += " 0 0 0 "; writer.write(line); writer.newLine(); } } // write formal atomic charges for (int i = 0; i < container.getAtomCount(); i++) { IAtom atom = container.getAtom(i); Integer charge = atom.getFormalCharge(); if (charge != null && charge != 0) { writer.write("M CHG 1 "); writer.write(formatMDLInt(i+1,3)); writer.write(" "); writer.write(formatMDLInt(charge,3)); writer.newLine(); } } // write formal isotope information for (int i = 0; i < container.getAtomCount(); i++) { IAtom atom = container.getAtom(i); if (!(atom instanceof IPseudoAtom)) { Integer atomicMass = atom.getMassNumber(); if (atomicMass != null) { int majorMass = IsotopeFactory.getInstance(atom.getBuilder()).getMajorIsotope(atom.getSymbol()).getMassNumber(); if (atomicMass != majorMass) { writer.write("M ISO 1 "); writer.write(formatMDLInt(i+1,3)); writer.write(" "); writer.write(formatMDLInt(atomicMass,3)); writer.newLine(); } } } } // close molecule writer.write("M END"); writer.newLine(); writer.flush(); } /** * Formats an integer to fit into the connection table and changes it * to a String. * * @param i The int to be formated * @param l Length of the String * @return The String to be written into the connectiontable */ private String formatMDLInt(int i, int l) { String s = "", fs = ""; NumberFormat nf = NumberFormat.getNumberInstance(Locale.ENGLISH); nf.setParseIntegerOnly(true); nf.setMinimumIntegerDigits(1); nf.setMaximumIntegerDigits(l); nf.setGroupingUsed(false); s = nf.format(i); l = l - s.length(); for (int f = 0; f < l; f++) fs += " "; fs += s; return fs; } /** * Formats a float to fit into the connectiontable and changes it * to a String. * * @param fl The float to be formated * @return The String to be written into the connectiontable */ private String formatMDLFloat(float fl) { String s = "", fs = ""; int l; NumberFormat nf = NumberFormat.getNumberInstance(Locale.ENGLISH); nf.setMinimumIntegerDigits(1); nf.setMaximumIntegerDigits(4); nf.setMinimumFractionDigits(4); nf.setMaximumFractionDigits(4); nf.setGroupingUsed(false); s = nf.format(fl); l = 10 - s.length(); for (int f = 0; f < l; f++) fs += " "; fs += s; return fs; } /** * Formats a String to fit into the connectiontable. * * @param s The String to be formated * @param le The length of the String * @return The String to be written in the connectiontable */ private String formatMDLString(String s, int le) { s = s.trim(); if (s.length() > le) return s.substring(0, le); int l; l = le - s.length(); for (int f = 0; f < l; f++) s += " "; return s; } private void initIOSettings() { forceWriteAs2DCoords = new BooleanIOSetting( "ForceWriteAs2DCoordinates", IOSetting.LOW, "Should coordinates always be written as 2D?", "false" ); } public void customizeJob() { fireIOSettingQuestion(forceWriteAs2DCoords); } public IOSetting[] getIOSettings() { IOSetting[] settings = new IOSetting[1]; settings[0] = forceWriteAs2DCoords; return settings; } } cdk-1.2.10/src/main/org/openscience/cdk/io/Mol2Reader.java100644 0 0 35221 11570154753 20262 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2003-2007 Egon Willighagen * * 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 org.openscience.cdk.io; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.util.StringTokenizer; import javax.vecmath.Point3d; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.AtomTypeFactory; import org.openscience.cdk.config.Symbols; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.Mol2Format; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.manipulator.AtomTypeManipulator; /** * Reads a molecule from an Mol2 file, such as written by Sybyl. * See the specs here. * * @cdk.module io * @cdk.githash * * @author Egon Willighagen * @cdk.created 2003-08-21 * * @cdk.keyword file format, Mol2 */ @TestClass("org.openscience.cdk.io.Mol2ReaderTest") public class Mol2Reader extends DefaultChemObjectReader { BufferedReader input = null; private LoggingTool logger = null; /** * Contructs a new MDLReader that can read Molecule from a given Reader. * * @param in The Reader to read from */ public Mol2Reader(Reader in) { logger = new LoggingTool(this); input = new BufferedReader(in); } public Mol2Reader(InputStream input) { this(new InputStreamReader(input)); } public Mol2Reader() { this(new StringReader("")); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return Mol2Format.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader input) throws CDKException { if (input instanceof BufferedReader) { this.input = (BufferedReader)input; } else { this.input = new BufferedReader(input); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; iMOLECULE")) { logger.info("Reading molecule block"); // second line has atom/bond counts? input.readLine(); // disregard the name line String counts = input.readLine(); StringTokenizer tokenizer = new StringTokenizer(counts); try { atomCount = Integer.parseInt(tokenizer.nextToken()); } catch (NumberFormatException nfExc) { String error = "Error while reading atom count from MOLECULE block"; logger.error(error); logger.debug(nfExc); throw new CDKException(error, nfExc); } if (tokenizer.hasMoreTokens()) { try { bondCount = Integer.parseInt(tokenizer.nextToken()); } catch (NumberFormatException nfExc) { String error = "Error while reading atom and bond counts"; logger.error(error); logger.debug(nfExc); throw new CDKException(error, nfExc); } } else { bondCount = 0; } logger.info("Reading #atoms: ", atomCount); logger.info("Reading #bonds: ", bondCount); logger.warn("Not reading molecule qualifiers"); } else if (line.startsWith("@ATOM")) { logger.info("Reading atom block"); for (int i=0; iBOND")) { logger.info("Reading bond block"); for (int i=0; i * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.io; import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.StringWriter; import java.io.Writer; import java.util.Iterator; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.atomtype.SybylAtomTypeMatcher; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomType; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.Mol2Format; import org.openscience.cdk.tools.LoggingTool; /** * An output Writer that writes molecular data into the * Tripos Mol2 format. * Writes the atoms and the bonds only at this moment. * * @cdk.module io * @cdk.githash * * @author Egon Willighagen */ @TestClass("org.openscience.cdk.io.Mol2WriterTest") public class Mol2Writer extends DefaultChemObjectWriter { private BufferedWriter writer; private LoggingTool logger; private SybylAtomTypeMatcher matcher; public Mol2Writer() { this(new StringWriter()); } /** * Constructs a new Mol2 writer. * @param out the stream to write the Mol2 file to. */ public Mol2Writer(Writer out) { logger = new LoggingTool(this); try { if (out instanceof BufferedWriter) { writer = (BufferedWriter)out; } else { writer = new BufferedWriter(out); } } catch (Exception exc) { } } public Mol2Writer(OutputStream output) { this(new OutputStreamWriter(output)); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return Mol2Format.getInstance(); } public void setWriter(Writer out) throws CDKException { if (out instanceof BufferedWriter) { writer = (BufferedWriter)out; } else { writer = new BufferedWriter(out); } } public void setWriter(OutputStream output) throws CDKException { setWriter(new OutputStreamWriter(output)); } /** * Flushes the output and closes this object. */ @TestMethod("testClose") public void close() throws IOException { writer.close(); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (Class anInterface : interfaces) { if (IMolecule.class.equals(anInterface)) return true; } return false; } public void write(IChemObject object) throws CDKException { if (object instanceof IMolecule) { try { writeMolecule((IMolecule)object); } catch(Exception ex) { throw new CDKException("Error while writing Mol2 file: " + ex.getMessage(), ex); } } else { throw new CDKException("Mol2Writer only supports output of Molecule classes."); } } /** * Writes a single frame in XYZ format to the Writer. * * @param mol the Molecule to write * @throws java.io.IOException if there is an error during writing */ public void writeMolecule(IMolecule mol) throws IOException { matcher = SybylAtomTypeMatcher.getInstance(mol.getBuilder()); try { logger.debug("Writing header..."); if (mol.getProperty(CDKConstants.TITLE) != null) { writer.write("# Name: " + mol.getProperty(CDKConstants.TITLE)); writer.newLine(); } // FIXME: add other types of meta data writer.newLine(); /* @MOLECULE benzene 12 12 1 0 0 SMALL NO_CHARGES */ logger.debug("Writing molecule block..."); writer.write("@MOLECULE"); writer.newLine(); if (mol.getID() == null) { writer.write("CDKMolecule"); } else { writer.write(mol.getID()); } writer.newLine(); writer.write(mol.getAtomCount() + " " + mol.getBondCount()); // that's the minimum amount of info required the format writer.newLine(); writer.write("SMALL"); // no biopolymer writer.newLine(); writer.write("NO CHARGES"); // other options include Gasteiger charges writer.newLine(); /* @ATOM 1 C1 1.207 2.091 0.000 C.ar 1 BENZENE 0.000 2 C2 2.414 1.394 0.000 C.ar 1 BENZENE 0.000 3 C3 2.414 0.000 0.000 C.ar 1 BENZENE 0.000 4 C4 1.207 -0.697 0.000 C.ar 1 BENZENE 0.000 5 C5 0.000 0.000 0.000 C.ar 1 BENZENE 0.000 6 C6 0.000 1.394 0.000 C.ar 1 BENZENE 0.000 7 H1 1.207 3.175 0.000 H 1 BENZENE 0.000 8 H2 3.353 1.936 0.000 H 1 BENZENE 0.000 9 H3 3.353 -0.542 0.000 H 1 BENZENE 0.000 10 H4 1.207 -1.781 0.000 H 1 BENZENE 0.000 11 H5 -0.939 -0.542 0.000 H 1 BENZENE 0.000 12 H6 -0.939 1.936 0.000 H 1 BENZENE 0.000 */ // write atom block logger.debug("Writing atom block..."); writer.write("@ATOM"); writer.newLine(); for (int i = 0; i < mol.getAtomCount(); i++) { IAtom atom = mol.getAtom(i); writer.write((i+1) + " " + atom.getSymbol() + (mol.getAtomNumber(atom)+1) + " "); if (atom.getPoint3d() != null) { writer.write(atom.getPoint3d().x + " "); writer.write(atom.getPoint3d().y + " "); writer.write(atom.getPoint3d().z + " "); } else if (atom.getPoint2d() != null) { writer.write(atom.getPoint2d().x + " "); writer.write(atom.getPoint2d().y + " "); writer.write(" 0.000 "); } else { writer.write("0.000 0.000 0.000 "); } IAtomType sybylType = null; try { sybylType = matcher.findMatchingAtomType(mol, atom); } catch ( CDKException e ) { e.printStackTrace(); } if (sybylType != null) { writer.write(sybylType.getAtomTypeName()); } else { writer.write(atom.getSymbol()); } writer.newLine(); } /* @BOND 1 1 2 ar 2 1 6 ar 3 2 3 ar 4 3 4 ar 5 4 5 ar 6 5 6 ar 7 1 7 1 8 2 8 1 9 3 9 1 10 4 10 1 11 5 11 1 12 6 12 1 */ // write bond block logger.debug("Writing bond block..."); writer.write("@BOND"); writer.newLine(); int counter = 0; for (IBond bond : mol.bonds()) { String sybylBondOrder = "-1"; if (bond.getOrder().equals(IBond.Order.SINGLE)) sybylBondOrder = "1"; else if (bond.getOrder().equals(IBond.Order.DOUBLE)) sybylBondOrder = "2"; else if (bond.getOrder().equals(IBond.Order.TRIPLE)) sybylBondOrder = "3"; if (bond.getFlag(CDKConstants.ISAROMATIC)) sybylBondOrder = "ar"; // we need to check the atom types to see if we have an amide bond // and we're assuming a 2-centered bond IAtom bondAtom1 = bond.getAtom(0); IAtom bondAtom2 = bond.getAtom(1); try { if ( (matcher.findMatchingAtomType(mol, bondAtom1).getAtomTypeName().equals("N.am") && matcher.findMatchingAtomType(mol, bondAtom2).getAtomTypeName().equals("C.2")) || (matcher.findMatchingAtomType(mol, bondAtom2).getAtomTypeName().equals("N.am") && matcher.findMatchingAtomType(mol, bondAtom1).getAtomTypeName().equals("C.2")) ) { sybylBondOrder = "am"; } } catch (CDKException e) { e.printStackTrace(); } writer.write((counter+1) + " " + (mol.getAtomNumber(bond.getAtom(0))+1) + " " + (mol.getAtomNumber(bond.getAtom(1))+1) + " " + sybylBondOrder); writer.newLine(); counter++; } } catch (IOException e) { throw e; } } } cdk-1.2.10/src/main/org/openscience/cdk/io/PCCompoundASNReader.java100644 0 0 35365 11570154753 22033 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2006-2007 Egon Willighagen * * 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 org.openscience.cdk.io; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.util.HashMap; import java.util.Map; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.PubChemASNFormat; import org.openscience.cdk.tools.LoggingTool; /** * Reads an object from ASN formated input for PubChem Compound entries. The following * bits are supported: atoms.aid, atoms.element, bonds.aid1, bonds.aid2. Additionally, * it extracts the InChI and canonical SMILES properties. * * @cdk.module io * @cdk.githash * * @cdk.keyword file format, PubChem Compound ASN */ @TestClass("org.openscience.cdk.io.PCCompoundASNReaderTest") public class PCCompoundASNReader extends DefaultChemObjectReader { private BufferedReader input; private LoggingTool logger; IMolecule molecule = null; Map atomIDs = null; /** * Construct a new reader from a Reader type object. * * @param input reader from which input is read */ public PCCompoundASNReader(Reader input) { this.input = new BufferedReader(input); logger = new LoggingTool(this); } public PCCompoundASNReader(InputStream input) { this(new InputStreamReader(input)); } public PCCompoundASNReader() { this(new StringReader("")); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return PubChemASNFormat.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader input) throws CDKException { if (input instanceof BufferedReader) { this.input = (BufferedReader)input; } else { this.input = new BufferedReader(input); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i * * 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 org.openscience.cdk.io; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.PubChemSubstanceXMLFormat; import org.openscience.cdk.io.pubchemxml.PubChemXMLHelper; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserFactory; /** * Reads an object from ASN.1 XML formated input for PubChem Compound entries. * The following bits are supported: atoms.aid, atoms.element, atoms.2d, * atoms.3d, bonds.aid1, bonds.aid2. * * @cdk.module io * @cdk.githash * * @cdk.keyword file format, PubChem Compound XML */ @TestClass("org.openscience.cdk.io.PCCompounsXMLReaderTest") public class PCCompoundXMLReader extends DefaultChemObjectReader { private Reader input; private XmlPullParser parser; private PubChemXMLHelper parserHelper; private IChemObjectBuilder builder; IMolecule molecule = null; /** * Construct a new reader from a Reader type object. * * @param input reader from which input is read */ public PCCompoundXMLReader(Reader input) throws Exception { setReader(input); } public PCCompoundXMLReader(InputStream input) throws Exception { setReader(input); } public PCCompoundXMLReader() throws Exception { this(new StringReader("")); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return PubChemSubstanceXMLFormat.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader input) throws CDKException { try { XmlPullParserFactory factory = XmlPullParserFactory.newInstance( System.getProperty(XmlPullParserFactory.PROPERTY_NAME), null ); factory.setNamespaceAware(true); parser = factory.newPullParser(); this.input = input; parser.setInput(input); } catch (Exception exception) { throw new CDKException("Error while creating reader: " + exception.getMessage(), exception); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i * * 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 org.openscience.cdk.io; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.PubChemSubstanceXMLFormat; import org.openscience.cdk.io.pubchemxml.PubChemXMLHelper; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserFactory; /** * Reads an object from ASN formated input for PubChem Compound entries. The following * bits are supported: atoms.aid, atoms.element, bonds.aid1, bonds.aid2. Additionally, * it extracts the InChI and canonical SMILES properties. * * @cdk.module io * @cdk.githash * * @cdk.keyword file format, PubChem Compound ASN */ @TestClass("org.openscience.cdk.io.PCSubstanceXMLReaderTest") public class PCSubstanceXMLReader extends DefaultChemObjectReader { private Reader input; private XmlPullParser parser; private PubChemXMLHelper parserHelper; private IChemObjectBuilder builder; IMolecule molecule = null; /** * Construct a new reader from a Reader type object. * * @param input reader from which input is read */ public PCSubstanceXMLReader(Reader input) throws Exception { setReader(input); } public PCSubstanceXMLReader(InputStream input) throws Exception { setReader(input); } public PCSubstanceXMLReader() throws Exception { this(new StringReader("")); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return PubChemSubstanceXMLFormat.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader input) throws CDKException { try { XmlPullParserFactory factory = XmlPullParserFactory.newInstance( System.getProperty(XmlPullParserFactory.PROPERTY_NAME), null ); factory.setNamespaceAware(true); parser = factory.newPullParser(); this.input = input; parser.setInput(input); } catch (Exception exception) { throw new CDKException("Error while creating reader: " + exception.getMessage(), exception); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; iA description can be found at * http://www.rcsb.org/pdb/static.do?p=file_formats/pdb/index.html. * * @cdk.module pdb * @cdk.githash * * @author Edgar Luttmann * @author Bradley Smith * @author Martin Eklund * @author Ola Spjuth * @cdk.created 2001-08-06 * @cdk.keyword file format, PDB * @cdk.bug 1714141 * @cdk.bug 1794439 */ @TestClass("org.openscience.cdk.io.PDBReaderTest") public class PDBReader extends DefaultChemObjectReader { private LoggingTool logger; private BufferedReader _oInput; // The internal used BufferedReader private BooleanIOSetting useRebondTool; private BooleanIOSetting readConnect; private Map atomNumberMap; /* * This is a temporary store for bonds from CONNECT records. * As CONNECT is deliberately fully redundant (a->b and b->a) * we need to use this to weed out the duplicates. */ private ArrayList bondsFromConnectRecords; private static AtomTypeFactory pdbFactory; /** * * Contructs a new PDBReader that can read Molecules from a given * InputStream. * * @param oIn The InputStream to read from * */ public PDBReader(InputStream oIn) { this(new InputStreamReader(oIn)); } /** * * Contructs a new PDBReader that can read Molecules from a given * Reader. * * @param oIn The Reader to read from * */ public PDBReader(Reader oIn) { logger = new LoggingTool(this.getClass()); _oInput = new BufferedReader(oIn); initIOSettings(); pdbFactory = null; } public PDBReader() { this(new StringReader("")); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return PDBFormat.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader input) throws CDKException { if (input instanceof BufferedReader) { this._oInput = (BufferedReader)input; } else { this._oInput = new BufferedReader(input); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; iChemFile from a file in PDB format. The molecules * in the file are stored as BioPolymers in the * ChemFile. The residues are the monomers of the * BioPolymer, and their names are the concatenation of the * residue, chain id, and the sequence number. Separate chains (denoted by * TER records) are stored as separate BioPolymer molecules. * *

Connectivity information is not currently read. * * @return The ChemFile that was read from the PDB file. */ private IChemFile readChemFile(IChemFile oFile) { // initialize all containers IChemSequence oSeq = oFile.getBuilder().newChemSequence(); IChemModel oModel = oFile.getBuilder().newChemModel(); IMoleculeSet oSet = oFile.getBuilder().newMoleculeSet(); // some variables needed String cCol; PDBAtom oAtom; PDBPolymer oBP = new PDBPolymer(); IMolecule molecularStructure = oFile.getBuilder().newMolecule(); StringBuffer cResidue; String oObj; IMonomer oMonomer; String cRead = ""; char chain = 'A'; // To ensure stringent name giving of monomers IStrand oStrand; int lineLength = 0; boolean isProteinStructure = false; atomNumberMap = new Hashtable(); if (readConnect.isSet()) { bondsFromConnectRecords = new ArrayList(); } // do the reading of the Input try { do { cRead = _oInput.readLine(); logger.debug("Read line: ", cRead); if (cRead != null) { lineLength = cRead.length(); if (lineLength < 80) { logger.warn("Line is not of the expected length 80!"); } // make sure the record name is 6 characters long if (lineLength < 6) { cRead = cRead + " "; } // check the first column to decide what to do cCol = cRead.substring(0,6); if ("SEQRES".equalsIgnoreCase(cCol)) { isProteinStructure = true; } else if ("ATOM ".equalsIgnoreCase(cCol)) { // read an atom record oAtom = readAtom(cRead, lineLength); if (isProteinStructure) { // construct a string describing the residue cResidue = new StringBuffer(8); oObj = oAtom.getResName(); if (oObj != null) { cResidue = cResidue.append(oObj.trim()); } oObj = oAtom.getChainID(); if (oObj != null) { // cResidue = cResidue.append(((String)oObj).trim()); cResidue = cResidue.append(String.valueOf(chain)); } oObj = oAtom.getResSeq(); if (oObj != null) { cResidue = cResidue.append(oObj.trim()); } // search for an existing strand or create a new one. String strandName = oAtom.getChainID(); if (strandName == null || strandName.length() == 0) { strandName = String.valueOf(chain); } oStrand = oBP.getStrand(strandName); if (oStrand == null) { oStrand = new PDBStrand(); oStrand.setStrandName(strandName); oStrand.setID(String.valueOf(chain)); } // search for an existing monomer or create a new one. oMonomer = oBP.getMonomer(cResidue.toString(), String.valueOf(chain)); if (oMonomer == null) { PDBMonomer monomer = new PDBMonomer(); monomer.setMonomerName(cResidue.toString()); monomer.setMonomerType(oAtom.getResName()); monomer.setChainID(oAtom.getChainID()); monomer.setICode(oAtom.getICode()); monomer.setResSeq(oAtom.getResSeq()); oMonomer = monomer; } // add the atom oBP.addAtom(oAtom, oMonomer, oStrand); if (readConnect.isSet() && atomNumberMap.put(new Integer(oAtom.getSerial()), oAtom) != null) { logger.warn("Duplicate serial ID found for atom: ", oAtom); } } else { molecularStructure.addAtom(oAtom); } logger.debug("Added ATOM: ", oAtom); /** As HETATMs cannot be considered to either belong to a certain monomer or strand, * they are dealt with seperately.*/ } else if("HETATM".equalsIgnoreCase(cCol)) { // read an atom record oAtom = readAtom(cRead, lineLength); oAtom.setHetAtom(true); oBP.addAtom(oAtom); if (atomNumberMap.put(new Integer(oAtom.getSerial()), oAtom) != null) { logger.warn("Duplicate serial ID found for atom: ", oAtom); } logger.debug("Added HETATM: ", oAtom); } else if ("TER ".equalsIgnoreCase(cCol)) { // start new strand chain++; oStrand = new PDBStrand(); oStrand.setStrandName(String.valueOf(chain)); logger.debug("Added new STRAND"); } else if ("END ".equalsIgnoreCase(cCol)) { atomNumberMap.clear(); if (isProteinStructure) { // create bonds and finish the molecule if (useRebondTool.isSet()) { try { if(!createBondsWithRebondTool(oBP)) { // Get rid of all potentially created bonds. logger.info("Bonds could not be created using the RebondTool when PDB file was read."); oBP.removeAllBonds(); } } catch (Exception exception) { logger.info("Bonds could not be created when PDB file was read."); logger.debug(exception); } } oSet.addMolecule(oBP); } else { oSet.addMolecule(molecularStructure); } } else if (cCol.equals("MODEL ")) { // OK, start a new model and save the current one first *if* it contains atoms if (isProteinStructure) { if (oBP.getAtomCount() > 0) { // save the model oSet.addAtomContainer(oBP); oModel.setMoleculeSet(oSet); oSeq.addChemModel(oModel); // setup a new one oBP = new PDBPolymer(); oModel = oFile.getBuilder().newChemModel(); oSet = oFile.getBuilder().newMoleculeSet(); } } else { if (molecularStructure.getAtomCount() > 0) { // save the model oSet.addAtomContainer(molecularStructure); oModel.setMoleculeSet(oSet); oSeq.addChemModel(oModel); // setup a new one molecularStructure = oFile.getBuilder().newMolecule(); oModel = oFile.getBuilder().newChemModel(); oSet = oFile.getBuilder().newMoleculeSet(); } } } else if ("REMARK".equalsIgnoreCase(cCol)) { Object comment = oFile.getProperty(CDKConstants.COMMENT); if (comment == null) { comment = ""; } if (lineLength >12) { comment = comment.toString() + cRead.substring(11).trim() + System.getProperty("line.separator"); oFile.setProperty(CDKConstants.COMMENT, comment); } else { logger.warn("REMARK line found without any comment!"); } } else if ("COMPND".equalsIgnoreCase(cCol)) { String title = cRead.substring(10).trim(); oFile.setProperty(CDKConstants.TITLE, title); } /************************************************************* * Read connectivity information from CONECT records. * Only covalent bonds are dealt with. Perhaps salt bridges * should be dealt with in the same way..? */ else if (readConnect.isSet() && "CONECT".equalsIgnoreCase(cCol)) { cRead.trim(); if (cRead.length() < 16) { logger.debug("Skipping unexpected empty CONECT line! : ", cRead); } else { String bondAtom = cRead.substring(7, 11).trim(); int bondAtomNo = Integer.parseInt(bondAtom); String bondedAtom = cRead.substring(12, 16).trim(); int bondedAtomNo = -1; try {bondedAtomNo = Integer.parseInt(bondedAtom);} catch(Exception e) {bondedAtomNo = -1;} if(bondedAtomNo != -1) { addBond(oBP, bondAtomNo, bondedAtomNo); logger.warn("Bonded " + bondAtomNo + " with " + bondedAtomNo); } if(cRead.length() > 17) { bondedAtom = cRead.substring(17, 21); bondedAtom = bondedAtom.trim(); try {bondedAtomNo = Integer.parseInt(bondedAtom);} catch(Exception e) {bondedAtomNo = -1;} if(bondedAtomNo != -1) { addBond(oBP, bondAtomNo, bondedAtomNo); logger.warn("Bonded " + bondAtomNo + " with " + bondedAtomNo); } } if(cRead.length() > 22) { bondedAtom = cRead.substring(22, 26); bondedAtom = bondedAtom.trim(); try {bondedAtomNo = Integer.parseInt(bondedAtom);} catch(Exception e) {bondedAtomNo = -1;} if(bondedAtomNo != -1) { addBond(oBP, bondAtomNo, bondedAtomNo); logger.warn("Bonded " + bondAtomNo + " with " + bondedAtomNo); } } if(cRead.length() > 27) { bondedAtom = cRead.substring(27, 31); bondedAtom = bondedAtom.trim(); try {bondedAtomNo = Integer.parseInt(bondedAtom);} catch(Exception e) {bondedAtomNo = -1;} if(bondedAtomNo != -1) { addBond(oBP, bondAtomNo, bondedAtomNo); logger.warn("Bonded " + bondAtomNo + " with " + bondedAtomNo); } } } } /*************************************************************/ else if ("HELIX ".equalsIgnoreCase(cCol)) { // HELIX 1 H1A CYS A 11 LYS A 18 1 RESIDUE 18 HAS POSITIVE PHI 1D66 72 // 1 2 3 4 5 6 7 // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 PDBStructure structure = new PDBStructure(); structure.setStructureType(PDBStructure.HELIX); structure.setStartChainID(cRead.charAt(19)); structure.setStartSequenceNumber(Integer.parseInt(cRead.substring(21, 25).trim())); structure.setStartInsertionCode(cRead.charAt(25)); structure.setEndChainID(cRead.charAt(31)); structure.setEndSequenceNumber(Integer.parseInt(cRead.substring(33, 37).trim())); structure.setEndInsertionCode(cRead.charAt(37)); oBP.addStructure(structure); } else if ("SHEET ".equalsIgnoreCase(cCol)) { PDBStructure structure = new PDBStructure(); structure.setStructureType(PDBStructure.SHEET); structure.setStartChainID(cRead.charAt(21)); structure.setStartSequenceNumber(Integer.parseInt(cRead.substring(22, 26).trim())); structure.setStartInsertionCode(cRead.charAt(26)); structure.setEndChainID(cRead.charAt(32)); structure.setEndSequenceNumber(Integer.parseInt(cRead.substring(33, 37).trim())); structure.setEndInsertionCode(cRead.charAt(37)); oBP.addStructure(structure); } else if ("TURN ".equalsIgnoreCase(cCol)) { PDBStructure structure = new PDBStructure(); structure.setStructureType(PDBStructure.TURN); structure.setStartChainID(cRead.charAt(19)); structure.setStartSequenceNumber(Integer.parseInt(cRead.substring(20, 24).trim())); structure.setStartInsertionCode(cRead.charAt(24)); structure.setEndChainID(cRead.charAt(30)); structure.setEndSequenceNumber(Integer.parseInt(cRead.substring(31, 35).trim())); structure.setEndInsertionCode(cRead.charAt(35)); oBP.addStructure(structure); } // ignore all other commands } } while (_oInput.ready() && (cRead != null)); } catch (Exception e) { logger.error("Found a problem at line:"); logger.error(cRead); logger.error("01234567890123456789012345678901234567890123456789012345678901234567890123456789"); logger.error(" 1 2 3 4 5 6 7 "); logger.error(" error: " + e.getMessage()); logger.debug(e); } // try to close the Input try { _oInput.close(); } catch (Exception e) { logger.debug(e); } // Set all the dependencies oModel.setMoleculeSet(oSet); oSeq.addChemModel(oModel); oFile.addChemSequence(oSeq); return oFile; } private void addBond(PDBPolymer obp, int bondAtomNo, int bondedAtomNo) { IAtom firstAtom = (PDBAtom)atomNumberMap.get(new Integer(bondAtomNo)); IAtom secondAtom = (PDBAtom)atomNumberMap.get(new Integer(bondedAtomNo)); if (firstAtom == null) { logger.error("Could not find bond start atom in map with serial id: ", bondAtomNo); } if (secondAtom == null) { logger.error("Could not find bond target atom in map with serial id: ", bondAtomNo); } IBond bond = firstAtom.getBuilder().newBond( firstAtom, secondAtom, IBond.Order.SINGLE); for (int i = 0; i < bondsFromConnectRecords.size(); i++) { IBond existingBond = (IBond) bondsFromConnectRecords.get(i); IAtom a = existingBond.getAtom(0); IAtom b = existingBond.getAtom(1); if ((a == firstAtom && b == secondAtom) || (b == firstAtom && a == secondAtom)) { // already stored return; } } bondsFromConnectRecords.add(bond); obp.addBond(bond); } private boolean createBondsWithRebondTool(IBioPolymer pol){ RebondTool tool = new RebondTool(2.0, 0.5, 0.5); try { // configure atoms AtomTypeFactory factory = AtomTypeFactory.getInstance("org/openscience/cdk/config/data/jmol_atomtypes.txt", pol.getBuilder()); java.util.Iterator atoms = pol.atoms().iterator(); while (atoms.hasNext()) { IAtom atom = (IAtom)atoms.next(); try { IAtomType[] types = factory.getAtomTypes(atom.getSymbol()); if (types.length > 0) { // just pick the first one AtomTypeManipulator.configure(atom, types[0]); } else { logger.warn("Could not configure atom with symbol: "+ atom.getSymbol()); } } catch (Exception e) { logger.warn("Could not configure atom (but don't care): " + e.getMessage()); logger.debug(e); } } tool.rebond(pol); } catch (Exception e) { logger.error("Could not rebond the polymer: " + e.getMessage()); logger.debug(e); } return true; } /** * Creates an Atom and sets properties to their values from * the ATOM record. If the line is shorter than 80 characters, the information * past 59 characters is treated as optional. If the line is shorter than 59 * characters, a RuntimeException is thrown. * * @param cLine the PDB ATOM record. * @return the Atom created from the record. * @throws RuntimeException if the line is too short (less than 59 characters). */ private PDBAtom readAtom(String cLine, int lineLength) { // a line looks like: // 01234567890123456789012345678901234567890123456789012345678901234567890123456789 // ATOM 1 O5* C A 1 20.662 36.632 23.475 1.00 10.00 114D 45 // ATOM 1186 1H ALA 1 10.105 5.945 -6.630 1.00 0.00 1ALE1288 if (lineLength < 59) { throw new RuntimeException("PDBReader error during readAtom(): line too short"); } String elementSymbol = cLine.substring(12, 14).trim(); if (elementSymbol.length() == 2) { // ensure that the second char is lower case elementSymbol = elementSymbol.charAt(0) + elementSymbol.substring(1).toLowerCase(); } String rawAtomName = cLine.substring(12, 16).trim(); String resName = cLine.substring(17, 20).trim(); try { IAtomType type = pdbFactory.getAtomType(resName+"."+rawAtomName); elementSymbol = type.getSymbol(); } catch (NoSuchAtomTypeException e) { logger.error("Did not recognize PDB atom type: " + resName+"."+rawAtomName); } PDBAtom oAtom = new PDBAtom(elementSymbol, new Point3d(Double.parseDouble(cLine.substring(30, 38)), Double.parseDouble(cLine.substring(38, 46)), Double.parseDouble(cLine.substring(46, 54)) ) ); oAtom.setRecord(cLine); oAtom.setSerial(Integer.parseInt(cLine.substring(6, 11).trim())); oAtom.setName(rawAtomName.trim()); oAtom.setAltLoc(cLine.substring(16, 17).trim()); oAtom.setResName(resName); oAtom.setChainID(cLine.substring(21, 22).trim()); oAtom.setResSeq(cLine.substring(22, 26).trim()); oAtom.setICode(cLine.substring(26, 27).trim()); oAtom.setAtomTypeName(oAtom.getResName()+"."+rawAtomName); if (lineLength >= 59) { String frag = cLine.substring(54, 60).trim(); if (frag.length() > 0) { oAtom.setOccupancy(Double.parseDouble(frag)); } } if (lineLength >= 65) { String frag = cLine.substring(60, 66).trim(); if (frag.length() > 0) { oAtom.setTempFactor(Double.parseDouble(frag)); } } if (lineLength >= 75) { oAtom.setSegID(cLine.substring(72, 76).trim()); } // if (lineLength >= 78) { // oAtom.setSymbol((new String(cLine.substring(76, 78))).trim()); // } if (lineLength >= 79) { String frag = cLine.substring(78, 80).trim(); if (frag.length() > 0) { oAtom.setCharge(Double.parseDouble(frag)); } } /************************************************************************************* * It sets a flag in the property content of an atom, * which is used when bonds are created to check if the atom is an OXT-record => needs * special treatment. */ String oxt = cLine.substring(13, 16).trim(); if(oxt.equals("OXT")) { oAtom.setOxt(true); } else { oAtom.setOxt(false); } /*************************************************************************************/ return oAtom; } @TestMethod("testClose") public void close() throws IOException { _oInput.close(); } private void initIOSettings() { useRebondTool = new BooleanIOSetting("UseRebondTool", IOSetting.LOW, "Should the PDBReader deduce bonding patterns?", "false"); readConnect = new BooleanIOSetting("ReadConnectSection", IOSetting.LOW, "Should the CONECT be read?", "true"); } public void customizeJob() { fireIOSettingQuestion(useRebondTool); fireIOSettingQuestion(readConnect); } public IOSetting[] getIOSettings() { IOSetting[] settings = new IOSetting[2]; settings[0] = useRebondTool; settings[1] = readConnect; return settings; } } cdk-1.2.10/src/main/org/openscience/cdk/io/PDBWriter.java100644 0 0 22423 11570154753 20130 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2000-2003 The Jmol Development Team * Copyright (C) 2003-2007 The CDK Project * * Contact: cdk-devel@lists.sf.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.io; import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.StringWriter; import java.io.Writer; import java.util.Iterator; import javax.vecmath.Point3d; import javax.vecmath.Vector3d; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.geometry.CrystalGeometryTools; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.ICrystal; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.PDBFormat; import org.openscience.cdk.tools.FormatStringBuffer; import org.openscience.cdk.tools.manipulator.ChemModelManipulator; /** * Saves small molecules in a rudimentary PDB format. It does not allow * writing of PDBProtein data structures. * * @cdk.module io * @cdk.githash */ @TestClass("org.openscience.cdk.io.PDBWriterTest") public class PDBWriter extends DefaultChemObjectWriter { final String SERIAL_FORMAT = "%5d"; final String ATOM_NAME_FORMAT = "%-4s"; final String POSITION_FORMAT = "%8.3f"; private BufferedWriter writer; public PDBWriter() { this(new StringWriter()); } /** * Creates a PDB writer. * * @param out the stream to write the PDB file to. */ public PDBWriter(Writer out) { try { if (out instanceof BufferedWriter) { writer = (BufferedWriter)out; } else { writer = new BufferedWriter(out); } } catch (Exception exc) { } } public PDBWriter(OutputStream output) { this(new OutputStreamWriter(output)); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return PDBFormat.getInstance(); } public void setWriter(Writer out) throws CDKException { if (out instanceof BufferedWriter) { writer = (BufferedWriter)out; } else { writer = new BufferedWriter(out); } } public void setWriter(OutputStream output) throws CDKException { setWriter(new OutputStreamWriter(output)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i " + atom); // if it got 3D coordinates, use that. If not, try fractional coordinates if (atom.getPoint3d() == null && atom.getFractionalPoint3d() != null) { Point3d frac = new Point3d(atom.getFractionalPoint3d()); Point3d cart = CrystalGeometryTools.fractionalToCartesian(a,b,c, frac); atom.setPoint3d(cart); } } writeMolecule(crystal.getBuilder().newMolecule(crystal)); } catch (IOException exception) { throw new CDKException("Error while writing file: " + exception.getMessage(), exception); } } /** * Flushes the output and closes this object. */ @TestMethod("testClose") public void close() throws IOException { writer.close(); } } cdk-1.2.10/src/main/org/openscience/cdk/io/PMPReader.java100644 0 0 56512 11570154753 20113 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2004-2008 Egon Willighagen * * 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 org.openscience.cdk.io; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.util.Hashtable; import java.util.Iterator; import java.util.Map; import java.util.StringTokenizer; import java.util.regex.Matcher; import java.util.regex.Pattern; import javax.vecmath.Point3d; import javax.vecmath.Vector3d; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.graph.rebond.RebondTool; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemObjectBuilder; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.ICrystal; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.PMPFormat; import org.openscience.cdk.tools.LoggingTool; /** * Reads an frames from a PMP formated input. * Both compilation and use of this class requires Java 1.4. * * @cdk.module io * @cdk.githash * * @cdk.keyword file format, Polymorph Predictor (tm) * * @author E.L. Willighagen * @cdk.require java1.4+ */ @TestClass("org.openscience.cdk.io.PMPReaderTest") public class PMPReader extends DefaultChemObjectReader { private static final String PMP_ZORDER = "ZOrder"; private static final String PMP_ID = "Id"; private BufferedReader input; private LoggingTool logger; /* Keep a copy of the PMP model */ private IAtomContainer modelStructure; private IChemObject chemObject; /* Keep an index of PMP id -> AtomCountainer id */ private Map atomids = new Hashtable(); private Map atomGivenIds = new Hashtable(); private Map atomZOrders = new Hashtable(); private Map bondids = new Hashtable(); private Map bondAtomOnes = new Hashtable(); private Map bondAtomTwos = new Hashtable(); private Map bondOrders = new Hashtable(); /* Often used patterns */ Pattern objHeader; Pattern objCommand; Pattern atomTypePattern; int lineNumber = 0; int bondCounter = 0; private RebondTool rebonder; /* * construct a new reader from a Reader type object * * @param input reader from which input is read */ public PMPReader(Reader input) { this.input = new BufferedReader(input); logger = new LoggingTool(this); this.lineNumber = 0; /* compile patterns */ objHeader = Pattern.compile(".*\\((\\d+)\\s(\\w+)$"); objCommand = Pattern.compile(".*\\(A\\s(C|F|D|I|O)\\s(\\w+)\\s+\"?(.*?)\"?\\)$"); atomTypePattern = Pattern.compile("^(\\d+)\\s+(\\w+)$"); rebonder = new RebondTool(2.0, 0.5, 0.5); } public PMPReader(InputStream input) { this(new InputStreamReader(input)); } public PMPReader() { this(new StringReader("")); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return PMPFormat.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader input) throws CDKException { if (input instanceof BufferedReader) { this.input = (BufferedReader)input; } else { this.input = new BufferedReader(input); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i bonds = bondids.keySet().iterator(); while (bonds.hasNext()) { Integer index = bonds.next(); double order = (bondOrders.get(index) != null ? ((Double)bondOrders.get(index)).doubleValue() : 1.0); logger.debug("index: ", index); logger.debug("ones: ", bondAtomOnes.get(index)); IAtom atom1 = modelStructure.getAtom( ((Integer)atomids.get( (Integer)bondAtomOnes.get(index) )).intValue() ); IAtom atom2 = modelStructure.getAtom( ((Integer)atomids.get( (Integer)bondAtomTwos.get(index) )).intValue() ); IBond bond = modelStructure.getBuilder().newBond(atom1, atom2); if (order == 1.0) { bond.setOrder(IBond.Order.SINGLE); } else if (order == 2.0) { bond.setOrder(IBond.Order.DOUBLE); } else if (order == 3.0) { bond.setOrder(IBond.Order.TRIPLE); } else if (order == 4.0) { bond.setOrder(IBond.Order.QUADRUPLE); } modelStructure.addBond(bond); } } } else if (line.startsWith("%%Traj Start")) { chemSequence = chemFile.getBuilder().newChemSequence(); double energyFragment = 0.0; double energyTotal = 0.0; int Z = 1; while (input.ready() && line != null && !(line.startsWith("%%Traj End"))) { if (line.startsWith("%%Start Frame")) { chemModel = chemFile.getBuilder().newChemModel(); crystal = chemFile.getBuilder().newCrystal(); while (input.ready() && line != null && !(line.startsWith("%%End Frame"))) { // process frame data if (line.startsWith("%%Atom Coords")) { // calculate Z: as it is not explicitely given, try to derive it from the // energy per fragment and the total energy if (energyFragment != 0.0 && energyTotal != 0.0) { Z = (int)Math.round(energyTotal/energyFragment); logger.debug("Z derived from energies: ", Z); } // add atomC as atoms to crystal int expatoms = modelStructure.getAtomCount(); for (int molCount = 1; molCount<=Z; molCount++) { IAtomContainer clone = modelStructure.getBuilder().newAtomContainer(); for (int i=0; i < expatoms; i++) { line = readLine(); IAtom a = clone.getBuilder().newAtom(); StringTokenizer st = new StringTokenizer(line, " "); a.setPoint3d( new Point3d( Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()) ) ); a.setCovalentRadius(0.6); IAtom modelAtom = modelStructure.getAtom(atomids.get(atomGivenIds.get(Integer.valueOf(i+1)))); a.setSymbol(modelAtom.getSymbol()); clone.addAtom(a); } rebonder.rebond(clone); crystal.add(clone); } } else if (line.startsWith("%%E/Frag")) { line = readLine().trim(); energyFragment = Double.parseDouble(line); } else if (line.startsWith("%%Tot E")) { line = readLine().trim(); energyTotal = Double.parseDouble(line); } else if (line.startsWith("%%Lat Vects")) { StringTokenizer st; line = readLine(); st = new StringTokenizer(line, " "); crystal.setA(new Vector3d( Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()) )); line = readLine(); st = new StringTokenizer(line, " "); crystal.setB(new Vector3d( Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()) )); line = readLine(); st = new StringTokenizer(line, " "); crystal.setC(new Vector3d( Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()), Double.parseDouble(st.nextToken()) )); } else if (line.startsWith("%%Space Group")) { line = readLine().trim(); /* standardize space group name. See Crystal.setSpaceGroup() */ if ("P 21 21 21 (1)".equals(line)) { crystal.setSpaceGroup("P 2_1 2_1 2_1"); } else { crystal.setSpaceGroup("P1"); } } else { } line = readLine(); } chemModel.setCrystal(crystal); chemSequence.addChemModel(chemModel); } line = readLine(); } chemFile.addChemSequence(chemSequence); } else { // disregard line } // read next line line = readLine(); } } catch (IOException e) { logger.error("An IOException happened: ", e.getMessage()); logger.debug(e); chemFile = null; } catch (CDKException e) { logger.error("An CDKException happened: ", e.getMessage()); logger.debug(e); chemFile = null; } return chemFile; } private void processModelCommand(String object, String command, String format, String field) { logger.debug(object + "->" + command + " (" + format + "): " + field); if ("Model".equals(object)) { logger.warn("Unkown PMP Model command: " + command); } else if ("Atom".equals(object)) { if ("ACL".equals(command)) { Matcher atomTypeMatcher = atomTypePattern.matcher(field); if (atomTypeMatcher.matches()) { int atomicnum = Integer.parseInt(atomTypeMatcher.group(1)); String type = atomTypeMatcher.group(2); ((IAtom)chemObject).setAtomicNumber(atomicnum); ((IAtom)chemObject).setSymbol(type); } else { logger.error("Incorrectly formated field value: " + field + "."); } } else if ("Charge".equals(command)) { try { double charge = Double.parseDouble(field); ((IAtom)chemObject).setCharge(charge); } catch (NumberFormatException e) { logger.error("Incorrectly formated float field: " + field + "."); } } else if ("CMAPPINGS".equals(command)) { } else if ("FFType".equals(command)) { } else if ("Id".equals(command)) { // ok, should take this into account too chemObject.setProperty(PMP_ID, field); } else if ("Mass".equals(command)) { } else if ("XYZ".equals(command)) { } else if ("ZOrder".equals(command)) { // ok, should take this into account too chemObject.setProperty(PMP_ZORDER, field); } else { logger.warn("Unkown PMP Atom command: " + command); } } else if ("Bond".equals(object)) { if ("Atom1".equals(command)) { int atomid = Integer.parseInt(field); // this assumes that the atoms involved in this bond are // already added, which seems the case in the PMP files bondAtomOnes.put(Integer.valueOf(bondCounter), Integer.valueOf(atomid)); // IAtom a = molecule.getAtom(realatomid); // ((IBond)chemObject).setAtomAt(a, 0); } else if ("Atom2".equals(command)) { int atomid = Integer.parseInt(field); // this assumes that the atoms involved in this bond are // already added, which seems the case in the PMP files logger.debug("atomids: " + atomids); logger.debug("atomid: " + atomid); bondAtomTwos.put(Integer.valueOf(bondCounter), Integer.valueOf(atomid)); // IAtom a = molecule.getAtom(realatomid); // ((IBond)chemObject).setAtomAt(a, 1); } else if ("Order".equals(command)) { double order = Double.parseDouble(field); bondOrders.put(Integer.valueOf(bondCounter), order); // ((IBond)chemObject).setOrder(order); } else if ("Id".equals(command)) { int bondid = Integer.parseInt(field); bondids.put(Integer.valueOf(bondCounter), Integer.valueOf(bondid)); } else if ("Label".equals(command)) { } else if ("3DGridOrigin".equals(command)) { } else if ("3DGridMatrix".equals(command)) { } else if ("3DGridDivision".equals(command)) { } else { logger.warn("Unkown PMP Bond command: " + command); } } else { logger.warn("Unkown PMP object: " + object); } } private void constructObject(IChemObjectBuilder builder, String object) { if ("Atom".equals(object)) { chemObject = builder.newAtom("C"); } else if ("Bond".equals(object)) { bondCounter++; chemObject = builder.newBond(); } else if ("Model".equals(object)) { modelStructure = builder.newAtomContainer(); } else { logger.error("Cannot construct PMP object type: " + object); } }; @TestMethod("testClose") public void close() throws IOException { input.close(); } } cdk-1.2.10/src/main/org/openscience/cdk/io/ReaderEvent.java100644 0 0 3054 11570154753 20511 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2002-2007 The Jmol Development Team * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.io; import java.util.EventObject; /** * Signals that something has happened in a file reader. This class is * primarily in place for future development when additional information * may be passed to ReaderListeners. * * @cdk.module io * @cdk.githash * * @author Bradley A. Smith */ public class ReaderEvent extends EventObject { private static final long serialVersionUID = 660541244342274716L; /** * Creates a reader event. * * @param source the object on which the event initially occurred. */ public ReaderEvent(Object source) { super(source); } } cdk-1.2.10/src/main/org/openscience/cdk/io/ReaderFactory.java100644 0 0 15757 11570154753 21074 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2001-2007 Bradley A. Smith * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.io; import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.Reader; import java.util.List; import java.util.zip.GZIPInputStream; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.io.formats.IChemFormat; import org.openscience.cdk.io.formats.IChemFormatMatcher; import org.openscience.cdk.tools.LoggingTool; /** * A factory for creating ChemObjectReaders. The type of reader * created is determined from the content of the input. Formats * of GZiped files can be detected too. * * A typical example is: *

 *   StringReader stringReader = "<molecule/>";
 *   ChemObjectReader reader = new ReaderFactory().createReader(stringReader);
 * 
* * @cdk.module io * @cdk.githash * * @author Egon Willighagen * @author Bradley A. Smith */ public class ReaderFactory { private LoggingTool logger; private FormatFactory formatFactory = null; private int headerLength = 8192; /** * Constructs a ReaderFactory which tries to detect the format in the * first 65536 chars. */ public ReaderFactory() { this(8192); } /** * Constructs a ReaderFactory which tries to detect the format in the * first given number of chars. * * @param headerLength length of the header in number of chars */ public ReaderFactory(int headerLength) { logger = new LoggingTool(this); formatFactory = new FormatFactory(headerLength); this.headerLength = headerLength; } /** * Registers a format for detection. */ public void registerFormat(IChemFormatMatcher format) { formatFactory.registerFormat(format); } public List getFormats(){ return formatFactory.getFormats(); } /** * Detects the format of the Reader input, and if known, it will return * a CDK Reader to read the format, or null when the reader is not * implemented. * * @return null if CDK does not contain a reader for the detected format. * * @see #createReader(Reader) */ public ISimpleChemObjectReader createReader(InputStream input) throws IOException { IChemFormat format = null; ISimpleChemObjectReader reader = null; if (input instanceof GZIPInputStream) { format = formatFactory.guessFormat(input); reader = createReader(format); if (reader != null) { try { reader.setReader(input); } catch ( CDKException e1 ) { IOException wrapper = new IOException("Exception while setting the InputStream: " + e1.getMessage()); wrapper.initCause(e1); throw wrapper; } } } else { BufferedInputStream bistream = new BufferedInputStream(input, headerLength); InputStream istreamToRead = bistream; // if gzip test fails, then take default bistream.mark(5); int countRead = 0; byte[] abMagic = new byte[4]; countRead = bistream.read(abMagic, 0, 4); bistream.reset(); if (countRead == 4) { if (abMagic[0] == (byte)0x1F && abMagic[1] == (byte)0x8B) { istreamToRead = new BufferedInputStream( new GZIPInputStream(bistream) ); } } format = formatFactory.guessFormat(istreamToRead); reader = createReader(format); if (reader != null) { try { reader.setReader(istreamToRead); } catch ( CDKException e1 ) { IOException wrapper = new IOException("Exception while setting the InputStream: " + e1.getMessage()); wrapper.initCause(e1); throw wrapper; } } } return reader; } /** * Creates a new IChemObjectReader based on the given IChemFormat. * * @see #createReader(InputStream) */ public ISimpleChemObjectReader createReader(IChemFormat format) { if (format != null) { String readerClassName = format.getReaderClassName(); if (readerClassName != null) { try { // make a new instance of this class return (ISimpleChemObjectReader)this.getClass().getClassLoader(). loadClass(readerClassName).newInstance(); } catch (ClassNotFoundException exception) { logger.error("Could not find this ChemObjectReader: ", readerClassName); logger.debug(exception); } catch (Exception exception) { logger.error("Could not create this ChemObjectReader: ", readerClassName); logger.debug(exception); } } else { logger.warn("ChemFormat is recognized, but no reader is available."); } } else { logger.warn("ChemFormat is not recognized."); } return null; } /** * Detects the format of the Reader input, and if known, it will return * a CDK Reader to read the format. This method is not able to detect the * format of gziped files. Use createReader(InputStream) instead for such * files. * * @see #createReader(InputStream) */ public ISimpleChemObjectReader createReader(Reader input) throws IOException { if (!(input instanceof BufferedReader)) { input = new BufferedReader(input); } IChemFormat chemFormat = formatFactory.guessFormat((BufferedReader)input); ISimpleChemObjectReader coReader = createReader(chemFormat); try { coReader.setReader(input); } catch (Exception exception) { logger.error("Could not set the Reader source: ", exception.getMessage()); logger.debug(exception); } return coReader; } } cdk-1.2.10/src/main/org/openscience/cdk/io/RssWriter.java100644 0 0 35062 11570154753 20275 0ustar 0 0 package org.openscience.cdk.io; import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; import java.text.SimpleDateFormat; import java.util.Collection; import java.util.Date; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Vector; import nu.xom.Attribute; import nu.xom.Document; import nu.xom.Element; import nu.xom.ProcessingInstruction; import nu.xom.Text; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IAtomContainerSet; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.ICrystal; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.interfaces.IReaction; import org.openscience.cdk.interfaces.IReactionSet; import org.openscience.cdk.io.formats.CMLRSSFormat; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.libio.cml.Convertor; /** * Generates an RSS feed. It the object is a {@link IMoleculeSet}, the molecules * are put in separately. All other objects are made CML and put in. * * @cdk.module libiocml * @cdk.githash * @cdk.builddepends xom-1.0.jar * * @author Stefan Kuhn * * @cdk.keyword RSS */ @TestClass("org.openscience.cdk.io.RssWriterTest") public class RssWriter extends DefaultChemObjectWriter { private final static String NS_RSS10 = "http://purl.org/rss/1.0/"; private final static String NS_RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"; private final static String NS_DCELEMENTS = "http://purl.org/dc/elements/1.1/"; private BufferedWriter writer; private Map linkmap=new HashMap(); private Map datemap=new HashMap(); private Map titlemap=new HashMap(); private Map creatormap=new HashMap(); private Map inchimap=new HashMap(); private String creator=""; private String title=""; private String link=""; private String description=""; private String publisher=""; private String imagelink=""; private String about=""; private String timezone="+01:00"; private Map multiMap=new HashMap(); /** * Flushes the output and closes this object. */ @TestMethod("testClose") public void close() throws IOException { writer.close(); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return CMLRSSFormat.getInstance(); } public void setWriter(Writer out) throws CDKException { if (out instanceof BufferedWriter) { writer = (BufferedWriter)out; } else { writer = new BufferedWriter(out); } } public void setWriter(OutputStream output) throws CDKException { setWriter(new OutputStreamWriter(output)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { return true; } /** * Writes a IChemObject to the MDL molfile formated output. * * @param object Best choice is a set of molecules */ /* (non-Javadoc) * @see org.openscience.cdk.io.IChemObjectWriter#write(org.openscience.cdk.interfaces.IChemObject) */ public void write(IChemObject object) throws CDKException { try{ ProcessingInstruction processingInstruction =new ProcessingInstruction("xml-stylesheet", "href=\"http://www.w3.org/2000/08/w3c-synd/style.css\" type=\"text/css\""); Element rdfElement = new Element("rdf:RDF",NS_RDF); rdfElement.addNamespaceDeclaration("",NS_RSS10); rdfElement.addNamespaceDeclaration("mn","http://usefulinc.com/rss/manifest/"); rdfElement.addNamespaceDeclaration("dc",NS_DCELEMENTS); rdfElement.addNamespaceDeclaration("cml",Convertor.NS_CML); Document doc = new Document(rdfElement); doc.insertChild(processingInstruction,0); Element channelElement = new Element("channel",NS_RSS10); Element titleElement = new Element("title",NS_RSS10); titleElement.appendChild(new Text(title)); channelElement.appendChild(titleElement); Element linkElement = new Element("link",NS_RSS10); linkElement.appendChild(new Text(link)); channelElement.appendChild(linkElement); Element descriptionElement = new Element("description",NS_RSS10); descriptionElement.appendChild(new Text(description)); channelElement.appendChild(descriptionElement); Element publisherElement = new Element("dc:publisher",NS_DCELEMENTS); publisherElement.appendChild(new Text(publisher)); channelElement.appendChild(publisherElement); Element creatorElement = new Element("dc:creator",NS_DCELEMENTS); creatorElement.appendChild(new Text(creator)); channelElement.appendChild(creatorElement); Element imageElement = new Element("image",NS_RSS10); imageElement.addAttribute(new Attribute("rdf:resource",NS_RDF,imagelink)); channelElement.appendChild(imageElement); Element itemsElement = new Element("items",NS_RSS10); Element seqElement = new Element("rdf:Seq",NS_RDF); itemsElement.appendChild(seqElement); channelElement.appendChild(itemsElement); channelElement.addAttribute(new Attribute("rdf:about",NS_RDF,about)); rdfElement.appendChild(channelElement); List list =new Vector(); if(object instanceof IAtomContainerSet){ for(int i=0;i<((IAtomContainerSet)object).getAtomContainerCount();i++){ list.add(((IAtomContainerSet)object).getAtomContainer(i)); } }else{ list.add(object); } for(int i=0;i sdFields = container.getProperties(); if(sdFields != null){ for (Object propKey : sdFields.keySet()) { if (!isCDKInternalProperty(propKey)) { writer.write("> <" + propKey + ">"); writer.newLine(); writer.write("" + sdFields.get(propKey)); writer.newLine(); writer.newLine(); } } } writer.write("$$$$\n"); } catch (IOException exception) { throw new CDKException( "Error while writing a SD file entry: " + exception.getMessage(), exception ); } } /** * A list of properties used by CDK algorithms which must never be * serialized into the SD file format. */ private static List cdkInternalProperties = new ArrayList(); static { cdkInternalProperties.add(InvPair.CANONICAL_LABEL); cdkInternalProperties.add(InvPair.INVARIANCE_PAIR); // I think there are a few more, but cannot find them right now } private boolean isCDKInternalProperty(Object propKey) { return cdkInternalProperties.contains(propKey); } private void initIOSettings() { writerProperties = new BooleanIOSetting("writeProperties", IOSetting.LOW, "Should molecular properties be written?", "true" ); } public void customizeJob() { fireIOSettingQuestion(writerProperties); } public IOSetting[] getIOSettings() { IOSetting[] settings = new IOSetting[1]; settings[0] = writerProperties; return settings; } } cdk-1.2.10/src/main/org/openscience/cdk/io/SMILESReader.java100644 0 0 16152 11570154753 20447 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2001-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.io; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import org.openscience.cdk.DefaultChemObjectBuilder; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.SMILESFormat; import org.openscience.cdk.smiles.SmilesParser; import org.openscience.cdk.tools.LoggingTool; /** * This Reader reads files which has one SMILES string on each * line, where the format is given as below: *
 * COC ethoxy ethane
 * 
* Thus first the SMILES, and then after the first space (or tab) on the line a title * that is stored as "SMIdbNAME" property in the Molecule. * *

For each line a molecule is generated, and multiple Molecules are * read as MoleculeSet. * * @cdk.module smiles * @cdk.githash * @cdk.keyword file format, SMILES * * @see org.openscience.cdk.io.iterator.IteratingSMILESReader */ @TestClass("org.openscience.cdk.io.SMILESReaderTest") public class SMILESReader extends DefaultChemObjectReader { private BufferedReader input = null; private SmilesParser sp = null; private LoggingTool logger; /* * construct a new reader from a Reader type object * * @param input reader from which input is read */ public SMILESReader(Reader input) { logger = new LoggingTool(this); this.input = new BufferedReader(input); sp = new SmilesParser(DefaultChemObjectBuilder.getInstance()); } public SMILESReader(InputStream input) { this(new InputStreamReader(input)); } public SMILESReader() { this(new StringReader("")); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return SMILESFormat.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader input) throws CDKException { if (input instanceof BufferedReader) { this.input = (BufferedReader)input; } else { this.input = new BufferedReader(input); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (Class anInterface : interfaces) { if (IChemFile.class.equals(anInterface)) return true; if (IMoleculeSet.class.equals(anInterface)) return true; } Class superClass = classObject.getSuperclass(); if (superClass != null) return this.accepts(superClass); return false; } /** * reads the content from a XYZ input. It can only return a * IChemObject of type ChemFile * * @param object class must be of type ChemFile * * @see IChemFile */ @TestMethod("testReading,testReadingSmiFile_1,testReadingSmiFile_2,testReadingSmiFile_3") public IChemObject read(IChemObject object) throws CDKException { if (object instanceof IMoleculeSet) { return readMoleculeSet((IMoleculeSet)object); } else if (object instanceof IChemFile) { IChemFile file = (IChemFile)object; IChemSequence sequence = file.getBuilder().newChemSequence(); IChemModel chemModel = file.getBuilder().newChemModel(); chemModel.setMoleculeSet(readMoleculeSet( file.getBuilder().newMoleculeSet() )); sequence.addChemModel(chemModel); file.addChemSequence(sequence); return file; } else { throw new CDKException("Only supported is reading of MoleculeSet objects."); } } // private procedures /** * Private method that actually parses the input to read a ChemFile * object. * * @param som The set of molecules that came fron the file * @return A ChemFile containing the data parsed from input. */ private IMoleculeSet readMoleculeSet(IMoleculeSet som) { try { String line = input.readLine().trim(); while (line != null) { logger.debug("Line: ", line); String[] tokens = line.split("[\\s\\t]+",2); if (tokens.length > 2) throw new Exception("Malformed line"); String SMILES = tokens[0]; String name = null; if (tokens.length == 2) name = tokens[1]; logger.debug("Line contains SMILES and name: ", SMILES, " + " , name); try { IMolecule molecule = sp.parseSmiles(SMILES); som.addMolecule(molecule); if (name != null) { molecule.setProperty("SMIdbNAME", name); } } catch (Exception exception) { logger.warn("This SMILES could not be parsed: ", SMILES); logger.warn("Because of: ", exception.getMessage()); logger.debug(exception); } if (input.ready()) { line = input.readLine(); } else { line = null; } } } catch (Exception exception) { logger.error("Error while reading SMILES line: ", exception.getMessage()); logger.debug(exception); } return som; } @TestMethod("testClose") public void close() throws IOException { input.close(); } } cdk-1.2.10/src/main/org/openscience/cdk/io/SMILESWriter.java100644 0 0 13054 11570154753 20517 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.io; import java.io.BufferedWriter; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.StringWriter; import java.io.Writer; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.SMILESFormat; import org.openscience.cdk.smiles.SmilesGenerator; import org.openscience.cdk.tools.LoggingTool; /** * Writes the SMILES strings to a plain text file. * * @cdk.module smiles * @cdk.githash * * @cdk.keyword file format, SMILES */ @TestClass("org.openscience.cdk.io.SMILESWriterTest") public class SMILESWriter extends DefaultChemObjectWriter { private LoggingTool logger; private BufferedWriter writer; /** * Contructs a new SMILESWriter that can write a list of SMILES to a Writer * * @param out The Writer to write to */ public SMILESWriter(Writer out) { logger = new LoggingTool(this); try { if (out instanceof BufferedWriter) { writer = (BufferedWriter)out; } else { writer = new BufferedWriter(out); } } catch (Exception exc) { } } public SMILESWriter(OutputStream output) { this(new OutputStreamWriter(output)); } public SMILESWriter() { this(new StringWriter()); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return SMILESFormat.getInstance(); } public void setWriter(Writer out) throws CDKException { if (out instanceof BufferedWriter) { writer = (BufferedWriter)out; } else { writer = new BufferedWriter(out); } } public void setWriter(OutputStream output) throws CDKException { setWriter(new OutputStreamWriter(output)); } /** * Contructs a new SMILESWriter that can write an list of SMILES to a given OutputStream * * @param out The OutputStream to write to */ public SMILESWriter(FileOutputStream out) { this(new OutputStreamWriter(out)); } /** * Flushes the output and closes this object */ @TestMethod("testClose") public void close() throws IOException { writer.flush(); writer.close(); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i * * 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 org.openscience.cdk.io; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.util.StringTokenizer; import javax.vecmath.Point3d; import javax.vecmath.Vector3d; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.geometry.CrystalGeometryTools; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.ICrystal; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.ShelXFormat; import org.openscience.cdk.math.FortranFormat; import org.openscience.cdk.tools.LoggingTool; /** * A reader for ShelX output (RES) files. It does not read all information. * The list of fields that is read: REM, END, CELL, SPGR. * In additions atoms are read. * *

A reader for ShelX files. It currently supports ShelXL. * *

The ShelXL format is described on the net: * . * * @cdk.module io * @cdk.githash * * @cdk.keyword file format, ShelXL * @author E.L. Willighagen */ @TestClass("org.openscience.cdk.io.ShelXReaderTest") public class ShelXReader extends DefaultChemObjectReader { private BufferedReader input; private LoggingTool logger; /** * Create an ShelX file reader. * * @param input source of ShelX data */ public ShelXReader(Reader input) { this.input = new BufferedReader(input); this.logger = new LoggingTool(this); } public ShelXReader(InputStream input) { this(new InputStreamReader(input)); } public ShelXReader() { this(new StringReader("")); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return ShelXFormat.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader input) throws CDKException { if (input instanceof BufferedReader) { this.input = (BufferedReader)input; } else { this.input = new BufferedReader(input); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i 0 && line.substring(line.length()-1).equals("=")) { /* yes, line is continued */ line = line + input.readLine(); } /* determine ShelX command */ String command; try { command = new String(line.substring(0, 4)); } catch (StringIndexOutOfBoundsException sioobe) { // disregard this line break; } logger.debug("command: " + command); if (command.substring(0,3).equalsIgnoreCase("REM")) { /* line is comment, disregard */ /* 7.1 Crystal data and general instructions */ } else if (command.substring(0,3).equalsIgnoreCase("END")) { end_found = true; } else if (command.equalsIgnoreCase("TITL")) { } else if (command.equalsIgnoreCase("CELL")) { /* example: * CELL 1.54184 23.56421 7.13203 18.68928 90.0000 109.3799 90.0000 * CELL 1.54184 7.11174 21.71704 30.95857 90.000 90.000 90.000 */ StringTokenizer st = new StringTokenizer(line); st.nextToken(); // String command_again st.nextToken(); // String wavelength String sa = st.nextToken(); String sb = st.nextToken(); String sc = st.nextToken(); String salpha = st.nextToken(); String sbeta = st.nextToken(); String sgamma = st.nextToken(); logger.debug("a: " + sa); logger.debug("b: " + sb); logger.debug("c: " + sc); logger.debug("alpha: " + salpha); logger.debug("beta : " + sbeta); logger.debug("gamma: " + sgamma); double a = FortranFormat.atof(sa); double b = FortranFormat.atof(sb); double c = FortranFormat.atof(sc); double alpha = FortranFormat.atof(salpha); double beta = FortranFormat.atof(sbeta); double gamma = FortranFormat.atof(sgamma); Vector3d[] axes = CrystalGeometryTools.notionalToCartesian(a,b,c, alpha, beta, gamma); crystal.setA(axes[0]); crystal.setB(axes[1]); crystal.setC(axes[2]); } else if (command.equalsIgnoreCase("ZERR")) { } else if (command.equalsIgnoreCase("LATT")) { } else if (command.equalsIgnoreCase("SYMM")) { } else if (command.equalsIgnoreCase("SFAC")) { } else if (command.equalsIgnoreCase("DISP")) { } else if (command.equalsIgnoreCase("UNIT")) { } else if (command.equalsIgnoreCase("LAUE")) { } else if (command.equalsIgnoreCase("REM ")) { } else if (command.equalsIgnoreCase("MORE")) { } else if (command.equalsIgnoreCase("TIME")) { /* 7.2 Reflection data input */ } else if (command.equalsIgnoreCase("HKLF")) { } else if (command.equalsIgnoreCase("OMIT")) { } else if (command.equalsIgnoreCase("SHEL")) { } else if (command.equalsIgnoreCase("BASF")) { } else if (command.equalsIgnoreCase("TWIN")) { } else if (command.equalsIgnoreCase("EXTI")) { } else if (command.equalsIgnoreCase("SWAT")) { } else if (command.equalsIgnoreCase("HOPE")) { } else if (command.equalsIgnoreCase("MERG")) { /* 7.3 Atom list and least-squares constraints */ } else if (command.equalsIgnoreCase("SPEC")) { } else if (command.equalsIgnoreCase("RESI")) { } else if (command.equalsIgnoreCase("MOVE")) { } else if (command.equalsIgnoreCase("ANIS")) { } else if (command.equalsIgnoreCase("AFIX")) { } else if (command.equalsIgnoreCase("HFIX")) { } else if (command.equalsIgnoreCase("FRAG")) { } else if (command.equalsIgnoreCase("FEND")) { } else if (command.equalsIgnoreCase("EXYZ")) { } else if (command.equalsIgnoreCase("EXTI")) { } else if (command.equalsIgnoreCase("EADP")) { } else if (command.equalsIgnoreCase("EQIV")) { /* 7.4 The connectivity list */ } else if (command.equalsIgnoreCase("CONN")) { } else if (command.equalsIgnoreCase("PART")) { } else if (command.equalsIgnoreCase("BIND")) { } else if (command.equalsIgnoreCase("FREE")) { /* 7.5 Least-squares restraints */ } else if (command.equalsIgnoreCase("DFIX")) { } else if (command.equalsIgnoreCase("DANG")) { } else if (command.equalsIgnoreCase("BUMP")) { } else if (command.equalsIgnoreCase("SAME")) { } else if (command.equalsIgnoreCase("SADI")) { } else if (command.equalsIgnoreCase("CHIV")) { } else if (command.equalsIgnoreCase("FLAT")) { } else if (command.equalsIgnoreCase("DELU")) { } else if (command.equalsIgnoreCase("SIMU")) { } else if (command.equalsIgnoreCase("DEFS")) { } else if (command.equalsIgnoreCase("ISOR")) { } else if (command.equalsIgnoreCase("NCSY")) { } else if (command.equalsIgnoreCase("SUMP")) { /* 7.6 Least-squares organization */ } else if (command.equalsIgnoreCase("L.S.")) { } else if (command.equalsIgnoreCase("CGLS")) { } else if (command.equalsIgnoreCase("BLOC")) { } else if (command.equalsIgnoreCase("DAMP")) { } else if (command.equalsIgnoreCase("STIR")) { } else if (command.equalsIgnoreCase("WGHT")) { } else if (command.equalsIgnoreCase("FVAR")) { /* 7.7 Lists and tables */ } else if (command.equalsIgnoreCase("BOND")) { } else if (command.equalsIgnoreCase("CONF")) { } else if (command.equalsIgnoreCase("MPLA")) { } else if (command.equalsIgnoreCase("RTAB")) { } else if (command.equalsIgnoreCase("HTAB")) { } else if (command.equalsIgnoreCase("LIST")) { } else if (command.equalsIgnoreCase("ACTA")) { } else if (command.equalsIgnoreCase("SIZE")) { } else if (command.equalsIgnoreCase("TEMP")) { } else if (command.equalsIgnoreCase("WPDB")) { /* 7.8 Fouriers, peak search and lineprinter plots */ } else if (command.equalsIgnoreCase("FMAP")) { } else if (command.equalsIgnoreCase("GRID")) { } else if (command.equalsIgnoreCase("PLAN")) { } else if (command.equalsIgnoreCase("MOLE")) { /* NOT DOCUMENTED BUT USED BY PLATON */ } else if (command.equalsIgnoreCase("SPGR")) { // Line added by PLATON stating the spacegroup StringTokenizer st = new StringTokenizer(line); st.nextToken(); // String command_again String spacegroup = st.nextToken(); crystal.setSpaceGroup(spacegroup); } else if (command.equalsIgnoreCase(" ")) { logger.debug("Disrgarding line assumed to be added by PLATON: " + line); /* All other is atom */ } else { //logger.debug("Assumed to contain an atom: " + line); /* this line gives an atom, because all lines not starting with a ShelX command is an atom (that sucks!) */ StringTokenizer st = new StringTokenizer(line); String atype = st.nextToken(); st.nextToken(); // String scatt_factor String sa = st.nextToken(); String sb = st.nextToken(); String sc = st.nextToken(); // skip the rest if (Character.isDigit(atype.charAt(1))) { // atom type has a one letter code atype = atype.substring(0,1); } else { StringBuffer sb2 = new StringBuffer(); sb2.append(atype.charAt(1)); atype = atype.substring(0,1) + sb2.toString().toLowerCase(); } double[] frac = new double[3]; frac[0] = FortranFormat.atof(sa); // fractional coordinates frac[1] = FortranFormat.atof(sb); frac[2] = FortranFormat.atof(sc); logger.debug("fa,fb,fc: " + frac[0] + ", " + frac[1] + ", " + frac[2]); if (atype.equalsIgnoreCase("Q")) { // ingore atoms named Q } else { logger.info("Adding atom: " + atype + ", " + frac[0] + ", " + frac[1] + ", " + frac[2]); IAtom atom = crystal.getBuilder().newAtom(atype); atom.setFractionalPoint3d(new Point3d(frac[0], frac[1], frac[2])); crystal.addAtom(atom); logger.debug("Atom added: ", atom); } } line = input.readLine(); } return crystal; } @TestMethod("testClose") public void close() throws IOException { input.close(); } } cdk-1.2.10/src/main/org/openscience/cdk/io/ShelXWriter.java100644 0 0 21023 11570154753 20541 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2001-2007 Egon Willighagen * * 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.io; import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.StringWriter; import java.io.Writer; import java.util.Iterator; import java.util.List; import javax.vecmath.Point3d; import javax.vecmath.Vector3d; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.geometry.CrystalGeometryTools; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.ICrystal; import org.openscience.cdk.interfaces.IElement; import org.openscience.cdk.interfaces.IMolecularFormula; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.ShelXFormat; import org.openscience.cdk.tools.FormatStringBuffer; import org.openscience.cdk.tools.manipulator.MolecularFormulaManipulator; /** *

Serializes a MoleculeSet or a Molecule object to ShelX code. * The output can be read with Platon. * * @cdk.module extra * @cdk.githash * * @author Egon Willighagen * * @cdk.keyword file format, ShelX */ @TestClass("org.openscience.cdk.io.ShelXWriterTest") public class ShelXWriter extends DefaultChemObjectWriter { private BufferedWriter writer; //private LoggingTool logger; /** * Constructs a new ShelXWriter class. Output will be stored in the Writer * class given as parameter. * * @param out Writer to redirect the output to. */ public ShelXWriter(Writer out) { //logger = new LoggingTool(this); try { if (out instanceof BufferedWriter) { writer = (BufferedWriter)out; } else { writer = new BufferedWriter(out); } } catch (Exception exc) { } } public ShelXWriter(OutputStream output) { this(new OutputStreamWriter(output)); } public ShelXWriter() { this(new StringWriter()); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return ShelXFormat.getInstance(); } public void setWriter(Writer out) throws CDKException { if (out instanceof BufferedWriter) { writer = (BufferedWriter)out; } else { writer = new BufferedWriter(out); } } public void setWriter(OutputStream output) throws CDKException { setWriter(new OutputStreamWriter(output)); } /** * Flushes the output and closes this object */ @TestMethod("testClose") public void close() throws IOException { writer.close(); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i 0) { writeln("TITL " + title.toString().trim()); } else { writeln("TITL Produced with CDK (http://cdk.sf.net/)"); } Vector3d a = crystal.getA(); Vector3d b = crystal.getB(); Vector3d c = crystal.getC(); double alength = a.length(); double blength = b.length(); double clength = c.length(); double alpha = Math.toDegrees(b.angle(c)); double beta = Math.toDegrees(a.angle(c)); double gamma = Math.toDegrees(a.angle(b)); FormatStringBuffer format = new FormatStringBuffer("%7.5lf"); write("CELL " + format.reset("%7.5f").format(1.54184).toString() + " "); write(format.reset("%8.5f").format(alength) + " "); write(format.reset("%8.5f").format(blength) + " "); write(format.reset("%8.5f").format(clength) + " "); write(format.reset("%8.4f").format(alpha) + " "); write(format.reset("%8.4f").format(beta) + " "); writeln(format.reset("%8.4f").format(gamma) + ""); writeln("ZERR " + format.reset("%1.5f").format((double)crystal.getZ()) + " 0.01000 0.01000 0.01000 0.0100 0.0100 0.0100"); String spaceGroup = crystal.getSpaceGroup(); if ("P1".equals(spaceGroup)) { writeln("LATT -1"); } else if ("P 2_1 2_1 2_1".equals(spaceGroup)) { writeln("LATT -1"); writeln("SYMM 1/2+X , 1/2-Y , -Z"); writeln("SYMM -X , 1/2+Y , 1/2-Z"); writeln("SYMM 1/2-X , -Y , 1/2+Z"); } // MFAnalyser mfa = new MFAnalyser(crystal); String elemNames = ""; String elemCounts = ""; IMolecularFormula formula = MolecularFormulaManipulator.getMolecularFormula(crystal); List asortedElements = MolecularFormulaManipulator.elements(formula); Iterator elements = asortedElements.iterator(); while (elements.hasNext()) { IElement element = elements.next(); String symbol = element.getSymbol(); elemNames += symbol + " ".substring(symbol.length()); String countS = Integer.valueOf(MolecularFormulaManipulator.getElementCount(formula, element)).toString(); elemCounts += countS + " ".substring(countS.length()); } writeln("SFAC " + elemNames); writeln("UNIT " + elemCounts); /* write atoms */ for (int i = 0; i < crystal.getAtomCount(); i++) { IAtom atom = crystal.getAtom(i); Point3d cartCoord = atom.getPoint3d(); Point3d fracCoord = CrystalGeometryTools.cartesianToFractional(a, b, c, cartCoord); String symbol = atom.getSymbol(); String output = symbol + (i+1); write(output); for (int j=1; j<5 - output.length(); j++) { write(" "); } write(" "); String elemID = Integer.valueOf(asortedElements.indexOf(symbol)+1).toString(); write(elemID); write(" ".substring(elemID.length())); write(format.reset("%7.5f").format(fracCoord.x) + " "); write(format.reset("%7.5f").format(fracCoord.y) + " "); writeln(format.reset("%7.5f").format(fracCoord.z) + " 11.00000 0.05000"); } writeln("END"); } private void write(String s) { try { writer.write(s); } catch (IOException e) { System.err.println("CMLWriter IOException while printing \"" + s + "\":" + e.toString()); } } private void writeln(String s) { try { writer.write(s); writer.newLine(); } catch (IOException e) { System.err.println("CMLWriter IOException while printing \"" + s + "\":" + e.toString()); } } } cdk-1.2.10/src/main/org/openscience/cdk/io/VASPReader.java100644 0 0 31054 11570154753 20222 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2003-2007 The Jmol Development Team (v. 1.1.2.2) * Copyright (C) 2003-2007 The Chemistry Development Kit (CDK) project * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.io; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.util.StringTokenizer; import javax.vecmath.Point3d; import javax.vecmath.Vector3d; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.config.IsotopeFactory; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.ICrystal; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.VASPFormat; import org.openscience.cdk.math.FortranFormat; import org.openscience.cdk.tools.LoggingTool; /** * Read output files generated with the VASP software. * * @cdk.module extra * @cdk.githash * * @author Fabian Dortu */ @TestClass("org.openscience.cdk.io.VSPReaderTest") public class VASPReader extends DefaultChemObjectReader { private LoggingTool logger = null; // This variable is used to parse the input file protected StringTokenizer st = new StringTokenizer("", "");; protected String fieldVal; protected int repVal = 0; protected BufferedReader inputBuffer; // VASP VARIABLES int natom = 1; int ntype = 1; double acell[] = new double[3]; double[][] rprim = new double[3][3]; String info = ""; String line; String[] anames; //size is ntype. Contains the names of the atoms int natom_type[]; //size is natom. Contain the atomic number String representation; // "Direct" only so far /** * Creates a new VASPReader instance. * * @param input a Reader value */ public VASPReader(Reader input) { logger = new LoggingTool(this); if (input instanceof BufferedReader) { this.inputBuffer = (BufferedReader)input; } else { this.inputBuffer = new BufferedReader(input); } } public VASPReader(InputStream input) { this(new InputStreamReader(input)); } public VASPReader() { this(new StringReader("")); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return VASPFormat.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader input) throws CDKException { if (input instanceof BufferedReader) { this.inputBuffer = (BufferedReader)input; } else { this.inputBuffer = new BufferedReader(input); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; iString value * @exception IOException if an error occurs */ public String nextVASPToken(boolean newLine) throws IOException { String line; if (newLine) { // We ignore the end of the line and go to the following line if (inputBuffer.ready()) { line = inputBuffer.readLine(); st = new StringTokenizer(line, " =\t"); } } while (!st.hasMoreTokens() && inputBuffer.ready()) { line = inputBuffer.readLine(); st = new StringTokenizer(line, " =\t"); } if (st.hasMoreTokens()) { fieldVal = st.nextToken(); if (fieldVal.startsWith("#")) { nextVASPToken(true); } } else { fieldVal = null; } return this.fieldVal; } //end nextVASPToken(boolean newLine) /** * Find the next token of a VASP file begining * with the *next* line. */ public String nextVASPTokenFollowing(String string) throws IOException { int index; String line; while (inputBuffer.ready()) { line = inputBuffer.readLine(); index = line.indexOf(string); if (index > 0) { index = index + string.length(); line = line.substring(index); st = new StringTokenizer(line, " =\t"); while(!st.hasMoreTokens() && inputBuffer.ready()) { line = inputBuffer.readLine(); st = new StringTokenizer(line, " =\t"); } if (st.hasMoreTokens()) { fieldVal = st.nextToken(); } else { fieldVal = null; } break; } } return fieldVal; } //end nextVASPTokenFollowing(String string) @TestMethod("testClose") public void close() throws IOException { inputBuffer.close(); } } cdk-1.2.10/src/main/org/openscience/cdk/io/WriterFactory.java100644 0 0 15414 11570154753 21134 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 1997-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.io; import java.io.BufferedReader; import java.io.InputStreamReader; import java.lang.reflect.Method; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; import java.util.List; import java.util.Map; import org.openscience.cdk.io.formats.IChemFormat; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.tools.LoggingTool; /** * Helper tool to create IChemObjectWriters. * * @author Egon Willighagen * @cdk.module io * @cdk.githash **/ public class WriterFactory { private final static String IO_FORMATS_LIST = "io-formats.set"; private LoggingTool logger; private static List formats = null; private static Map> registeredReaders; /** * Constructs a ChemObjectIOInstantionTests. */ public WriterFactory() { logger = new LoggingTool(this); registeredReaders = new HashMap>(); } public void registerWriter(Class writer) { if (writer == null) return; if (IChemObjectWriter.class.isAssignableFrom(writer)) { registeredReaders.put( writer.getName(), (Class)writer ); } } /** * Finds IChemFormats that provide a container for serialization for the * given features. The syntax of the integer is explained in the DataFeatures class. * * @param features the data features for which a IChemFormat is searched * @return an array of IChemFormat's that can contain the given features * * @see org.openscience.cdk.tools.DataFeatures */ public IChemFormat[] findChemFormats(int features) { if (formats == null) loadFormats(); Iterator iter = formats.iterator(); List matches = new ArrayList(); while (iter.hasNext()) { IChemFormat format = (IChemFormat)iter.next(); if ((format.getSupportedDataFeatures() & features) == features) matches.add(format); } return (IChemFormat[])matches.toArray(new IChemFormat[matches.size()]); } public int formatCount() { if (formats == null) loadFormats(); return formats.size(); } private void loadFormats() { if (formats == null) { formats = new ArrayList(); try { logger.debug("Starting loading Formats..."); BufferedReader reader = new BufferedReader(new InputStreamReader( this.getClass().getClassLoader().getResourceAsStream(IO_FORMATS_LIST) )); int formatCount = 0; while (reader.ready()) { // load them one by one String formatName = reader.readLine(); formatCount++; try { Class formatClass = this.getClass().getClassLoader().loadClass(formatName); Method getinstanceMethod = formatClass.getMethod("getInstance", new Class[0]); IResourceFormat format = (IResourceFormat)getinstanceMethod.invoke(null, new Object[0]); if (format instanceof IChemFormat) { formats.add((IChemFormat)format); logger.info("Loaded IChemFormat: " + format.getClass().getName()); } } catch (ClassNotFoundException exception) { logger.error("Could not find this IResourceFormat: ", formatName); logger.debug(exception); } catch (Exception exception) { logger.error("Could not load this IResourceFormat: ", formatName); logger.debug(exception); } } logger.info("Number of loaded formats used in detection: ", formatCount); } catch (Exception exception) { logger.error("Could not load this io format list: ", IO_FORMATS_LIST); logger.debug(exception); } } } /** * Creates a new IChemObjectWriter based on the given IChemFormat. */ public IChemObjectWriter createWriter(IChemFormat format) { if (format != null) { String writerClassName = format.getWriterClassName(); if (writerClassName != null) { try { if (registeredReaders.containsKey(writerClassName)) { Class writer = registeredReaders.get(writerClassName); if (writer != null) return writer.newInstance(); } // make a new instance of this class return (IChemObjectWriter)this.getClass().getClassLoader(). loadClass(writerClassName).newInstance(); } catch (ClassNotFoundException exception) { logger.error("Could not find this ChemObjectWriter: ", writerClassName); logger.debug(exception); } catch (Exception exception) { logger.error("Could not create this ChemObjectWriter: ", writerClassName); logger.debug(exception); } } else { logger.warn("ChemFormat is recognized, but no writer is available."); } } else { logger.warn("ChemFormat is not recognized."); } return null; } } cdk-1.2.10/src/main/org/openscience/cdk/io/XYZReader.java100644 0 0 17746 11570154753 20157 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2001-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.io; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.io.StringReader; import java.util.StringTokenizer; import javax.vecmath.Point3d; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.XYZFormat; import org.openscience.cdk.tools.LoggingTool; /** * Reads an object from XYZ formated input. * *

This class is based on Dan Gezelter's XYZReader from Jmol * * @cdk.module io * @cdk.githash * * @cdk.keyword file format, XYZ */ @TestClass("org.openscience.cdk.io.XYZReaderTest") public class XYZReader extends DefaultChemObjectReader { private BufferedReader input; private LoggingTool logger; /** * Construct a new reader from a Reader type object. * * @param input reader from which input is read */ public XYZReader(Reader input) { this.input = new BufferedReader(input); logger = new LoggingTool(this); } public XYZReader(InputStream input) { this(new InputStreamReader(input)); } public XYZReader() { this(new StringReader("")); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return XYZFormat.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader input) throws CDKException { if (input instanceof BufferedReader) { this.input = (BufferedReader)input; } else { this.input = new BufferedReader(input); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i 1) { Object comment = m.getProperty(CDKConstants.COMMENT); if (comment == null) { comment = ""; } comment = comment.toString() + line.substring(1).trim(); m.setProperty(CDKConstants.COMMENT, comment); logger.debug("Found and set comment: ", comment); i--; // a comment line does not count as an atom } else { double x = 0.0f, y = 0.0f, z = 0.0f; double charge = 0.0f; tokenizer = new StringTokenizer(line, "\t ,;"); int fields = tokenizer.countTokens(); if (fields < 4) { // this is an error but cannot throw exception } else { String atomtype = tokenizer.nextToken(); x = (new Double(tokenizer.nextToken())).doubleValue(); y = (new Double(tokenizer.nextToken())).doubleValue(); z = (new Double(tokenizer.nextToken())).doubleValue(); if (fields == 8) charge = (new Double(tokenizer.nextToken())).doubleValue(); IAtom atom = file.getBuilder().newAtom(atomtype, new Point3d(x,y,z)); atom.setCharge(charge); m.addAtom(atom); } } } setOfMolecules.addMolecule(m); chemModel.setMoleculeSet(setOfMolecules); chemSequence.addChemModel(chemModel); line = input.readLine(); } file.addChemSequence(chemSequence); } catch (IOException e) { // should make some noise now file = null; logger.error("Error while reading file: ", e.getMessage()); logger.debug(e); } return file; } @TestMethod("testClose") public void close() throws IOException { input.close(); } } cdk-1.2.10/src/main/org/openscience/cdk/io/XYZWriter.java100644 0 0 13735 11570154753 20223 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2002 Bradley A. Smith * 2002 Miguel Howard * 2003-2007 Egon Willighagen * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.io; import java.io.BufferedWriter; import java.io.IOException; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.StringWriter; import java.io.Writer; import java.util.Iterator; import javax.vecmath.Point3d; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IChemObject; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.XYZFormat; import org.openscience.cdk.tools.FormatStringBuffer; import org.openscience.cdk.tools.LoggingTool; /** * @cdk.module io * @cdk.githash * * @author Bradley A. Smith * @author J. Daniel Gezelter * @author Egon Willighagen */ @TestClass("org.openscience.cdk.io.XYZWriterTest") public class XYZWriter extends DefaultChemObjectWriter { private BufferedWriter writer; private LoggingTool logger; private FormatStringBuffer fsb; /** * Constructor. * * @param out the stream to write the XYZ file to. */ public XYZWriter(Writer out) { logger = new LoggingTool(this); fsb = new FormatStringBuffer("%-8.6f"); try { if (out instanceof BufferedWriter) { writer = (BufferedWriter)out; } else { writer = new BufferedWriter(out); } } catch (Exception exc) { } } public XYZWriter(OutputStream output) { this(new OutputStreamWriter(output)); } public XYZWriter() { this(new StringWriter()); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return XYZFormat.getInstance(); } public void setWriter(Writer out) throws CDKException { if (out instanceof BufferedWriter) { writer = (BufferedWriter)out; } else { writer = new BufferedWriter(out); } } public void setWriter(OutputStream output) throws CDKException { setWriter(new OutputStreamWriter(output)); } /** * Flushes the output and closes this object. */ @TestMethod("testClose") public void close() throws IOException { writer.close(); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (int i=0; i atoms = mol.atoms().iterator(); while (atoms.hasNext()) { IAtom a = atoms.next(); st = a.getSymbol(); Point3d p3 = a.getPoint3d(); if (p3 != null) { st = st + "\t" + (p3.x < 0 ? "" : " ") + fsb.format(p3.x) + "\t" + (p3.y < 0 ? "" : " ") + fsb.format(p3.y) + "\t" + (p3.z < 0 ? "" : " ") + fsb.format(p3.z); } else { st = st + "\t " + fsb.format(0.0) + "\t " + fsb.format(0.0) + "\t " + fsb.format(0.0); } if (writecharge) { double ct = a.getCharge() == CDKConstants.UNSET ? 0.0 : a.getCharge(); st = st + "\t" + ct; } writer.write(st, 0, st.length()); writer.newLine(); } } catch (IOException e) { // throw e; logger.error("Error while writing file: ", e.getMessage()); logger.debug(e); } } } cdk-1.2.10/src/main/org/openscience/cdk/io/ZMatrixReader.java100644 0 0 20036 11570154753 21045 0ustar 0 0 /* $RCSfile$ * $Author$ * $Date$ * $Revision$ * * Copyright (C) 2001-2007 The Chemistry Development Kit (CDK) project * * 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 org.openscience.cdk.io; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; import org.openscience.cdk.exception.CDKException; import org.openscience.cdk.geometry.ZMatrixTools; import org.openscience.cdk.interfaces.*; import org.openscience.cdk.io.formats.IResourceFormat; import org.openscience.cdk.io.formats.ZMatrixFormat; import javax.vecmath.Point3d; import java.io.*; import java.util.StringTokenizer; /** * It reads Z matrices like in Gaussian input files. It seems that it cannot * handle Z matrices where values are given via a stringID for which the value * is given later. * * @cdk.module extra * @cdk.githash * * @cdk.keyword file format, Z-matrix */ @TestClass("org.openscience.cdk.io.ZMatrixReaderTest") public class ZMatrixReader extends DefaultChemObjectReader { private BufferedReader input; /** * Constructs a ZMatrixReader from a Reader that contains the * data to be parsed. * * @param input Reader containing the data to read */ public ZMatrixReader(Reader input) { this.input = new BufferedReader(input); } public ZMatrixReader(InputStream input) { this(new InputStreamReader(input)); } public ZMatrixReader() { this(new StringReader("")); } @TestMethod("testGetFormat") public IResourceFormat getFormat() { return ZMatrixFormat.getInstance(); } @TestMethod("testSetReader_Reader") public void setReader(Reader input) throws CDKException { if (input instanceof BufferedReader) { this.input = (BufferedReader)input; } else { this.input = new BufferedReader(input); } } @TestMethod("testSetReader_InputStream") public void setReader(InputStream input) throws CDKException { setReader(new InputStreamReader(input)); } @TestMethod("testAccepts") public boolean accepts(Class classObject) { Class[] interfaces = classObject.getInterfaces(); for (Class anInterface : interfaces) { if (IChemFile.class.equals(anInterface)) return true; } return false; } /** * Returns a IChemObject of type object bye reading from * the input. * * The function supports only reading of ChemFile's. * * @param object IChemObject that types the class to return. * @throws CDKException when a IChemObject is requested that cannot be read. */ public IChemObject read(IChemObject object) throws CDKException { if (object instanceof IChemFile) return readChemFile((IChemFile)object); else throw new CDKException("Only ChemFile objects can be read."); } /** * Private method that actually parses the input to read a ChemFile * object. * * @param file the file to read from * @return A ChemFile containing the data parsed from input. */ private IChemFile readChemFile(IChemFile file) { IChemSequence chemSequence = file.getBuilder().newChemSequence(); int number_of_atoms; StringTokenizer tokenizer; try { String line = input.readLine(); while (line.startsWith("#")) line = input.readLine(); /*while (input.ready() && line != null) {*/ // logger.debug("lauf"); // parse frame by frame tokenizer = new StringTokenizer(line, "\t ,;"); String token = tokenizer.nextToken(); number_of_atoms = Integer.parseInt(token); String info = input.readLine(); IChemModel chemModel = file.getBuilder().newChemModel(); IMoleculeSet setOfMolecules = file.getBuilder().newMoleculeSet(); IMolecule m = file.getBuilder().newMolecule(); m.setProperty(CDKConstants.TITLE ,info); String[] types = new String[number_of_atoms]; double[] d = new double[number_of_atoms]; int[] d_atom = new int[number_of_atoms]; // Distances double[] a = new double[number_of_atoms]; int[] a_atom = new int[number_of_atoms]; // Angles double[] da = new double[number_of_atoms]; int[] da_atom = new int[number_of_atoms]; // Diederangles //Point3d[] pos = new Point3d[number_of_atoms]; // calculated positions int i = 0; while(i < number_of_atoms) { line = input.readLine(); // logger.debug("line:\""+line+"\""); if (line == null) break; if (line.startsWith("#")) { // skip comment in file } else { d[i] = 0d; d_atom[i] = -1; a[i] = 0d; a_atom[i] = -1; da[i] = 0d; da_atom[i] = -1; tokenizer = new StringTokenizer(line, "\t ,;"); int fields = tokenizer.countTokens(); if (fields < Math.min(i*2+1,7)) { // this is an error but cannot throw exception } else if (i==0) { types[i] = tokenizer.nextToken(); i++; } else if (i==1) { types[i] = tokenizer.nextToken(); d_atom[i] = Integer.valueOf(tokenizer.nextToken()) -1; d[i] = new Double(tokenizer.nextToken()); i++; } else if (i==2) { types[i] = tokenizer.nextToken(); d_atom[i] = Integer.valueOf(tokenizer.nextToken()) -1; d[i] = new Double(tokenizer.nextToken()); a_atom[i] = new Integer(tokenizer.nextToken()) -1; a[i] = new Double(tokenizer.nextToken()); i++; } else { types[i] = tokenizer.nextToken(); d_atom[i] = new Integer(tokenizer.nextToken()) -1; d[i] = new Double(tokenizer.nextToken()); a_atom[i] = new Integer(tokenizer.nextToken()) -1; a[i] = new Double(tokenizer.nextToken()); da_atom[i] = new Integer(tokenizer.nextToken()) -1; da[i] = new Double(tokenizer.nextToken()); i++; } } } // calculate cartesian coordinates Point3d[] cartCoords = ZMatrixTools.zmatrixToCartesian(d, d_atom, a, a_atom, da, da_atom); for (i=0; i * * 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 org.openscience.cdk.io.cml; import java.util.StringTokenizer; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.tools.manipulator.BondManipulator; import org.xml.sax.Attributes; /** * This is an implementation for the CDK convention. * * @cdk.module io * @cdk.githash * * @author egonw */ public class CDKConvention extends CMLCoreModule { private boolean isBond; public CDKConvention(IChemFile chemFile) { super(chemFile); } public CDKConvention(ICMLModule conv) { super(conv); } public void startDocument() { super.startDocument(); isBond = false; } public void startElement(CMLStack xpath, String uri, String local, String raw, Attributes atts) { isBond = false; if (xpath.toString().endsWith("string/")) { for (int i = 0; i < atts.getLength(); i++) { if (atts.getQName(i).equals("buildin") && atts.getValue(i).equals("order")) { isBond = true; } } } else { super.startElement(xpath, uri, local, raw, atts); } } public void characterData(CMLStack xpath, char ch[], int start, int length) { String s = new String(ch, start, length).trim(); if (isBond) { logger.debug("CharData (bond): " + s); StringTokenizer st = new StringTokenizer(s); while (st.hasMoreElements()) { String border = (String)st.nextElement(); logger.debug("new bond order: " + border); // assume cdk bond object has already started // cdo.setObjectProperty("Bond", "order", border); currentBond.setOrder( BondManipulator.createBondOrder(Double.parseDouble(border)) ); } } else { super.characterData(xpath, ch, start, length); } } } cdk-1.2.10/src/main/org/openscience/cdk/io/cml/CMLCoreModule.java100644 0 0 201636 11570154753 21520 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 1997-2007 Egon Willighagen * * 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 org.openscience.cdk.io.cml; import java.util.ArrayList; import java.util.HashMap; import java.util.Hashtable; import java.util.Iterator; import java.util.List; import java.util.Map; import java.util.StringTokenizer; import javax.vecmath.Point2d; import javax.vecmath.Point3d; import javax.vecmath.Vector3d; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.dict.DictRef; import org.openscience.cdk.geometry.CrystalGeometryTools; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IBond; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IChemModel; import org.openscience.cdk.interfaces.IChemSequence; import org.openscience.cdk.interfaces.ICrystal; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.openscience.cdk.interfaces.IMonomer; import org.openscience.cdk.interfaces.IPseudoAtom; import org.openscience.cdk.interfaces.IReaction; import org.openscience.cdk.interfaces.IReactionSet; import org.openscience.cdk.interfaces.IStrand; import org.openscience.cdk.tools.LoggingTool; import org.openscience.cdk.tools.manipulator.AtomContainerManipulator; import org.openscience.cdk.tools.manipulator.BondManipulator; import org.xml.sax.Attributes; /** * Core CML 1.x and 2.x elements are parsed by this class. * *

Please file a bug report if this parser fails to parse * a certain element or attribute value in a valid CML document. * * @cdk.module io * @cdk.githash * * @author Egon Willighagen **/ public class CMLCoreModule implements ICMLModule { protected org.openscience.cdk.tools.LoggingTool logger; protected final String SYSTEMID = "CML-1999-05-15"; // protected IChemicalDocumentObject cdo; // data model to store things into protected IChemFile currentChemFile; protected IAtomContainer currentMolecule; protected IMoleculeSet currentMoleculeSet; protected IChemModel currentChemModel; protected IChemSequence currentChemSequence; protected IReactionSet currentReactionSet; protected IReaction currentReaction; protected IAtom currentAtom; protected IBond currentBond; protected IStrand currentStrand; protected IMonomer currentMonomer; protected Map atomEnumeration; protected List moleculeCustomProperty; // helper fields protected int formulaCounter; protected int atomCounter; protected List elsym; protected List eltitles; protected List elid; protected List formula; protected List formalCharges; protected List partialCharges; protected List isotope; protected List atomicNumbers; protected List exactMasses; protected List x3; protected List y3; protected List z3; protected List x2; protected List y2; protected List xfract; protected List yfract; protected List zfract; protected List hCounts; protected List atomParities; protected List atomDictRefs; protected List spinMultiplicities; protected List occupancies; protected Map> atomCustomProperty; protected int bondCounter; protected List bondid; protected List bondARef1; protected List bondARef2; protected List order; protected List bondStereo; protected List bondDictRefs; protected List bondElid; protected List bondAromaticity; protected Map> bondCustomProperty; protected boolean stereoGiven; protected String inchi; protected int curRef; protected int CurrentElement; protected String BUILTIN; protected String DICTREF; protected String elementTitle; protected String currentChars; protected double[] unitcellparams; protected int crystalScalar; // private Vector3d aAxis; // private Vector3d bAxis; // private Vector3d cAxis; boolean cartesianAxesSet = false; public CMLCoreModule(IChemFile chemFile) { logger = new LoggingTool(this); this.currentChemFile = chemFile; } public CMLCoreModule(ICMLModule conv) { logger = new LoggingTool(this); inherit(conv); } public void inherit(ICMLModule convention) { if (convention instanceof CMLCoreModule) { CMLCoreModule conv = (CMLCoreModule)convention; // copy the data model this.currentChemFile = conv.currentChemFile; this.currentMolecule = conv.currentMolecule; this.currentMoleculeSet = conv.currentMoleculeSet; this.currentChemModel = conv.currentChemModel; this.currentChemSequence = conv.currentChemSequence; this.currentReactionSet = conv.currentReactionSet; this.currentReaction = conv.currentReaction; this.currentAtom = conv.currentAtom; this.currentStrand = conv.currentStrand; this.currentMonomer = conv.currentMonomer; this.atomEnumeration = conv.atomEnumeration; this.moleculeCustomProperty = conv.moleculeCustomProperty; // copy the intermediate fields this.logger = conv.logger; this.BUILTIN = conv.BUILTIN; this.atomCounter = conv.atomCounter; this.formulaCounter = conv.formulaCounter; this.elsym = conv.elsym; this.eltitles = conv.eltitles; this.elid = conv.elid; this.formalCharges = conv.formalCharges; this.partialCharges = conv.partialCharges; this.isotope = conv.isotope; this.atomicNumbers = conv.atomicNumbers; this.exactMasses = conv.exactMasses; this.x3 = conv.x3; this.y3 = conv.y3; this.z3 = conv.z3; this.x2 = conv.x2; this.y2 = conv.y2; this.xfract = conv.xfract; this.yfract = conv.yfract; this.zfract = conv.zfract; this.hCounts = conv.hCounts; this.atomParities = conv.atomParities; this.atomDictRefs = conv.atomDictRefs; this.spinMultiplicities = conv.spinMultiplicities; this.occupancies = conv.occupancies; this.bondCounter = conv.bondCounter; this.bondid = conv.bondid; this.bondARef1 = conv.bondARef1; this.bondARef2 = conv.bondARef2; this.order = conv.order; this.bondStereo = conv.bondStereo; this.bondCustomProperty = conv.bondCustomProperty; this.atomCustomProperty = conv.atomCustomProperty; this.bondDictRefs = conv.bondDictRefs; this.bondAromaticity = conv.bondAromaticity; this.curRef = conv.curRef; this.unitcellparams = conv.unitcellparams; this.inchi = conv.inchi; } else { logger.warn("Cannot inherit information from module: ", convention.getClass().getName()); } } public IChemFile returnChemFile() { return currentChemFile; } /** * Clean all data about parsed data. */ protected void newMolecule() { newMoleculeData(); newAtomData(); newBondData(); newCrystalData(); newFormulaData(); } /** * Clean all data about the molecule itself. */ protected void newMoleculeData() { this.inchi = null; } /** * Clean all data about read formulas. */ protected void newFormulaData() { formulaCounter = 0; formula = new ArrayList(); } /** * Clean all data about read atoms. */ protected void newAtomData() { atomCounter = 0; elsym = new ArrayList(); elid = new ArrayList(); eltitles = new ArrayList(); formalCharges = new ArrayList(); partialCharges = new ArrayList(); isotope = new ArrayList(); atomicNumbers = new ArrayList(); exactMasses = new ArrayList(); x3 = new ArrayList(); y3 = new ArrayList(); z3 = new ArrayList(); x2 = new ArrayList(); y2 = new ArrayList(); xfract = new ArrayList(); yfract = new ArrayList(); zfract = new ArrayList(); hCounts = new ArrayList(); atomParities = new ArrayList(); atomDictRefs = new ArrayList(); spinMultiplicities = new ArrayList(); occupancies = new ArrayList(); atomCustomProperty = new HashMap>(); } /** * Clean all data about read bonds. */ protected void newBondData() { bondCounter = 0; bondid = new ArrayList(); bondARef1 = new ArrayList(); bondARef2 = new ArrayList(); order = new ArrayList(); bondStereo = new ArrayList(); bondCustomProperty = new Hashtable>(); bondDictRefs = new ArrayList(); bondElid = new ArrayList(); bondAromaticity = new ArrayList(); } /** * Clean all data about read bonds. */ protected void newCrystalData() { unitcellparams = new double[6]; cartesianAxesSet = false; crystalScalar = 0; // aAxis = new Vector3d(); // bAxis = new Vector3d(); // cAxis = new Vector3d(); } public void startDocument() { logger.info("Start XML Doc"); // cdo.startDocument(); currentChemSequence = currentChemFile.getBuilder().newChemSequence(); currentChemModel = currentChemFile.getBuilder().newChemModel(); currentMoleculeSet = currentChemFile.getBuilder().newMoleculeSet(); currentMolecule = currentChemFile.getBuilder().newMolecule(); atomEnumeration = new HashMap(); moleculeCustomProperty = new ArrayList(); newMolecule(); BUILTIN = ""; curRef = 0; } public void endDocument() { // cdo.endDocument(); if (currentReactionSet != null && currentReactionSet.getReactionCount() == 0 && currentReaction != null) { logger.debug("Adding reaction to ReactionSet"); currentReactionSet.addReaction(currentReaction); } if (currentReactionSet != null && currentChemModel.getReactionSet() == null) { logger.debug("Adding SOR to ChemModel"); currentChemModel.setReactionSet(currentReactionSet); } if (currentMoleculeSet != null && currentMoleculeSet.getMoleculeCount() != 0) { logger.debug("Adding reaction to MoleculeSet"); currentChemModel.setMoleculeSet(currentMoleculeSet); } if (currentChemSequence.getChemModelCount() == 0) { logger.debug("Adding ChemModel to ChemSequence"); currentChemSequence.addChemModel(currentChemModel); } if (currentChemFile.getChemSequenceCount() == 0) { // assume there is one non-animation ChemSequence // addChemSequence(currentChemSequence); currentChemFile.addChemSequence(currentChemSequence); } logger.info("End XML Doc"); } public void startElement(CMLStack xpath, String uri, String local, String raw, Attributes atts) { String name = local; logger.debug("StartElement"); currentChars = ""; BUILTIN = ""; DICTREF = ""; for (int i=0; iBUILTIN found: ", atts.getValue(i)); } else if (qname.equals("dictRef")) { DICTREF = atts.getValue(i); logger.debug(name, "->DICTREF found: ", atts.getValue(i)); } else if (qname.equals("title")) { elementTitle = atts.getValue(i); logger.debug(name, "->TITLE found: ", atts.getValue(i)); } else { logger.debug("Qname: ", qname); } } if ("atom".equals(name)) { atomCounter++; for (int i = 0; i < atts.getLength(); i++) { String att = atts.getQName(i); String value = atts.getValue(i); if (att.equals("id")) { // this is supported in CML 1.x elid.add(value); } // this is supported in CML 2.0 else if (att.equals("elementType")) { elsym.add(value); } // this is supported in CML 2.0 else if (att.equals("title")) { eltitles.add(value); } // this is supported in CML 2.0 else if (att.equals("x2")) { x2.add(value); } // this is supported in CML 2.0 else if (att.equals("xy2")) { StringTokenizer tokenizer = new StringTokenizer(value); x2.add(tokenizer.nextToken()); y2.add(tokenizer.nextToken()); } // this is supported in CML 2.0 else if (att.equals("xyzFract")) { StringTokenizer tokenizer = new StringTokenizer(value); xfract.add(tokenizer.nextToken()); yfract.add(tokenizer.nextToken()); zfract.add(tokenizer.nextToken()); } // this is supported in CML 2.0 else if (att.equals("xyz3")) { StringTokenizer tokenizer = new StringTokenizer(value); x3.add(tokenizer.nextToken()); y3.add(tokenizer.nextToken()); z3.add(tokenizer.nextToken()); } // this is supported in CML 2.0 else if (att.equals("y2")) { y2.add(value); } // this is supported in CML 2.0 else if (att.equals("x3")) { x3.add(value); } // this is supported in CML 2.0 else if (att.equals("y3")) { y3.add(value); } // this is supported in CML 2.0 else if (att.equals("z3")) { z3.add(value); } // this is supported in CML 2.0 else if (att.equals("xFract")) { xfract.add(value); } // this is supported in CML 2.0 else if (att.equals("yFract")) { yfract.add(value); } // this is supported in CML 2.0 else if (att.equals("zFract")) { zfract.add(value); } // this is supported in CML 2.0 else if (att.equals("formalCharge")) { formalCharges.add(value); } // this is supported in CML 2.0 else if (att.equals("hydrogenCount")) { hCounts.add(value); } else if (att.equals("isotopeNumber")) { isotope.add(value); } else if (att.equals("dictRef")) { logger.debug("ocupaccy: "+value); atomDictRefs.add(value); } else if (att.equals("spinMultiplicity")) { spinMultiplicities.add(value); } else if (att.equals("occupancy")) { occupancies.add(value); } else { logger.warn("Unparsed attribute: " + att); } } } else if ("atomArray".equals(name) && !xpath.endsWith("formula", "atomArray")) { boolean atomsCounted = false; for (int i = 0; i < atts.getLength(); i++) { String att = atts.getQName(i); int count = 0; if (att.equals("atomID")) { count = addArrayElementsTo(elid, atts.getValue(i)); } else if (att.equals("elementType")) { count = addArrayElementsTo(elsym, atts.getValue(i)); } else if (att.equals("x2")) { count = addArrayElementsTo(x2, atts.getValue(i)); } else if (att.equals("y2")) { count = addArrayElementsTo(y2, atts.getValue(i)); } else if (att.equals("x3")) { count = addArrayElementsTo(x3, atts.getValue(i)); } else if (att.equals("y3")) { count = addArrayElementsTo(y3, atts.getValue(i)); } else if (att.equals("z3")) { count = addArrayElementsTo(z3, atts.getValue(i)); } else if (att.equals("xFract")) { count = addArrayElementsTo(xfract, atts.getValue(i)); } else if (att.equals("yFract")) { count = addArrayElementsTo(yfract, atts.getValue(i)); } else if (att.equals("zFract")) { count = addArrayElementsTo(zfract, atts.getValue(i)); } else { logger.warn("Unparsed attribute: " + att); } if (!atomsCounted) { atomCounter += count; atomsCounted = true; } } } else if ("bond".equals(name)) { bondCounter++; for (int i = 0; i < atts.getLength(); i++) { String att = atts.getQName(i); logger.debug("B2 ", att, "=", atts.getValue(i)); if (att.equals("id")) { bondid.add(atts.getValue(i)); logger.debug("B3 ", bondid); } else if (att.equals("atomRefs") || // this is CML 1.x support att.equals("atomRefs2")) { // this is CML 2.0 support // expect exactly two references try { StringTokenizer st = new StringTokenizer( atts.getValue(i) ); bondARef1.add((String)st.nextElement()); bondARef2.add((String)st.nextElement()); } catch (Exception e) { logger.error("Error in CML file: ", e.getMessage()); logger.debug(e); } } else if (att.equals("order")) { // this is CML 2.0 support order.add(atts.getValue(i).trim()); } else if (att.equals("dictRef")) { bondDictRefs.add(atts.getValue(i).trim()); } } stereoGiven = false; curRef = 0; } else if ("bondArray".equals(name)) { boolean bondsCounted = false; for (int i = 0; i < atts.getLength(); i++) { String att = atts.getQName(i); int count = 0; if (att.equals("bondID")) { count = addArrayElementsTo(bondid, atts.getValue(i)); } else if (att.equals("atomRefs1")) { count = addArrayElementsTo(bondARef1, atts.getValue(i)); } else if (att.equals("atomRefs2")) { count = addArrayElementsTo(bondARef2, atts.getValue(i)); } else if (att.equals("atomRef1")) { count = addArrayElementsTo(bondARef1, atts.getValue(i)); } else if (att.equals("atomRef2")) { count = addArrayElementsTo(bondARef2, atts.getValue(i)); } else if (att.equals("order")) { count = addArrayElementsTo(order, atts.getValue(i)); } else { logger.warn("Unparsed attribute: " + att); } if (!bondsCounted) { bondCounter += count; bondsCounted = true; } } curRef = 0; } else if ("bondStereo".equals(name)) { for (int i = 0; i < atts.getLength(); i++) { if (atts.getQName(i).equals("dictRef")) { if (atts.getValue(i).startsWith("cml:")) bondStereo.add(atts.getValue(i).substring(4)); stereoGiven=true; } } } else if ("bondType".equals(name)) { for (int i = 0; i < atts.getLength(); i++) { if (atts.getQName(i).equals("dictRef")) { if (atts.getValue(i).equals("cdk:aromaticBond")) bondAromaticity.add(Boolean.TRUE); } } } else if ("molecule".equals(name)) { newMolecule(); BUILTIN = ""; // cdo.startObject("Molecule"); if (currentChemModel == null) currentChemModel = currentChemFile.getBuilder().newChemModel(); if (currentMoleculeSet == null) currentMoleculeSet = currentChemFile.getBuilder().newMoleculeSet(); currentMolecule = currentChemFile.getBuilder().newMolecule(); for (int i = 0; i < atts.getLength(); i++) { if (atts.getQName(i).equals("id")) { // cdo.setObjectProperty("Molecule", "id", atts.getValue(i)); currentMolecule.setID(atts.getValue(i)); } else if (atts.getQName(i).equals("dictRef")) { // cdo.setObjectProperty("Molecule", "dictRef", atts.getValue(i)); currentMolecule.setProperty(new DictRef(DICTREF, atts.getValue(i)), atts.getValue(i)); } } } else if ("crystal".equals(name)) { newCrystalData(); // cdo.startObject("Crystal"); currentMolecule = currentChemFile.getBuilder().newCrystal(currentMolecule); for (int i = 0; i < atts.getLength(); i++) { String att = atts.getQName(i); if (att.equals("z")) { // cdo.setObjectProperty("Crystal", "z", atts.getValue(i)); ((ICrystal)currentMolecule).setZ(Integer.parseInt(atts.getValue(i))); } } } else if ("symmetry".equals(name)) { for (int i = 0; i < atts.getLength(); i++) { String att = atts.getQName(i); if (att.equals("spaceGroup")) { // cdo.setObjectProperty("Crystal", "spacegroup", atts.getValue(i)); ((ICrystal)currentMolecule).setSpaceGroup(atts.getValue(i)); } } } else if ("identifier".equals(name)) { if (atts.getValue("convention") != null && atts.getValue("convention").equals("iupac:inchi") && atts.getValue("value") != null) { // cdo.setObjectProperty("Molecule", "inchi", atts.getValue("value")); currentMolecule.setProperty(CDKConstants.INCHI, atts.getValue("value")); } } else if ("scalar".equals(name)) { if (xpath.endsWith("crystal", "scalar")) crystalScalar++; } else if ("label".equals(name)) { if (xpath.endsWith("atomType", "label")) { // cdo.setObjectProperty("Atom", "atomTypeLabel", atts.getValue("value")); currentAtom.setAtomTypeName(atts.getValue("value")); } } else if ("list".equals(name)) { // cdo.startObject("MoleculeSet"); if (DICTREF.equals("cdk:model")) { currentChemModel = currentChemFile.getBuilder().newChemModel(); // see if there is an ID attribute for (int i = 0; i < atts.getLength(); i++) { String att = atts.getQName(i); if (att.equals("id")) { currentChemModel.setID(atts.getValue(i)); } } } else if (DICTREF.equals("cdk:moleculeSet")) { currentMoleculeSet = currentChemFile.getBuilder().newMoleculeSet(); // see if there is an ID attribute for (int i = 0; i < atts.getLength(); i++) { String att = atts.getQName(i); if (att.equals("id")) { currentMoleculeSet.setID(atts.getValue(i)); } } currentMolecule = currentChemFile.getBuilder().newMolecule(); } else { // the old default currentMoleculeSet = currentChemFile.getBuilder().newMoleculeSet(); // see if there is an ID attribute for (int i = 0; i < atts.getLength(); i++) { String att = atts.getQName(i); if (att.equals("id")) { currentMoleculeSet.setID(atts.getValue(i)); } } currentMolecule = currentChemFile.getBuilder().newMolecule(); } }else if ("formula".equals(name)){ formulaCounter++; for (int i = 0; i < atts.getLength(); i++) { String att = atts.getQName(i); String value = atts.getValue(i); if (att.equals("concise")) { formula.add(value); } } } } public void endElement(CMLStack xpath, String uri, String name, String raw) { logger.debug("EndElement: ", name); String cData = currentChars; if ("bond".equals(name)) { if (!stereoGiven) bondStereo.add(""); if (bondCounter > bondDictRefs.size()) bondDictRefs.add(null); if (bondCounter > bondAromaticity.size()) bondAromaticity.add(null); } else if ("atom".equals(name)) { if (atomCounter > eltitles.size()) { eltitles.add(null); } if (atomCounter > hCounts.size()) { hCounts.add(null); } if (atomCounter > atomDictRefs.size()) { atomDictRefs.add(null); } if (atomCounter > isotope.size()) { isotope.add(null); } if (atomCounter > atomicNumbers.size()) { atomicNumbers.add(null); } if (atomCounter > exactMasses.size()) { exactMasses.add(null); } if (atomCounter > spinMultiplicities.size()) { spinMultiplicities.add(null); } if (atomCounter > occupancies.size()) { occupancies.add(null); } if (atomCounter > formalCharges.size()) { /* while strictly undefined, assume zero formal charge when no number is given */ formalCharges.add("0"); } /* It may happen that not all atoms have associated 2D or 3D coordinates. accept that */ if (atomCounter > x2.size() && x2.size() != 0) { /* apparently, the previous atoms had atomic coordinates, add 'null' for this atom */ x2.add(null); y2.add(null); } if (atomCounter > x3.size() && x3.size() != 0) { /* apparently, the previous atoms had atomic coordinates, add 'null' for this atom */ x3.add(null); y3.add(null); z3.add(null); } if (atomCounter > xfract.size() && xfract.size() != 0) { /* apparently, the previous atoms had atomic coordinates, add 'null' for this atom */ xfract.add(null); yfract.add(null); zfract.add(null); } } else if ("molecule".equals(name)) { storeData(); // cdo.endObject("Molecule"); if (currentMolecule instanceof IMolecule) { logger.debug("Adding molecule to set"); currentMoleculeSet.addMolecule((IMolecule)currentMolecule); logger.debug("#mols in set: " + currentMoleculeSet.getMoleculeCount()); } else if (currentMolecule instanceof ICrystal) { logger.debug("Adding crystal to chemModel"); currentChemModel.setCrystal((ICrystal)currentMolecule); currentChemSequence.addChemModel(currentChemModel); } } else if ("crystal".equals(name)) { if (crystalScalar > 0) { // convert unit cell parameters to cartesians Vector3d[] axes = CrystalGeometryTools.notionalToCartesian( unitcellparams[0], unitcellparams[1], unitcellparams[2], unitcellparams[3], unitcellparams[4], unitcellparams[5] ); cartesianAxesSet = true; // cdo.startObject("a-axis"); // cdo.setObjectProperty("a-axis", "x", new Double(aAxis.x).toString()); // cdo.setObjectProperty("a-axis", "y", new Double(aAxis.y).toString()); // cdo.setObjectProperty("a-axis", "z", new Double(aAxis.z).toString()); // cdo.endObject("a-axis"); // cdo.startObject("b-axis"); // cdo.setObjectProperty("b-axis", "x", new Double(bAxis.x).toString()); // cdo.setObjectProperty("b-axis", "y", new Double(bAxis.y).toString()); // cdo.setObjectProperty("b-axis", "z", new Double(bAxis.z).toString()); // cdo.endObject("b-axis"); // cdo.startObject("c-axis"); // cdo.setObjectProperty("c-axis", "x", new Double(cAxis.x).toString()); // cdo.setObjectProperty("c-axis", "y", new Double(cAxis.y).toString()); // cdo.setObjectProperty("c-axis", "z", new Double(cAxis.z).toString()); // cdo.endObject("c-axis"); ((ICrystal)currentMolecule).setA(axes[0]); ((ICrystal)currentMolecule).setB(axes[1]); ((ICrystal)currentMolecule).setC(axes[2]); } else { logger.error("Could not find crystal unit cell parameters"); } // cdo.endObject("Crystal"); } else if ("list".equals(name)) { // cdo.endObject("MoleculeSet"); // FIXME: I really should check the DICTREF, but there is currently // no mechanism for storing these for use with endTag() :( // So, instead, for now, just see if it already has done the setting // to work around duplication if (currentChemModel.getMoleculeSet() != currentMoleculeSet) { currentChemModel.setMoleculeSet(currentMoleculeSet); currentChemSequence.addChemModel(currentChemModel); } } else if ("coordinate3".equals(name)) { if (BUILTIN.equals("xyz3")) { logger.debug("New coord3 xyz3 found: ", currentChars); try { StringTokenizer st = new StringTokenizer(currentChars); x3.add(st.nextToken()); y3.add(st.nextToken()); z3.add(st.nextToken()); logger.debug("coord3 x3.length: ", x3.size()); logger.debug("coord3 y3.length: ", y3.size()); logger.debug("coord3 z3.length: ", z3.size()); } catch (Exception exception) { logger.error( "CMLParsing error while setting coordinate3!"); logger.debug(exception); } } else { logger.warn("Unknown coordinate3 BUILTIN: " + BUILTIN); } } else if ("string".equals(name)) { if (BUILTIN.equals("elementType")) { logger.debug("Element: ", cData.trim()); elsym.add(cData); } else if (BUILTIN.equals("atomRef")) { curRef++; logger.debug("Bond: ref #", curRef); if (curRef == 1) { bondARef1.add(cData.trim()); } else if (curRef == 2) { bondARef2.add(cData.trim()); } } else if (BUILTIN.equals("order")) { logger.debug("Bond: order ", cData.trim()); order.add(cData.trim()); } else if (BUILTIN.equals("formalCharge")) { // NOTE: this combination is in violation of the CML DTD!!! logger.warn("formalCharge BUILTIN accepted but violating CML DTD"); logger.debug("Charge: ", cData.trim()); String charge = cData.trim(); if (charge.startsWith("+") && charge.length() > 1) { charge = charge.substring(1); } formalCharges.add(charge); } } else if ("float".equals(name)) { if (BUILTIN.equals("x3")) { x3.add(cData.trim()); } else if (BUILTIN.equals("y3")) { y3.add(cData.trim()); } else if (BUILTIN.equals("z3")) { z3.add(cData.trim()); } else if (BUILTIN.equals("x2")) { x2.add(cData.trim()); } else if (BUILTIN.equals("y2")) { y2.add(cData.trim()); } else if (BUILTIN.equals("order")) { // NOTE: this combination is in violation of the CML DTD!!! order.add(cData.trim()); } else if (BUILTIN.equals("charge") || BUILTIN.equals("partialCharge")) { partialCharges.add(cData.trim()); } } else if ("integer".equals(name)) { if (BUILTIN.equals("formalCharge")) { formalCharges.add(cData.trim()); } } else if ("coordinate2".equals(name)) { if (BUILTIN.equals("xy2")) { logger.debug("New coord2 xy2 found.", cData); try { StringTokenizer st = new StringTokenizer(cData); x2.add(st.nextToken()); y2.add(st.nextToken()); } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 175, 1); } } } else if ("stringArray".equals(name)) { if (BUILTIN.equals("id") || BUILTIN.equals("atomId") || BUILTIN.equals("atomID")) { // invalid according to CML1 DTD but found in OpenBabel 1.x output try { boolean countAtoms = (atomCounter == 0) ? true : false; StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) { if (countAtoms) { atomCounter++; } String token = st.nextToken(); logger.debug("StringArray (Token): ", token); elid.add(token); } } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 186, 1); } } else if (BUILTIN.equals("elementType")) { try { boolean countAtoms = (atomCounter == 0) ? true : false; StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) { if (countAtoms) { atomCounter++; } elsym.add(st.nextToken()); } } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 194, 1); } } else if (BUILTIN.equals("atomRefs")) { curRef++; logger.debug("New atomRefs found: ", curRef); try { boolean countBonds = (bondCounter == 0) ? true : false; StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) { if (countBonds) { bondCounter++; } String token = st.nextToken(); logger.debug("Token: ", token); if (curRef == 1) { bondARef1.add(token); } else if (curRef == 2) { bondARef2.add(token); } } } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 194, 1); } } else if (BUILTIN.equals("atomRef")) { curRef++; logger.debug("New atomRef found: ", curRef); // this is CML1 stuff, we get things like: /* a2 a2 a2 a2 a3 a3 a4 a4 a5 a6 a7 a9 a9 a11 a12 a13 a5 a4 a6 a9 a7 a8 a8 a10 1 1 1 1 2 1 2 1 1 1 2 2 */ try { boolean countBonds = (bondCounter == 0) ? true : false; StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) { if (countBonds) { bondCounter++; } String token = st.nextToken(); logger.debug("Token: ", token); if (curRef == 1) { bondARef1.add(token); } else if (curRef == 2) { bondARef2.add(token); } } } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 194, 1); } } else if (BUILTIN.equals("order")) { logger.debug("New bond order found."); try { StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) { String token = st.nextToken(); logger.debug("Token: ", token); order.add(token); } } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 194, 1); } } } else if ("integerArray".equals(name)) { logger.debug("IntegerArray: builtin = ", BUILTIN); if (BUILTIN.equals("formalCharge")) { try { StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) { String token = st.nextToken(); logger.debug("Charge added: ", token); formalCharges.add(token); } } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 205, 1); } } } else if ("scalar".equals(name)) { if (xpath.endsWith("crystal", "scalar")) { logger.debug("Going to set a crystal parameter: " + crystalScalar, " to ", cData); try { unitcellparams[crystalScalar-1] = Double.parseDouble(cData.trim()); } catch (NumberFormatException exception) { logger.error("Content must a float: " + cData); } } else if (xpath.endsWith("bond", "scalar")) { if (DICTREF.equals("mdl:stereo")) { bondStereo.add(cData.trim()); stereoGiven=true; }else{ Map bp = bondCustomProperty.get(bondid.get(bondid.size()-1)); if (bp == null) { bp = new Hashtable(); bondCustomProperty.put(bondid.get(bondid.size()-1), bp); } bp.put(elementTitle, cData.trim()); } } else if (xpath.endsWith("atom", "scalar")) { if (DICTREF.equals("cdk:partialCharge")) { partialCharges.add(cData.trim()); } else if (DICTREF.equals("cdk:atomicNumber")) { atomicNumbers.add(cData.trim()); } else if (DICTREF.equals("cdk:isotopicMass")) { exactMasses.add(cData.trim()); }else { if(atomCustomProperty.get(Integer.valueOf(atomCounter-1))==null) atomCustomProperty.put(Integer.valueOf(atomCounter-1),new ArrayList()); atomCustomProperty.get(Integer.valueOf(atomCounter-1)).add(elementTitle); atomCustomProperty.get(Integer.valueOf(atomCounter-1)).add(cData.trim()); } } else if (xpath.endsWith("molecule", "scalar")) { if (DICTREF.equals("pdb:id")) { // cdo.setObjectProperty("Molecule", DICTREF, cData); currentMolecule.setProperty(new DictRef(DICTREF, cData), cData); } else if (DICTREF.equals("cdk:molecularProperty")) { currentMolecule.setProperty(elementTitle, cData); }else{ moleculeCustomProperty.add(elementTitle); moleculeCustomProperty.add(cData.trim()); } } else { logger.warn("Ignoring scalar: " + xpath); } } else if ("floatArray".equals(name)) { if (BUILTIN.equals("x3")) { try { StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) x3.add(st.nextToken()); } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 205, 1); } } else if (BUILTIN.equals("y3")) { try { StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) y3.add(st.nextToken()); } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 213, 1); } } else if (BUILTIN.equals("z3")) { try { StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) z3.add(st.nextToken()); } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 221, 1); } } else if (BUILTIN.equals("x2")) { logger.debug("New floatArray found."); try { StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) x2.add(st.nextToken()); } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 205, 1); } } else if (BUILTIN.equals("y2")) { logger.debug("New floatArray found."); try { StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) y2.add(st.nextToken()); } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 454, 1); } } else if (BUILTIN.equals("partialCharge")) { logger.debug("New floatArray with partial charges found."); try { StringTokenizer st = new StringTokenizer(cData); while (st.hasMoreTokens()) partialCharges.add(st.nextToken()); } catch (Exception e) { notify("CMLParsing error: " + e, SYSTEMID, 462, 1); } } } else if ("basic".equals(name)) { // assuming this is the child element of this.inchi = cData; } else if ("name".equals(name)) { if (xpath.endsWith("molecule", "name")) { if (DICTREF.length() > 0) { // cdo.setObjectProperty("Molecule", DICTREF, cData); currentMolecule.setProperty(new DictRef(DICTREF, cData), cData); } else { // cdo.setObjectProperty("Molecule", "Name", cData); currentMolecule.setProperty(CDKConstants.TITLE, cData); } } }else if ("formula".equals(name)) { currentMolecule.setProperty(CDKConstants.FORMULA, cData); }else { logger.warn("Skipping element: " + name); } currentChars = ""; BUILTIN = ""; elementTitle = ""; } public void characterData(CMLStack xpath, char[] ch, int start, int length) { currentChars = currentChars + new String(ch, start, length); logger.debug("CD: ", currentChars); } protected void notify(String message, String systemId, int line, int column) { logger.debug("Message: ", message); logger.debug("SystemId: ", systemId); logger.debug("Line: ", line); logger.debug("Column: ", column); } protected void storeData() { if (inchi != null) { // cdo.setObjectProperty("Molecule", "inchi", inchi); currentMolecule.setProperty(CDKConstants.INCHI, inchi); } if (formula != null){ currentMolecule.setProperty(CDKConstants.FORMULA, formula); } Iterator customs=moleculeCustomProperty.iterator(); while(customs.hasNext()){ String x = customs.next(); String y = customs.next(); currentMolecule.setProperty(x,y); } storeAtomData(); storeBondData(); convertCMLToCDKHydrogenCounts(); } private void convertCMLToCDKHydrogenCounts() { for (IAtom atom : currentMolecule.atoms()) { if (atom.getHydrogenCount() != null) { int explicitHCount = AtomContainerManipulator.countExplicitHydrogens(currentMolecule, atom); if (explicitHCount != 0) { atom.setHydrogenCount(atom.getHydrogenCount() - explicitHCount); } } } } protected void storeAtomData() { logger.debug("No atoms: ", atomCounter); if (atomCounter == 0) { return; } boolean hasID = false; boolean has3D = false; boolean has3Dfract = false; boolean has2D = false; boolean hasFormalCharge = false; boolean hasPartialCharge = false; boolean hasHCounts = false; boolean hasSymbols = false; boolean hasTitles = false; boolean hasIsotopes = false; boolean hasAtomicNumbers = false; boolean hasExactMasses = false; boolean hasDictRefs = false; boolean hasSpinMultiplicities = false; boolean hasOccupancies = false; if (elid.size() == atomCounter) { hasID = true; } else { logger.debug("No atom ids: " + elid.size(), " != " + atomCounter); } if (elsym.size() == atomCounter) { hasSymbols = true; } else { logger.debug( "No atom symbols: " + elsym.size(), " != " + atomCounter); } if (eltitles.size() == atomCounter) { hasTitles = true; } else { logger.debug( "No atom titles: " + eltitles.size(), " != " + atomCounter); } if ((x3.size() == atomCounter) && (y3.size() == atomCounter) && (z3.size() == atomCounter)) { has3D = true; } else { logger.debug( "No 3D info: " + x3.size(), " " + y3.size(), " " + z3.size(), " != " + atomCounter); } if ((xfract.size() == atomCounter) && (yfract.size() == atomCounter) && (zfract.size() == atomCounter)) { has3Dfract = true; } else { logger.debug( "No 3D fractional info: " + xfract.size(), " " + yfract.size(), " " + zfract.size(), " != " + atomCounter); } if ((x2.size() == atomCounter) && (y2.size() == atomCounter)) { has2D = true; } else { logger.debug( "No 2D info: " + x2.size(), " " + y2.size(), " != " + atomCounter); } if (formalCharges.size() == atomCounter) { hasFormalCharge = true; } else { logger.debug( "No formal Charge info: " + formalCharges.size(), " != " + atomCounter); } if (partialCharges.size() == atomCounter) { hasPartialCharge = true; } else { logger.debug( "No partial Charge info: " + partialCharges.size(), " != " + atomCounter); } if (hCounts.size() == atomCounter) { hasHCounts = true; } else { logger.debug( "No hydrogen Count info: " + hCounts.size(), " != " + atomCounter); } if (spinMultiplicities.size() == atomCounter) { hasSpinMultiplicities = true; } else { logger.debug( "No spinMultiplicity info: " + spinMultiplicities.size(), " != " + atomCounter); } if (occupancies.size() == atomCounter) { hasOccupancies = true; } else { logger.debug( "No occupancy info: " + occupancies.size(), " != " + atomCounter); } if (atomDictRefs.size() == atomCounter) { hasDictRefs = true; } else { logger.debug( "No dictRef info: " + atomDictRefs.size(), " != " + atomCounter); } if (isotope.size() == atomCounter) { hasIsotopes = true; } else { logger.debug( "No isotope info: " + isotope.size(), " != " + atomCounter); } if (atomicNumbers.size() == atomCounter) { hasAtomicNumbers = true; } else { logger.debug( "No atomicNumbers info: " + atomicNumbers.size(), " != " + atomCounter); } if (exactMasses.size() == atomCounter) { hasExactMasses = true; } else { logger.debug( "No atomicNumbers info: " + atomicNumbers.size(), " != " + atomCounter); } for (int i = 0; i < atomCounter; i++) { logger.info("Storing atom: ", i); // cdo.startObject("Atom"); currentAtom = currentChemFile.getBuilder().newAtom("H"); logger.debug("Atom # " + atomCounter); if (hasID) { // cdo.setObjectProperty("Atom", "id", (String)elid.get(i)); logger.debug("id: ", (String)elid.get(i)); currentAtom.setID((String)elid.get(i)); atomEnumeration.put((String)elid.get(i), currentAtom); } if (hasTitles) { if (hasSymbols) { String symbol = (String)elsym.get(i); if (symbol.equals("Du") || symbol.equals("Dummy")) { // cdo.setObjectProperty("PseudoAtom", "label", (String)eltitles.get(i)); if (!(currentAtom instanceof IPseudoAtom)) { currentAtom = currentChemFile.getBuilder().newPseudoAtom(currentAtom); if (hasID) atomEnumeration.put((String)elid.get(i), currentAtom); } ((IPseudoAtom)currentAtom).setLabel((String)eltitles.get(i)); } else { // cdo.setObjectProperty("Atom", "title", (String)eltitles.get(i)); // FIXME: huh? if (eltitles.get(i) != null) currentAtom.setProperty(CDKConstants.TITLE, (String)eltitles.get(i)); } } else { // cdo.setObjectProperty("Atom", "title", (String)eltitles.get(i)); // FIXME: huh? if (eltitles.get(i) != null) currentAtom.setProperty(CDKConstants.TITLE, (String)eltitles.get(i)); } } // store optional atom properties if (hasSymbols) { String symbol = (String)elsym.get(i); if (symbol.equals("Du") || symbol.equals("Dummy")) { symbol = "R"; } // cdo.setObjectProperty("Atom", "type", symbol); if (symbol.equals("R") && !(currentAtom instanceof IPseudoAtom)) { currentAtom = currentChemFile.getBuilder().newPseudoAtom(currentAtom); if (hasID) atomEnumeration.put((String)elid.get(i), currentAtom); } currentAtom.setSymbol(symbol); } if (has3D) { // cdo.setObjectProperty("Atom", "x3", (String)x3.get(i)); // cdo.setObjectProperty("Atom", "y3", (String)y3.get(i)); // cdo.setObjectProperty("Atom", "z3", (String)z3.get(i)); if (x3.get(i) != null && y3.get(i) != null && z3.get(i) != null) { currentAtom.setPoint3d( new Point3d( Double.parseDouble((String)x3.get(i)), Double.parseDouble((String)y3.get(i)), Double.parseDouble((String)z3.get(i)) ) ); } } if (has3Dfract) { // ok, need to convert fractional into eucledian coordinates // cdo.setObjectProperty("Atom", "xFract", (String)xfract.get(i)); // cdo.setObjectProperty("Atom", "yFract", (String)yfract.get(i)); // cdo.setObjectProperty("Atom", "zFract", (String)zfract.get(i)); currentAtom.setFractionalPoint3d( new Point3d( Double.parseDouble((String)xfract.get(i)), Double.parseDouble((String)yfract.get(i)), Double.parseDouble((String)zfract.get(i)) ) ); } if (hasFormalCharge) { // cdo.setObjectProperty("Atom", "formalCharge", // (String)formalCharges.get(i)); currentAtom.setFormalCharge(Integer.parseInt((String)formalCharges.get(i))); } if (hasPartialCharge) { logger.debug("Storing partial atomic charge..."); // cdo.setObjectProperty("Atom", "partialCharge", // (String)partialCharges.get(i)); currentAtom.setCharge(Double.parseDouble((String)partialCharges.get(i))); } if (hasHCounts) { // cdo.setObjectProperty("Atom", "hydrogenCount", (String)hCounts.get(i)); // FIXME: the hCount in CML is the total of implicit *and* explicit String hCount = hCounts.get(i); if (hCount != null) { currentAtom.setHydrogenCount(Integer.parseInt(hCount)); } else { currentAtom.setHydrogenCount((Integer)CDKConstants.UNSET); } } if (has2D) { if (x2.get(i) != null && y2.get(i) != null) { // cdo.setObjectProperty("Atom", "x2", (String)x2.get(i)); // cdo.setObjectProperty("Atom", "y2", (String)y2.get(i)); currentAtom.setPoint2d( new Point2d( Double.parseDouble((String)x2.get(i)), Double.parseDouble((String)y2.get(i)) ) ); } } if (hasDictRefs) { // cdo.setObjectProperty("Atom", "dictRef", (String)atomDictRefs.get(i)); if (atomDictRefs.get(i) != null) currentAtom.setProperty("org.openscience.cdk.dict", (String)atomDictRefs.get(i)); } if (hasSpinMultiplicities && spinMultiplicities.get(i) != null) { // cdo.setObjectProperty("Atom", "spinMultiplicity", (String)spinMultiplicities.get(i)); int unpairedElectrons = Integer.parseInt((String)spinMultiplicities.get(i))-1; for (int sm=0; sm it=atomCustomProperty.get(Integer.valueOf(i)).iterator(); while(it.hasNext()){ currentAtom.setProperty(it.next(),it.next()); } } // cdo.endObject("Atom"); currentMolecule.addAtom(currentAtom); } if (elid.size() > 0) { // assume this is the current working list bondElid = elid; } newAtomData(); } protected void storeBondData() { logger.debug( "Testing a1,a2,stereo,order = count: " + bondARef1.size(), "," + bondARef2.size(), "," + bondStereo.size(), "," + order.size(), "=" + bondCounter); if ((bondARef1.size() == bondCounter) && (bondARef2.size() == bondCounter)) { logger.debug("About to add bond info..."); Iterator orders = order.iterator(); Iterator ids = bondid.iterator(); Iterator bar1s = bondARef1.iterator(); Iterator bar2s = bondARef2.iterator(); Iterator stereos = bondStereo.iterator(); Iterator aroms = bondAromaticity.iterator(); while (bar1s.hasNext()) { // cdo.startObject("Bond"); // if (ids.hasNext()) { // cdo.setObjectProperty("Bond", "id", (String)ids.next()); // } // cdo.setObjectProperty("Bond", "atom1", // Integer.valueOf(bondElid.indexOf( // (String)bar1s.next())).toString()); // cdo.setObjectProperty("Bond", "atom2", // Integer.valueOf(bondElid.indexOf( // (String)bar2s.next())).toString()); IAtom a1 = (IAtom)atomEnumeration.get((String)bar1s.next()); IAtom a2 = (IAtom)atomEnumeration.get((String)bar2s.next()); currentBond = currentChemFile.getBuilder().newBond(a1, a2); if (ids.hasNext()) { currentBond.setID((String)ids.next()); } if (orders.hasNext()) { String bondOrder = (String)orders.next(); if ("S".equals(bondOrder)) { // cdo.setObjectProperty("Bond", "order", "1"); currentBond.setOrder(CDKConstants.BONDORDER_SINGLE); } else if ("D".equals(bondOrder)) { // cdo.setObjectProperty("Bond", "order", "2"); currentBond.setOrder(CDKConstants.BONDORDER_DOUBLE); } else if ("T".equals(bondOrder)) { // cdo.setObjectProperty("Bond", "order", "3"); currentBond.setOrder(CDKConstants.BONDORDER_TRIPLE); } else if ("A".equals(bondOrder)) { // cdo.setObjectProperty("Bond", "order", "1.5"); currentBond.setOrder(CDKConstants.BONDORDER_SINGLE); currentBond.setFlag(CDKConstants.ISAROMATIC, true); } else { // cdo.setObjectProperty("Bond", "order", bondOrder); currentBond.setOrder( BondManipulator.createBondOrder(Double.parseDouble(bondOrder)) ); } } if (stereos.hasNext()) { // cdo.setObjectProperty("Bond", "stereo", // (String)stereos.next()); String nextStereo = (String)stereos.next(); if ("H".equals(nextStereo)) { currentBond.setStereo(CDKConstants.STEREO_BOND_DOWN); } else if ("W".equals(nextStereo)) { currentBond.setStereo(CDKConstants.STEREO_BOND_UP); } else if (nextStereo != null){ logger.warn("Cannot interpret stereo information: " + nextStereo); } } if (aroms.hasNext()) { Object nextArom = aroms.next(); if (nextArom != null && nextArom == Boolean.TRUE) { currentBond.setFlag(CDKConstants.ISAROMATIC, true); } } if (currentBond.getID() != null) { Map currentBondProperties = bondCustomProperty.get(currentBond.getID()); if (currentBondProperties != null) { Iterator keys = currentBondProperties.keySet().iterator(); while (keys.hasNext()) { String key = keys.next(); currentBond.setProperty(key,currentBondProperties.get(key)); } bondCustomProperty.remove(currentBond.getID()); } } // cdo.endObject("Bond"); currentMolecule.addBond(currentBond); } } newBondData(); } protected int addArrayElementsTo(List toAddto, String array) { StringTokenizer tokenizer = new StringTokenizer(array); int i = 0; while (tokenizer.hasMoreElements()) { toAddto.add(tokenizer.nextToken()); i++; } return i; } } cdk-1.2.10/src/main/org/openscience/cdk/io/cml/CMLErrorHandler.java100644 0 0 7266 11570154753 22014 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 1997-2007 Egon Willighagen * * 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 org.openscience.cdk.io.cml; import org.openscience.cdk.tools.LoggingTool; import org.xml.sax.ErrorHandler; import org.xml.sax.SAXException; import org.xml.sax.SAXParseException; /** * CDK's SAX2 ErrorHandler for giving feedback on XML errors in the CML document. * Output is redirected to org.openscience.cdk.tools.LoggingTool. * * @cdk.module io * @cdk.githash * * @author Egon Willighagen **/ public class CMLErrorHandler implements ErrorHandler { private LoggingTool logger; public boolean reportErrors = true; public boolean abortOnErrors = false; /** * Constructor a SAX2 ErrorHandler that uses the cdk.tools.LoggingTool * class to output errors and warnings to. **/ public CMLErrorHandler() { logger = new LoggingTool(this); logger.info("instantiated"); } /** * Internal procedure that outputs an SAXParseException with a significance level * to the cdk.tools.LoggingTool logger. * * @param level significance level * @param exception Exception to output */ private void print (String level, SAXParseException exception) { if (level.equals("warning")) { logger.warn("** " + level + ": " + exception.getMessage ()); logger.warn(" URI = " + exception.getSystemId ()); logger.warn(" line = " + exception.getLineNumber ()); } else { logger.error("** " + level + ": " + exception.getMessage ()); logger.error(" URI = " + exception.getSystemId ()); logger.error(" line = " + exception.getLineNumber ()); } } // for recoverable errors, like validity problems /** * Outputs a SAXParseException error to the logger. * * @param exception Exception to output **/ public void error (SAXParseException exception) throws SAXException { if (reportErrors) print("error", exception); if (abortOnErrors) throw exception; } /** * Outputs as fatal SAXParseException error to the logger. * * @param exception Exception to output **/ public void fatalError (SAXParseException exception) throws SAXException { if (reportErrors) print("fatal", exception); if (abortOnErrors) throw exception; } /** * Outputs a SAXParseException warning to the logger. * * @param exception Exception to output **/ public void warning (SAXParseException exception) throws SAXException { if (reportErrors) print("warning", exception); } } cdk-1.2.10/src/main/org/openscience/cdk/io/cml/CMLHandler.java100644 0 0 14150 11570154753 21010 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 1997-2007 Egon Willighagen * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * */ package org.openscience.cdk.io.cml; import java.util.Hashtable; import java.util.Map; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.tools.LoggingTool; import org.xml.sax.Attributes; import org.xml.sax.helpers.DefaultHandler; /** * SAX2 implementation for CML XML fragment reading. CML Core is supported * as well is the CRML module. * *

Data is stored into the Chemical Document Object which is passed when * instantiating this class. This makes it possible that programs that do not * use CDK for internal data storage, use this CML library. * * @cdk.module io * @cdk.githash * * @author Egon Willighagen **/ public class CMLHandler extends DefaultHandler { private ICMLModule conv; private LoggingTool logger; private boolean debug = true; private Map userConventions; private CMLStack xpath; private CMLStack conventionStack; /** * Constructor for the CMLHandler. * * @param chemFile The document in which data is stored **/ public CMLHandler(IChemFile chemFile) { logger = new LoggingTool(this); conv = new CMLCoreModule(chemFile); userConventions = new Hashtable(); xpath = new CMLStack(); conventionStack = new CMLStack(); } public void registerConvention(String convention, ICMLModule conv) { userConventions.put(convention, conv); } /** * Implementation of the characters() procedure overwriting the DefaultHandler interface. * * @param ch characters to handle */ public void characters(char ch[], int start, int length) { if (debug) logger.debug(new String(ch, start, length)); conv.characterData(xpath, ch, start, length); } public void doctypeDecl(String name, String publicId, String systemId) throws Exception {} /** * Calling this procedure signals the end of the XML document. */ public void endDocument() { conv.endDocument(); } public void endElement(String uri, String local, String raw) { if (debug) logger.debug(""); conv.endElement(xpath, uri, local, raw); xpath.pop(); conventionStack.pop(); } public void startDocument() { conv.startDocument(); conventionStack.push("CML"); } public void startElement(String uri, String local, String raw, Attributes atts) { xpath.push(local); if (debug) logger.debug("<", raw, "> -> ", xpath); // Detect CML modules, like CRML and CCML if (local.startsWith("reaction")) { // e.g. reactionList, reaction -> CRML module logger.info("Detected CRML module"); conv = new CMLReactionModule(conv); conventionStack.push(conventionStack.current()); } else { // assume CML Core // Detect conventions String convName = ""; for (int i = 0; i < atts.getLength(); i++) { if (atts.getQName(i).equals("convention")) { convName = atts.getValue(i); } } if (convName.length() > 0) { if (convName.equals(conventionStack.current())) { logger.debug("Same convention as parent"); } else { logger.info("New Convention: ", convName); if (convName.equals("CML")) { /* Don't reset the convention handler to CMLCore, becuase all handlers should extend this handler, and use it for any content other then specifically put into the specific convention */ } else if (convName.equals("PDB")) { conv = new PDBConvention(conv); } else if (convName.equals("PMP")) { conv = new PMPConvention(conv); } else if (convName.equals("MDLMol")) { if (debug) logger.debug("MDLMolConvention instantiated..."); conv = new MDLMolConvention(conv); } else if (convName.equals("JMOL-ANIMATION")) { conv = new JMOLANIMATIONConvention(conv); } else if (convName.equals("qsar:DescriptorValue")) { conv = new QSARConvention(conv); } else if (userConventions.containsKey(convName)) { //unknown convention. userConvention? ICMLModule newconv = (ICMLModule)userConventions.get(convName); newconv.inherit(conv); conv = newconv; } else { logger.warn("Detected unknown convention: ", convName); } } conventionStack.push(convName); } else { // no convention set/reset: take convention of parent conventionStack.push(conventionStack.current()); } } if (debug) logger.debug("ConventionStack: ", conventionStack); conv.startElement(xpath, uri, local, raw, atts); } } cdk-1.2.10/src/main/org/openscience/cdk/io/cml/CMLReactionModule.java100644 0 0 16566 11570154753 22362 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2003-2007 Egon Willighagen * * 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 org.openscience.cdk.io.cml; import org.openscience.cdk.interfaces.IAtomContainer; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IMoleculeSet; import org.xml.sax.Attributes; /** * @author Egon Willighagen * * @cdk.module io * @cdk.githash */ public class CMLReactionModule extends CMLCoreModule { private String objectType; public CMLReactionModule(IChemFile chemFile) { super(chemFile); } public CMLReactionModule(ICMLModule conv) { super(conv); logger.debug("New CML-Reaction Module!"); } public void startElement(CMLStack xpath, String uri, String local, String raw, Attributes atts) { if ("reaction".equals(local)) { // cdo.startObject("Reaction"); if (currentReactionSet == null) currentReactionSet = currentChemFile.getBuilder().newReactionSet(); currentReaction = currentChemFile.getBuilder().newReaction(); String id = atts.getValue("id"); if(id != null) currentReaction.setID(id); // cdo.setObjectProperty("Reaction", "id", id); } else if ("reactionList".equals(local)) { // cdo.startObject("ReactionSet"); currentReactionSet = currentChemFile.getBuilder().newReactionSet(); String id = atts.getValue("id"); if(id != null) currentReactionSet.setID(id); // cdo.setObjectProperty("reactionList", "id", id); } else if ("reactant".equals(local)) { // cdo.startObject("Reactant"); if (currentReaction == null) { if (currentReactionSet == null) currentReactionSet = currentChemFile.getBuilder().newReactionSet(); currentReaction = currentChemFile.getBuilder().newReaction(); } currentMolecule = currentChemFile.getBuilder().newMolecule(); objectType = "Reactant"; String id = atts.getValue("id"); if(id != null) currentMolecule.setID(id); else{ String ref = atts.getValue("ref"); if(ref != null)currentMolecule.setID(ref); } // cdo.setObjectProperty("Reactant", "id", id); } else if ("product".equals(local)) { // cdo.startObject("Product"); if (currentReaction == null) { if (currentReactionSet == null) currentReactionSet = currentChemFile.getBuilder().newReactionSet(); currentReaction = currentChemFile.getBuilder().newReaction(); } currentMolecule = currentChemFile.getBuilder().newMolecule(); objectType = "Product"; String id = atts.getValue("id"); if(id != null) currentMolecule.setID(id); else{ String ref = atts.getValue("ref"); if(ref != null) currentMolecule.setID(ref); } // cdo.setObjectProperty("Product", "id", id); } else if ("substance".equals(local)) { // cdo.startObject("Agent"); if (currentReaction == null) { if (currentReactionSet == null) currentReactionSet = currentChemFile.getBuilder().newReactionSet(); currentReaction = currentChemFile.getBuilder().newReaction(); } currentMolecule = currentChemFile.getBuilder().newMolecule(); objectType = "Agent"; String id = atts.getValue("id"); if(id != null) currentMolecule.setID(id); else{ String ref = atts.getValue("ref"); if(ref != null) currentMolecule.setID(ref); } // cdo.setObjectProperty("Agent", "id", id); } else if ("molecule".equals(local)) { // do nothing for now super.newMolecule(); String id = atts.getValue("id"); if(id != null) { // cdo.setObjectProperty(objectType, "id", id); currentMolecule.setID(id); }else{ String ref = atts.getValue("ref"); if(ref != null){ IAtomContainer atomC = getMoleculeFromID(currentMoleculeSet, ref); super.currentMolecule = atomC; // currentMolecule.setID(ref); } } } else { super.startElement(xpath, uri, local, raw, atts); } } public void endElement(CMLStack xpath, String uri, String local, String raw) { if ("reaction".equals(local)) { // cdo.endObject("Reaction"); currentReactionSet.addReaction(currentReaction); } else if ("reactionList".equals(local)) { // cdo.endObject("ReactionSet"); currentChemModel.setReactionSet(currentReactionSet); currentChemSequence.addChemModel(currentChemModel); /* FIXME: this should be when document is closed! */ } else if ("reactant".equals(local)) { // cdo.endObject("Reactant"); currentReaction.addReactant((IMolecule)currentMolecule); } else if ("product".equals(local)) { // cdo.endObject("Product"); currentReaction.addProduct((IMolecule)currentMolecule); } else if ("substance".equals(local)) { // cdo.endObject("Agent"); currentReaction.addAgent((IMolecule)currentMolecule); } else if ("molecule".equals(local)) { logger.debug("Storing Molecule"); //if the current molecule exists in the currentMoleculeSet means that is a reference in these. if(currentMoleculeSet.getMultiplier(currentMolecule) == -1) super.storeData(); // do nothing else but store atom/bond information } else { super.endElement(xpath, uri, local, raw); } } /** * Get the IMolecule contained in a IMoleculeSet object with a ID. * * @param molSet The IMoleculeSet * @param id The ID the look * @return The IMolecule with the ID */ private IAtomContainer getMoleculeFromID(IMoleculeSet molSet, String id){ for (IAtomContainer mol : molSet.molecules()) { if (mol.getID().equals(id)) return mol; } return null; } } cdk-1.2.10/src/main/org/openscience/cdk/io/cml/CMLResolver.java100644 0 0 7674 11570154753 21231 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 1997-2007 Dan Gezelter * * Contact: cdk-devel@lists.sourceforge.net * * This library 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. * * This library 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 library; if not, write to the Free Software * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. */ package org.openscience.cdk.io.cml; import java.io.BufferedReader; import java.io.InputStream; import java.io.InputStreamReader; import org.openscience.cdk.tools.LoggingTool; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; /** * This class resolves DOCTYPE declaration for Chemical Markup Language (CML) * files and uses a local version for validation. More information about * CML can be found at http://www.xml-cml.org/. * * @cdk.module io * @cdk.githash * * @author Egon Willighagen **/ public class CMLResolver implements EntityResolver { private LoggingTool logger; public CMLResolver() { logger = new LoggingTool(this); } /** * Not implemented: always returns null. **/ public InputSource getExternalSubset(String name, String baseURI) { return null; } /** * Not implemented, but uses resolveEntity(String publicId, String systemId) * instead. **/ public InputSource resolveEntity(String name, String publicId, String baseURI, String systemId) { return resolveEntity(publicId, systemId); } /** * Resolves SYSTEM and PUBLIC identifiers for CML DTDs. * * @param publicId the PUBLIC identifier of the DTD (unused) * @param systemId the SYSTEM identifier of the DTD * @return the CML DTD as an InputSource or null if id's unresolvable */ public InputSource resolveEntity (String publicId, String systemId) { logger.debug("CMLResolver: resolving ", publicId, ", ", systemId); systemId = systemId.toLowerCase(); if ((systemId.indexOf("cml-1999-05-15.dtd") != -1) || (systemId.indexOf("cml.dtd") != -1) || (systemId.indexOf("cml1_0.dtd") != -1)) { logger.info("File has CML 1.0 DTD"); return getCMLType( "cml1_0.dtd" ); } else if ((systemId.indexOf("cml-2001-04-06.dtd") != -1) || (systemId.indexOf("cml1_0_1.dtd") != -1) || (systemId.indexOf("cml_1_0_1.dtd") != -1)) { logger.info("File has CML 1.0.1 DTD"); return getCMLType( "cml1_0_1.dtd" ); } else { logger.warn("Could not resolve systemID: ", systemId); return null; } } /** * Returns an InputSource of the appropriate CML DTD. It accepts * two CML DTD names: cml1_0.dtd and cml1_0_1.dtd. Returns null * for any other name. * * @param type the name of the CML DTD version * @return the InputSource to the CML DTD */ private InputSource getCMLType( String type ) { try { InputStream ins = this.getClass().getClassLoader().getResourceAsStream("org/openscience/cdk/io/cml/data/" + type); return new InputSource(new BufferedReader(new InputStreamReader(ins))); } catch (Exception e) { logger.error("Error while trying to read CML DTD (" + type + "): ", e.getMessage()); logger.debug(e); return null; } } } cdk-1.2.10/src/main/org/openscience/cdk/io/cml/CMLStack.java100644 0 0 6342 11570154753 20464 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 1997-2007 Egon Willighagen * * 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 org.openscience.cdk.io.cml; import org.openscience.cdk.annotations.TestClass; import org.openscience.cdk.annotations.TestMethod; /** * Low weigth alternative to Sun's Stack class. * * @cdk.module io * @cdk.githash * * @cdk.keyword stack */ @TestClass("org.openscience.cdk.io.cml.CMLStackTest") public class CMLStack { String[] stack = new String[64]; int sp = 0; /** * Adds an entry to the stack. */ @TestMethod("testPush_String") public void push(String item) { if (sp == stack.length) { String[] temp = new String[2 * sp]; System.arraycopy(stack, 0, temp, 0, sp); stack = temp; } stack[sp++] = item; } public int length() { return sp; } /** * Retrieves and deletes to last added entry. * * @see #current() */ @TestMethod("testPop") public String pop() { return stack[--sp]; } /** * Returns the last added entry. * * @see #pop() */ @TestMethod("testCurrent") public String current() { if (sp > 0) { return stack[sp-1]; } else { return ""; } } /** * Returns a String representation of the stack. */ public String toString() { StringBuffer sb = new StringBuffer(); sb.append("/"); for (int i = 0; i < sp; ++i) { sb.append(stack[i]); sb.append("/"); } return sb.toString(); } /** * Convenience method to check the last added elements. */ @TestMethod("testEndsWith_String") public boolean endsWith(String lastElement) { return stack[sp-1].equals(lastElement); } /** * Convenience method to check the last two added elements. */ @TestMethod("testEndsWith_String_String") public boolean endsWith(String oneButLast, String lastElement) { return endsWith(lastElement) && stack[sp-2].equals(oneButLast); } /** * Convenience method to check the last three added elements. */ @TestMethod("testEndsWith_String_String_String") public boolean endsWith(String twoButLast, String oneButLast, String lastElement) { return endsWith(oneButLast,lastElement) && stack[sp-3].equals(twoButLast); } } cdk-1.2.10/src/main/org/openscience/cdk/io/cml/CustomSerializer.java100644 0 0 4637 11570154753 22374 0ustar 0 0 /* Copyright (C) 2009 Egon Willighagen * * 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 org.openscience.cdk.io.cml; import java.io.IOException; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import nu.xom.Serializer; /** * Custom {@link Serializer} with the sole purpose and functionality to not * output the XML declaration. * * @author egonw * @cdk.module libiocml */ public class CustomSerializer extends Serializer { /** * Instantiates a new {@link CustomSerializer} using the matching * {@link Serializer#Serializer(OutputStream)}. * * @param out the output stream to write the document on */ public CustomSerializer(OutputStream out) { super(out); } /** * Instantiates a new {@link CustomSerializer} using the matching * {@link Serializer#Serializer(OutputStream, String)}. * * @param out the output stream to write the document on * @param encoding the character encoding for the serialization */ public CustomSerializer(OutputStream out, String encoding) throws UnsupportedEncodingException { super(out, encoding); } /** * Overwrite the {@link Serializer#writeXMLDeclaration()} method, and have * it not output the XML declaration. */ protected void writeXMLDeclaration() throws IOException { // do nothing } } cdk-1.2.10/src/main/org/openscience/cdk/io/cml/ICMLConvention.java100644 0 0 2733 11570154753 21652 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 1997-2007 Egon Willighagen * * 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 org.openscience.cdk.io.cml; /** * This interface describes the procedures classes must implement to be plugable * into the CMLHandler. Most procedures reflect those in SAX2. * * @cdk.module io * @cdk.githash * * @author Egon Willighagen **/ public interface ICMLConvention extends ICMLModule { } cdk-1.2.10/src/main/org/openscience/cdk/io/cml/ICMLModule.java100644 0 0 3564 11570154753 20760 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 1997-2007 Egon Willighagen * * 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 org.openscience.cdk.io.cml; import org.openscience.cdk.interfaces.IChemFile; import org.xml.sax.Attributes; /** * This interface describes the procedures classes must implement to be plugable * into the CMLHandler. Most procedures reflect those in SAX2. * * @cdk.module io * @cdk.githash * * @author Egon Willighagen **/ public interface ICMLModule{ void startDocument(); void endDocument(); void startElement(CMLStack xpath, String uri, String local, String raw, Attributes atts); void endElement(CMLStack xpath, String uri, String local, String raw); void characterData(CMLStack xpath, char ch[], int start, int length); IChemFile returnChemFile(); void inherit(ICMLModule conv); } cdk-1.2.10/src/main/org/openscience/cdk/io/cml/JMOLANIMATIONConvention.java100644 0 0 10635 11570154753 23147 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 1997-2007 Egon Willighagen * * 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 org.openscience.cdk.io.cml; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.tools.LoggingTool; import org.xml.sax.Attributes; /** * @author Egon Willighagen * * @cdk.module io * @cdk.githash */ public class JMOLANIMATIONConvention extends CMLCoreModule { private final int UNKNOWN = -1; private final int ENERGY = 1; private int current; private String frame_energy; private LoggingTool logger; public JMOLANIMATIONConvention(IChemFile chemFile) { super(chemFile); logger = new LoggingTool(this); current = UNKNOWN; } public JMOLANIMATIONConvention(ICMLModule conv) { super(conv); logger = new LoggingTool(this); } public void startElement(CMLStack xpath, String uri, String local, String raw, Attributes atts) { String name = local; if (name.equals("list")) { logger.debug("Oke, JMOLANIMATION seems to be kicked in :)"); // cdo.startObject("Animation"); currentChemSequence = currentChemFile.getBuilder().newChemSequence(); super.startElement(xpath, uri, local, raw, atts); } else if (name.equals("molecule")) { // cdo.startObject("Frame"); currentChemModel = currentChemFile.getBuilder().newChemModel(); logger.debug("New frame being parsed."); super.startElement(xpath, uri, local, raw, atts); } else if (name.equals("float")) { boolean isEnergy = false; logger.debug("FLOAT found!"); for (int i = 0; i < atts.getLength(); i++) { logger.debug(" att: ", atts.getQName(i), " -> ", atts.getValue(i)); if (atts.getQName(i).equals("title") && atts.getValue(i).equals("FRAME_ENERGY")) { isEnergy = true; } } if (isEnergy) { // oke, this is the frames energy! current = ENERGY; } else { super.startElement(xpath, uri, local, raw, atts); } } else { super.startElement(xpath, uri, local, raw, atts); } } public void endElement(CMLStack xpath, String uri, String local, String raw) { String name = local; if (current == ENERGY) { // cdo.setObjectProperty("Frame", "energy", frame_energy); // + " " + units); // FIXME: does not have a ChemFileCDO equivalent current = UNKNOWN; frame_energy = ""; } else if (name.equals("list")) { super.endElement(xpath, uri, local, raw); // cdo.endObject("Animation"); currentChemFile.addChemSequence(currentChemSequence); } else if (name.equals("molecule")) { super.endElement(xpath, uri, local, raw); // cdo.endObject("Frame"); // nothing done in the CD upon this event } else { super.endElement(xpath, uri, local, raw); } } public void characterData(CMLStack xpath, char ch[], int start, int length) { if (current == ENERGY) { frame_energy = new String(ch, start, length); } else { super.characterData(xpath, ch, start, length); } } } cdk-1.2.10/src/main/org/openscience/cdk/io/cml/MDLMolConvention.java100644 0 0 5142 11570154753 22207 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 1997-2007 Egon Willighagen * * 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 org.openscience.cdk.io.cml; import org.openscience.cdk.interfaces.IChemFile; import org.xml.sax.Attributes; /** * Implementation of the MDLMol Covention for CML. * * @cdk.module io * @cdk.githash * * @author Egon Willighagen */ public class MDLMolConvention extends CMLCoreModule { public MDLMolConvention(IChemFile chemFile) { super(chemFile); } public MDLMolConvention(ICMLModule conv) { super(conv); } public void startDocument() { super.startDocument(); // cdo.startObject("Frame"); currentChemModel = currentChemFile.getBuilder().newChemModel(); } public void startElement(CMLStack xpath, String uri, String local, String raw, Attributes atts) { logger.debug("MDLMol element: name"); super.startElement(xpath, uri, local, raw, atts); } public void characterData(CMLStack xpath, char ch[], int start, int length) { String s = new String(ch, start, length).trim(); if (xpath.toString().endsWith("string/") && BUILTIN.equals("stereo")) { stereoGiven = true; if (s.trim().equals("W")) { logger.debug("CML W stereo found"); bondStereo.add("1"); } else if (s.trim().equals("H")) { logger.debug("CML H stereo found"); bondStereo.add("6"); } } else { super.characterData(xpath, ch, start, length); } } } cdk-1.2.10/src/main/org/openscience/cdk/io/cml/MDMoleculeConvention.java100644 0 0 17245 11570154753 23140 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 2007 Ola Spjuth * * 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 org.openscience.cdk.io.cml; import org.openscience.cdk.interfaces.IAtom; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.libio.md.ChargeGroup; import org.openscience.cdk.libio.md.MDMolecule; import org.openscience.cdk.libio.md.Residue; import org.xml.sax.Attributes; /** * * Implements a Convention for parsing an MDMolecule from CML. * * @cdk.module libiomd * @cdk.githash * * @author Ola Spjuth * */ public class MDMoleculeConvention extends CMLCoreModule { private Residue currentResidue; private ChargeGroup currentChargeGroup; public MDMoleculeConvention(IChemFile chemFile) { super(chemFile); } public MDMoleculeConvention(ICMLModule conv) { super(conv); } /** * Add parsing of elements in mdmolecule: * * mdmolecule * chargeGroup * id * cgNumber * atomArray * switchingAtom * residue * id * title * resNumber * atomArray * * @cdk.todo The JavaDoc of this class needs to be converted into HTML */ public void startElement(CMLStack xpath, String uri, String local, String raw, Attributes atts) { // // // // // // // 5 // // // // // // // 3 // // // // // // // let the CMLCore convention deal with things first if ("molecule".equals(local)) { // the copy the parsed content into a new MDMolecule if (atts.getValue("convention") != null && atts.getValue("convention").equals("md:mdMolecule")) { // System.out.println("creating a MDMolecule"); super.startElement(xpath, uri, local, raw, atts); currentMolecule = new MDMolecule(currentMolecule); } else { DICTREF = atts.getValue("dictRef") != null ? atts.getValue("dictRef") : ""; //If residue or chargeGroup, set up a new one if (DICTREF.equals("md:chargeGroup")){ // System.out.println("Creating a new charge group..."); currentChargeGroup = new ChargeGroup(); } else if (DICTREF.equals("md:residue")){ // System.out.println("Creating a new residue group..."); currentResidue = new Residue(); if (atts.getValue("title")!=null) currentResidue.setName(atts.getValue("title")); } } } else //We have a scalar element. Now check who it belongs to if ("scalar".equals(local)) { DICTREF = atts.getValue("dictRef"); //Switching Atom if ("md:switchingAtom".equals(DICTREF)){ //Set current atom as switching atom System.out.println("Adding Switching atom: " + currentAtom); currentChargeGroup.setSwitchingAtom(currentAtom); } else { super.startElement(xpath, uri, local, raw, atts); } } else if ("atom".equals(local)) { if (currentChargeGroup != null) { String id = atts.getValue("ref"); if (id != null) { // ok, an atom is referenced; look it up currentAtom = null; // System.out.println("#atoms: " + currentMolecule.getAtomCount()); for (IAtom nextAtom : currentMolecule.atoms()) { if (nextAtom.getID().equals(id)) { currentAtom = nextAtom; } } if (currentAtom == null) { logger.error("Could not found the referenced atom '" + id + "' for this charge group!"); } else { currentChargeGroup.addAtom(currentAtom); } } } else if (currentResidue != null) { String id = atts.getValue("ref"); if (id != null) { // ok, an atom is referenced; look it up IAtom referencedAtom = null; // System.out.println("#atoms: " + currentMolecule.getAtomCount()); for (IAtom nextAtom : currentMolecule.atoms()) { if (nextAtom.getID().equals(id)) { referencedAtom = nextAtom; } } if (referencedAtom == null) { logger.error("Could not found the referenced atom '" + id + "' for this residue!"); } else { currentResidue.addAtom(referencedAtom); } } } else { // ok, fine, just add it to the currentMolecule super.startElement(xpath, uri, local, raw, atts); } } else { super.startElement(xpath, uri, local, raw, atts); } } /** * Finish up parsing of elements in mdmolecule */ public void endElement(CMLStack xpath, String uri, String name, String raw) { if (name.equals("molecule")){ // System.out.println("Ending element mdmolecule"); // add chargeGroup, and then delete them if (currentChargeGroup != null) { if (currentMolecule instanceof MDMolecule) { ((MDMolecule)currentMolecule).addChargeGroup(currentChargeGroup); } else { logger.error("Need to store a charge group, but the current molecule is not a MDMolecule!"); } currentChargeGroup = null; } else // add chargeGroup, and then delete them if (currentResidue != null) { if (currentMolecule instanceof MDMolecule) { ((MDMolecule)currentMolecule).addResidue(currentResidue); } else { logger.error("Need to store a residue group, but the current molecule is not a MDMolecule!"); } currentResidue = null; } else { // System.out.println("OK, that was the last end mdmolecule"); super.endElement(xpath, uri, name, raw); } } else if ("atomArray".equals(name)) { if (xpath.length() == 2 && xpath.endsWith("molecule", "atomArray")) { storeAtomData(); } else if (xpath.length() > 2 && xpath.endsWith("cml", "molecule", "atomArray")) { storeAtomData(); } } else if ("bondArray".equals(name)) { if (xpath.length() == 2 && xpath.endsWith("molecule", "bondArray")) { storeBondData(); } else if (xpath.length() > 2 && xpath.endsWith("cml", "molecule", "bondArray")) { storeBondData(); } } else if ("scalar".equals(name)) { //Residue number if ("md:resNumber".equals(DICTREF)){ int myInt=Integer.parseInt(currentChars); currentResidue.setNumber(myInt); } //ChargeGroup number else if ("md:cgNumber".equals(DICTREF)){ int myInt=Integer.parseInt(currentChars); currentChargeGroup.setNumber(myInt); } } else { super.endElement(xpath, uri, name, raw); } } } cdk-1.2.10/src/main/org/openscience/cdk/io/cml/PDBConvention.java100644 0 0 62151 11570154753 21553 0ustar 0 0 /* $Revision$ $Author$ $Date$ * * Copyright (C) 1997-2007 Egon Willighagen * * 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 org.openscience.cdk.io.cml; import java.util.ArrayList; import java.util.List; import java.util.StringTokenizer; import javax.vecmath.Point2d; import javax.vecmath.Point3d; import org.openscience.cdk.CDKConstants; import org.openscience.cdk.config.IsotopeFactory; import org.openscience.cdk.interfaces.IChemFile; import org.openscience.cdk.interfaces.ICrystal; import org.openscience.cdk.interfaces.IMolecule; import org.openscience.cdk.interfaces.IPDBAtom; import org.openscience.cdk.interfaces.IPDBMonomer; import org.openscience.cdk.interfaces.IPDBPolymer; import org.openscience.cdk.interfaces.IPseudoAtom; import org.xml.sax.Attributes; /** * Implements the PDB convention used by PDB2CML. * *

This is a lousy implementation, though. Problems that will arise: *