From: kiramt Date: Mon, 15 Jan 2018 13:32:35 +0000 (+0000) Subject: JAL-2759 Refactor of hideInsertionsFor after review X-Git-Tag: Release_2_10_4~55^2~1^2~40 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=2a66892874abea357a5e5d9ef2f69919453c31d0;p=jalview.git JAL-2759 Refactor of hideInsertionsFor after review --- diff --git a/src/jalview/bin/JalviewLite.java b/src/jalview/bin/JalviewLite.java index 6504290..a60496c 100644 --- a/src/jalview/bin/JalviewLite.java +++ b/src/jalview/bin/JalviewLite.java @@ -31,7 +31,6 @@ import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentOrder; import jalview.datamodel.ColumnSelection; -import jalview.datamodel.HiddenColumns; import jalview.datamodel.PDBEntry; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; @@ -471,7 +470,7 @@ public class JalviewLite extends Applet SequenceI rs = sel.getSequenceAt(0); start = rs.findIndex(start); end = rs.findIndex(end); - List cs = new ArrayList(csel.getSelected()); + List cs = new ArrayList<>(csel.getSelected()); csel.clear(); for (Integer selectedCol : cs) { @@ -921,7 +920,7 @@ public class JalviewLite extends Applet setMouseoverListener(currentAlignFrame, listener); } - private Vector javascriptListeners = new Vector(); + private Vector javascriptListeners = new Vector<>(); /* * (non-Javadoc) @@ -2165,8 +2164,8 @@ public class JalviewLite extends Applet else { param = st.nextToken(); - List tmp = new ArrayList(); - List tmp2 = new ArrayList(); + List tmp = new ArrayList<>(); + List tmp2 = new ArrayList<>(); while (st.hasMoreTokens()) { @@ -2279,12 +2278,9 @@ public class JalviewLite extends Applet JnetAnnotationMaker.add_annotation(predictions, alignFrame.viewport.getAlignment(), 0, false); // false == do not add sequence profile from concise output - SequenceI repseq = alignFrame.viewport.getAlignment() - .getSequenceAt(0); - alignFrame.viewport.getAlignment().setSeqrep(repseq); - HiddenColumns cs = new HiddenColumns(); - cs.hideInsertionsFor(repseq); - alignFrame.viewport.getAlignment().setHiddenColumns(cs); + + alignFrame.viewport.getAlignment().setupJPredAlignment(); + alignFrame.alignPanel.fontChanged(); alignFrame.alignPanel.setScrollValues(0, 0); result = true; @@ -2802,9 +2798,9 @@ public class JalviewLite extends Applet // callInitCallback(); } - private Hashtable jshashes = new Hashtable(); + private Hashtable jshashes = new Hashtable<>(); - private Hashtable> jsmessages = new Hashtable>(); + private Hashtable> jsmessages = new Hashtable<>(); public void setJsMessageSet(String messageclass, String viewId, String[] colcommands) @@ -2812,7 +2808,7 @@ public class JalviewLite extends Applet Hashtable msgset = jsmessages.get(messageclass); if (msgset == null) { - msgset = new Hashtable(); + msgset = new Hashtable<>(); jsmessages.put(messageclass, msgset); } msgset.put(viewId, colcommands); diff --git a/src/jalview/datamodel/Alignment.java b/src/jalview/datamodel/Alignment.java index 8c5e4ac..f052c05 100755 --- a/src/jalview/datamodel/Alignment.java +++ b/src/jalview/datamodel/Alignment.java @@ -1913,4 +1913,14 @@ public class Alignment implements AlignmentI { hiddenCols = cols; } + + @Override + public void setupJPredAlignment() + { + SequenceI repseq = getSequenceAt(0); + setSeqrep(repseq); + HiddenColumns cs = new HiddenColumns(); + cs.hideInsertionsFor(repseq.getInsertions()); + setHiddenColumns(cs); + } } diff --git a/src/jalview/datamodel/AlignmentI.java b/src/jalview/datamodel/AlignmentI.java index 084b80e..bdc48d0 100755 --- a/src/jalview/datamodel/AlignmentI.java +++ b/src/jalview/datamodel/AlignmentI.java @@ -580,6 +580,17 @@ public interface AlignmentI extends AnnotatedCollectionI */ AlignedCodonFrame getMapping(SequenceI mapFrom, SequenceI mapTo); + /** + * Set the hidden columns collection on the alignment + * + * @param cols + */ public void setHiddenColumns(HiddenColumns cols); + /** + * Set the first sequence as representative and hide its insertions. Typically + * used when loading JPred files. + */ + public void setupJPredAlignment(); + } diff --git a/src/jalview/datamodel/HiddenColumns.java b/src/jalview/datamodel/HiddenColumns.java index d1345e3..2b5185f 100644 --- a/src/jalview/datamodel/HiddenColumns.java +++ b/src/jalview/datamodel/HiddenColumns.java @@ -303,14 +303,13 @@ public class HiddenColumns * mark the columns corresponding to gap characters as hidden in the column * selection * - * @param sr + * @param insertions */ - public void hideInsertionsFor(SequenceI sr) + public void hideInsertionsFor(List inserts) { try { LOCK.writeLock().lock(); - List inserts = sr.getInsertions(); for (int[] r : inserts) { hideColumns(r[0], r[1]); diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index fa052f1..0c452c3 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -4627,11 +4627,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, new JnetAnnotationMaker(); JnetAnnotationMaker.add_annotation(predictions, viewport.getAlignment(), 0, false); - SequenceI repseq = viewport.getAlignment().getSequenceAt(0); - viewport.getAlignment().setSeqrep(repseq); - HiddenColumns cs = new HiddenColumns(); - cs.hideInsertionsFor(repseq); - viewport.getAlignment().setHiddenColumns(cs); + viewport.getAlignment().setupJPredAlignment(); isAnnotation = true; } // else if (IdentifyFile.FeaturesFile.equals(format)) diff --git a/src/jalview/io/AnnotationFile.java b/src/jalview/io/AnnotationFile.java index 00476d6..885a298 100755 --- a/src/jalview/io/AnnotationFile.java +++ b/src/jalview/io/AnnotationFile.java @@ -968,7 +968,7 @@ public class AnnotationFile else { // consider deferring this till after the file has been parsed ? - hidden.hideInsertionsFor(sr); + hidden.hideInsertionsFor(sr.getInsertions()); } } modified = true; diff --git a/test/jalview/datamodel/HiddenColumnsTest.java b/test/jalview/datamodel/HiddenColumnsTest.java index ba2c1ea..a31d527 100644 --- a/test/jalview/datamodel/HiddenColumnsTest.java +++ b/test/jalview/datamodel/HiddenColumnsTest.java @@ -420,7 +420,7 @@ public class HiddenColumnsTest new SequenceI[] { new Sequence("refseqGaptest", "KTDVTI----------NFI-----G----L") }); HiddenColumns cs = new HiddenColumns(); - cs.hideInsertionsFor(al.getSequenceAt(0)); + cs.hideInsertionsFor(al.getSequenceAt(0).getInsertions()); assertEquals("G", "" + al.getSequenceAt(0).getCharAt(cs.visibleToAbsoluteColumn(9))); @@ -1139,10 +1139,10 @@ public class HiddenColumnsTest SequenceI seq1 = new Sequence("TEST1", "GAL---MFW-KQESPVICY--HRNDT"); SequenceI seq2 = new Sequence("TEST1", "GALMFWKQESPVICYHRNDT"); - h.hideInsertionsFor(seq2); + h.hideInsertionsFor(seq2.getInsertions()); assertTrue(h.equals(h2)); - h.hideInsertionsFor(seq1); + h.hideInsertionsFor(seq1.getInsertions()); h2.hideColumns(3, 5); h2.hideColumns(9, 9); h2.hideColumns(19, 20);