Debian Codegraph @

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

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