From bdf1428136ce701e58a90f346973dbdf9d42b316 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Tue, 7 Mar 2017 15:53:30 +0000 Subject: [PATCH] JAL-2295 status messages for Chimera attributes set and for failed superposition --- resources/lang/Messages.properties | 5 +- resources/lang/Messages_es.properties | 2 +- src/jalview/ext/jmol/JalviewJmolBinding.java | 91 +++++++-------- .../ext/rbvi/chimera/JalviewChimeraBinding.java | 119 ++++++++++---------- src/jalview/gui/ChimeraViewFrame.java | 27 +++-- src/jalview/gui/StructureViewerBase.java | 61 ++++++++-- src/jalview/jbgui/GStructureViewer.java | 5 +- .../structure/StructureSelectionManager.java | 4 +- .../structures/models/AAStructureBindingModel.java | 35 ++++-- .../models/AAStructureBindingModelTest.java | 49 ++++---- 10 files changed, 231 insertions(+), 167 deletions(-) diff --git a/resources/lang/Messages.properties b/resources/lang/Messages.properties index 138cf89..d6d3034 100644 --- a/resources/lang/Messages.properties +++ b/resources/lang/Messages.properties @@ -515,7 +515,7 @@ label.retrieve_parse_sequence_database_records_alignment_or_selected_sequences = label.standard_databases = Standard Databases label.fetch_embl_uniprot = Fetch from EMBL/EMBLCDS or Uniprot/PDB and any selected DAS sources label.reset_min_max_colours_to_defaults = Reset min and max colours to defaults from user preferences. -label.align_structures_using_linked_alignment_views = Superpose structures using selected alignment view +label.align_structures_using_linked_alignment_views = Superpose structures using {0} selected alignment view(s) label.connect_to_session = Connect to session {0} label.threshold_feature_display_by_score = Threshold the feature display by score. label.threshold_feature_no_threshold = No Threshold @@ -716,10 +716,13 @@ label.pdb_file = PDB file label.colour_with_jmol = Colour with Jmol label.colour_with_chimera = Colour with Chimera label.superpose_structures = Superpose Structures +error.superposition_failed = Superposition failed: {0} +label.insufficient_residues = Not enough aligned residues ({0}) to perform superposition label.jmol = Jmol label.chimera = Chimera label.create_chimera_attributes = Write Jalview features label.create_chimera_attributes_tip = Set Chimera residue attributes for visible features +label.attributes_set = {0} attribute values set on Chimera label.sort_alignment_by_tree = Sort Alignment By Tree label.mark_unlinked_leaves = Mark Unlinked Leaves label.associate_leaves_with = Associate Leaves With diff --git a/resources/lang/Messages_es.properties b/resources/lang/Messages_es.properties index d408fee..6b8761e 100644 --- a/resources/lang/Messages_es.properties +++ b/resources/lang/Messages_es.properties @@ -476,7 +476,7 @@ label.retrieve_parse_sequence_database_records_alignment_or_selected_sequences = label.standard_databases = Bases de datos estándar label.fetch_embl_uniprot = Recuperar de EMBL/EMBLCDS o Uniprot/PDB y de cualquier fuente DAS seleccionada label.reset_min_max_colours_to_defaults = Reiniciar los colores min y max colours a los valores por defecto establecidos en las preferencias de usuario -label.align_structures_using_linked_alignment_views = Alinear las estructuras utlizando las {0} vistas de alineamiento enlazadas +label.align_structures_using_linked_alignment_views = Alinear las estructuras utilizando las {0} vista(s) de alineamiento enlazada(s) label.connect_to_session = Conectar a la sesión {0} label.threshold_feature_display_by_score = Filtrar la característica mostrada por puntuación. label.threshold_feature_no_threshold = Sin umbral diff --git a/src/jalview/ext/jmol/JalviewJmolBinding.java b/src/jalview/ext/jmol/JalviewJmolBinding.java index bf80831..f21f630 100644 --- a/src/jalview/ext/jmol/JalviewJmolBinding.java +++ b/src/jalview/ext/jmol/JalviewJmolBinding.java @@ -34,6 +34,7 @@ import jalview.structure.AtomSpec; import jalview.structure.StructureMappingcommandSet; import jalview.structure.StructureSelectionManager; import jalview.structures.models.AAStructureBindingModel; +import jalview.util.MessageManager; import java.awt.Color; import java.awt.Container; @@ -43,6 +44,7 @@ import java.io.File; import java.net.URL; import java.security.AccessControlException; import java.util.ArrayList; +import java.util.BitSet; import java.util.Hashtable; import java.util.List; import java.util.Map; @@ -227,21 +229,10 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel } /** - * Construct and send a command to align structures against a reference - * structure, based on one or more sequence alignments - * - * @param _alignment - * an array of alignments to process - * @param _refStructure - * an array of corresponding reference structures (index into pdb - * file array); if a negative value is passed, the first PDB file - * mapped to an alignment sequence is used as the reference for - * superposition - * @param _hiddenCols - * an array of corresponding hidden columns for each alignment + * {@inheritDoc} */ @Override - public void superposeStructures(AlignmentI[] _alignment, + public String superposeStructures(AlignmentI[] _alignment, int[] _refStructure, ColumnSelection[] _hiddenCols) { while (viewer.isScriptExecuting()) @@ -261,7 +252,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel String[] files = getPdbFile(); if (!waitForFileLoad(files)) { - return; + return null; } StringBuilder selectioncom = new StringBuilder(256); @@ -277,6 +268,7 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel nSeconds = " " + (2.0 / files.length) + " "; // if (nSeconds).substring(0,5)+" "; } + // see JAL-1345 - should really automatically turn off the animation for // large numbers of structures, but Jmol doesn't seem to allow that. // nSeconds = " "; @@ -302,14 +294,16 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel } /* - * 'matched' array will hold 'true' for visible alignment columns where + * 'matched' bit j will be set for visible alignment columns j where * all sequences have a residue with a mapping to the PDB structure */ - // TODO could use a BitSet for matched - boolean matched[] = new boolean[alignment.getWidth()]; - for (int m = 0; m < matched.length; m++) + BitSet matched = new BitSet(); + for (int m = 0; m < alignment.getWidth(); m++) { - matched[m] = (hiddenCols != null) ? hiddenCols.isVisible(m) : true; + if (hiddenCols == null || hiddenCols.isVisible(m)) + { + matched.set(m); + } } SuperposeData[] structures = new SuperposeData[files.length]; @@ -334,17 +328,12 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel } String[] selcom = new String[files.length]; - int nmatched = 0; - for (boolean b : matched) - { - if (b) - { - nmatched++; - } - } + int nmatched = matched.cardinality(); if (nmatched < 4) { - // TODO: bail out here because superposition illdefined? + return (MessageManager.formatMessage( +"label.insufficient_residues", + nmatched)); } /* @@ -359,35 +348,35 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel boolean run = false; StringBuilder molsel = new StringBuilder(); molsel.append("{"); - for (int r = 0; r < matched.length; r++) + + int nextColumnMatch = matched.nextSetBit(0); + while (nextColumnMatch != -1) { - if (matched[r]) + int pdbResNo = structures[pdbfnum].pdbResNo[nextColumnMatch]; + if (lpos != pdbResNo - 1) { - int pdbResNo = structures[pdbfnum].pdbResNo[r]; - if (lpos != pdbResNo - 1) + // discontinuity + if (lpos != -1) { - // discontinuity - if (lpos != -1) - { - molsel.append(lpos); - molsel.append(chainCd); - molsel.append("|"); - } - run = false; + molsel.append(lpos); + molsel.append(chainCd); + molsel.append("|"); } - else + run = false; + } + else + { + // continuous run - and lpos >-1 + if (!run) { - // continuous run - and lpos >-1 - if (!run) - { - // at the beginning, so add dash - molsel.append(lpos); - molsel.append("-"); - } - run = true; + // at the beginning, so add dash + molsel.append(lpos); + molsel.append("-"); } - lpos = pdbResNo; + run = true; } + lpos = pdbResNo; + nextColumnMatch = matched.nextSetBit(nextColumnMatch + 1); } /* * add final selection phrase @@ -473,6 +462,8 @@ public abstract class JalviewJmolBinding extends AAStructureBindingModel + selectioncom.toString() + "); cartoons; "); // evalStateCommand("select *; backbone; select "+selcom.toString()+"; cartoons; center "+selcom.toString()); } + + return null; } public void evalStateCommand(String command) diff --git a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java index 2042ac4..408256a 100644 --- a/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java +++ b/src/jalview/ext/rbvi/chimera/JalviewChimeraBinding.java @@ -29,7 +29,7 @@ import jalview.datamodel.AlignmentI; import jalview.datamodel.ColumnSelection; import jalview.datamodel.PDBEntry; import jalview.datamodel.SearchResultMatchI; -import jalview.datamodel.SearchResults; +import jalview.datamodel.SearchResultsI; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceI; import jalview.httpserver.AbstractRequestHandler; @@ -49,6 +49,7 @@ import java.io.IOException; import java.io.PrintWriter; import java.net.BindException; import java.util.ArrayList; +import java.util.BitSet; import java.util.Collections; import java.util.Hashtable; import java.util.LinkedHashMap; @@ -340,21 +341,10 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel } /** - * Construct and send a command to align structures against a reference - * structure, based on one or more sequence alignments - * - * @param _alignment - * an array of alignments to process - * @param _refStructure - * an array of corresponding reference structures (index into pdb - * file array); if a negative value is passed, the first PDB file - * mapped to an alignment sequence is used as the reference for - * superposition - * @param _hiddenCols - * an array of corresponding hidden columns for each alignment + * {@inheritDoc} */ @Override - public void superposeStructures(AlignmentI[] _alignment, + public String superposeStructures(AlignmentI[] _alignment, int[] _refStructure, ColumnSelection[] _hiddenCols) { StringBuilder allComs = new StringBuilder(128); @@ -362,7 +352,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel if (!waitForFileLoad(files)) { - return; + return null; } refreshPdbEntries(); @@ -381,13 +371,16 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel } /* - * 'matched' array will hold 'true' for visible alignment columns where + * 'matched' bit i will be set for visible alignment columns i where * all sequences have a residue with a mapping to the PDB structure */ - boolean matched[] = new boolean[alignment.getWidth()]; - for (int m = 0; m < matched.length; m++) + BitSet matched = new BitSet(); + for (int m = 0; m < alignment.getWidth(); m++) { - matched[m] = (hiddenCols != null) ? hiddenCols.isVisible(m) : true; + if (hiddenCols == null || hiddenCols.isVisible(m)) + { + matched.set(m); + } } SuperposeData[] structures = new SuperposeData[files.length]; @@ -411,17 +404,11 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel refStructure = candidateRefStructure; } - int nmatched = 0; - for (boolean b : matched) - { - if (b) - { - nmatched++; - } - } + int nmatched = matched.cardinality(); if (nmatched < 4) { - // TODO: bail out here because superposition illdefined? + return MessageManager.formatMessage("label.insufficient_residues", + nmatched); } /* @@ -434,41 +421,41 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel int lpos = -1; boolean run = false; StringBuilder molsel = new StringBuilder(); - for (int r = 0; r < matched.length; r++) + + int nextColumnMatch = matched.nextSetBit(0); + while (nextColumnMatch != -1) { - if (matched[r]) + int pdbResNum = structures[pdbfnum].pdbResNo[nextColumnMatch]; + if (lpos != pdbResNum - 1) { - int pdbResNum = structures[pdbfnum].pdbResNo[r]; - if (lpos != pdbResNum - 1) + /* + * discontiguous - append last residue now + */ + if (lpos != -1) { - /* - * discontiguous - append last residue now - */ - if (lpos != -1) - { - molsel.append(String.valueOf(lpos)); - molsel.append(chainCd); - molsel.append(","); - } - run = false; + molsel.append(String.valueOf(lpos)); + molsel.append(chainCd); + molsel.append(","); } - else + run = false; + } + else + { + /* + * extending a contiguous run + */ + if (!run) { /* - * extending a contiguous run + * start the range selection */ - if (!run) - { - /* - * start the range selection - */ - molsel.append(String.valueOf(lpos)); - molsel.append("-"); - } - run = true; + molsel.append(String.valueOf(lpos)); + molsel.append("-"); } - lpos = pdbResNum; + run = true; } + lpos = pdbResNum; + nextColumnMatch = matched.nextSetBit(nextColumnMatch + 1); } /* @@ -544,6 +531,8 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel .append(";" + command.toString()); } } + + String error = null; if (selectioncom.length() > 0) { // TODO: visually distinguish regions that were superposed @@ -557,9 +546,17 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel } allComs.append("; ~display all; chain @CA|P; ribbon ") .append(selectioncom.toString()).append("; focus"); - sendChimeraCommand(allComs.toString(), false); + List chimeraReplies = sendChimeraCommand(allComs.toString(), + true); + for (String reply : chimeraReplies) + { + if (reply.toLowerCase().contains("unequal numbers of atoms")) + { + error = reply; + } + } } - + return error; } /** @@ -1106,8 +1103,9 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel * features visible in Jalview * * @param avp + * @return */ - public void sendFeaturesToViewer(AlignmentViewPanel avp) + public int sendFeaturesToViewer(AlignmentViewPanel avp) { // TODO refactor as required to pull up to an interface AlignmentI alignment = avp.getAlignment(); @@ -1118,13 +1116,13 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel */ if (fr == null) { - return; + return 0; } String[] files = getPdbFile(); if (files == null) { - return; + return 0; } StructureMappingcommandSet commandSet = ChimeraCommands @@ -1142,6 +1140,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel sendAsynchronousCommand(command, null); } } + return commands.length; } /** @@ -1274,7 +1273,7 @@ public abstract class JalviewChimeraBinding extends AAStructureBindingModel /* * locate the mapped position in the alignment (if any) */ - SearchResults sr = getSsm() + SearchResultsI sr = getSsm() .findAlignmentPositionsForStructurePositions(atoms); /* diff --git a/src/jalview/gui/ChimeraViewFrame.java b/src/jalview/gui/ChimeraViewFrame.java index 67eddca..fe4a000 100644 --- a/src/jalview/gui/ChimeraViewFrame.java +++ b/src/jalview/gui/ChimeraViewFrame.java @@ -76,6 +76,10 @@ public class ChimeraViewFrame extends StructureViewerBase private Random random = new Random(); + private int myWidth = 500; + + private int myHeight = 150; + /** * Initialise menu options. */ @@ -185,7 +189,9 @@ public class ChimeraViewFrame extends StructureViewerBase */ protected void sendFeaturesToChimera() { - jmb.sendFeaturesToViewer(getAlignmentPanel()); + int count = jmb.sendFeaturesToViewer(getAlignmentPanel()); + statusBar.setText(MessageManager.formatMessage("label.attributes_set", + count)); } /** @@ -254,7 +260,7 @@ public class ChimeraViewFrame extends StructureViewerBase useAlignmentPanelForSuperposition(ap); } jmb.setColourBySequence(true); - setSize(400, 400); // probably should be a configurable/dynamic default here + setSize(myWidth, myHeight); initMenus(); addingStructures = false; @@ -852,19 +858,18 @@ public class ChimeraViewFrame extends StructureViewerBase } /** - * Override superclass method to make the 'Chimera' menu always visible, but - * 'Superpose with...' only enabled if there is more than one structure shown + * Sends commands to align structures according to associated alignment(s). + * + * @return */ @Override - public void updateTitleAndMenus() + protected String alignStructs_withAllAlignPanels() { - super.updateTitleAndMenus(); - viewerActionMenu.setVisible(true); - viewSelectionMenu.setEnabled(false); - if (getBinding().getPdbFile().length > 1 - && getBinding().getSequence().length > 1) + String reply = super.alignStructs_withAllAlignPanels(); + if (reply != null) { - viewSelectionMenu.setEnabled(true); + statusBar.setText("Superposition failed: " + reply); } + return reply; } } diff --git a/src/jalview/gui/StructureViewerBase.java b/src/jalview/gui/StructureViewerBase.java index 44a429c..d7f7c31 100644 --- a/src/jalview/gui/StructureViewerBase.java +++ b/src/jalview/gui/StructureViewerBase.java @@ -747,9 +747,9 @@ public abstract class StructureViewerBase extends GStructureViewer public void itemStateChanged(ItemEvent e) { alignStructs.setEnabled(!_alignwith.isEmpty()); - alignStructs - .setToolTipText(MessageManager - .getString("label.align_structures_using_linked_alignment_views")); + alignStructs.setToolTipText(MessageManager.formatMessage( + "label.align_structures_using_linked_alignment_views", + _alignwith.size())); } }; viewSelectionMenu = new ViewSelectionMenu( @@ -783,16 +783,24 @@ public abstract class StructureViewerBase extends GStructureViewer public void setJalviewColourScheme(ColourSchemeI cs) { getBinding().setJalviewColourScheme(cs); } + + /** + * Sends commands to the structure viewer to superimpose structures based on + * currently associated alignments. May optionally return an error message for + * the operation. + */ @Override - protected void alignStructs_actionPerformed(ActionEvent actionEvent) + protected String alignStructs_actionPerformed( + ActionEvent actionEvent) { - alignStructs_withAllAlignPanels(); + return alignStructs_withAllAlignPanels(); } - protected void alignStructs_withAllAlignPanels() + + protected String alignStructs_withAllAlignPanels() { if (getAlignmentPanel() == null) { - return; + return null; } if (_alignwith.size() == 0) @@ -800,6 +808,7 @@ public abstract class StructureViewerBase extends GStructureViewer _alignwith.add(getAlignmentPanel()); } + String reply = null; try { AlignmentI[] als = new Alignment[_alignwith.size()]; @@ -813,7 +822,13 @@ public abstract class StructureViewerBase extends GStructureViewer alm[a] = -1; alc[a++] = ap.av.getColumnSelection(); } - getBinding().superposeStructures(als, alm, alc); + reply = getBinding().superposeStructures(als, alm, alc); + if (reply != null) + { + String text = MessageManager.formatMessage( + "error.superposition_failed", reply); + statusBar.setText(text); + } } catch (Exception e) { StringBuffer sp = new StringBuffer(); @@ -824,7 +839,9 @@ public abstract class StructureViewerBase extends GStructureViewer Cache.log.info("Couldn't align structures with the " + sp.toString() + "associated alignment panels.", e); } + return reply; } + @Override public void background_actionPerformed(ActionEvent actionEvent) { @@ -954,6 +971,10 @@ public abstract class StructureViewerBase extends GStructureViewer } protected abstract String getViewerName(); + + /** + * Configures the title and menu items of the viewer panel. + */ public void updateTitleAndMenus() { AAStructureBindingModel binding = getBinding(); @@ -965,10 +986,30 @@ public abstract class StructureViewerBase extends GStructureViewer setChainMenuItems(binding.getChainNames()); this.setTitle(binding.getViewerTitle(getViewerName(), true)); - if (binding.getPdbFile().length > 1 && binding.getSequence().length > 1) + + /* + * enable 'Superpose with' if more than one mapped structure + */ + viewSelectionMenu.setEnabled(false); + if (getBinding().getPdbFile().length > 1 + && getBinding().getSequence().length > 1) { - viewerActionMenu.setVisible(true); + viewSelectionMenu.setEnabled(true); } + + /* + * Show action menu if it has any enabled items + */ + viewerActionMenu.setVisible(false); + for (int i = 0; i < viewerActionMenu.getItemCount(); i++) + { + if (viewerActionMenu.getItem(i).isEnabled()) + { + viewerActionMenu.setVisible(true); + break; + } + } + if (!binding.isLoadingFromArchive()) { seqColour_actionPerformed(null); diff --git a/src/jalview/jbgui/GStructureViewer.java b/src/jalview/jbgui/GStructureViewer.java index 5c7a31a..d8f3f61 100644 --- a/src/jalview/jbgui/GStructureViewer.java +++ b/src/jalview/jbgui/GStructureViewer.java @@ -219,9 +219,8 @@ public abstract class GStructureViewer extends JInternalFrame implements { } - protected void alignStructs_actionPerformed(ActionEvent actionEvent) - { - } + protected abstract String alignStructs_actionPerformed( + ActionEvent actionEvent); public void pdbFile_actionPerformed(ActionEvent actionEvent) { diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index 7519538..428cf6d 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -824,10 +824,10 @@ public class StructureSelectionManager * @param atoms * @return */ - public SearchResults findAlignmentPositionsForStructurePositions( + public SearchResultsI findAlignmentPositionsForStructurePositions( List atoms) { - SearchResults results = new SearchResults(); + SearchResultsI results = new SearchResults(); for (AtomSpec atom : atoms) { SequenceI lastseq = null; diff --git a/src/jalview/structures/models/AAStructureBindingModel.java b/src/jalview/structures/models/AAStructureBindingModel.java index fda08fd..bb9ee85 100644 --- a/src/jalview/structures/models/AAStructureBindingModel.java +++ b/src/jalview/structures/models/AAStructureBindingModel.java @@ -42,6 +42,7 @@ import jalview.util.MessageManager; import java.awt.Color; import java.util.ArrayList; import java.util.Arrays; +import java.util.BitSet; import java.util.List; /** @@ -521,15 +522,15 @@ public abstract class AAStructureBindingModel extends * the sequence alignment which is the basis of structure * superposition * @param matched - * an array of booleans, indexed by alignment column, where true - * indicates that every structure has a mapped residue present in the - * column (so the column can participate in structure alignment) + * a BitSet, where bit j is set to indicate that every structure has + * a mapped residue present in column j (so the column can + * participate in structure alignment) * @param structures * an array of data beans corresponding to pdb file index * @return */ protected int findSuperposableResidues(AlignmentI alignment, - boolean[] matched, SuperposeData[] structures) + BitSet matched, SuperposeData[] structures) { int refStructure = -1; String[] files = getPdbFile(); @@ -559,16 +560,16 @@ public abstract class AAStructureBindingModel extends { refStructure = pdbfnum; } - for (int r = 0; r < matched.length; r++) + for (int r = 0; r < alignment.getWidth(); r++) { - if (!matched[r]) + if (!matched.get(r)) { continue; } int pos = getMappedPosition(theSequence, r, mapping); if (pos < 1 || pos == lastPos) { - matched[r] = false; + matched.clear(r); continue; } lastPos = pos; @@ -700,8 +701,24 @@ public abstract class AAStructureBindingModel extends public abstract void setJalviewColourScheme(ColourSchemeI cs); - public abstract void superposeStructures(AlignmentI[] als, int[] alm, - ColumnSelection[] alc); + /** + * Constructs and sends a command to align structures against a reference + * structure, based on one or more sequence alignments. May optionally return + * an error or warning message for the alignment command. + * + * @param alignments + * an array of alignments to process + * @param structureIndices + * an array of corresponding reference structures (index into pdb + * file array); if a negative value is passed, the first PDB file + * mapped to an alignment sequence is used as the reference for + * superposition + * @param hiddenCols + * an array of corresponding hidden columns for each alignment + * @return + */ + public abstract String superposeStructures(AlignmentI[] alignments, int[] structureIndices, + ColumnSelection[] hiddenCols); public abstract void setBackgroundColour(Color col); diff --git a/test/jalview/structures/models/AAStructureBindingModelTest.java b/test/jalview/structures/models/AAStructureBindingModelTest.java index 0422537..bdbbe88 100644 --- a/test/jalview/structures/models/AAStructureBindingModelTest.java +++ b/test/jalview/structures/models/AAStructureBindingModelTest.java @@ -44,6 +44,7 @@ import jalview.structures.models.AAStructureBindingModel.SuperposeData; import java.awt.Color; import java.util.Arrays; +import java.util.BitSet; import java.util.List; import org.testng.annotations.BeforeClass; @@ -169,9 +170,10 @@ public class AAStructureBindingModelTest } @Override - public void superposeStructures(AlignmentI[] als, int[] alm, + public String superposeStructures(AlignmentI[] als, int[] alm, ColumnSelection[] alc) { + return null; } @Override @@ -234,11 +236,14 @@ public class AAStructureBindingModelTest structs[i] = testee.new SuperposeData(al.getWidth()); } /* - * initialise array of 'superposable columns' to true (would be false for + * initialise BitSet of 'superposable columns' to true (would be false for * hidden columns) */ - boolean[] matched = new boolean[al.getWidth()]; - Arrays.fill(matched, true); + BitSet matched = new BitSet(); + for (int i = 0; i < al.getWidth(); i++) + { + matched.set(i); + } int refStructure = testee .findSuperposableResidues(al, matched, structs); @@ -248,12 +253,12 @@ public class AAStructureBindingModelTest /* * only ungapped, structure-mapped columns are superposable */ - assertFalse(matched[0]); // gap in first sequence - assertTrue(matched[1]); - assertFalse(matched[2]); // gap in third sequence - assertFalse(matched[3]); // gap in fourth sequence - assertTrue(matched[4]); - assertTrue(matched[5]); // gap in second sequence + assertFalse(matched.get(0)); // gap in first sequence + assertTrue(matched.get(1)); + assertFalse(matched.get(2)); // gap in third sequence + assertFalse(matched.get(3)); // gap in fourth sequence + assertTrue(matched.get(4)); + assertTrue(matched.get(5)); // gap in second sequence assertEquals("1YCS", structs[0].pdbId); assertEquals("3A6S", structs[1].pdbId); @@ -278,13 +283,17 @@ public class AAStructureBindingModelTest structs[i] = testee.new SuperposeData(al.getWidth()); } /* - * initialise array of 'superposable columns' to true (would be false for + * initialise BitSet of 'superposable columns' to true (would be false for * hidden columns) */ - boolean[] matched = new boolean[al.getWidth()]; - Arrays.fill(matched, true); + BitSet matched = new BitSet(); + for (int i = 0; i < al.getWidth(); i++) + { + matched.set(i); + } + // treat column 5 of the alignment as hidden - matched[4] = false; + matched.clear(4); int refStructure = testee .findSuperposableResidues(al, matched, structs); @@ -292,12 +301,12 @@ public class AAStructureBindingModelTest assertEquals(0, refStructure); // only ungapped, structure-mapped columns are not superposable - assertFalse(matched[0]); - assertTrue(matched[1]); - assertFalse(matched[2]); - assertFalse(matched[3]); - assertFalse(matched[4]); // superposable, but hidden, column - assertTrue(matched[5]); + assertFalse(matched.get(0)); + assertTrue(matched.get(1)); + assertFalse(matched.get(2)); + assertFalse(matched.get(3)); + assertFalse(matched.get(4)); // superposable, but hidden, column + assertTrue(matched.get(5)); } public FeatureRenderer getFeatureRenderer(AlignmentViewPanel alignment) -- 1.7.10.2