X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fstructure%2FStructureSelectionManager.java;h=24320b54276f0f29539677311bd6a85a6914c0ff;hb=refs%2Fheads%2Ffeatures%2Fr2_11_2_alphafold%2FJAL-2349_JAL-3855;hp=c8a846c1cadee06efebeda4a45c4c8d2a19c5544;hpb=57738a1f3c19b1c3a00bd3ac5108f8cd0af32f99;p=jalview.git diff --git a/src/jalview/structure/StructureSelectionManager.java b/src/jalview/structure/StructureSelectionManager.java index c8a846c..24320b5 100644 --- a/src/jalview/structure/StructureSelectionManager.java +++ b/src/jalview/structure/StructureSelectionManager.java @@ -42,6 +42,7 @@ import jalview.datamodel.AlignedCodonFrame; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.Annotation; +import jalview.datamodel.ContiguousI; import jalview.datamodel.HiddenColumns; import jalview.datamodel.PDBEntry; import jalview.datamodel.SearchResults; @@ -874,6 +875,52 @@ public class StructureSelectionManager } /** + * hack to highlight a range of positions at once on any structure views + * + * @param sequenceRef + * @param is + * - series of int start-end ranges as positions on sequenceRef + * @param i + * @param object + */ + public void highlightPositionsOn(SequenceI sequenceRef, int[][] is, + Object source) + { + boolean hasSequenceListeners = handlingVamsasMo + || !seqmappings.isEmpty(); + SearchResultsI results = null; + ArrayList listOfPositions = new ArrayList(); + for (int[] s_e : is) + { + for (int p = s_e[0]; p <= s_e[1]; listOfPositions.add(p++)) + ; + } + int seqpos[] = new int[listOfPositions.size()]; + int i = 0; + for (Integer p : listOfPositions) + { + seqpos[i++] = p; + } + + for (i = 0; i < listeners.size(); i++) + { + Object listener = listeners.elementAt(i); + if (listener == source) + { + // TODO listener (e.g. SeqPanel) is never == source (AlignViewport) + // Temporary fudge with SequenceListener.getVamsasSource() + continue; + } + if (listener instanceof StructureListener) + { + highlightStructure((StructureListener) listener, sequenceRef, + seqpos); + } + + } + } + + /** * Propagate mouseover of a single position in a structure * * @param pdbResNum @@ -1083,6 +1130,62 @@ public class StructureSelectionManager sl.highlightAtoms(atoms); } + public void highlightStructureRegionsFor(StructureListener sl, + SequenceI[] seqs, int... columns) + { + List to_highlight = new ArrayList(); + for (SequenceI seq : seqs) + { + if (sl.isListeningFor(seq)) + { + to_highlight.add(seq); + } + } + if (to_highlight.size() == 0) + { + return; + } + List atoms = new ArrayList<>(); + for (SequenceI seq : to_highlight) + { + int atomNo; + for (StructureMapping sm : mappings) + { + if (sm.sequence == seq || sm.sequence == seq.getDatasetSequence() + || (sm.sequence.getDatasetSequence() != null && sm.sequence + .getDatasetSequence() == seq.getDatasetSequence())) + { + + for (int i = 0; i < columns.length; i += 2) + { + ContiguousI positions = seq.findPositions(columns[i] + 1, + columns[i + 1] + 1); + if (positions == null) + { + continue; + } + for (int index = positions.getBegin(); index <= positions + .getEnd(); index++) + { + + atomNo = sm.getAtomNum(index); + + if (atomNo > 0) + { + atoms.add(new AtomSpec(sm.pdbfile, sm.pdbchain, + sm.getPDBResNum(index), atomNo)); + } + } + } + } + } + if (atoms.size() > 0) + { + sl.highlightAtoms(atoms); + } + } + } + /** * true if a mouse over event from an external (ie Vamsas) source is being * handled @@ -1461,4 +1564,34 @@ public class StructureSelectionManager return seqmappings; } + /** + * quick and dirty route to just highlight all structure positions for a range + * of columns + * + * @param sequencesArray + * @param is + * start-end columns on sequencesArray + * @param source + * origin parent AlignmentPanel + */ + public void highlightPositionsOnMany(SequenceI[] sequencesArray, int[] is, + Object source) + { + for (int i = 0; i < listeners.size(); i++) + { + Object listener = listeners.elementAt(i); + if (listener == source) + { + // TODO listener (e.g. SeqPanel) is never == source (AlignViewport) + // Temporary fudge with SequenceListener.getVamsasSource() + continue; + } + if (listener instanceof StructureListener) + { + highlightStructureRegionsFor((StructureListener) listener, + sequencesArray, is); + } + } + } + }