|
24 | 24 |
|
25 | 25 | package org.biojava.nbio.structure.align.gui.jmol; |
26 | 26 |
|
27 | | -import org.biojava.nbio.structure.*; |
| 27 | +import java.awt.Color; |
| 28 | +import java.awt.Dimension; |
| 29 | +import java.awt.Graphics; |
| 30 | +import java.awt.Rectangle; |
| 31 | +import java.awt.event.ActionEvent; |
| 32 | +import java.awt.event.ActionListener; |
| 33 | +import java.io.BufferedInputStream; |
| 34 | +import java.io.IOException; |
| 35 | +import java.io.InputStream; |
| 36 | +import java.io.PipedInputStream; |
| 37 | +import java.io.PipedOutputStream; |
| 38 | +import java.text.DecimalFormat; |
| 39 | +import java.util.List; |
| 40 | + |
| 41 | +import javax.swing.JComboBox; |
| 42 | + |
| 43 | +import org.biojava.nbio.structure.Atom; |
| 44 | +import org.biojava.nbio.structure.Calc; |
| 45 | +import org.biojava.nbio.structure.Group; |
| 46 | +import org.biojava.nbio.structure.Structure; |
| 47 | +import org.biojava.nbio.structure.StructureTools; |
28 | 48 | import org.biojava.nbio.structure.align.gui.JPrintPanel; |
29 | 49 | import org.biojava.nbio.structure.domain.LocalProteinDomainParser; |
30 | 50 | import org.biojava.nbio.structure.domain.pdp.Domain; |
31 | 51 | import org.biojava.nbio.structure.domain.pdp.Segment; |
32 | 52 | import org.biojava.nbio.structure.gui.util.color.ColorUtils; |
| 53 | +import org.biojava.nbio.structure.io.mmtf.MmtfActions; |
33 | 54 | import org.biojava.nbio.structure.jama.Matrix; |
34 | 55 | import org.biojava.nbio.structure.scop.ScopDatabase; |
35 | 56 | import org.biojava.nbio.structure.scop.ScopDomain; |
|
42 | 63 | import org.slf4j.Logger; |
43 | 64 | import org.slf4j.LoggerFactory; |
44 | 65 |
|
45 | | -import javax.swing.*; |
46 | | - |
47 | | -import java.awt.*; |
48 | | -import java.awt.event.ActionEvent; |
49 | | -import java.awt.event.ActionListener; |
50 | | -import java.text.DecimalFormat; |
51 | | -import java.util.List; |
52 | | - |
53 | 66 |
|
54 | 67 | public class JmolPanel |
55 | 68 | extends JPrintPanel |
@@ -114,11 +127,28 @@ public void executeCmd(String rasmolScript) { |
114 | 127 | viewer.evalString(rasmolScript); |
115 | 128 | } |
116 | 129 |
|
117 | | - public void setStructure(Structure s) |
| 130 | + public void setStructure(final Structure s) |
118 | 131 | { |
119 | 132 | this.structure = s; |
120 | | - String serialized = s.toMMCIF(); |
121 | | - viewer.openStringInline(serialized); |
| 133 | + try ( |
| 134 | + PipedOutputStream out = new PipedOutputStream(); |
| 135 | + // Viewer requires a BufferedInputStream for reflection |
| 136 | + InputStream in = new BufferedInputStream(new PipedInputStream(out)); |
| 137 | + ) { |
| 138 | + new Thread((Runnable)() -> { |
| 139 | + try { |
| 140 | + MmtfActions.writeToOutputStream(s,out); |
| 141 | + } catch (Exception e) { |
| 142 | + logger.error("Error generating MMTF output for {}", |
| 143 | + s.getStructureIdentifier()==null ? s.getStructureIdentifier().getIdentifier() : s.getName(), e); |
| 144 | + } |
| 145 | + }).start(); |
| 146 | + viewer.openReader(null, in); |
| 147 | + } catch (IOException e) { |
| 148 | + logger.error("Error transfering {} to Jmol", |
| 149 | + s.getStructureIdentifier()==null ? s.getStructureIdentifier().getIdentifier() : s.getName(), e); |
| 150 | + } |
| 151 | + |
122 | 152 | evalString("save STATE state_1"); |
123 | 153 | } |
124 | 154 |
|
|
0 commit comments