From ec1c914a99011e20634fbff19df71e2627766dfd Mon Sep 17 00:00:00 2001 From: gmungoc Date: Sat, 10 Aug 2019 05:20:02 +0100 Subject: [PATCH] JAL-3404 explicit getModelForPdbFile lookup --- src/jalview/ext/jmol/JalviewJmolBinding.java | 22 +++++++------------- .../ext/rbvi/chimera/JalviewChimeraBinding.java | 14 +++++++++++++ .../structures/models/AAStructureBindingModel.java | 17 +++++++++++++-- src/jalview/util/StructureCommands.java | 10 ++++----- 4 files changed, 41 insertions(+), 22 deletions(-) diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index 5243b40..2645980 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -59,7 +59,6 @@ import org.jmol.api.JmolSelectionListener; import org.jmol.api.JmolStatusListener; import org.jmol.api.JmolViewer; import org.jmol.c.CBK; -import org.jmol.script.T; import org.jmol.viewer.Viewer; public abstract class JalviewJmolBinding extends AAStructureBindingModel @@ -558,19 +557,6 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel return null; } - public Color getColour(int atomIndex, int pdbResNum, String chain, - String pdbfile) - { - if (getModelNum(pdbfile) < 0) - { - return null; - } - // TODO: verify atomIndex is selecting correct model. - // return new Color(viewer.getAtomArgb(atomIndex)); Jmol 12.2.4 - int colour = viewer.ms.at[atomIndex].atomPropertyInt(T.color); - return new Color(colour); - } - /** * instruct the Jalview binding to update the pdbentries vector if necessary * prior to matching the jmol view's contents to the list of structure files @@ -605,7 +591,6 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel @Override public synchronized String[] getStructureFiles() { - List mset = new ArrayList<>(); if (viewer == null) { return new String[0]; @@ -613,6 +598,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel if (modelFileNames == null) { + List mset = new ArrayList<>(); int modelCount = viewer.ms.mc; String filePath = null; for (int i = 0; i < modelCount; ++i) @@ -1464,4 +1450,10 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel */ viewer.evalString("zoom 0"); } + + @Override + public int getModelForPdbFile(String fileName, int fileIndex) + { + return fileIndex; + } } diff --git a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java index f7d5c6a..3498f23 100644 --- a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java +++ b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java @@ -1283,4 +1283,18 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel } sendChimeraCommand(cmd.toString(), false); } + + @Override + public int getModelForPdbFile(String fileName, int fileIndex) + { + if (chimeraMaps.containsKey(fileName)) + { + List models = chimeraMaps.get(fileName); + if (!models.isEmpty()) + { + return models.get(0).getModelNumber(); + } + } + return -1; + } } diff --git a/src/jalview/structures/models/AAStructureBindingModel.java b/src/jalview/structures/models/AAStructureBindingModel.java index 448ed24..05c09e9 100644 --- a/src/jalview/structures/models/AAStructureBindingModel.java +++ b/src/jalview/structures/models/AAStructureBindingModel.java @@ -979,7 +979,9 @@ public abstract class AAStructureBindingModel for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++) { - StructureMapping[] mappings = getSsm().getMapping(files[pdbfnum]); + String fileName = files[pdbfnum]; + final int modelNumber = getModelForPdbFile(fileName, pdbfnum); + StructureMapping[] mappings = getSsm().getMapping(fileName); /* * Find the first mapped sequence (if any) for this PDB entry which is in @@ -1021,7 +1023,7 @@ public abstract class AAStructureBindingModel { for (int[] range : residueRanges) { - model.addRange(pdbfnum, range[0], range[1], chainCd); + model.addRange(modelNumber, range[0], range[1], chainCd); } } } @@ -1034,6 +1036,17 @@ public abstract class AAStructureBindingModel } /** + * Answers the structure viewer's model number for the given PDB file, or -1 if + * not found + * + * @param fileName + * @param fileIndex + * index of the file in the stored array of file names + * @return + */ + public abstract int getModelForPdbFile(String fileName, int fileIndex); + + /** * Answers a default structure model specification which is simply the string * form of the model number. Override if needed to specify submodels. * diff --git a/src/jalview/util/StructureCommands.java b/src/jalview/util/StructureCommands.java index 8e66da8..fb52340 100644 --- a/src/jalview/util/StructureCommands.java +++ b/src/jalview/util/StructureCommands.java @@ -95,8 +95,10 @@ public abstract class StructureCommands for (int pdbfnum = 0; pdbfnum < files.length; pdbfnum++) { + String fileName = files[pdbfnum]; + final int modelNumber = binding.getModelForPdbFile(fileName, pdbfnum); StructureMapping[] mapping = binding.getSsm() - .getMapping(files[pdbfnum]); + .getMapping(fileName); if (mapping == null || mapping.length < 1) { @@ -160,8 +162,7 @@ public abstract class StructureCommands if (startPos != -1) { StructureCommands.addAtomSpecRange(colourMap, lastColour, - pdbfnum, startPos, - lastPos, lastChain); + modelNumber, startPos, lastPos, lastChain); } startPos = pos; } @@ -173,8 +174,7 @@ public abstract class StructureCommands if (lastColour != null) { StructureCommands.addAtomSpecRange(colourMap, lastColour, - pdbfnum, - startPos, lastPos, lastChain); + modelNumber, startPos, lastPos, lastChain); } } } -- 1.7.10.2