Skip to content

Commit 6678415

Browse files
authored
Merge pull request #785 from lafita/master
Update Jmol version and revert to MMCIF format for JmolPanel
2 parents 461419c + 00f25a7 commit 6678415

File tree

2 files changed

+36
-22
lines changed

2 files changed

+36
-22
lines changed

biojava-structure-gui/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<dependency>
4343
<groupId>net.sourceforge.jmol</groupId>
4444
<artifactId>jmol</artifactId>
45-
<version>14.6.2_2016.08.28</version>
45+
<version>14.29.17</version>
4646
</dependency>
4747
<!-- logging dependencies (managed by parent pom, don't set versions or
4848
scopes here) -->

biojava-structure-gui/src/main/java/org/biojava/nbio/structure/align/gui/jmol/JmolPanel.java

Lines changed: 35 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -126,30 +126,44 @@ public JmolStatusListener getStatusListener(){
126126
public void executeCmd(String rasmolScript) {
127127
viewer.evalString(rasmolScript);
128128
}
129-
130-
public void setStructure(final Structure s)
131-
{
129+
130+
public void setStructure(final Structure s, boolean useMmtf) {
131+
132132
this.structure = s;
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);
133+
134+
if (useMmtf) {
135+
try (
136+
PipedOutputStream out = new PipedOutputStream();
137+
// Viewer requires a BufferedInputStream for reflection
138+
InputStream in = new BufferedInputStream(new PipedInputStream(out));
139+
) {
140+
new Thread((Runnable)() -> {
141+
try {
142+
MmtfActions.writeToOutputStream(s,out);
143+
} catch (Exception e) {
144+
logger.error("Error generating MMTF output for {}",
145+
s.getStructureIdentifier()==null ? s.getStructureIdentifier().getIdentifier() : s.getName(), e);
146+
}
147+
}).start();
148+
viewer.openReader(null, in);
149+
} catch (IOException e) {
150+
logger.error("Error transfering {} to Jmol",
151+
s.getStructureIdentifier()==null ? s.getStructureIdentifier().getIdentifier() : s.getName(), e);
152+
}
153+
} else {
154+
// Use mmCIF format
155+
String serialized = s.toMMCIF();
156+
viewer.openStringInline(serialized);
157+
150158
}
151-
159+
152160
evalString("save STATE state_1");
161+
162+
}
163+
164+
public void setStructure(final Structure s) {
165+
// Set the default to MMCIF (until issue #629 is fixed)
166+
setStructure(s, false);
153167
}
154168

155169
/** assign a custom color to the Jmol chains command.

0 commit comments

Comments
 (0)