From 80300778ebd2107d12371d5073ccb8870f875eda Mon Sep 17 00:00:00 2001 From: tcofoegbu Date: Mon, 10 Aug 2015 10:33:48 +0100 Subject: [PATCH] JAL-1486 fixed flatfile output of visible region for consensus sequence --- src/jalview/gui/AlignFrame.java | 3 +-- src/jalview/gui/AnnotationLabels.java | 31 ++++++++++++++++++++----------- src/jalview/io/FormatAdapter.java | 4 ++-- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/jalview/gui/AlignFrame.java b/src/jalview/gui/AlignFrame.java index 68d7397..b37b442 100644 --- a/src/jalview/gui/AlignFrame.java +++ b/src/jalview/gui/AlignFrame.java @@ -1291,7 +1291,7 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, return ed; } - private static int[] getStartEnd(int[] aligmentStartEnd, + public static int[] getStartEnd(int[] aligmentStartEnd, List hiddenCols) { int startPos = aligmentStartEnd[0]; @@ -1303,7 +1303,6 @@ public class AlignFrame extends GAlignFrame implements DropTargetListener, for (int[] hiddenCol : hiddenCols) { // System.out.println("comparing : " + hiddenCol[0] + "-" + hiddenCol[1]); - lowestRange = (hiddenCol[0] <= startPos) ? hiddenCol : lowestRange; higestRange = (hiddenCol[1] >= endPos) ? hiddenCol : higestRange; } diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index fad9dcd..4e625e1 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -20,6 +20,16 @@ */ package jalview.gui; +import jalview.analysis.AlignmentUtils; +import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.Annotation; +import jalview.datamodel.Sequence; +import jalview.datamodel.SequenceGroup; +import jalview.datamodel.SequenceI; +import jalview.io.FormatAdapter; +import jalview.util.MessageManager; + import java.awt.Color; import java.awt.Dimension; import java.awt.Font; @@ -41,6 +51,7 @@ import java.awt.image.BufferedImage; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.List; import java.util.regex.Pattern; import javax.swing.JCheckBoxMenuItem; @@ -50,16 +61,6 @@ import javax.swing.JPopupMenu; import javax.swing.SwingUtilities; import javax.swing.ToolTipManager; -import jalview.analysis.AlignmentUtils; -import jalview.datamodel.Alignment; -import jalview.datamodel.AlignmentAnnotation; -import jalview.datamodel.Annotation; -import jalview.datamodel.Sequence; -import jalview.datamodel.SequenceGroup; -import jalview.datamodel.SequenceI; -import jalview.io.FormatAdapter; -import jalview.util.MessageManager; - /** * DOCUMENT ME! * @@ -874,8 +875,16 @@ public class AnnotationLabels extends JPanel implements MouseListener, sq.getLength(), seqs); } + int[] alignmentStartEnd = new int[] + { 0, ds.getWidth() - 1 }; + List hiddenCols = av.getColumnSelection().getHiddenColumns(); + if (hiddenCols != null) + { + alignmentStartEnd = AlignFrame.getStartEnd(alignmentStartEnd, + hiddenCols); + } String output = new FormatAdapter().formatSequences("Fasta", seqs, - omitHidden, null); + omitHidden, alignmentStartEnd); Toolkit.getDefaultToolkit().getSystemClipboard() .setContents(new StringSelection(output), Desktop.instance); diff --git a/src/jalview/io/FormatAdapter.java b/src/jalview/io/FormatAdapter.java index 8a563fa..63a14d7 100755 --- a/src/jalview/io/FormatAdapter.java +++ b/src/jalview/io/FormatAdapter.java @@ -108,11 +108,11 @@ public class FormatAdapter extends AppletFormatAdapter startRes = seqs[i].getStart(); endRes = seqs[i].getEnd(); - startIndex = startEnd[0]; - endIndex = startEnd[1]; if (startEnd != null) { + startIndex = startEnd[0]; + endIndex = startEnd[1]; // get first non-gaped residue start position while (jalview.util.Comparison.isGap(seqs[i] .getCharAt(startIndex)) && startIndex < endIndex) -- 1.7.10.2