+
+ /**
+ * get sequences selected in current alignFrame and return their alignment in
+ * format 'format' either with or without suffix
+ *
+ * @param alf -
+ * where selection is
+ * @param format -
+ * format of alignment file
+ * @param suffix -
+ * "true" to append /start-end string to each sequence ID
+ * @return selected sequences as flat file or empty string if there was no
+ * current selection
+ */
+ public String getSelectedSequencesAsAlignment(String format, String suffix)
+ {
+ return getSelectedSequencesAsAlignmentFrom(currentAlignFrame, format,
+ suffix);
+ }
+
+ /**
+ * get sequences selected in alf and return their alignment in format 'format'
+ * either with or without suffix
+ *
+ * @param alf -
+ * where selection is
+ * @param format -
+ * format of alignment file
+ * @param suffix -
+ * "true" to append /start-end string to each sequence ID
+ * @return selected sequences as flat file or empty string if there was no
+ * current selection
+ */
+ public String getSelectedSequencesAsAlignmentFrom(AlignFrame alf,
+ String format, String suffix)
+ {
+ try
+ {
+ boolean seqlimits = suffix.equalsIgnoreCase("true");
+ if (alf.viewport.getSelectionGroup() != null)
+ {
+ String reply = new AppletFormatAdapter().formatSequences(format,
+ new Alignment(alf.viewport.getSelectionAsNewSequence()),
+ seqlimits);
+ return reply;
+ }
+ } catch (Exception ex)
+ {
+ ex.printStackTrace();
+ return "Error retrieving alignment in " + format + " format. ";
+ }
+ return "";
+ }
+