+ /**
+ * character used to write newlines
+ */
+ protected String newline = System.getProperty("line.separator");
+
+ private AlignExportSettingI exportSettings;
+
+ /**
+ * List of valid format strings used in the isValidFormat method
+ */
+ public static final String[] READABLE_FORMATS = new String[] { "BLC",
+ "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "STH", "PDB",
+ "JnetFile", "RNAML", PhylipFile.FILE_DESC, JSONFile.FILE_DESC,
+ IdentifyFile.FeaturesFile, "HTML", "mmCIF" };
+
+ /**
+ * List of readable format file extensions by application in order
+ * corresponding to READABLE_FNAMES
+ */
+ public static final String[] READABLE_EXTENSIONS = new String[] {
+ "fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa",
+ "sto,stk", "xml,rnaml", PhylipFile.FILE_EXT, JSONFile.FILE_EXT,
+ ".gff2,gff3", "jar,jvp", HtmlFile.FILE_EXT, "cif" };
+
+ /**
+ * List of readable formats by application in order corresponding to
+ * READABLE_EXTENSIONS
+ */
+ public static final String[] READABLE_FNAMES = new String[] { "Fasta",
+ "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "Stockholm", "RNAML",
+ PhylipFile.FILE_DESC, JSONFile.FILE_DESC, IdentifyFile.FeaturesFile,
+ "Jalview", HtmlFile.FILE_DESC, "mmCIF" };
+
+ /**
+ * List of valid format strings for use by callers of the formatSequences
+ * method
+ */
+ public static final String[] WRITEABLE_FORMATS = new String[] { "BLC",
+ "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "AMSA", "STH",
+ PhylipFile.FILE_DESC, JSONFile.FILE_DESC };
+
+ /**
+ * List of extensions corresponding to file format types in WRITABLE_FNAMES
+ * that are writable by the application.
+ */
+ public static final String[] WRITABLE_EXTENSIONS = new String[] {
+ "fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa",
+ "sto,stk", PhylipFile.FILE_EXT, JSONFile.FILE_EXT, "jvp" };
+
+ /**
+ * List of writable formats by the application. Order must correspond with the
+ * WRITABLE_EXTENSIONS list of formats.
+ */
+ public static final String[] WRITABLE_FNAMES = new String[] { "Fasta",
+ "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "STH",
+ PhylipFile.FILE_DESC, JSONFile.FILE_DESC, "Jalview" };
+
+ public static String INVALID_CHARACTERS = "Contains invalid characters";
+
+ // TODO: make these messages dynamic
+ public static String SUPPORTED_FORMATS = "Formats currently supported are\n"
+ + prettyPrint(READABLE_FORMATS);
+
+ public AppletFormatAdapter()
+ {
+ }
+
+ public AppletFormatAdapter(AlignmentViewPanel viewpanel)
+ {
+ this.viewpanel = viewpanel;
+ }
+
+ public AppletFormatAdapter(AlignmentViewPanel alignPanel,
+ AlignExportSettingI settings)
+ {
+ viewpanel = alignPanel;
+ exportSettings = settings;
+ }
+
+ /**
+ *
+ * @param els
+ * @return grammatically correct(ish) list consisting of els elements.
+ */
+ public static String prettyPrint(String[] els)
+ {
+ StringBuffer list = new StringBuffer();
+ for (int i = 0, iSize = els.length - 1; i < iSize; i++)
+ {
+ list.append(els[i]);
+ list.append(", ");
+ }
+ list.append(" and " + els[els.length - 1] + ".");
+ return list.toString();
+ }
+
+ public void setNewlineString(String nl)
+ {
+ newline = nl;
+ }
+
+ public String getNewlineString()
+ {
+ return newline;
+ }
+
+ /**
+ * check that this format is valid for reading
+ *
+ * @param format
+ * a format string to be compared with READABLE_FORMATS
+ * @return true if format is readable
+ */