{
  "version": "https://jsonfeed.org/version/1.1",
  "title": "chem-bla-ics",
  "description": "Chemblaics (pronounced chem-bla-ics) is the science that uses open science and computers to solve problems in chemistry, biochemistry and related fields.",
  "home_page_url": "https://chem-bla-ics.linkedchemistry.info/",
  "feed_url": "https://chem-bla-ics.linkedchemistry.info/2011/03/13/unfortunate-cdk-decisions.json",
  "icon": "https://chem-bla-ics.linkedchemistry.info/assets/images/chem-bla-ics_logo.png",
  "language": "en",
  "authors": [
    {
      "name": "Egon Willighagen",
      "url": "https://orcid.org/0000-0001-7542-0286",
      "_orcid": "0000-0001-7542-0286"
    }
  ],
  "items": [

    {
      "id": "https://doi.org/10.59350/nhf0n-h5687",
      "url": "https://chem-bla-ics.linkedchemistry.info/2011/03/13/unfortunate-cdk-decisions.html",
      "title": "Unfortunate (CDK) decisions",
      "content_html": "<p>Sometimes you make decisions which turn out unlucky. <a href=\"http://www.steinbeck-molecular.de/steinblog/\">Christoph</a>,\n<a href=\"http://www.openscience.org/blog/?author=2\">Dan</a>, and I made one about 10 years\nago (see <a href=\"http://www.openscience.org/blog/?p=428\">this photo</a> from Dan with\nhis whiteboard where we wrote down our thoughts). The one I am talking about\nis not bad in itself, but the implementation is bad; bad in the sense that it\nmakes it easy for other toolkits to make a difference in size and performance\n(see also <a href=\"http://chem-bla-ics.blogspot.com/2010/09/quo-vadis-cdk.html\">Quo vadis, CDK?</a>).</p>\n\n<p>The reason why I bring this up, is that I am answering a <a href=\"http://www.ccl.net/cgi-bin/ccl/message-new?2011+03+06+001\">question on the CCL\nmailing list</a> on\nhow to convert a XYZ file into an adjacency matrix, and my <a href=\"http://chem-bla-ics.blogspot.com/2011/02/groovy-cheminformatics.html\">Groovy Cheminformatics</a>\ndid not have a section on graph matrices yet. And I just ran into the issue\nthat the CDK <a href=\"http://pele.farmbio.uu.se/nightly/cdk-javadoc-1.5.0.git/org/openscience/cdk/io/XYZReader.html\">XYZReader</a>\nonly accepts an <a href=\"http://pele.farmbio.uu.se/nightly/cdk-javadoc-1.5.0.git/org/openscience/cdk/interfaces/IChemFile.html\">IChemFile</a>.\nThen I realized the book doesn’t explain yet why that is either.</p>\n\n<p>It basically comes down that chemical files can contain a wide variety of chemistry.\nMDL molfiles can contain a single Molecule, but also a set of molecules. Chemical\ndocuments in general, think <a href=\"http://www.jmol.org/\">Jmol</a>, can also contain trajectories\nfor <a href=\"http://en.wikipedia.org/wiki/Cyclohexane\">cyclohexane</a> (see <a href=\"http://chemapps.stolaf.edu/jmol/docs/examples-12/jmol-flot-energy.htm?model=data/cyclohexaneFlip.jmol\">this nice\nanimation by Bob</a>),\netc, etc. And because the CDK is a general chemistry development toolkit, it\nhas to support all. So, we have the IChemFile concept which corresponds to a\nchemical file, containing a sequence of one or more models, which may be if\na single molecules (e.g. geometry optimizations), or multiple models (e.g. MDL\nSD files). Similarly, each model can contain a variety of objects: reactions,\nset of molecules, and crystals. Well, you get the point.</p>\n\n<p>Now, at some point, it was decided that being able to convert file formats from\none into another might in fact be interesting (think <a href=\"http://www.openbabel.org/\">OpenBabel</a>).\nThat’s where it went wrong (and if you start <a href=\"http://www.kernel.org/pub/software/scm/git/docs/git-blame.html\">git blaming</a>\nit would not surprise me if I am the center of all evil here). Just to keep\nit simple, it made sense to have all IO classes at least support ChemFile, because\nwhatever the content, it could always be wrapped in an ChemFile.</p>\n\n<p>So, the answer to the question on the CCL mailing list is a bit more involved\nthan I wanted:</p>\n\n<pre>import org.openscience.cdk.*;\nimport org.openscience.cdk.config.*;\nimport org.openscience.cdk.interfaces.*;\nimport org.openscience.cdk.io.*;\nimport org.openscience.cdk.graph.matrix.*;\nimport org.openscience.cdk.tools.manipulator.*;\nimport org.openscience.cdk.graph.rebond.*;\nimport java.io.File;\n\nreader = new XYZReader(\n  new File(\"data/ethanoicacid.xyz\").newReader()\n);\nallContent = ChemFileManipulator.getAllAtomContainers(\n  reader.read(new ChemFile())\n)\nethanoicAcid = allContent.get(0)\n\nfactory = AtomTypeFactory.getInstance(\n  \"org/openscience/cdk/config/data/jmol_atomtypes.txt\", \n  ethanoicAcid.getBuilder()\n);\nfor (IAtom atom : ethanoicAcid.atoms()) {\n  factory.configure(atom);\n}\nRebondTool rebonder = new RebondTool(2.0, 0.5, 0.5);\nrebonder.rebond(ethanoicAcid);\n\nint[][] matrix = AdjacencyMatrix.getMatrix(ethanoicAcid)\n\nprintln \"The adjaceny matrix:\"\nfor (row=0;row&lt;ethanoicAcid.getAtomCount();row++) {\n  for (col=0;col&lt;ethanoicAcid.getAtomCount();col++) {\n    print matrix[row][col] + \" \"\n  }\n  println \"\"\n}\n</pre>\n\n<p>This code gives this output:</p>\n\n<pre>The adjaceny matrix:\n0 1 1 1 1 0 0 0 \n1 0 0 0 0 1 1 0 \n1 0 0 0 0 0 0 0 \n1 0 0 0 0 0 0 0 \n1 0 0 0 0 0 0 0 \n0 1 0 0 0 0 0 0 \n0 1 0 0 0 0 0 1 \n0 0 0 0 0 0 1 0 \n</pre>\n\n<p>Note that the RebondTool didn’t pick up the bond order, but that’s not needed\nfor the adjacency matrix anyway.</p>\n\n<p>Getting back on the unfortunate design decision: what would things have looked\nliked if we had typed our IChemObject reading and writing classes, allowing\nus to differentiate IChemObjectReader&lt;IAtomContaienr&gt; from IChemObjectReader&lt;IChemFile&gt;.\nIt would have greatly reduced the size of simple programs, or something like\nthe wished-for 50k <a href=\"http://jchempaint.sourceforge.net/\">JChemPaint</a> applet.\nRight now, pulling in a single reader, will automatically pull in all IChemObject\nclasses. Rather, I would just pull in IAtomContainer, which in itself is too\nlarge too. But that’s for another blog post.</p>\n\n<p>The key thing to remember is: <strong>don’t be afraid to add some complexity if that\nallows you to make other things optional.</strong></p>",
      "summary": "Sometimes you make decisions which turn out unlucky. Christoph, Dan, and I made one about 10 years ago (see this photo from Dan with his whiteboard where we wrote down our thoughts). The one I am talking about is not bad in itself, but the implementation is bad; bad in the sense that it makes it easy for other toolkits to make a difference in size and performance (see also Quo vadis, CDK?).",
      
      "date_published": "2011-03-13T00:10:00+00:00",
      "date_modified": "2011-03-13T00:10:00+00:00",
      "tags": ["cdk","cheminf","opensource"],
      
      
      
      
      
      
        "authors": [ { "name": "Egon Willighagen", "url": "https://orcid.org/0000-0001-7542-0286" } ]
      
    }

  ]
}
