From 952ae154954fe87b94cccb765d32718689b9e9a0 Mon Sep 17 00:00:00 2001 From: jprocter Date: Tue, 18 Dec 2007 13:20:18 +0000 Subject: [PATCH] incorrect colour-by-sequence when gaps are present in alignment sequence and pdb-sequence mapping start>1 --- src/jalview/appletgui/AppletJmol.java | 15 +++++++++++---- src/jalview/gui/AppJmol.java | 18 ++++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/src/jalview/appletgui/AppletJmol.java b/src/jalview/appletgui/AppletJmol.java index 26fc708..1202c68 100644 --- a/src/jalview/appletgui/AppletJmol.java +++ b/src/jalview/appletgui/AppletJmol.java @@ -502,15 +502,22 @@ public class AppletJmol extends EmbmenuFrame int lastPos = -1; for (int s = 0; s < sequence.length; s++) { - for (int m = 0; m < mapping.length; m++) + for (int sp,m = 0; m < mapping.length; m++) { if (mapping[m].getSequence() == sequence[s] - && ap.av.alignment.findIndex(sequence[s]) > -1) + && (sp=ap.av.alignment.findIndex(sequence[s])) > -1) { - for (int r = 0; r < sequence[s].getLength(); r++) + SequenceI asp = ap.av.alignment.getSequenceAt(sp); + for (int r = 0; r < asp.getLength(); r++) { + // no mapping to gaps in sequence + if (jalview.util.Comparison.isGap(asp.getCharAt(r))) + { + continue; + } int pos = mapping[m].getPDBResNum( - sequence[s].findPosition(r)); + asp.findPosition(r)); + if (pos < 1 || pos == lastPos) continue; diff --git a/src/jalview/gui/AppJmol.java b/src/jalview/gui/AppJmol.java index 7269e1d..f340457 100644 --- a/src/jalview/gui/AppJmol.java +++ b/src/jalview/gui/AppJmol.java @@ -649,27 +649,33 @@ public synchronized void addSequence(SequenceI [] seq) StringBuffer command = new StringBuffer(); int lastPos = -1; - for (int s = 0; s < sequence.length; s++) + for (int sp,s = 0; s < sequence.length; s++) { for (int m = 0; m < mapping.length; m++) { if (mapping[m].getSequence() == sequence[s] - && ap.av.alignment.findIndex(sequence[s])>-1) + && (sp=ap.av.alignment.findIndex(sequence[s]))>-1) { - for (int r = 0; r < sequence[s].getLength(); r++) + SequenceI asp = ap.av.alignment.getSequenceAt(sp); + for (int r = 0; r < asp.getLength(); r++) { + // No mapping to gaps in sequence. + if (jalview.util.Comparison.isGap(asp.getCharAt(r))) + { + continue; + } int pos = mapping[m].getPDBResNum( - sequence[s].findPosition(r)); + asp.findPosition(r)); if (pos < 1 || pos==lastPos) continue; lastPos = pos; - Color col = sr.getResidueBoxColour(sequence[s], r); + Color col = sr.getResidueBoxColour(asp, r); if (showFeatures) - col = fr.findFeatureColour(col, sequence[s], r); + col = fr.findFeatureColour(col, asp, r); if (command.toString().endsWith(":" + mapping[m].getChain()+ ";color[" -- 1.7.10.2