From: Jim Procter Date: Wed, 7 Feb 2018 12:50:36 +0000 (+0000) Subject: JAL-2780 JAL-2781 don’t assume contiguous mapping to PDB residue numbering when gener... X-Git-Tag: Release_2_10_4~68^2~36 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=bf10bf9b8f2f4b680cceb1db258e65a2ecc84293;hp=9c1b1b147d64ebcf62b9e20953cda99fb0c82900;p=jalview.git JAL-2780 JAL-2781 don’t assume contiguous mapping to PDB residue numbering when generating Jmol colour commands (unmapped PDB residue data shouldn’t receive colour if mapped positions either side receive the same colour). --- diff --git a/src/jalview/ext/jmol/JmolCommands.java b/src/jalview/ext/jmol/JmolCommands.java index 6bf7010..7a52ba9 100644 --- a/src/jalview/ext/jmol/JmolCommands.java +++ b/src/jalview/ext/jmol/JmolCommands.java @@ -77,7 +77,6 @@ public class JmolCommands continue; } - int lastPos = -1; for (int s = 0; s < sequence[pdbfnum].length; s++) { for (int sp, m = 0; m < mapping.length; m++) @@ -85,6 +84,7 @@ public class JmolCommands if (mapping[m].getSequence() == sequence[pdbfnum][s] && (sp = al.findIndex(sequence[pdbfnum][s])) > -1) { + int lastPos = StructureMapping.UNASSIGNED_VALUE; SequenceI asp = al.getSequenceAt(sp); for (int r = 0; r < asp.getLength(); r++) { @@ -95,10 +95,22 @@ public class JmolCommands } int pos = mapping[m].getPDBResNum(asp.findPosition(r)); - if (pos < 1 || pos == lastPos) + if (pos == lastPos) { continue; } + if (pos == StructureMapping.UNASSIGNED_VALUE) + { + // terminate current colour op + if (command.length() > 0 + && command.charAt(command.length() - 1) != ';') + { + command.append(";"); + } + // reset lastPos + lastPos = StructureMapping.UNASSIGNED_VALUE; + continue; + } lastPos = pos; @@ -128,7 +140,12 @@ public class JmolCommands // TODO: deal with case when buffer is too large for Jmol to parse // - execute command and flush - command.append(";"); + if (command.length() > 0 + && command.charAt(command.length() - 1) == ';') + { + command.append(";"); + } + if (command.length() > 51200) { // add another chunk