PageRenderTime 41ms CodeModel.GetById 15ms RepoModel.GetById 1ms app.codeStats 0ms

/rcdkjar/src/org/guha/rcdk/test/View2DTest.java

http://github.com/rajarshi/cdkr
Java | 93 lines | 72 code | 13 blank | 8 comment | 0 complexity | 601711330db9e590fded4341cd310290 MD5 | raw file
  1. package org.guha.rcdk.test;
  2. import org.guha.rcdk.util.Misc;
  3. import org.guha.rcdk.view.ViewMolecule2D;
  4. import org.guha.rcdk.view.ViewMolecule2DTable;
  5. import org.guha.rcdk.view.panels.MoleculeCell;
  6. import org.openscience.cdk.DefaultChemObjectBuilder;
  7. import org.openscience.cdk.exception.CDKException;
  8. import org.openscience.cdk.interfaces.IAtomContainer;
  9. import org.openscience.cdk.smiles.SmilesParser;
  10. import javax.swing.*;
  11. import java.io.IOException;
  12. /**
  13. * Created by IntelliJ IDEA. User: rguha Date: Aug 28, 2006 Time: 2:58:26 PM To change this template use File | Settings
  14. * | File Templates.
  15. */
  16. public class View2DTest {
  17. String home = "/Users/rguha/";
  18. public static void main(String[] args) throws Exception {
  19. View2DTest w = new View2DTest();
  20. w.testView2DFromSmiles();
  21. }
  22. public void testMoleculeCell() throws Exception {
  23. SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
  24. IAtomContainer container = sp.parseSmiles("C1CN2CCN(CCCN(CCN(C1)Cc1ccccn1)CC2)C");
  25. MoleculeCell mcell = new MoleculeCell(container, Misc.getDefaultDepictor());
  26. JFrame frame = new JFrame("Molecule Cell");
  27. frame.getContentPane().add(mcell);
  28. frame.pack();
  29. frame.setVisible(true);
  30. }
  31. public void testView2DFromSmiles() throws Exception {
  32. SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
  33. IAtomContainer container = sp.parseSmiles("C1CN2CCN(CCCN(CCN(C1)Cc1ccccn1)CC2)C");
  34. ViewMolecule2D v2d = new ViewMolecule2D(container);
  35. v2d.draw();
  36. // fail();
  37. }
  38. public void testView2D() throws Exception {
  39. String[] fname = {home + "src/R/trunk/rcdk/data/dan001.sdf",
  40. home + "src/R/trunk/rcdk/data/dan002.sdf",
  41. home + "src/R/trunk/rcdk/data/dan003.sdf"};
  42. IAtomContainer[] acs = null;
  43. try {
  44. acs = Misc.loadMolecules(fname, true, true, true);
  45. } catch (CDKException e) {
  46. e.printStackTrace();
  47. }
  48. ViewMolecule2D v2d = new ViewMolecule2D(acs[1]);
  49. v2d.draw();
  50. // fail();
  51. }
  52. public void testView2Dv2() throws Exception {
  53. String[] fname = {home + "src/R/trunk/rcdk/data/dan001.hin",
  54. home + "src/R/trunk/rcdk/data/dan002.hin",
  55. home + "src/R/trunk/rcdk/data/dan003.hin"};
  56. IAtomContainer[] acs = null;
  57. try {
  58. acs = Misc.loadMolecules(fname, true, true, true);
  59. } catch (CDKException e) {
  60. e.printStackTrace();
  61. }
  62. ViewMolecule2D v2d = new ViewMolecule2D(acs[1]);
  63. // fail();
  64. }
  65. public void testView2DT() throws IOException {
  66. String[] fname = {home + "src/R/trunk/rcdk/data/dan001.hin",
  67. home + "src/R/trunk/rcdk/data/dan002.hin",
  68. home + "src/R/trunk/rcdk/data/dan008.hin"};
  69. IAtomContainer[] acs = null;
  70. try {
  71. acs = Misc.loadMolecules(fname, true, true, true);
  72. } catch (CDKException e) {
  73. e.printStackTrace();
  74. } catch (IOException e) {
  75. e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
  76. }
  77. ViewMolecule2DTable v2dt = new ViewMolecule2DTable(acs, 3, 200, 200, Misc.getDefaultDepictor());
  78. // fail();
  79. }
  80. }