From f14ab8c56014768bb0f94df591e83511aa506bdd Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Tue, 28 Mar 2017 18:03:41 +0100 Subject: [PATCH] JAL-2465 bugfix and rerefactor renamed getPdbFile() method to getStructureFile() --- src/MCview/AppletPDBCanvas.java | 2 +- src/MCview/PDBCanvas.java | 2 +- src/jalview/ext/jmol/JalviewJmolBinding.java | 38 ++++++++++++++++---- .../ext/rbvi/chimera/JalviewChimeraBinding.java | 10 +++--- src/jalview/gui/AppJmol.java | 8 ++--- src/jalview/gui/StructureViewerBase.java | 4 +-- .../javascript/MouseOverStructureListener.java | 2 +- src/jalview/structure/StructureListener.java | 2 +- .../structure/StructureSelectionManager.java | 2 +- .../structures/models/AAStructureBindingModel.java | 4 +-- .../ext/rbvi/chimera/JalviewChimeraView.java | 2 +- .../models/AAStructureBindingModelTest.java | 4 +-- 12 files changed, 53 insertions(+), 27 deletions(-) diff --git a/src/MCview/AppletPDBCanvas.java b/src/MCview/AppletPDBCanvas.java index edcd754..0f3da69 100644 --- a/src/MCview/AppletPDBCanvas.java +++ b/src/MCview/AppletPDBCanvas.java @@ -1125,7 +1125,7 @@ public class AppletPDBCanvas extends Panel implements MouseListener, // //////////////////////////////// // /StructureListener @Override - public String[] getPdbFile() + public String[] getStructureFiles() { return new String[] { pdbentry.getFile() }; } diff --git a/src/MCview/PDBCanvas.java b/src/MCview/PDBCanvas.java index baecac0..ec0804a 100644 --- a/src/MCview/PDBCanvas.java +++ b/src/MCview/PDBCanvas.java @@ -1082,7 +1082,7 @@ public class PDBCanvas extends JPanel implements MouseListener, // //////////////////////////////// // /StructureListener @Override - public String[] getPdbFile() + public String[] getStructureFiles() { return new String[] { pdbentry.getFile() }; } diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index 8d49bff..f409ff7 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -165,7 +165,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel public void closeViewer() { // remove listeners for all structures in viewer - getSsm().removeStructureViewerListener(this, this.getPdbFile()); + getSsm().removeStructureViewerListener(this, this.getStructureFiles()); viewer.dispose(); lastCommand = null; viewer = null; @@ -251,7 +251,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel * get the distinct structure files modelled * (a file with multiple chains may map to multiple sequences) */ - String[] files = getPdbFile(); + String[] files = getStructureFiles(); if (!waitForFileLoad(files)) { return null; @@ -580,7 +580,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel private int getModelNum(String modelFileName) { - String[] mfn = getPdbFile(); + String[] mfn = getStructureFiles(); if (mfn == null) { return -1; @@ -604,8 +604,8 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel // //////////////////////////////// // /StructureListener - @Override - public synchronized String[] getPdbFile() + // @Override + public synchronized String[] getPdbFilex() { if (viewer == null) { @@ -670,6 +670,32 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel return modelFileNames; } + @Override + public synchronized String[] getStructureFiles() + { + List mset = new ArrayList(); + if (viewer == null) + { + return new String[0]; + } + + if (modelFileNames == null) + { + int modelCount = viewer.ms.mc; + String filePath = null; + for (int i = 0; i < modelCount; ++i) + { + filePath = viewer.ms.getModelFileName(i); + if (!mset.contains(filePath)) + { + mset.add(filePath); + } + } + modelFileNames = mset.toArray(new String[mset.size()]); + } + + return modelFileNames; + } /** * map from string to applet */ @@ -1038,7 +1064,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel chainNames = new ArrayList(); chainFile = new Hashtable(); boolean notifyLoaded = false; - String[] modelfilenames = getPdbFile(); + String[] modelfilenames = getStructureFiles(); // first check if we've lost any structures if (oldmodels != null && oldmodels.length > 0) { diff --git a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java index 9a570fc..745b1e1 100644 --- a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java +++ b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java @@ -298,7 +298,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel */ public void closeViewer(boolean closeChimera) { - getSsm().removeStructureViewerListener(this, this.getPdbFile()); + getSsm().removeStructureViewerListener(this, this.getStructureFiles()); if (closeChimera) { viewer.exitChimera(); @@ -349,7 +349,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel int[] _refStructure, ColumnSelection[] _hiddenCols) { StringBuilder allComs = new StringBuilder(128); - String[] files = getPdbFile(); + String[] files = getStructureFiles(); if (!waitForFileLoad(files)) { @@ -586,7 +586,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel * to the Chimera command 'list models type molecule', see * ChimeraManager.getModelList(). */ - List maps = chimeraMaps.get(getPdbFile()[pdbfnum]); + List maps = chimeraMaps.get(getStructureFiles()[pdbfnum]); boolean hasSubModels = maps != null && maps.size() > 1; return "#" + String.valueOf(pdbfnum) + (hasSubModels ? ".1" : ""); } @@ -756,7 +756,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel // //////////////////////////////// // /StructureListener @Override - public synchronized String[] getPdbFile() + public synchronized String[] getStructureFiles() { if (viewer == null) { @@ -1120,7 +1120,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel return 0; } - String[] files = getPdbFile(); + String[] files = getStructureFiles(); if (files == null) { return 0; diff --git a/src/jalview/gui/AppJmol.java b/src/jalview/gui/AppJmol.java index 9c4dd9d..940f606 100644 --- a/src/jalview/gui/AppJmol.java +++ b/src/jalview/gui/AppJmol.java @@ -416,8 +416,8 @@ public class AppJmol extends StructureViewerBase int waitFor = 35; int waitTotal = 0; while (addingStructures ? lastnotify >= jmb.getLoadNotifiesHandled() - : !(jmb.isFinishedInit() && jmb.getPdbFile() != null && jmb - .getPdbFile().length == files.size())) + : !(jmb.isFinishedInit() && jmb.getStructureFiles() != null && jmb + .getStructureFiles().length == files.size())) { try { @@ -435,7 +435,7 @@ public class AppJmol extends StructureViewerBase // System.err.println("finished: " + jmb.isFinishedInit() // + "; loaded: " + Arrays.toString(jmb.getPdbFile()) // + "; files: " + files.toString()); - jmb.getPdbFile(); + jmb.getStructureFiles(); break; } } @@ -500,7 +500,7 @@ public class AppJmol extends StructureViewerBase String pdbid = ""; try { - String[] filesInViewer = jmb.getPdbFile(); + String[] filesInViewer = jmb.getStructureFiles(); // TODO: replace with reference fetching/transfer code (validate PDBentry // as a DBRef?) Pdb pdbclient = new Pdb(); diff --git a/src/jalview/gui/StructureViewerBase.java b/src/jalview/gui/StructureViewerBase.java index 964f1ff..6e7936b 100644 --- a/src/jalview/gui/StructureViewerBase.java +++ b/src/jalview/gui/StructureViewerBase.java @@ -923,7 +923,7 @@ public abstract class StructureViewerBase extends GStructureViewer { // TODO: cope with multiple PDB files in view in = new BufferedReader( - new FileReader(getBinding().getPdbFile()[0])); + new FileReader(getBinding().getStructureFiles()[0])); File outFile = chooser.getSelectedFile(); PrintWriter out = new PrintWriter(new FileOutputStream(outFile)); @@ -995,7 +995,7 @@ public abstract class StructureViewerBase extends GStructureViewer * enable 'Superpose with' if more than one mapped structure */ viewSelectionMenu.setEnabled(false); - if (getBinding().getPdbFile().length > 1 + if (getBinding().getStructureFiles().length > 1 && getBinding().getSequence().length > 1) { viewSelectionMenu.setEnabled(true); diff --git a/src/jalview/javascript/MouseOverStructureListener.java b/src/jalview/javascript/MouseOverStructureListener.java index 6d366d0..e4758a8 100644 --- a/src/jalview/javascript/MouseOverStructureListener.java +++ b/src/jalview/javascript/MouseOverStructureListener.java @@ -126,7 +126,7 @@ public class MouseOverStructureListener extends JSFunctionExec implements } @Override - public String[] getPdbFile() + public String[] getStructureFiles() { return modelSet; } diff --git a/src/jalview/structure/StructureListener.java b/src/jalview/structure/StructureListener.java index e5c5d04..9fde3f1 100644 --- a/src/jalview/structure/StructureListener.java +++ b/src/jalview/structure/StructureListener.java @@ -31,7 +31,7 @@ public interface StructureListener * handles messages for, or null if generic listener (only used by * removeListener method) */ - public String[] getPdbFile(); + public String[] getStructureFiles(); /** * Called by StructureSelectionManager to inform viewer to highlight given diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index 991ba82..c91317e 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -785,7 +785,7 @@ public class StructureSelectionManager if (listeners.elementAt(i) instanceof StructureListener) { sl = (StructureListener) listeners.elementAt(i); - for (String pdbfile : sl.getPdbFile()) + for (String pdbfile : sl.getStructureFiles()) { pdbs.remove(pdbfile); } diff --git a/src/jalview/structures/models/AAStructureBindingModel.java b/src/jalview/structures/models/AAStructureBindingModel.java index 7d57886..e0c2226 100644 --- a/src/jalview/structures/models/AAStructureBindingModel.java +++ b/src/jalview/structures/models/AAStructureBindingModel.java @@ -534,7 +534,7 @@ public abstract class AAStructureBindingModel extends BitSet matched, SuperposeData[] structures) { int refStructure = -1; - String[] files = getPdbFile(); + String[] files = getStructureFiles(); if (files == null) { return -1; @@ -769,7 +769,7 @@ public abstract class AAStructureBindingModel extends { return; } - String[] files = getPdbFile(); + String[] files = getStructureFiles(); SequenceRenderer sr = getSequenceRenderer(alignmentv); diff --git a/test/jalview/ext/rbvi/chimera/JalviewChimeraView.java b/test/jalview/ext/rbvi/chimera/JalviewChimeraView.java index d85bb10..29fd092 100644 --- a/test/jalview/ext/rbvi/chimera/JalviewChimeraView.java +++ b/test/jalview/ext/rbvi/chimera/JalviewChimeraView.java @@ -217,7 +217,7 @@ public class JalviewChimeraView * (or possibly 52-145 to 1-94 - see JAL-2319) */ StructureSelectionManager ssm = binding.getSsm(); - String pdbFile = binding.getPdbFile()[0]; + String pdbFile = binding.getStructureFiles()[0]; StructureMapping[] mappings = ssm.getMapping(pdbFile); assertTrue(mappings[0].getMappingDetailsOutput().contains("SIFTS"), "Failed to perform SIFTS mapping"); diff --git a/test/jalview/structures/models/AAStructureBindingModelTest.java b/test/jalview/structures/models/AAStructureBindingModelTest.java index 855bdb9..02e0cde 100644 --- a/test/jalview/structures/models/AAStructureBindingModelTest.java +++ b/test/jalview/structures/models/AAStructureBindingModelTest.java @@ -140,7 +140,7 @@ public class AAStructureBindingModelTest testee = new AAStructureBindingModel(ssm, pdbFiles, seqs, null) { @Override - public String[] getPdbFile() + public String[] getStructureFiles() { return new String[] { "INLINE1YCS", "INLINE3A6S", "INLINE1OOT" }; } @@ -232,7 +232,7 @@ public class AAStructureBindingModelTest /* * create a data bean to hold data per structure file */ - SuperposeData[] structs = new SuperposeData[testee.getPdbFile().length]; + SuperposeData[] structs = new SuperposeData[testee.getStructureFiles().length]; for (int i = 0; i < structs.length; i++) { structs[i] = testee.new SuperposeData(al.getWidth()); -- 1.7.10.2