From bc97c1d6107222987fc31af58ba390c5425dcdda Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Fri, 28 Oct 2022 15:48:32 +0100 Subject: [PATCH] JAL-4089 use column selection to superpose if 4 or more selected --- .../structures/models/AAStructureBindingModel.java | 38 ++++++++++++++++---- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/jalview/structures/models/AAStructureBindingModel.java b/src/jalview/structures/models/AAStructureBindingModel.java index 906cb59..8436b48 100644 --- a/src/jalview/structures/models/AAStructureBindingModel.java +++ b/src/jalview/structures/models/AAStructureBindingModel.java @@ -42,6 +42,7 @@ import jalview.api.StructureSelectionManagerProvider; import jalview.api.structures.JalviewStructureDisplayI; import jalview.bin.Console; import jalview.datamodel.AlignmentI; +import jalview.datamodel.ColumnSelection; import jalview.datamodel.HiddenColumns; import jalview.datamodel.MappedFeatures; import jalview.datamodel.PDBEntry; @@ -870,21 +871,39 @@ public abstract class AAStructureBindingModel { AlignmentI alignment = view.getAlignment(); HiddenColumns hiddenCols = alignment.getHiddenColumns(); - /* * 'matched' bit i will be set for visible alignment columns i where * all sequences have a residue with a mapping to their PDB structure */ - BitSet matched = new BitSet(); final int width = alignment.getWidth(); - for (int m = 0; m < width; m++) + BitSet matched = new BitSet(); + ColumnSelection cs = view.getAlignViewport().getColumnSelection(); + // restrict to active column selection, if there is one + if (cs != null && cs.hasSelectedColumns() + && cs.getSelected().size() >= 4) { - if (hiddenCols == null || hiddenCols.isVisible(m)) + for (int s : cs.getSelected()) { - matched.set(m); + if (hiddenCols == null) + { + matched.set(s); + } + else + { + matched.set(hiddenCols.visibleToAbsoluteColumn(s)); + } + } + } + else + { + for (int m = 0; m < width; m++) + { + if (hiddenCols == null || hiddenCols.isVisible(m)) + { + matched.set(m); + } } } - AAStructureBindingModel.SuperposeData[] structures = new AAStructureBindingModel.SuperposeData[files.length]; for (int f = 0; f < files.length; f++) { @@ -927,6 +946,8 @@ public abstract class AAStructureBindingModel AtomSpecType backbone = structures[refStructure].isRna ? AtomSpecType.PHOSPHATE : AtomSpecType.ALPHA; + List models = new ArrayList(); + models.add(refAtoms); /* * superpose each (other) structure to the reference in turn */ @@ -947,10 +968,13 @@ public abstract class AAStructureBindingModel error += "; " + reply; } } + models.add(atomSpec); } } + List finalView = commandGenerator + .centerViewOn(models); + executeCommands(finalView, false, "Centered on Superposition"); } - return error; } -- 1.7.10.2