Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merged branch cdk-1.4.x

  • Loading branch information...
commit 54eee52e28b80237bb0c95bfb017150e63775cc0 2 parents 1ef89fb + 8a01b8e
@egonw egonw authored
Showing with 549,724 additions and 540 deletions.
  1. +1 −0  AUTHORS
  2. +1 −1  build.xml
  3. +5 −5 javadoc.xml
  4. +1 −1  src/META-INF/builder3d.libdepends
  5. +1 −1  src/META-INF/builder3dtools.libdepends
  6. +1 −1  src/META-INF/charges.libdepends
  7. +1 −1  src/META-INF/control.libdepends
  8. +1 −1  src/META-INF/data.libdepends
  9. +1 −1  src/META-INF/datadebug.libdepends
  10. +1 −1  src/META-INF/dict.libdepends
  11. +1 −1  src/META-INF/diff.libdepends
  12. +2 −2 src/META-INF/extra.libdepends
  13. +1 −1  src/META-INF/fingerprint.libdepends
  14. +1 −1  src/META-INF/forcefield.libdepends
  15. +1 −1  src/META-INF/formula.libdepends
  16. +2 −2 src/META-INF/inchi.libdepends
  17. +1 −1  src/META-INF/interfaces.libdepends
  18. +1 −1  src/META-INF/io.libdepends
  19. +1 −1  src/META-INF/isomorphism.libdepends
  20. +2 −2 src/META-INF/libiocml.libdepends
  21. +1 −1  src/META-INF/libiomd.libdepends
  22. +1 −1  src/META-INF/log4j.libdepends
  23. +1 −1  src/META-INF/nonotify.libdepends
  24. +2 −2 src/META-INF/pcore.libdepends
  25. +1 −1  src/META-INF/pdb.libdepends
  26. +1 −1  src/META-INF/pdbcml.libdepends
  27. +1 −1  src/META-INF/qm.libdepends
  28. +2 −2 src/META-INF/qsar.libdepends
  29. +2 −2 src/META-INF/qsaratomic.libdepends
  30. +2 −2 src/META-INF/qsarbond.libdepends
  31. +1 −1  src/META-INF/qsarcml.libdepends
  32. +2 −2 src/META-INF/qsarmolecular.libdepends
  33. +2 −2 src/META-INF/qsarprotein.libdepends
  34. +2 −2 src/META-INF/reaction.libdepends
  35. +1 −1  src/META-INF/render.libdepends
  36. +1 −1  src/META-INF/sdg.libdepends
  37. +1 −1  src/META-INF/smarts.libdepends
  38. +1 −1  src/META-INF/smiles.libdepends
  39. +1 −1  src/META-INF/standard.libdepends
  40. +2 −2 src/META-INF/test-atomtype.libdepends
  41. +2 −2 src/META-INF/test-builder3d.libdepends
  42. +2 −2 src/META-INF/test-charges.libdepends
  43. +2 −2 src/META-INF/test-core.libdepends
  44. +2 −2 src/META-INF/test-data.libdepends
  45. +2 −2 src/META-INF/test-datadebug.libdepends
  46. +2 −2 src/META-INF/test-diff.libdepends
  47. +3 −3 src/META-INF/test-extra.libdepends
  48. +2 −2 src/META-INF/test-fingerprint.libdepends
  49. +2 −2 src/META-INF/test-forcefield.libdepends
  50. +3 −3 src/META-INF/test-formula.libdepends
  51. +3 −3 src/META-INF/test-inchi.libdepends
  52. +2 −2 src/META-INF/test-interfaces.libdepends
  53. +3 −3 src/META-INF/test-io.libdepends
  54. +3 −3 src/META-INF/test-ioformats.libdepends
  55. +3 −3 src/META-INF/test-ionpot.libdepends
  56. +2 −2 src/META-INF/test-isomorphism.libdepends
  57. +3 −3 src/META-INF/test-libiocml.libdepends
  58. +3 −3 src/META-INF/test-libiomd.libdepends
  59. +2 −2 src/META-INF/test-nonotify.libdepends
  60. +3 −3 src/META-INF/test-pcore.libdepends
  61. +3 −3 src/META-INF/test-pdb.libdepends
  62. +1 −1  src/META-INF/test-qm.libdepends
  63. +3 −3 src/META-INF/test-qsar.libdepends
  64. +3 −3 src/META-INF/test-qsaratomic.libdepends
  65. +3 −3 src/META-INF/test-qsarbond.libdepends
  66. +3 −3 src/META-INF/test-qsarionpot.libdepends
  67. +3 −3 src/META-INF/test-qsarmolecular.libdepends
  68. +3 −3 src/META-INF/test-qsarprotein.libdepends
  69. +3 −3 src/META-INF/test-reaction.libdepends
  70. +2 −2 src/META-INF/test-render.libdepends
  71. +2 −2 src/META-INF/test-sdg.libdepends
  72. +2 −2 src/META-INF/test-smarts.libdepends
  73. +3 −3 src/META-INF/test-smiles.libdepends
  74. +3 −3 src/META-INF/test-standard.libdepends
  75. +2 −2 src/META-INF/test-structgen.libdepends
  76. +2 −2 src/META-INF/test-valencycheck.libdepends
  77. +2 −2 src/META-INF/test.libdepends
  78. +1 −1  src/META-INF/valencycheck.libdepends
  79. +3 −3 src/main/org/openscience/cdk/AtomContainerSet.java
  80. +24 −0 src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
  81. +548,187 −0 src/main/org/openscience/cdk/config/data/type_map.txt
  82. +9 −0 src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
  83. +2 −1  src/main/org/openscience/cdk/fingerprint/Fingerprinter.java
  84. +299 −0 src/main/org/openscience/cdk/fingerprint/HybridizationFingerprinter.java
  85. +6 −0 src/main/org/openscience/cdk/inchi/InChIToStructure.java
  86. +4 −3 src/main/org/openscience/cdk/io/MDLV2000Reader.java
  87. +170 −87 src/main/org/openscience/cdk/io/PDBReader.java
  88. +118 −13 src/main/org/openscience/cdk/io/PDBWriter.java
  89. +2 −0  src/main/org/openscience/cdk/io/iterator/IteratingMDLReader.java
  90. +2 −3 src/main/org/openscience/cdk/qsar/descriptors/molecular/BCUTDescriptor.java
  91. +7 −2 src/main/org/openscience/cdk/smiles/SmilesParser.java
  92. +2 −2 src/main/org/openscience/cdk/tautomers/InChITautomerGenerator.java
  93. +41 −0 src/test/data/mdl/error.sdf
  94. +17 −0 src/test/data/pdb/hetatm_only.pdb
  95. +7 −0 src/test/data/pdb/unk.pdb
  96. +21 −0 src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherFilesTest.java
  97. +19 −0 src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherSMILESTest.java
  98. +88 −3 src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java
  99. +35 −0 src/test/org/openscience/cdk/fingerprint/HybridizationFingerprinterTest.java
  100. +87 −0 src/test/org/openscience/cdk/inchi/InChIToStructureTest.java
  101. +134 −204 src/test/org/openscience/cdk/io/PDBReaderTest.java
  102. +129 −2 src/test/org/openscience/cdk/io/PDBWriterTest.java
  103. +3 −1 src/test/org/openscience/cdk/modulesuites/MinchiTests.java
  104. +2 −0  src/test/org/openscience/cdk/modulesuites/MstandardTests.java
  105. +82 −67 src/test/org/openscience/cdk/qsar/descriptors/molecular/MolecularDescriptorTest.java
  106. +76 −2 src/test/org/openscience/cdk/tautomers/InChITautomerGeneratorTest.java
View
1  AUTHORS
@@ -48,6 +48,7 @@ David Robinson
Miguel Rojas Cherto
Bhupinder Sandhu
Jean-Sebastien Senecal
+Onkar Shinde
Sulev Sild
Bradley Smith
Ola Spjuth
View
2  build.xml
@@ -975,7 +975,7 @@
<copy todir="${sourcedist.dir}/src/META-INF">
<fileset dir="src/META-INF" />
</copy>
- <copy todir="${sourcedist.dir}/${src}/org/openscience/cdk/config/data/">
+ <copy todir="${sourcedist.dir}/${src}/main/org/openscience/cdk/config/data/">
<fileset dir="${src}/main/org/openscience/cdk/config/data/"
includes="*" />
</copy>
View
10 javadoc.xml
@@ -12,7 +12,11 @@
<property name="doxygen.dir" value="doc/doxygen" />
<property name="pathtojava3d" value="" />
+
+ <!-- directories -->
<property name="build" value="build" />
+ <property name="lib" value="jar" />
+ <property name="devellib" value="develjar" />
<!-- Used in the html task to properly link to java library classes -->
<property name="javaURL" value="http://java.sun.com/j2se/1.5.0/docs/api/"/>
@@ -173,11 +177,7 @@
<fileset dir="${devellib}">
<exclude name="**/*" unless="module.devellibdepends.present" />
<includesfile name="${metainf}/${module}.devellibdepends" if="module.devellibdepends.present" />
- </fileset>
- <fileset dir="${dist}/jar">
- <exclude name="**/*" unless="module.cdkdepends.present" />
- <includesfile name="${metainf}/${module}.cdkdepends" if="module.cdkdepends.present" />
- </fileset>
+ </fileset>
</classpath>
<doclet name="com.github.ojdcheck.OpenJavaDocCheck"
View
2  src/META-INF/builder3d.libdepends
@@ -1,3 +1,3 @@
jama-1.0.2.jar
-vecmath1.2-1.14.jar
+vecmath*.jar
View
2  src/META-INF/builder3dtools.libdepends
@@ -1,2 +1,2 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
View
2  src/META-INF/charges.libdepends
@@ -1,3 +1,3 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
jgrapht-0.6.0.jar
View
2  src/META-INF/control.libdepends
@@ -1,2 +1,2 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
View
2  src/META-INF/data.libdepends
@@ -1 +1 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
View
2  src/META-INF/datadebug.libdepends
@@ -1 +1 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
View
2  src/META-INF/dict.libdepends
@@ -1 +1 @@
-xom-1.1.jar
+xom*.jar
View
2  src/META-INF/diff.libdepends
@@ -1 +1 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
View
4 src/META-INF/extra.libdepends
@@ -1,3 +1,3 @@
jama-1.0.2.jar
-vecmath1.2-1.14.jar
-xom-1.1.jar
+vecmath*.jar
+xom*.jar
View
2  src/META-INF/fingerprint.libdepends
@@ -1 +1 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
View
2  src/META-INF/forcefield.libdepends
@@ -1,3 +1,3 @@
jama-1.0.2.jar
-vecmath1.2-1.14.jar
+vecmath*.jar
View
2  src/META-INF/formula.libdepends
@@ -1,2 +1,2 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
View
4 src/META-INF/inchi.libdepends
@@ -1,4 +1,4 @@
-vecmath1.2-1.14.jar
-xom-1.1.jar
+vecmath*.jar
+xom*.jar
jniinchi-0.7.jar
cmlxom-2.5-b1.jar
View
2  src/META-INF/interfaces.libdepends
@@ -1 +1 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
View
2  src/META-INF/io.libdepends
@@ -1,2 +1,2 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
xpp3-1.1.4c.jar
View
2  src/META-INF/isomorphism.libdepends
@@ -1,2 +1,2 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
jgrapht-0.6.0.jar
View
4 src/META-INF/libiocml.libdepends
@@ -1,4 +1,4 @@
-vecmath1.2-1.14.jar
-xom-1.1.jar
+vecmath*.jar
+xom*.jar
cmlxom-2.5-b1.jar
View
2  src/META-INF/libiomd.libdepends
@@ -1,2 +1,2 @@
cmlxom-2.5-b1.jar
-xom-1.1.jar
+xom*.jar
View
2  src/META-INF/log4j.libdepends
@@ -1 +1 @@
-log4j.jar
+log4j*.jar
View
2  src/META-INF/nonotify.libdepends
@@ -1 +1 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
View
4 src/META-INF/pcore.libdepends
@@ -1,2 +1,2 @@
-vecmath1.2-1.14.jar
-xom-1.1.jar
+vecmath*.jar
+xom*.jar
View
2  src/META-INF/pdb.libdepends
@@ -1,2 +1,2 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
View
2  src/META-INF/pdbcml.libdepends
@@ -1,2 +1,2 @@
-xom-1.1.jar
+xom*.jar
cmlxom-2.5-b1.jar
View
2  src/META-INF/qm.libdepends
@@ -1 +1 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
View
4 src/META-INF/qsar.libdepends
@@ -1,4 +1,4 @@
jama-1.0.2.jar
jgrapht-0.6.0.jar
-vecmath1.2-1.14.jar
-xom-1.1.jar
+vecmath*.jar
+xom*.jar
View
4 src/META-INF/qsaratomic.libdepends
@@ -1,4 +1,4 @@
jama-1.0.2.jar
jgrapht-0.6.0.jar
-vecmath1.2-1.14.jar
-xom-1.1.jar
+vecmath*.jar
+xom*.jar
View
4 src/META-INF/qsarbond.libdepends
@@ -1,4 +1,4 @@
jama-1.0.2.jar
jgrapht-0.6.0.jar
-vecmath1.2-1.14.jar
-xom-1.1.jar
+vecmath*.jar
+xom*.jar
View
2  src/META-INF/qsarcml.libdepends
@@ -1,2 +1,2 @@
-xom-1.1.jar
+xom*.jar
cmlxom-2.5-b1.jar
View
4 src/META-INF/qsarmolecular.libdepends
@@ -1,4 +1,4 @@
jama-1.0.2.jar
jgrapht-0.6.0.jar
-vecmath1.2-1.14.jar
-xom-1.1.jar
+vecmath*.jar
+xom*.jar
View
4 src/META-INF/qsarprotein.libdepends
@@ -1,4 +1,4 @@
jama-1.0.2.jar
jgrapht-0.6.0.jar
-vecmath1.2-1.14.jar
-xom-1.1.jar
+vecmath*.jar
+xom*.jar
View
4 src/META-INF/reaction.libdepends
@@ -1,4 +1,4 @@
jgrapht-0.6.0.jar
-vecmath1.2-1.14.jar
-xom-1.1.jar
+vecmath*.jar
+xom*.jar
View
2  src/META-INF/render.libdepends
@@ -1,2 +1,2 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
View
2  src/META-INF/sdg.libdepends
@@ -1,2 +1,2 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
View
2  src/META-INF/smarts.libdepends
@@ -1 +1 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
View
2  src/META-INF/smiles.libdepends
@@ -1 +1 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
View
2  src/META-INF/standard.libdepends
@@ -1,2 +1,2 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
jgrapht-0.6.0.jar
View
4 src/META-INF/test-atomtype.libdepends
@@ -1,3 +1,3 @@
-log4j.jar
-vecmath1.2-1.14.jar
+log4j*.jar
+vecmath*.jar
jgrapht-0.6.0.jar
View
4 src/META-INF/test-builder3d.libdepends
@@ -1,4 +1,4 @@
jama-1.0.2.jar
-vecmath1.2-1.14.jar
-log4j.jar
+vecmath*.jar
+log4j*.jar
jgrapht-0.6.0.jar
View
4 src/META-INF/test-charges.libdepends
@@ -1,3 +1,3 @@
-vecmath1.2-1.14.jar
-log4j.jar
+vecmath*.jar
+log4j*.jar
jgrapht-0.6.0.jar
View
4 src/META-INF/test-core.libdepends
@@ -1,3 +1,3 @@
-log4j.jar
-vecmath1.2-1.14.jar
+log4j*.jar
+vecmath*.jar
jgrapht-0.6.0.jar
View
4 src/META-INF/test-data.libdepends
@@ -1,2 +1,2 @@
-log4j.jar
-vecmath1.2-1.14.jar
+log4j*.jar
+vecmath*.jar
View
4 src/META-INF/test-datadebug.libdepends
@@ -1,2 +1,2 @@
-log4j.jar
-vecmath1.2-1.14.jar
+log4j*.jar
+vecmath*.jar
View
4 src/META-INF/test-diff.libdepends
@@ -1,2 +1,2 @@
-vecmath1.2-1.14.jar
-log4j.jar
+vecmath*.jar
+log4j*.jar
View
6 src/META-INF/test-extra.libdepends
@@ -1,6 +1,6 @@
jama-1.0.2.jar
jgrapht-0.6.0.jar
cmlxom-2.5-b1.jar
-log4j.jar
-vecmath1.2-1.14.jar
-xom-1.1.jar
+log4j*.jar
+vecmath*.jar
+xom*.jar
View
4 src/META-INF/test-fingerprint.libdepends
@@ -1,3 +1,3 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
jgrapht-0.6.0.jar
-log4j.jar
+log4j*.jar
View
4 src/META-INF/test-forcefield.libdepends
@@ -1,4 +1,4 @@
jama-1.0.2.jar
jgrapht-0.6.0.jar
-log4j.jar
-vecmath1.2-1.14.jar
+log4j*.jar
+vecmath*.jar
View
6 src/META-INF/test-formula.libdepends
@@ -1,5 +1,5 @@
jama-1.0.2.jar
jgrapht-0.6.0.jar
-log4j.jar
-vecmath1.2-1.14.jar
-xom-1.1.jar
+log4j*.jar
+vecmath*.jar
+xom*.jar
View
6 src/META-INF/test-inchi.libdepends
@@ -1,5 +1,5 @@
-vecmath1.2-1.14.jar
-xom-1.1.jar
+vecmath*.jar
+xom*.jar
jniinchi-0.7.jar
cmlxom-2.5-b1.jar
-log4j.jar
+log4j*.jar
View
4 src/META-INF/test-interfaces.libdepends
@@ -1,2 +1,2 @@
-vecmath1.2-1.14.jar
-log4j.jar
+vecmath*.jar
+log4j*.jar
View
6 src/META-INF/test-io.libdepends
@@ -1,6 +1,6 @@
jgrapht-0.6.0.jar
cmlxom-2.5-b1.jar
-log4j.jar
-vecmath1.2-1.14.jar
-xom-1.1.jar
+log4j*.jar
+vecmath*.jar
+xom*.jar
xpp3-1.1.4c.jar
View
6 src/META-INF/test-ioformats.libdepends
@@ -1,6 +1,6 @@
jgrapht-0.6.0.jar
cmlxom-2.5-b1.jar
-log4j.jar
-vecmath1.2-1.14.jar
-xom-1.1.jar
+log4j*.jar
+vecmath*.jar
+xom*.jar
xpp3-1.1.4c.jar
View
6 src/META-INF/test-ionpot.libdepends
@@ -1,5 +1,5 @@
jama-1.0.2.jar
jgrapht-0.6.0.jar
-log4j.jar
-vecmath1.2-1.14.jar
-xom-1.1.jar
+log4j*.jar
+vecmath*.jar
+xom*.jar
View
4 src/META-INF/test-isomorphism.libdepends
@@ -1,3 +1,3 @@
-vecmath1.2-1.14.jar
-log4j.jar
+vecmath*.jar
+log4j*.jar
jgrapht-0.6.0.jar
View
6 src/META-INF/test-libiocml.libdepends
@@ -1,5 +1,5 @@
-vecmath1.2-1.14.jar
-log4j.jar
+vecmath*.jar
+log4j*.jar
cmlxom-2.5-b1.jar
-xom-1.1.jar
+xom*.jar
jgrapht-0.6.0.jar
View
6 src/META-INF/test-libiomd.libdepends
@@ -1,4 +1,4 @@
-vecmath1.2-1.14.jar
-log4j.jar
+vecmath*.jar
+log4j*.jar
cmlxom-2.5-b1.jar
-xom-1.1.jar
+xom*.jar
View
4 src/META-INF/test-nonotify.libdepends
@@ -1,2 +1,2 @@
-log4j.jar
-vecmath1.2-1.14.jar
+log4j*.jar
+vecmath*.jar
View
6 src/META-INF/test-pcore.libdepends
@@ -1,4 +1,4 @@
jgrapht-0.6.0.jar
-log4j.jar
-vecmath1.2-1.14.jar
-xom-1.1.jar
+log4j*.jar
+vecmath*.jar
+xom*.jar
View
6 src/META-INF/test-pdb.libdepends
@@ -1,4 +1,4 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
-log4j.jar
-vecmath1.2-1.14.jar
+log4j*.jar
+vecmath*.jar
View
2  src/META-INF/test-qm.libdepends
@@ -1 +1 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
View
6 src/META-INF/test-qsar.libdepends
@@ -1,5 +1,5 @@
-vecmath1.2-1.14.jar
-log4j.jar
+vecmath*.jar
+log4j*.jar
jama-1.0.2.jar
jgrapht-0.6.0.jar
-xom-1.1.jar
+xom*.jar
View
6 src/META-INF/test-qsaratomic.libdepends
@@ -1,5 +1,5 @@
-vecmath1.2-1.14.jar
-log4j.jar
+vecmath*.jar
+log4j*.jar
jama-1.0.2.jar
jgrapht-0.6.0.jar
-xom-1.1.jar
+xom*.jar
View
6 src/META-INF/test-qsarbond.libdepends
@@ -1,5 +1,5 @@
-vecmath1.2-1.14.jar
-log4j.jar
+vecmath*.jar
+log4j*.jar
jama-1.0.2.jar
jgrapht-0.6.0.jar
-xom-1.1.jar
+xom*.jar
View
6 src/META-INF/test-qsarionpot.libdepends
@@ -1,5 +1,5 @@
-vecmath1.2-1.14.jar
-log4j.jar
+vecmath*.jar
+log4j*.jar
jama-1.0.2.jar
jgrapht-0.6.0.jar
-xom-1.1.jar
+xom*.jar
View
6 src/META-INF/test-qsarmolecular.libdepends
@@ -1,5 +1,5 @@
-vecmath1.2-1.14.jar
-log4j.jar
+vecmath*.jar
+log4j*.jar
jama-1.0.2.jar
jgrapht-0.6.0.jar
-xom-1.1.jar
+xom*.jar
View
6 src/META-INF/test-qsarprotein.libdepends
@@ -1,5 +1,5 @@
-vecmath1.2-1.14.jar
-log4j.jar
+vecmath*.jar
+log4j*.jar
jama-1.0.2.jar
jgrapht-0.6.0.jar
-xom-1.1.jar
+xom*.jar
View
6 src/META-INF/test-reaction.libdepends
@@ -1,5 +1,5 @@
jama-1.0.2.jar
jgrapht-0.6.0.jar
-log4j.jar
-vecmath1.2-1.14.jar
-xom-1.1.jar
+log4j*.jar
+vecmath*.jar
+xom*.jar
View
4 src/META-INF/test-render.libdepends
@@ -1,2 +1,2 @@
-log4j.jar
-vecmath1.2-1.14.jar
+log4j*.jar
+vecmath*.jar
View
4 src/META-INF/test-sdg.libdepends
@@ -1,3 +1,3 @@
-log4j.jar
-vecmath1.2-1.14.jar
+log4j*.jar
+vecmath*.jar
jgrapht-0.6.0.jar
View
4 src/META-INF/test-smarts.libdepends
@@ -1,3 +1,3 @@
jgrapht-0.6.0.jar
-log4j.jar
-vecmath1.2-1.14.jar
+log4j*.jar
+vecmath*.jar
View
6 src/META-INF/test-smiles.libdepends
@@ -1,5 +1,5 @@
jgrapht-0.6.0.jar
-log4j.jar
-vecmath1.2-1.14.jar
-xom-1.1.jar
+log4j*.jar
+vecmath*.jar
+xom*.jar
cmlxom-2.5-b1.jar
View
6 src/META-INF/test-standard.libdepends
@@ -1,5 +1,5 @@
-log4j.jar
+log4j*.jar
jgrapht-0.6.0.jar
-vecmath1.2-1.14.jar
+vecmath*.jar
cmlxom-2.5-b1.jar
-xom-1.1.jar
+xom*.jar
View
4 src/META-INF/test-structgen.libdepends
@@ -1,3 +1,3 @@
-log4j.jar
+log4j*.jar
jgrapht-0.6.0.jar
-vecmath1.2-1.14.jar
+vecmath*.jar
View
4 src/META-INF/test-valencycheck.libdepends
@@ -1,3 +1,3 @@
jgrapht-0.6.0.jar
-log4j.jar
-vecmath1.2-1.14.jar
+log4j*.jar
+vecmath*.jar
View
4 src/META-INF/test.libdepends
@@ -1,2 +1,2 @@
-vecmath1.2-1.14.jar
-log4j.jar
+vecmath*.jar
+log4j*.jar
View
2  src/META-INF/valencycheck.libdepends
@@ -1 +1 @@
-vecmath1.2-1.14.jar
+vecmath*.jar
View
6 src/main/org/openscience/cdk/AtomContainerSet.java
@@ -70,7 +70,7 @@
/** Constructs an empty AtomContainerSet. */
public AtomContainerSet() {
atomContainerCount = 0;
- atomContainers = new AtomContainer[growArraySize];
+ atomContainers = new IAtomContainer[growArraySize];
multipliers = new Double[growArraySize];
}
@@ -322,7 +322,7 @@ public Double getMultiplier(IAtomContainer container) {
*/
protected void growAtomContainerArray() {
growArraySize = atomContainers.length;
- AtomContainer[] newatomContainers = new AtomContainer[atomContainers.length + growArraySize];
+ IAtomContainer[] newatomContainers = new IAtomContainer[atomContainers.length + growArraySize];
System.arraycopy(atomContainers, 0, newatomContainers, 0, atomContainers.length);
atomContainers = newatomContainers;
Double[] newMultipliers = new Double[multipliers.length + growArraySize];
@@ -367,7 +367,7 @@ public String toString() {
*/
public Object clone() throws CloneNotSupportedException {
AtomContainerSet clone = (AtomContainerSet)super.clone();
- clone.atomContainers = new AtomContainer[atomContainerCount];
+ clone.atomContainers = new IAtomContainer[atomContainerCount];
clone.atomContainerCount = 0;
for (int i = 0; i < atomContainerCount; i++) {
clone.addAtomContainer((IAtomContainer)atomContainers[i].clone());
View
24 src/main/org/openscience/cdk/atomtype/CDKAtomTypeMatcher.java
@@ -128,6 +128,8 @@ public IAtomType findMatchingAtomType(IAtomContainer atomContainer, IAtom atom)
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())) {
@@ -173,6 +175,15 @@ private IAtomType perceiveSelenium(IAtomContainer atomContainer, IAtom atom) thr
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);
@@ -877,6 +888,9 @@ private IAtomType perceiveSulphurs(IAtomContainer atomContainer, IAtom atom)
} 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
@@ -912,11 +926,21 @@ private IAtomType perceivePhosphors(IAtomContainer atomContainer, IAtom atom)
} 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 (atom.getFormalCharge() != null &
atom.getFormalCharge().intValue() == 1) {
IAtomType type = getAtomType("P.anium");
if (isAcceptable(atom, atomContainer, type)) return type;
+ } else if (doubleBonds == 1) {
+ IAtomType type = getAtomType("P.ate");
+ if (isAcceptable(atom, atomContainer, type)) return type;
} else {
IAtomType type = getAtomType("P.ine");
if (isAcceptable(atom, atomContainer, type)) return type;
View
548,187 src/main/org/openscience/cdk/config/data/type_map.txt
548,187 additions, 0 deletions not shown
View
9 src/main/org/openscience/cdk/dict/data/cdk-atom-types.owl
@@ -1450,6 +1450,15 @@
<at:hybridization rdf:resource="&at;sp3"/>
</at:AtomType>
+ <at:AtomType rdf:ID="Te.3">
+ <at:formalCharge>0</at:formalCharge>
+ <at:hasElement rdf:resource="&elem;Te"/>
+ <at:formalNeighbourCount>2</at:formalNeighbourCount>
+ <at:lonePairCount>2</at:lonePairCount>
+ <at:piBondCount>0</at:piBondCount>
+ <at:hybridization rdf:resource="&at;sp3"/>
+ </at:AtomType>
+
<at:AtomType rdf:ID="Ga.3plus">
<at:formalCharge>3</at:formalCharge>
<at:hasElement rdf:resource="&elem;Ga"/>
View
3  src/main/org/openscience/cdk/fingerprint/Fingerprinter.java
@@ -59,7 +59,8 @@
*
* A fingerprint is generated for an AtomContainer with this code: <pre>
* Molecule molecule = new Molecule();
- * BitSet fingerprint = Fingerprinter.getFingerprint(molecule);
+ * IFingerprinter fingerprinter = new Fingerprinter();
+ * BitSet fingerprint = fingerprinter.getFingerprint(molecule);
* fingerprint.size(); // returns 1024 by default
* fingerprint.length(); // returns the highest set bit
* </pre> <p>
View
299 src/main/org/openscience/cdk/fingerprint/HybridizationFingerprinter.java
@@ -0,0 +1,299 @@
+/* Copyright (C) 2002-2007 Christoph Steinbeck <steinbeck@users.sf.net>
+ * 2009-2011 Egon Willighagen <egonw@users.sf.net>
+ *
+ * Contact: cdk-devel@lists.sourceforge.net
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser 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.ArrayList;
+import java.util.BitSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Random;
+import java.util.Set;
+
+import org.openscience.cdk.annotations.TestClass;
+import org.openscience.cdk.annotations.TestMethod;
+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.interfaces.IAtomType.Hybridization;
+import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
+import org.openscience.cdk.tools.periodictable.PeriodicTable;
+
+/**
+ * Generates a fingerprint for a given {@link IAtomContainer}. 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.
+ *
+ * <p>A fingerprint is generated for an AtomContainer with this code:<pre>
+ * Molecule molecule = new Molecule();
+ * IFingerprinter fingerprinter =
+ * new HybridizationFingerprinter();
+ * BitSet fingerprint = fingerprinter.getFingerprint(molecule);
+ * fingerprint.size(); // returns 1024 by default
+ * fingerprint.length(); // returns the highest set bit
+ * </pre></p>
+ *
+ * <p>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 Symbols}.
+ *
+ * <p>Unlike the {@link Fingerprinter}, this fingerprinter does not take into
+ * account aromaticity. Instead, it takes into account SP2
+ * {@link Hybridization}.
+ *
+ * @cdk.keyword fingerprint
+ * @cdk.keyword similarity
+ * @cdk.module standard
+ * @cdk.githash
+ */
+@TestClass("org.openscience.cdk.fingerprint.HybridizationFingerprinterTest")
+public class HybridizationFingerprinter 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 final Map<String, String> queryReplace
+ = new HashMap<String, String>() {
+
+ 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 <code>DEFAULT_SIZE</code>
+ * and with a search depth of <code>DEFAULT_SEARCH_DEPTH</code>.
+ */
+ public HybridizationFingerprinter() {
+ this(DEFAULT_SIZE, DEFAULT_SEARCH_DEPTH);
+ }
+
+ public HybridizationFingerprinter(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 HybridizationFingerprinter(int size, int searchDepth) {
+ this.size = size;
+ this.searchDepth = searchDepth;
+
+ }
+
+ /**
+ * Generates a fingerprint of the default size for the given AtomContainer.
+ *
+ * @param container The {@link IAtomContainer} for which a fingerprint is
+ * generated.
+ */
+ @TestMethod("testGetFingerprint_IAtomContainer")
+ public BitSet getFingerprint(IAtomContainer container) throws CDKException {
+ BitSet bitSet = new BitSet(size);
+
+ try {
+ IAtomContainer clonedContainer = (IAtomContainer)container.clone();
+ AtomContainerManipulator.
+ percieveAtomTypesAndConfigureUnsetProperties(clonedContainer);
+ int[] hashes = findPathes(clonedContainer, searchDepth);
+ for (int hash : hashes) {
+ bitSet.set(new Random(hash).nextInt(size));
+ }
+ } catch (CloneNotSupportedException exception) {
+ throw new CDKException(
+ "Exception while cloning the input: " + exception.getMessage(),
+ exception
+ );
+ }
+
+ return bitSet;
+ }
+
+ /**
+ * Get all paths of lengths 0 to the specified length.
+ * This method will find all paths up to 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<StringBuffer> allPaths = new ArrayList<StringBuffer>();
+
+ Map<IAtom,Map<IAtom, IBond>> cache
+ = new HashMap<IAtom, Map<IAtom,IBond>>();
+
+ for (IAtom startAtom : container.atoms()) {
+ List<List<IAtom>> p = PathTools.getPathsOfLengthUpto(
+ container, startAtom, searchDepth
+ );
+ for (List<IAtom> 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('0');
+ else {
+ Integer atnum = PeriodicTable.getAtomicNumber(x.getSymbol());
+ if (atnum != null) sb.append((char) atnum.intValue());
+ else sb.append('0');
+ }
+
+ for (int i = 1; i < path.size(); i++) {
+ final IAtom[] y = {path.get(i)};
+ Map<IAtom, IBond> 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<IAtom, IBond>() {
+ static final long serialVersionUID = 1L;
+ { 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<String> cleanPath = new HashSet<String>();
+ 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;
+ }
+
+ /**
+ * Maps two character element symbols unto unique single character
+ * equivalents.
+ */
+ private String convertSymbol(String symbol) {
+ String returnSymbol = queryReplace.get( symbol );
+ return returnSymbol == null ? symbol
+ : returnSymbol;
+ }
+
+
+ /**
+ * Gets the bond Symbol attribute of the Fingerprinter class.
+ *
+ * @return The bondSymbol value
+ */
+ protected String getBondSymbol(IBond bond) {
+ String bondSymbol = "";
+ if (bond.getOrder() == IBond.Order.SINGLE) {
+ if (isSP2Bond(bond)) {
+ bondSymbol = ":";
+ } else {
+ bondSymbol = "-";
+ }
+ } else if (bond.getOrder() == IBond.Order.DOUBLE) {
+ if (isSP2Bond(bond)) {
+ bondSymbol = ":";
+ } else {
+ bondSymbol = "=";
+ }
+ } else if (bond.getOrder() == IBond.Order.TRIPLE) {
+ bondSymbol = "#";
+ } else if (bond.getOrder() == IBond.Order.QUADRUPLE) {
+ bondSymbol = "*";
+ }
+ return bondSymbol;
+ }
+
+ /**
+ * Returns true if the bond binds two atoms, and both atoms are SP2.
+ */
+ private boolean isSP2Bond(IBond bond) {
+ if (bond.getAtomCount() == 2 &&
+ bond.getAtom(0).getHybridization() == Hybridization.SP2 &&
+ bond.getAtom(1).getHybridization() == Hybridization.SP2)
+ return true;
+ return false;
+ }
+
+ @TestMethod("testGetSearchDepth")
+ public int getSearchDepth() {
+ return searchDepth;
+ }
+
+ @TestMethod("testGetSize")
+ public int getSize() {
+ return size;
+ }
+
+}
+
View
6 src/main/org/openscience/cdk/inchi/InChIToStructure.java
@@ -38,6 +38,8 @@
import net.sf.jniinchi.JniInchiWrapper;
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;
@@ -80,6 +82,7 @@
* @cdk.module inchi
* @cdk.githash
*/
+@TestClass("org.openscience.cdk.inchi.InChIToStructureTest")
public class InChIToStructure {
protected JniInchiInputInchi input;
@@ -93,6 +96,7 @@
* @param inchi
* @throws CDKException
*/
+ @TestMethod("testConstructor_String_IChemObjectBuilder")
protected InChIToStructure(String inchi, IChemObjectBuilder builder) throws CDKException {
try {
input = new JniInchiInputInchi(inchi, "");
@@ -266,6 +270,7 @@ else if (stereo == INCHI_BOND_STEREO.SINGLE_1EITHER
* Returns generated molecule.
* @return An AtomContainer object
*/
+ @TestMethod("testGetAtomContainer")
public IAtomContainer getAtomContainer() {
return(molecule);
}
@@ -276,6 +281,7 @@ public IAtomContainer getAtomContainer() {
* InChI has been generated, in all other cases InChI generation
* has failed.
*/
+ @TestMethod("testGetReturnStatus_EOF")
public INCHI_RET getReturnStatus() {
return(output.getReturnStatus());
}
View
7 src/main/org/openscience/cdk/io/MDLV2000Reader.java
@@ -68,9 +68,10 @@
import org.openscience.cdk.isomorphism.matchers.QueryAtomContainer;
/**
- * 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.
+ * Reads a content from MDL molfiles and SD files.
+ * It can read a {@link IMolecule) or {@link IChemModel} from an MDL molfile, and
+ * a {@link IChemFile} from a SD file, with a {@link IChemSequence} of
+ * {@link IChemModel}'s, where each IChemModel will contain one IMolecule.
*
* <p>From the Atom block it reads atomic coordinates, element types and
* formal charges. From the Bond block it reads the bonds and the orders.
View
257 src/main/org/openscience/cdk/io/PDBReader.java
@@ -31,12 +31,14 @@
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Hashtable;
import java.util.Map;
import javax.vecmath.Point3d;
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.config.AtomTypeFactory;
@@ -45,7 +47,6 @@
import org.openscience.cdk.graph.rebond.RebondTool;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomType;
-import org.openscience.cdk.interfaces.IBioPolymer;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IChemFile;
import org.openscience.cdk.interfaces.IChemModel;
@@ -81,6 +82,7 @@
* @author Bradley Smith <bradley@baysmith.com>
* @author Martin Eklund <martin.eklund@farmbio.uu.se>
* @author Ola Spjuth <ola.spjuth@farmbio.uu.se>
+ * @author Gilleain Torrance <gilleain.torrance@gmail.com>
* @cdk.created 2001-08-06
* @cdk.keyword file format, PDB
* @cdk.bug 1714141
@@ -94,8 +96,9 @@
private BufferedReader _oInput; // The internal used BufferedReader
private BooleanIOSetting useRebondTool;
private BooleanIOSetting readConnect;
+ private BooleanIOSetting useHetDictionary;
- private Map atomNumberMap;
+ private Map<Integer, IAtom> atomNumberMap;
/*
* This is a temporary store for bonds from CONNECT records.
@@ -107,6 +110,17 @@
private static AtomTypeFactory pdbFactory;
/**
+ * A mapping between HETATM 3-letter codes + atomNames to CDK atom type
+ * names; for example "RFB.N13" maps to "N.planar3".
+ */
+ private Map<String, String> hetDictionary;
+
+ private AtomTypeFactory cdkAtomTypeFactory;
+
+ private static final String hetDictionaryPath =
+ "org/openscience/cdk/config/data/type_map.txt";
+
+ /**
*
* Constructs a new PDBReader that can read Molecules from a given
* InputStream.
@@ -130,6 +144,8 @@ public PDBReader(Reader oIn) {
_oInput = new BufferedReader(oIn);
initIOSettings();
pdbFactory = null;
+ hetDictionary = null;
+ cdkAtomTypeFactory = null;
}
public PDBReader() {
@@ -228,7 +244,7 @@ private IChemFile readChemFile(IChemFile oFile) {
boolean isProteinStructure = false;
- atomNumberMap = new Hashtable();
+ atomNumberMap = new Hashtable<Integer, IAtom>();
if (readConnect.isSet()) {
bondsFromConnectRecords = new ArrayList();
}
@@ -300,12 +316,13 @@ private IChemFile readChemFile(IChemFile oFile) {
// 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);
}
+
+ if (readConnect.isSet() && atomNumberMap.put(oAtom.getSerial(), oAtom) != null) {
+ logger.warn("Duplicate serial ID found for atom: ", oAtom);
+ }
logger.debug("Added ATOM: ", oAtom);
/** As HETATMs cannot be considered to either belong to a certain monomer or strand,
@@ -314,8 +331,12 @@ private IChemFile readChemFile(IChemFile oFile) {
// read an atom record
oAtom = readAtom(cRead, lineLength);
oAtom.setHetAtom(true);
- oBP.addAtom(oAtom);
- if (atomNumberMap.put(new Integer(oAtom.getSerial()), oAtom) != null) {
+ if (isProteinStructure) {
+ oBP.addAtom(oAtom);
+ } else {
+ molecularStructure.addAtom(oAtom);
+ }
+ if (atomNumberMap.put(oAtom.getSerial(), oAtom) != null) {
logger.warn("Duplicate serial ID found for atom: ", oAtom);
}
logger.debug("Added HETATM: ", oAtom);
@@ -329,22 +350,24 @@ private IChemFile readChemFile(IChemFile oFile) {
atomNumberMap.clear();
if (isProteinStructure) {
// create bonds and finish the molecule
+ oSet.addMolecule(oBP);
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);
- }
+ 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 {
+ createBondsWithRebondTool(molecularStructure);
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) {
@@ -396,55 +419,30 @@ else if (readConnect.isSet() && "CONECT".equalsIgnoreCase(cCol)) {
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);
- }
- }
+ int lineIndex = 6;
+ int atomFromNumber = -1;
+ int atomToNumber = -1;
+ IMolecule molecule = (isProteinStructure)? oBP : molecularStructure;
+ while (lineIndex + 5 <= cRead.length()) {
+ String part = cRead.substring(lineIndex, lineIndex + 5).trim();
+ if (atomFromNumber == -1) {
+ try {
+ atomFromNumber = Integer.parseInt(part);
+ } catch (NumberFormatException nfe) {
+ }
+ } else {
+ try {
+ atomToNumber = Integer.parseInt(part);
+ } catch (NumberFormatException nfe) {
+ atomToNumber = -1;
+ }
+ if (atomFromNumber != -1 && atomToNumber != -1) {
+ addBond(molecule, atomFromNumber, atomToNumber);
+ logger.warn("Bonded " + atomFromNumber + " with " + atomToNumber);
+ }
+ }
+ lineIndex += 5;
+ }
}
}
/* ***********************************************************/
@@ -492,6 +490,7 @@ else if ("HELIX ".equalsIgnoreCase(cCol)) {
logger.error(" 1 2 3 4 5 6 7 ");
logger.error(" error: " + e.getMessage());
logger.debug(e);
+ e.printStackTrace();
}
// try to close the Input
@@ -509,9 +508,9 @@ else if ("HELIX ".equalsIgnoreCase(cCol)) {
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));
+ private void addBond(IMolecule molecule, int bondAtomNo, int bondedAtomNo) {
+ IAtom firstAtom = atomNumberMap.get(bondAtomNo);
+ IAtom secondAtom = atomNumberMap.get(bondedAtomNo);
if (firstAtom == null) {
logger.error("Could not find bond start atom in map with serial id: ", bondAtomNo);
}
@@ -532,18 +531,16 @@ private void addBond(PDBPolymer obp, int bondAtomNo, int bondedAtomNo) {
}
}
bondsFromConnectRecords.add(bond);
- obp.addBond(bond);
+ molecule.addBond(bond);
}
- private boolean createBondsWithRebondTool(IBioPolymer pol){
+ private boolean createBondsWithRebondTool(IMolecule molecule){
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();
+ molecule.getBuilder());
+ for (IAtom atom : molecule.atoms()) {
try {
IAtomType[] types = factory.getAtomTypes(atom.getSymbol());
if (types.length > 0) {
@@ -557,7 +554,7 @@ private boolean createBondsWithRebondTool(IBioPolymer pol){
logger.debug(e);
}
}
- tool.rebond(pol);
+ tool.rebond(molecule);
} catch (Exception e) {
logger.error("Could not rebond the polymer: " + e.getMessage());
logger.debug(e);
@@ -567,36 +564,61 @@ private boolean createBondsWithRebondTool(IBioPolymer pol){
/**
* Creates an <code>Atom</code> 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 <code>RuntimeException</code> is thrown.
+ * the ATOM or HETATM 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 <code>RuntimeException</code> is thrown.
*
- * @param cLine the PDB ATOM record.
+ * @param cLine the PDB ATOM or HEATATM record.
* @return the <code>Atom</code> 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:
+ // a line can look like (two in old format, then two in new format):
+ //
+ // 1 2 3 4 5 6 7
// 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
+ // ATOM 31 CA SER A 3 -0.891 17.523 51.925 1.00 28.64 C
+ // HETATM 3486 MG MG A 302 24.885 14.008 59.194 1.00 29.42 MG+2
+ //
+ // note: the first two examples have the PDBID in col 72-75
+ // note: the last two examples have the element symbol in col 76-77
+ // note: the last (Mg hetatm) has a charge in col 78-79
if (lineLength < 59) {
throw new RuntimeException("PDBReader error during readAtom(): line too short");
}
- String elementSymbol = cLine.substring(12, 14).trim();
+ String elementSymbol;
+ if (cLine.length() > 78) {
+ elementSymbol = cLine.substring(76, 78).trim();
+ if (elementSymbol.length() == 0) {
+ elementSymbol = cLine.substring(12, 14).trim();
+ }
+ } else {
+ 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();
+ if (Character.isDigit(elementSymbol.charAt(0))) {
+ elementSymbol = elementSymbol.substring(1);
+ } else {
+ elementSymbol = elementSymbol.charAt(0)
+ + elementSymbol.substring(1).toLowerCase();
+ }
}
+
String rawAtomName = cLine.substring(12, 16).trim();
String resName = cLine.substring(17, 20).trim();
+ boolean isHetatm;
try {
IAtomType type = pdbFactory.getAtomType(resName+"."+rawAtomName);
elementSymbol = type.getSymbol();
+ isHetatm = false;
} catch (NoSuchAtomTypeException e) {
logger.error("Did not recognize PDB atom type: " + resName+"."+rawAtomName);
+ isHetatm = true;
}
PDBAtom oAtom = new PDBAtom(elementSymbol,
new Point3d(Double.parseDouble(cLine.substring(30, 38)),
@@ -604,6 +626,18 @@ private PDBAtom readAtom(String cLine, int lineLength) {
Double.parseDouble(cLine.substring(46, 54))
)
);
+ if (useHetDictionary.isSet() && isHetatm) {
+ String cdkType = typeHetatm(resName, rawAtomName);
+ oAtom.setAtomTypeName(cdkType);
+ if (cdkType != null) {
+ try {
+ cdkAtomTypeFactory.configure(oAtom);
+ } catch (CDKException cdke) {
+ logger.warn("Could not configure", resName, " ", rawAtomName);
+ }
+ }
+ }
+
oAtom.setRecord(cLine);
oAtom.setSerial(Integer.parseInt(cLine.substring(6, 11).trim()));
@@ -613,7 +647,11 @@ private PDBAtom readAtom(String cLine, int lineLength) {
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 (useHetDictionary.isSet() && isHetatm) {
+ oAtom.setID(oAtom.getResName() + "." + rawAtomName);
+ } else {
+ oAtom.setAtomTypeName(oAtom.getResName()+"."+rawAtomName);
+ }
if (lineLength >= 59) {
String frag = cLine.substring(54, 60).trim();
if (frag.length() > 0) {
@@ -657,6 +695,46 @@ private PDBAtom readAtom(String cLine, int lineLength) {
return oAtom;
}
+ private String typeHetatm(String resName, String atomName) {
+ if (hetDictionary == null) {
+ readHetDictionary();
+ cdkAtomTypeFactory =
+ AtomTypeFactory.getInstance(
+ "org/openscience/cdk/dict/data/cdk-atom-types.owl",
+ DefaultChemObjectBuilder.getInstance());
+ }
+ String key = resName + "." + atomName;
+ if (hetDictionary.containsKey(key)) {
+ return hetDictionary.get(key);
+ }
+ return null;
+ }
+
+ private void readHetDictionary() {
+ try {
+ InputStream ins =
+ getClass().getClassLoader().getResourceAsStream(hetDictionaryPath);
+ BufferedReader bufferedReader =
+ new BufferedReader(new InputStreamReader(ins));
+ hetDictionary = new HashMap<String, String>();
+ String line;
+ while ((line = bufferedReader.readLine()) != null) {
+ int colonIndex = line.indexOf(":");
+ if (colonIndex == -1) continue;
+ String typeKey = line.substring(0, colonIndex);
+ String typeValue = line.substring(colonIndex + 1);
+ if (typeValue.equals("null")) {
+ hetDictionary.put(typeKey, null);
+ } else {
+ hetDictionary.put(typeKey, typeValue);
+ }
+ }
+ bufferedReader.close();
+ } catch (IOException ioe) {
+ logger.error(ioe.getMessage());
+ }
+ }
+
@TestMethod("testClose")
public void close() throws IOException {
_oInput.close();
@@ -669,17 +747,22 @@ private void initIOSettings() {
readConnect = new BooleanIOSetting("ReadConnectSection", IOSetting.LOW,
"Should the CONECT be read?",
"true");
+ useHetDictionary = new BooleanIOSetting("UseHetDictionary", IOSetting.LOW,
+ "Should the PDBReader use the HETATM dictionary for atom types?",
+ "false");
}
public void customizeJob() {
fireIOSettingQuestion(useRebondTool);
fireIOSettingQuestion(readConnect);
+ fireIOSettingQuestion(useHetDictionary);
}
public IOSetting[] getIOSettings() {
- IOSetting[] settings = new IOSetting[2];
+ IOSetting[] settings = new IOSetting[3];
settings[0] = useRebondTool;
settings[1] = readConnect;
+ settings[2] = useHetDictionary;
return settings;
}
View
131 src/main/org/openscience/cdk/io/PDBWriter.java
@@ -31,10 +31,12 @@
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;
@@ -49,22 +51,32 @@
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.io.formats.IResourceFormat;
import org.openscience.cdk.io.formats.PDBFormat;
+import org.openscience.cdk.io.setting.BooleanIOSetting;
+import org.openscience.cdk.io.setting.IOSetting;
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.
- *
+ *
+ * @author Gilleain Torrance <gilleain.torrance@gmail.com>
* @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";
+ public final String SERIAL_FORMAT = "%5d";
+ public final String ATOM_NAME_FORMAT = "%-5s";
+ public final String POSITION_FORMAT = "%8.3f";
+ public final String RESIDUE_FORMAT = "%s";
+
+ private BooleanIOSetting writeAsHET;
+ private BooleanIOSetting useElementSymbolAsAtomName;
+ private BooleanIOSetting writeCONECTRecords;
+ private BooleanIOSetting writeTERRecord;
+ private BooleanIOSetting writeENDRecord;
private BufferedWriter writer;
@@ -86,6 +98,17 @@ public PDBWriter(Writer out) {
}
} catch (Exception exc) {
}
+ writeAsHET = new BooleanIOSetting("WriteAsHET", IOSetting.LOW,
+ "Should the output file use HETATM", "false");
+ useElementSymbolAsAtomName = new BooleanIOSetting(
+ "UseElementSymbolAsAtomName", IOSetting.LOW,
+ "Should the element symbol be written as the atom name", "false");
+ writeCONECTRecords = new BooleanIOSetting("WriteCONECT", IOSetting.LOW,
+ "Should the bonds be written as CONECT records?", "true");
+ writeTERRecord = new BooleanIOSetting("WriteTER", IOSetting.LOW,
+ "Should a TER record be put at the end of the atoms?", "false");
+ writeENDRecord = new BooleanIOSetting("WriteEND", IOSetting.LOW,
+ "Should an END record be put at the end of the file?", "true");
}
public PDBWriter(OutputStream output) {
@@ -159,15 +182,22 @@ public void write(IChemObject object) throws CDKException {
public void writeMolecule(IMolecule molecule) throws CDKException {
try {
+ writeHeader();
int atomNumber = 1;
- String hetatmRecordName = "HETATM";
+ String hetatmRecordName = (writeAsHET.isSet())? "HETATM" : "ATOM ";
+ String id = molecule.getID();
+ String residueName = (id == null || id.equals(""))? "MOL" : id;
String terRecordName = "TER";
// Loop through the atoms and write them out:
StringBuffer buffer = new StringBuffer();
- java.util.Iterator atoms = molecule.atoms().iterator();
+ Iterator atoms = molecule.atoms().iterator();
FormatStringBuffer fsb = new FormatStringBuffer("");
+ String[] connectRecords = null;
+ if (writeCONECTRecords.isSet()) {
+ connectRecords = new String[molecule.getAtomCount()];
+ }
while (atoms.hasNext()) {
buffer.setLength(0);
buffer.append(hetatmRecordName);
@@ -175,9 +205,20 @@ public void writeMolecule(IMolecule molecule) throws CDKException {
buffer.append(fsb.toString());
buffer.append(' ');
IAtom atom = (IAtom)atoms.next();
- fsb.reset(ATOM_NAME_FORMAT).format(atom.getSymbol());
+ String name;
+ if (useElementSymbolAsAtomName.isSet()) {
+ name = atom.getSymbol();
+ } else {
+ if (atom.getID() == null || atom.getID().equals("")) {
+ name = atom.getSymbol();
+ } else {
+ name = atom.getID();
+ }
+ }
+ fsb.reset(ATOM_NAME_FORMAT).format(name);
buffer.append(fsb.toString());
- buffer.append(" MOL ");
+ fsb.reset(RESIDUE_FORMAT).format(residueName);
+ buffer.append(fsb).append(" 0 ");
Point3d position = atom.getPoint3d();
fsb.reset(POSITION_FORMAT).format(position.x);
buffer.append(fsb.toString());
@@ -186,21 +227,75 @@ public void writeMolecule(IMolecule molecule) throws CDKException {
fsb.reset(POSITION_FORMAT).format(position.z);
buffer.append(fsb.toString());
+ buffer.append(" 1.00"); // occupancy
+ buffer.append(" 0.00"); // temperature factor
+ buffer.append(" ");
+ buffer.append(atom.getSymbol());
+ Integer formalCharge = atom.getFormalCharge();
+ if (formalCharge == CDKConstants.UNSET) {
+ buffer.append("+0");
+ } else {
+ if (formalCharge < 0) {
+ buffer.append(formalCharge);
+ } else {
+ buffer.append("+").append(formalCharge);
+ }
+ }
+
+ if (connectRecords != null && writeCONECTRecords.isSet()) {
+ List<IAtom> neighbours = molecule.getConnectedAtomsList(atom);
+ if (neighbours.size() != 0) {
+ StringBuffer connectBuffer = new StringBuffer("CONECT");
+ connectBuffer.append(String.format("%5d", atomNumber));
+ for (IAtom neighbour : neighbours) {
+ int neighbourNumber =
+ molecule.getAtomNumber(neighbour) + 1;
+ connectBuffer.append(
+ String.format("%5d", neighbourNumber));
+ }
+ connectRecords[atomNumber - 1] = connectBuffer.toString();
+ } else {
+ connectRecords[atomNumber - 1] = null;
+ }
+ }
+
writer.write(buffer.toString(), 0, buffer.length());
writer.newLine();
++atomNumber;
}
- writer.write(terRecordName, 0, terRecordName.length());
- writer.newLine();
+
+ if (writeTERRecord.isSet()) {
+ writer.write(terRecordName, 0, terRecordName.length());
+ writer.newLine();
+ }
+
+ if (connectRecords != null && writeCONECTRecords.isSet()) {
+ for (String connectRecord : connectRecords) {
+ if (connectRecord != null) {
+ writer.write(connectRecord);
+ writer.newLine();
+ }
+ }
+ }
+
+ if (writeENDRecord.isSet()) {
+ writer.write("END ");
+ writer.newLine();
+ }
+
} catch (IOException exception) {
throw new CDKException("Error while writing file: " + exception.getMessage(), exception);
}
}
+ private void writeHeader() throws IOException {
+ writer.write("HEADER created with the CDK (http://cdk.sf.net/)");
+ writer.newLine();
+ }
+
public void writeCrystal(ICrystal crystal) throws CDKException {
try {
- writer.write("HEADER created with the CDK (http://cdk.sf.net/)");
- writer.newLine();
+ writeHeader();
Vector3d a = crystal.getA();
Vector3d b = crystal.getB();
Vector3d c = crystal.getC();
@@ -223,7 +318,7 @@ public void writeCrystal(ICrystal crystal) throws CDKException {
writer.newLine();
// before saving the atoms, we need to create cartesian coordinates
- java.util.Iterator atoms = crystal.atoms().iterator();
+ Iterator atoms = crystal.atoms().iterator();
while (atoms.hasNext()) {
IAtom atom = (IAtom)atoms.next();
// logger.debug("PDBWriter: atom -> " + atom);
@@ -247,5 +342,15 @@ public void writeCrystal(ICrystal crystal) throws CDKException {
public void close() throws IOException {
writer.close();
}
+
+ public IOSetting[] getIOSettings() {
+ IOSetting[] settings = new IOSetting[7];
+ settings[0] = writeAsHET;
+ settings[1] = useElementSymbolAsAtomName;
+ settings[2] = writeCONECTRecords;
+ settings[3] = writeTERRecord;
+ settings[4] = writeENDRecord;
+ return settings;
+ }
}
View
2  src/main/org/openscience/cdk/io/iterator/IteratingMDLReader.java
@@ -156,6 +156,8 @@ public boolean hasNext() {
logger.debug("MDL file part read: ", buffer);
ISimpleChemObjectReader reader = factory.createReader(currentFormat);
reader.setReader(new StringReader(buffer.toString()));
+ reader.setErrorHandler(this.errorHandler);
+ reader.setReaderMode(this.mode);
if (currentFormat instanceof MDLV2000Format) {
reader.addChemObjectIOListener(this);
((MDLV2000Reader)reader).customizeJob();
View
5 src/main/org/openscience/cdk/qsar/descriptors/molecular/BCUTDescriptor.java
@@ -24,7 +24,6 @@
package org.openscience.cdk.qsar.descriptors.molecular;
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.aromaticity.CDKHueckelAromaticityDetector;
@@ -310,9 +309,9 @@ public Object getParameterType(String name) {
@TestMethod("testCalculate_IAtomContainer")
public DescriptorValue calculate(IAtomContainer container) {
int counter;
- Molecule molecule;
+ IAtomContainer molecule;
try {
- molecule = (Molecule) container.clone();
+ molecule = (IAtomContainer) container.clone();
} catch (CloneNotSupportedException e) {
logger.debug("Error during clone");
return getDummyDescriptorValue(new CDKException("Error occured during clone " + e));
View
9 src/main/org/openscience/cdk/smiles/SmilesParser.java
@@ -38,6 +38,7 @@
import org.openscience.cdk.aromaticity.CDKHueckelAromaticityDetector;
import org.openscience.cdk.atomtype.CDKAtomTypeMatcher;
import org.openscience.cdk.exception.InvalidSmilesException;
+import org.openscience.cdk.exception.NoSuchAtomTypeException;
import org.openscience.cdk.graph.ConnectivityChecker;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
@@ -262,9 +263,13 @@ public IMolecule parseSmiles(String smiles) throws InvalidSmilesException {
try {
IAtomType type = matcher.findMatchingAtomType(molecule, atom);
AtomTypeManipulator.configure(atom, type);
- } catch (Exception e) {
- System.out.println("Cannot percieve atom type for the " + i + "th atom: " + atom.getSymbol());
+ } catch (NoSuchAtomTypeException exception) {
+ logger.warn("Cannot percieve atom type for the ", i, "th atom: ", atom.getSymbol());
atom.setAtomTypeName("X");
+ } catch (Exception exception) {
+ logger.error("Caught unexpected Exception during atom typing.");
+ logger.debug(exception);
+ atom.setAtomTypeName("X");
}
}
this.addImplicitHydrogens(molecule);
View
4 src/main/org/openscience/cdk/tautomers/InChITautomerGenerator.java
@@ -54,7 +54,7 @@
* Creates tautomers for a given input molecule, based on the mobile H atoms listed in the InChI.
* Algorithm described in {@cdk.cite Thalheim2010}.
* <br>
- * <B>Provide your input molecules in Kekule form.</B></br>
+ * <B>Provide your input molecules in Kekule form, and make sure atom type are perceived.</B></br>
* When creating an input molecule by reading an MDL file, make sure to set implicit hydrogens. See the
* {@link InChITautomerGeneratorTest test case}.
* @author Mark Rijnbeek
@@ -72,7 +72,7 @@
* @throws CDKException
* @throws CloneNotSupportedException
*/
- @TestMethod("test_withJniInchi")
+ @TestMethod("test_withJniInchi,testAdenine")
public List<IAtomContainer> getTautomers(IAtomContainer molecule) throws CDKException, CloneNotSupportedException {
InChIGenerator gen = InChIGeneratorFactory.getInstance().getInChIGenerator(molecule);
View
41 src/test/data/mdl/error.sdf
@@ -0,0 +1,41 @@
+ZINC18196443
+ 3D
+ Structure written by MMmdl.
+ 10 9 0 0 1 0 999 V2000
+ 0.4049 -3.4591 -0.4133 C 0 0 0 0 0 0
+ 0.0935 -2.0949 -1.0146 C 0 0 0 0 0 0
+ -0.1040 -1.9774 -2.2222 O 0 0 0 0 0 0
+ 0.0425 -0.9169 -0.0304 C 0 0 0 0 0 0
+ -1.2832 -0.1170 0.0999 C 0 0 0 0 0 0
+ -1.7758 0.4793 -1.2353 C 0 0 0 0 0 0
+ -2.3622 -1.0665 0.6525 C 0 0 0 0 0 0
+ -1.0872 1.2796 1.3677 P 0 0 0 0 0 0
+ -0.7370 0.6636 2.6677 O 0 0 0 0 0 0
+ -0.1715 2.2876 0.7865 O 0 5 0 0 0 0
+ 1 2 1 0 0 0
+ 2 3 2 0 0 0
+ 2 4 1 0 0 0
+ 4 5 1 0 0 0
+ 5 6 1 0 0 0
+ 5 7 1 0 0 0
+ 5 8 1 0 0 0
+ 8 9 2 0 0 0
+ 8 10 1 0 0 0
+M CHG 1 10 -1
+M END
+> <s_m_entry_name>
+ep_conf_canv.24172
+
+> <i_canvas_RB>
+3
+
+> <i_canvas_canvasUID>
+24172
+
+> <r_canvas_MW>
+163.1314
+
+> <s_m_entry_id>
+221504
+
+$$$$
View
17 src/test/data/pdb/hetatm_only.pdb
@@ -0,0 +1,17 @@
+REMARK coffeine (as hetatm records)
+HETATM 1 C1 MOL 1 1.777 5.517 -0.003 1.00 0.00
+HETATM 2 C2 MOL 1 4.352 1.149 -0.001 1.00 0.00
+HETATM 3 O3 MOL 1 1.987 2.697 -0.013 1.00 0.00
+HETATM 4 O4 MOL 1 4.344 6.721 0.006 1.00 0.00
+HETATM 5 C5 MOL 1 7.349 6.475 -0.028 1.00 0.00
+HETATM 6 N6 MOL 1 6.843 5.095 -0.002 1.00 0.00
+HETATM 7 C7 MOL 1 7.637 3.886 0.002 1.00 0.00
+HETATM 8 N8 MOL 1 6.835 2.879 0.012 1.00 0.00
+HETATM 9 C9 MOL 1 4.304 5.484 0.005 1.00 0.00
+HETATM 10 C10 MOL 1 5.517 4.684 0.006 1.00 0.00
+HETATM 11 C11 MOL 1 5.511 3.374 0.009 1.00 0.00
+HETATM 12 N12 MOL 1 4.312 2.616 0.004 1.00 0.00
+HETATM 13 C13 MOL 1 3.053 3.325 -0.003 1.00 0.00
+HETATM 14 N14 MOL 1 3.049 4.779 0.001 1.00 0.00
+TER
+END
View
7 src/test/data/pdb/unk.pdb
@@ -0,0 +1,7 @@
+SEQRES 1 1 UNK
+ATOM 1 N UNK 163 64.138 48.860 15.587 1.00 93.13 N
+ATOM 2 CA UNK 163 62.727 49.237 15.756 1.00 88.34 C
+ATOM 3 C UNK 163 62.651 49.372 17.276 1.00 82.84 C
+ATOM 4 O UNK 163 62.339 50.439 17.805 1.00 83.16 O
+ATOM 5 1H UNK 163 63.727 49.237 15.756 1.00 88.34 H
+END
View
21 src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherFilesTest.java
@@ -30,6 +30,7 @@
import org.openscience.cdk.interfaces.IAtomType;
import org.openscience.cdk.interfaces.IChemFile;
import org.openscience.cdk.io.CMLReader;
+import org.openscience.cdk.io.MDLV2000Reader;
import org.openscience.cdk.nonotify.NNChemFile;
import org.openscience.cdk.nonotify.NoNotificationChemObjectBuilder;
import org.openscience.cdk.tools.manipulator.ChemFileManipulator;
@@ -61,6 +62,26 @@
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}
+ /**
+ * @cdk.bug 3141611
+ */
+ @Test public void testBug3141611() throws Exception {
+ String filename = "data/mdl/error.sdf";
+ InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
+ MDLV2000Reader reader = new MDLV2000Reader(ins);
+ IChemFile chemFile = (IChemFile)reader.read(new NNChemFile());
+
+ // test the resulting ChemFile content
+ Assert.assertNotNull(chemFile);
+ IAtomContainer mol = ChemFileManipulator.getAllAtomContainers(chemFile).get(0);
+
+ String[] expectedTypes = {
+ "C.sp3", "C.sp2", "O.sp2", "C.sp3", "C.sp3", "C.sp3",
+ "C.sp3", "P.ate", "O.sp2", "O.minus"
+ };
+ assertAtomTypes(testedAtomTypes, expectedTypes, mol);
+ }
+
@Test public void testOla28() throws Exception {
String filename = "data/cml/mol28.cml";
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
View
19 src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherSMILESTest.java
@@ -21,6 +21,7 @@
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
+import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomType;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.nonotify.NoNotificationChemObjectBuilder;
@@ -158,4 +159,22 @@
Assert.assertNotNull(type.getAtomTypeName());
}
}
+
+ @Test public void test4Sulphur() throws Exception {
+ String smiles = "Br.Br.CS(CCC(N)C#N)C[C@H]1OC([C@H](O)[C@@H]1O)n2cnc3c(N)ncnc23";
+
+ IMolecule mol = smilesParser.parseSmiles(smiles);
+ IAtomType[] types = atomTypeMatcher.findMatchingAtomType(mol);
+ for (IAtomType type : types) {
+ Assert.assertNotNull(type.getAtomTypeName());
+ }
+ }
+
+ @Test public void testTellaneLike() throws Exception {
+ String smiles = "Clc1cccc(N2CCN(CCCCNC(=O)C3=Cc4ccccc4[Te]3)CC2)c1Cl";
+ IMolecule mol = smilesParser.parseSmiles(smiles);
+ for (IAtom atom : mol.atoms())
+ Assert.assertNotSame("X", atom.getAtomTypeName());
+ }
+
}
View
91 src/test/org/openscience/cdk/atomtype/CDKAtomTypeMatcherTest.java
@@ -28,8 +28,8 @@
import org.openscience.cdk.Atom;
import org.openscience.cdk.Bond;
import org.openscience.cdk.CDKConstants;
-import org.openscience.cdk.Molecule;
import org.openscience.cdk.DefaultChemObjectBuilder;
+import org.openscience.cdk.Molecule;
import org.openscience.cdk.PseudoAtom;
import org.openscience.cdk.Ring;
import org.openscience.cdk.config.AtomTypeFactory;
@@ -37,17 +37,17 @@
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IAtomType;
-import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IAtomType.Hybridization;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IBond.Order;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IMolecule;
import org.openscience.cdk.nonotify.NNAtom;
import org.openscience.cdk.nonotify.NNAtomType;
import org.openscience.cdk.nonotify.NoNotificationChemObjectBuilder;
import org.openscience.cdk.templates.MoleculeFactory;
-import org.openscience.cdk.tools.periodictable.PeriodicTable;
import org.openscience.cdk.tools.manipulator.AtomTypeManipulator;
+import org.openscience.cdk.tools.periodictable.PeriodicTable;
/**
* This class tests the matching of atom types defined in the
@@ -3389,6 +3389,33 @@ public void testPine() throws Exception {
}
}
+ /**
+ * @cdk.inchi InChI=1S/H2Te/h1H2
+ */
+ @Test
+ public void testTellane() throws Exception {
+ IChemObjectBuilder builder = DefaultChemObjectBuilder.getInstance();
+ IMolecule mol = builder.newInstance(IMolecule.class);
+ IAtom a1 = builder.newInstance(IAtom.class,"Te");
+ a1.setFormalCharge(0);
+ mol.addAtom(a1);
+ IAtom a2 = builder.newInstance(IAtom.class,"H");
+ a2.setFormalCharge(0);
+ mol.addAtom(a2);
+ IAtom a3 = builder.newInstance(IAtom.class,"H");
+ a3.setFormalCharge(0);
+ mol.addAtom(a3);
+ IBond b1 = builder.newInstance(IBond.class,a1, a2, IBond.Order.SINGLE);