From: gmungoc Date: Thu, 18 Sep 2014 13:16:21 +0000 (+0100) Subject: Merge branch 'JAL-1360_Branch' into Release_2_8_2_Branch X-Git-Tag: Release_2_8_2b1^2~53 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=55fc8f004dac252b5b89ac91cf506e4844a6b1da;hp=f72a3a3b20d2b4cccb88e809fe27a7a76951772f;p=jalview.git Merge branch 'JAL-1360_Branch' into Release_2_8_2_Branch --- diff --git a/src/jalview/api/AlignViewControllerI.java b/src/jalview/api/AlignViewControllerI.java index fadc09e..35f084f 100644 --- a/src/jalview/api/AlignViewControllerI.java +++ b/src/jalview/api/AlignViewControllerI.java @@ -27,10 +27,13 @@ package jalview.api; * * All operations should return true if the view has changed as a result * of the operation - * @param + * + * The controller holds methods that operate on an alignment view, + * modifying its state in some way that may result in side effects + * reflected in an associated GUI * */ -public interface AlignViewControllerI +public interface AlignViewControllerI { public boolean makeGroupsFromSelection(); diff --git a/src/jalview/api/AlignViewportI.java b/src/jalview/api/AlignViewportI.java index 567ae83..d8ba30d 100644 --- a/src/jalview/api/AlignViewportI.java +++ b/src/jalview/api/AlignViewportI.java @@ -22,6 +22,7 @@ package jalview.api; import java.awt.Color; import java.util.Hashtable; +import java.util.List; import java.util.Map; import jalview.analysis.Conservation; @@ -191,4 +192,12 @@ public interface AlignViewportI void setConservation(Conservation cons); + /** + * get a copy of the currently visible alignment annotation + * @param selectedOnly if true - trim to selected regions on the alignment + * @return an empty list or new alignment annotation objects shown only visible columns trimmed to selected region only + */ + List getVisibleAlignmentAnnotation( + boolean selectedOnly); + } diff --git a/src/jalview/appletgui/APopupMenu.java b/src/jalview/appletgui/APopupMenu.java index d98e2aa..58c7703 100644 --- a/src/jalview/appletgui/APopupMenu.java +++ b/src/jalview/appletgui/APopupMenu.java @@ -672,9 +672,8 @@ public class APopupMenu extends java.awt.PopupMenu implements // TODO consider using getSequenceSelection instead here cap.setText(new jalview.io.AppletFormatAdapter().formatSequences( - e.getActionCommand(), - new Alignment(ap.av.getSelectionAsNewSequence()), - ap.av.showJVSuffix)); + e.getActionCommand(), + ap.av.showJVSuffix, ap.av, true)); } diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 44860a1..0957d28 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -20,23 +20,58 @@ */ package jalview.gui; -import java.util.*; - -import java.awt.*; -import java.awt.event.*; - -import javax.swing.*; - -import jalview.analysis.*; -import jalview.commands.*; -import jalview.datamodel.*; -import jalview.io.*; -import jalview.schemes.*; +import jalview.analysis.AAFrequency; +import jalview.analysis.Conservation; +import jalview.commands.ChangeCaseCommand; +import jalview.commands.EditCommand; +import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.AlignmentView; +import jalview.datamodel.Annotation; +import jalview.datamodel.DBRefEntry; +import jalview.datamodel.PDBEntry; +import jalview.datamodel.Sequence; +import jalview.datamodel.SequenceFeature; +import jalview.datamodel.SequenceGroup; +import jalview.datamodel.SequenceI; +import jalview.io.FormatAdapter; +import jalview.io.SequenceAnnotationReport; +import jalview.schemes.AnnotationColourGradient; +import jalview.schemes.Blosum62ColourScheme; +import jalview.schemes.BuriedColourScheme; +import jalview.schemes.ClustalxColourScheme; +import jalview.schemes.HelixColourScheme; +import jalview.schemes.HydrophobicColourScheme; +import jalview.schemes.NucleotideColourScheme; +import jalview.schemes.PIDColourScheme; +import jalview.schemes.PurinePyrimidineColourScheme; +import jalview.schemes.ResidueProperties; +import jalview.schemes.StrandColourScheme; +import jalview.schemes.TaylorColourScheme; +import jalview.schemes.TurnColourScheme; +import jalview.schemes.UserColourScheme; +import jalview.schemes.ZappoColourScheme; import jalview.util.GroupUrlLink; import jalview.util.GroupUrlLink.UrlStringTooLongException; import jalview.util.MessageManager; import jalview.util.UrlLink; +import java.awt.Color; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Hashtable; +import java.util.List; +import java.util.Vector; + +import javax.swing.ButtonGroup; +import javax.swing.JCheckBoxMenuItem; +import javax.swing.JColorChooser; +import javax.swing.JMenu; +import javax.swing.JMenuItem; +import javax.swing.JOptionPane; +import javax.swing.JPopupMenu; +import javax.swing.JRadioButtonMenuItem; + /** * DOCUMENT ME! * @@ -256,8 +291,8 @@ public class PopupMenu extends JPopupMenu { // TODO re JAL-860: optionally open dialog or provide a menu entry // allowing user to open just one structure per sequence - //new AppJmol(pdb, ap.av.collateForPDB(new PDBEntry[] - //{ pdb })[0], null, ap); + // new AppJmol(pdb, ap.av.collateForPDB(new PDBEntry[] + // { pdb })[0], null, ap); new StructureViewer(ap.getStructureSelectionManager()) .viewStructures(pdb, ap.av.collateForPDB(new PDBEntry[] @@ -522,7 +557,7 @@ public class PopupMenu extends JPopupMenu { Vector pes = (Vector) sq.getDatasetSequence() .getPDBId(); - if (pes != null && pes.size()>0) + if (pes != null && pes.size() > 0) { reppdb.put(pes.get(0).getId(), pes.get(0)); for (PDBEntry pe : pes) @@ -561,7 +596,8 @@ public class PopupMenu extends JPopupMenu @Override public void actionPerformed(ActionEvent e) { - new StructureViewer(ap.getStructureSelectionManager()).viewStructures(ap, pe, ap.av.collateForPDB(pe)); + new StructureViewer(ap.getStructureSelectionManager()) + .viewStructures(ap, pe, ap.av.collateForPDB(pe)); } }); if (reppdb.size() > 1 && reppdb.size() < pdbe.size()) @@ -579,7 +615,8 @@ public class PopupMenu extends JPopupMenu @Override public void actionPerformed(ActionEvent e) { - new StructureViewer(ap.getStructureSelectionManager()).viewStructures(ap, pr, ap.av.collateForPDB(pr)); + new StructureViewer(ap.getStructureSelectionManager()) + .viewStructures(ap, pr, ap.av.collateForPDB(pr)); } }); } @@ -2071,23 +2108,8 @@ public class PopupMenu extends JPopupMenu System.out.println("PROMPT USER HERE"); // TODO: decide if a prompt happens // or we simply trust the user wants // wysiwig behaviour - SequenceGroup sg = ap.av.getSelectionGroup(); - ColumnSelection csel = new ColumnSelection(ap.av.getColumnSelection()); - omitHidden = ap.av.getViewAsString(true); - Alignment oal = new Alignment(ap.av.getSequenceSelection()); - AlignmentAnnotation[] nala = ap.av.getAlignment() - .getAlignmentAnnotation(); - if (nala != null) - { - for (int i = 0; i < nala.length; i++) - { - AlignmentAnnotation na = nala[i]; - oal.addAnnotation(na); - } - } - cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(), - oal, omitHidden, csel, sg)); - oal = null; + + cap.setText(new FormatAdapter().formatSequences(e.getActionCommand(), ap.av, true)); } public void pdbFromFile_actionPerformed() diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index d7da302..3f9a425 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -22,7 +22,9 @@ package jalview.io; import java.io.File; import java.io.InputStream; +import java.util.List; +import jalview.api.AlignViewportI; import jalview.datamodel.*; /** @@ -48,7 +50,7 @@ public class AppletFormatAdapter * method */ public static final String[] WRITEABLE_FORMATS = new String[] - { "BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "AMSA" }; + { "BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "AMSA", "STH" }; /** * List of extensions corresponding to file format types in WRITABLE_FNAMES @@ -405,6 +407,35 @@ public class AppletFormatAdapter } } + + /** + * create an alignment flatfile from a Jalview alignment view + * @param format + * @param jvsuffix + * @param av + * @param selectedOnly + * @return flatfile in a string + */ + public String formatSequences(String format, boolean jvsuffix, + AlignViewportI av, boolean selectedOnly) + { + + AlignmentView selvew = av.getAlignmentView(selectedOnly, false); + AlignmentI aselview = selvew.getVisibleAlignment(av + .getGapCharacter()); + List ala = (av + .getVisibleAlignmentAnnotation(selectedOnly)); + if (ala != null) + { + for (AlignmentAnnotation aa : ala) + { + aselview.addAnnotation(aa); + } + } + + return formatSequences(format, aselview, jvsuffix); + } + /** * Construct an output class for an alignment in a particular filetype TODO: * allow caller to detect errors and warnings encountered when generating diff --git a/src/jalview/io/FormatAdapter.java b/src/jalview/io/FormatAdapter.java index 9913428..c2a317a 100755 --- a/src/jalview/io/FormatAdapter.java +++ b/src/jalview/io/FormatAdapter.java @@ -20,6 +20,7 @@ */ package jalview.io; +import jalview.api.AlignViewportI; import jalview.datamodel.*; /** @@ -247,4 +248,16 @@ public class FormatAdapter extends AppletFormatAdapter } return AppletFormatAdapter.isValidFormat(format, forwriting); } + + /** + * Create a flat file representation of a given view or selected region of a view + * @param format + * @param av + * @return String containing flat file + */ + public String formatSequences(String format, AlignViewportI av, boolean selectedOnly) + { + return formatSequences(format, getCacheSuffixDefault(format), av, selectedOnly); + } + } diff --git a/src/jalview/viewmodel/AlignmentViewport.java b/src/jalview/viewmodel/AlignmentViewport.java index 0c8afaa..0fa4a3c 100644 --- a/src/jalview/viewmodel/AlignmentViewport.java +++ b/src/jalview/viewmodel/AlignmentViewport.java @@ -1243,6 +1243,28 @@ public abstract class AlignmentViewport implements AlignViewportI } + @Override + public List getVisibleAlignmentAnnotation(boolean selectedOnly) + { + ArrayList ala = new ArrayList(); + AlignmentAnnotation[] aa; + if ((aa=alignment.getAlignmentAnnotation())!=null) + { + for (AlignmentAnnotation annot:aa) + { + AlignmentAnnotation clone = new AlignmentAnnotation(annot); + if (selectedOnly && selectionGroup!=null) + { + colSel.makeVisibleAnnotation(selectionGroup.getStartRes(), selectionGroup.getEndRes(),clone); + } else { + colSel.makeVisibleAnnotation(clone); + } + ala.add(clone); + } + } + return ala; + } + /** * @return the padGaps */