From 4a5137b64f7ec23db2a09290bfcd392984a52150 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Mon, 18 Jul 2016 08:51:24 +0100 Subject: [PATCH] fileFormat enum wip changes --- src/jalview/gui/AnnotationLabels.java | 5 +- src/jalview/gui/PopupMenu.java | 5 +- src/jalview/io/AMSAFile.java | 5 +- src/jalview/io/AlignFile.java | 26 ++- src/jalview/io/AlignmentFileI.java | 4 +- src/jalview/io/AppletFormatAdapter.java | 54 +----- src/jalview/io/BLCFile.java | 16 +- src/jalview/io/ClustalFile.java | 13 +- src/jalview/io/DBRefFile.java | 6 +- src/jalview/io/FastaFile.java | 35 +--- src/jalview/io/FeaturesFile.java | 5 +- src/jalview/io/FileFormat.java | 134 ++++++++++----- src/jalview/io/FileFormatI.java | 11 ++ src/jalview/io/FormatAdapter.java | 174 +++++++++----------- src/jalview/io/HtmlFile.java | 2 +- src/jalview/io/JPredFile.java | 2 +- src/jalview/io/JSONFile.java | 15 +- src/jalview/io/MSFfile.java | 39 ++--- src/jalview/io/PIRFile.java | 12 +- src/jalview/io/PfamFile.java | 14 +- src/jalview/io/PhylipFile.java | 12 +- src/jalview/io/PileUpfile.java | 18 +- src/jalview/io/RnamlFile.java | 10 +- src/jalview/io/SimpleBlastFile.java | 9 +- src/jalview/io/StockholmFile.java | 28 ++-- src/jalview/io/TCoffeeScoreFile.java | 2 +- src/jalview/io/packed/ParsePackedSet.java | 41 ++--- src/jalview/ws/jws1/JPredThread.java | 3 +- src/jalview/ws/seqfetcher/DbSourceProxyImpl.java | 10 +- test/jalview/analysis/DnaAlignmentGenerator.java | 2 +- test/jalview/ext/paradise/TestAnnotate3D.java | 8 +- .../ws/jabaws/DisorderAnnotExportImport.java | 4 +- .../ws/jabaws/JpredJabaStructExportImport.java | 4 +- test/jalview/ws/jabaws/RNAStructExportImport.java | 4 +- 34 files changed, 322 insertions(+), 410 deletions(-) diff --git a/src/jalview/gui/AnnotationLabels.java b/src/jalview/gui/AnnotationLabels.java index e27b919..c72cfaf 100755 --- a/src/jalview/gui/AnnotationLabels.java +++ b/src/jalview/gui/AnnotationLabels.java @@ -27,6 +27,7 @@ import jalview.datamodel.Annotation; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; +import jalview.io.FileFormat; import jalview.io.FormatAdapter; import jalview.util.MessageManager; @@ -943,8 +944,8 @@ public class AnnotationLabels extends JPanel implements MouseListener, alignmentStartEnd = av.getAlignment().getVisibleStartAndEndIndex( hiddenCols); } - String output = new FormatAdapter().formatSequences("Fasta", seqs, - omitHidden, alignmentStartEnd); + String output = new FormatAdapter().formatSequences(FileFormat.Fasta, + seqs, omitHidden, alignmentStartEnd); Toolkit.getDefaultToolkit().getSystemClipboard() .setContents(new StringSelection(output), Desktop.instance); diff --git a/src/jalview/gui/PopupMenu.java b/src/jalview/gui/PopupMenu.java index 497f3ba..f0fdb9f 100644 --- a/src/jalview/gui/PopupMenu.java +++ b/src/jalview/gui/PopupMenu.java @@ -38,6 +38,7 @@ import jalview.datamodel.Sequence; import jalview.datamodel.SequenceFeature; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; +import jalview.io.FileFormat; import jalview.io.FormatAdapter; import jalview.io.SequenceAnnotationReport; import jalview.schemes.AnnotationColourGradient; @@ -2338,8 +2339,8 @@ public class PopupMenu extends JPopupMenu // or we simply trust the user wants // wysiwig behaviour - cap.setText(new FormatAdapter(ap).formatSequences(e.getActionCommand(), - ap, true)); + FileFormat fileFormat = FileFormat.forName(e.getActionCommand()); + cap.setText(new FormatAdapter(ap).formatSequences(fileFormat, ap, true)); } public void sequenceFeature_actionPerformed() diff --git a/src/jalview/io/AMSAFile.java b/src/jalview/io/AMSAFile.java index f82407e..798249f 100644 --- a/src/jalview/io/AMSAFile.java +++ b/src/jalview/io/AMSAFile.java @@ -22,6 +22,7 @@ package jalview.io; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; +import jalview.datamodel.SequenceI; public class AMSAFile extends jalview.io.FastaFile { @@ -41,9 +42,9 @@ public class AMSAFile extends jalview.io.FastaFile * * @return DOCUMENT ME! */ - public String print() + public String print(SequenceI[] sqs, boolean jvsuffix) { - super.print(getSeqsAsArray()); + super.print(sqs, jvsuffix); AlignmentAnnotation aa; if (al.getAlignmentAnnotation() != null) diff --git a/src/jalview/io/AlignFile.java b/src/jalview/io/AlignFile.java index 6d6ab5c..d36a588 100755 --- a/src/jalview/io/AlignFile.java +++ b/src/jalview/io/AlignFile.java @@ -71,8 +71,6 @@ public abstract class AlignFile extends FileParse implements AlignmentFileI long end; - boolean jvSuffix = true; - private boolean parseCalled; /** @@ -86,6 +84,12 @@ public abstract class AlignFile extends FileParse implements AlignmentFileI initData(); } + public AlignFile(SequenceI[] seqs) + { + this(); + setSeqs(seqs); + } + /** * Constructor which parses the data from a file of some specified type. * @@ -335,18 +339,6 @@ public abstract class AlignFile extends FileParse implements AlignmentFileI public abstract void parse() throws IOException; /** - * Print out in alignment file format the Sequences in the seqs Vector. - */ - @Override - public abstract String print(); - - @Override - public void addJVSuffix(boolean b) - { - jvSuffix = b; - } - - /** * A general parser for ids. * * @String id Id to be parsed @@ -381,11 +373,13 @@ public abstract class AlignFile extends FileParse implements AlignmentFileI * Creates the output id. Adds prefix Uniprot format source|id And suffix * Jalview /start-end * + * @param jvsuffix + * * @String id Id to be parsed */ - String printId(SequenceI seq) + String printId(SequenceI seq, boolean jvsuffix) { - return seq.getDisplayId(jvSuffix); + return seq.getDisplayId(jvsuffix); } /** diff --git a/src/jalview/io/AlignmentFileI.java b/src/jalview/io/AlignmentFileI.java index bee36f6..1a000a3 100644 --- a/src/jalview/io/AlignmentFileI.java +++ b/src/jalview/io/AlignmentFileI.java @@ -17,15 +17,13 @@ public interface AlignmentFileI void setNewlineString(String newline); - void addJVSuffix(boolean jvsuffix); - void setExportSettings(AlignExportSettingI exportSettings); void configureForView(AlignmentViewPanel viewpanel); void setSeqs(SequenceI[] sequencesArray); - String print(); + String print(SequenceI[] seqs, boolean jvsuffix); boolean hasWarningMessage(); diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index 720bac4..0c99d26 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -26,6 +26,7 @@ import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; import jalview.datamodel.AlignmentI; import jalview.datamodel.AlignmentView; +import jalview.datamodel.SequenceI; import jalview.structure.StructureImportSettings; import java.io.File; @@ -87,7 +88,7 @@ public class AppletFormatAdapter public static final String[] READABLE_EXTENSIONS = new String[] { "fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa", "sto,stk", "xml,rnaml", "phy", "json", - ".gff2,gff3", "jar,jvp", HtmlFile.FILE_EXT, "cif" }; + ".gff2,gff3", "jar,jvp", "html", "cif" }; /** * List of readable formats by application in order corresponding to @@ -172,49 +173,6 @@ public class AppletFormatAdapter } /** - * 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 - */ - public static final boolean isValidFormat(String format) - { - return isValidFormat(format, false); - } - - /** - * validate format is valid for IO - * - * @param format - * a format string to be compared with either READABLE_FORMATS or - * WRITEABLE_FORMATS - * @param forwriting - * when true, format is checked for containment in WRITEABLE_FORMATS - * @return true if format is valid - */ - public static final boolean isValidFormat(String format, - boolean forwriting) - { - if (format == null) - { - return false; - } - boolean valid = false; - String[] format_list = (forwriting) ? WRITEABLE_FORMATS - : READABLE_FORMATS; - for (String element : format_list) - { - if (element.equalsIgnoreCase(format)) - { - return true; - } - } - - return valid; - } - - /** * Constructs the correct filetype parser for a characterised datasource * * @param inFile @@ -440,23 +398,23 @@ public class AppletFormatAdapter AlignmentFileI afile = format.getAlignmentFile(); afile.setNewlineString(newline); - afile.addJVSuffix(jvsuffix); afile.setExportSettings(exportSettings); afile.configureForView(viewpanel); // check whether we were given a specific alignment to export, rather than // the one in the viewpanel + SequenceI[] seqs = null; if (viewpanel == null || viewpanel.getAlignment() == null || viewpanel.getAlignment() != alignment) { - afile.setSeqs(alignment.getSequencesArray()); + seqs = alignment.getSequencesArray(); } else { - afile.setSeqs(viewpanel.getAlignment().getSequencesArray()); + seqs = viewpanel.getAlignment().getSequencesArray(); } - String afileresp = afile.print(); + String afileresp = afile.print(seqs, jvsuffix); if (afile.hasWarningMessage()) { System.err.println("Warning raised when writing as " + format diff --git a/src/jalview/io/BLCFile.java b/src/jalview/io/BLCFile.java index c0ecd58..6317e83 100755 --- a/src/jalview/io/BLCFile.java +++ b/src/jalview/io/BLCFile.java @@ -218,23 +218,13 @@ public class BLCFile extends AlignFile /** * DOCUMENT ME! * - * @return DOCUMENT ME! - */ - @Override - public String print() - { - return print(getSeqsAsArray()); - } - - /** - * DOCUMENT ME! - * * @param s * DOCUMENT ME! * * @return DOCUMENT ME! */ - public String print(SequenceI[] s) + @Override + public String print(SequenceI[] s, boolean jvsuffix) { StringBuffer out = new StringBuffer(); /** @@ -248,7 +238,7 @@ public class BLCFile extends AlignFile while ((i < s.length) && (s[i] != null)) { - out.append(">" + printId(s[i])); + out.append(">" + printId(s[i], jvsuffix)); if (s[i].getDescription() != null) { out.append(" " + s[i].getDescription()); diff --git a/src/jalview/io/ClustalFile.java b/src/jalview/io/ClustalFile.java index 166984f..5d58d42 100755 --- a/src/jalview/io/ClustalFile.java +++ b/src/jalview/io/ClustalFile.java @@ -197,13 +197,7 @@ public class ClustalFile extends AlignFile } @Override - public String print() - { - return print(getSeqsAsArray()); - // TODO: locaRNA style aln output - } - - public String print(SequenceI[] s) + public String print(SequenceI[] s, boolean jvsuffix) { StringBuffer out = new StringBuffer("CLUSTAL" + newline + newline); @@ -214,7 +208,7 @@ public class ClustalFile extends AlignFile while ((i < s.length) && (s[i] != null)) { - String tmp = printId(s[i]); + String tmp = printId(s[i], jvsuffix); if (s[i].getSequence().length > max) { @@ -245,7 +239,8 @@ public class ClustalFile extends AlignFile while ((j < s.length) && (s[j] != null)) { - out.append(new Format("%-" + maxid + "s").form(printId(s[j]) + " ")); + out.append(new Format("%-" + maxid + "s").form(printId(s[j], + jvsuffix) + " ")); int start = i * len; int end = start + len; diff --git a/src/jalview/io/DBRefFile.java b/src/jalview/io/DBRefFile.java index 769f8b9..11cb4bf 100644 --- a/src/jalview/io/DBRefFile.java +++ b/src/jalview/io/DBRefFile.java @@ -20,6 +20,8 @@ */ package jalview.io; +import jalview.datamodel.SequenceI; + import java.io.IOException; /** @@ -32,13 +34,15 @@ import java.io.IOException; public class DBRefFile extends AlignFile { + @Override public void parse() throws IOException { // TODO Auto-generated method stub } - public String print() + @Override + public String print(SequenceI[] sqs, boolean jvsuffix) { // TODO Auto-generated method stub return null; diff --git a/src/jalview/io/FastaFile.java b/src/jalview/io/FastaFile.java index bbc5a7e..9c8cdf6 100755 --- a/src/jalview/io/FastaFile.java +++ b/src/jalview/io/FastaFile.java @@ -72,6 +72,11 @@ public class FastaFile extends AlignFile super(source); } + public FastaFile(SequenceI[] seqs) + { + super(seqs); + } + /** * DOCUMENT ME! * @@ -182,28 +187,15 @@ public class FastaFile extends AlignFile } } - /** - * DOCUMENT ME! - * - * @param s - * DOCUMENT ME! - * @param len - * DOCUMENT ME! - * @param gaps - * DOCUMENT ME! - * @param displayId - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public String print(SequenceI[] s) + @Override + public String print(SequenceI[] s, boolean jvsuffix) { out = new StringBuffer(); int i = 0; while ((i < s.length) && (s[i] != null)) { - out.append(">" + printId(s[i])); + out.append(">" + printId(s[i], jvsuffix)); if (s[i].getDescription() != null) { out.append(" " + s[i].getDescription()); @@ -235,15 +227,4 @@ public class FastaFile extends AlignFile return out.toString(); } - - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - @Override - public String print() - { - return print(getSeqsAsArray()); - } } diff --git a/src/jalview/io/FeaturesFile.java b/src/jalview/io/FeaturesFile.java index 6f06a87..20c44bc 100755 --- a/src/jalview/io/FeaturesFile.java +++ b/src/jalview/io/FeaturesFile.java @@ -733,9 +733,10 @@ public class FeaturesFile extends AlignFile implements FeaturesSourceI * @return error message */ @Override - public String print() + public String print(SequenceI[] sqs, boolean jvsuffix) { - return "Use printGffFormat() or printJalviewFormat()"; + System.out.println("Use printGffFormat() or printJalviewFormat()"); + return null; } /** diff --git a/src/jalview/io/FileFormat.java b/src/jalview/io/FileFormat.java index 893a8ac..bca365f 100644 --- a/src/jalview/io/FileFormat.java +++ b/src/jalview/io/FileFormat.java @@ -4,10 +4,12 @@ import jalview.ext.jmol.JmolParser; import jalview.structure.StructureImportSettings; import java.io.IOException; +import java.util.HashMap; +import java.util.Map; public enum FileFormat implements FileFormatI { - Fasta + Fasta("FASTA", "fa, fasta, mfa, fastq", true, true) { @Override public AlignmentFileI getAlignmentFile(String inFile, @@ -29,7 +31,7 @@ public enum FileFormat implements FileFormatI return new FastaFile(); } }, - Pfam + Pfam("PFAM", "pfam", true, true) { @Override public AlignmentFileI getAlignmentFile(String inFile, @@ -51,7 +53,7 @@ public enum FileFormat implements FileFormatI return new PfamFile(); } }, - Stockholm + Stockholm("STH", "sto,stk", true, true) { @Override public AlignmentFileI getAlignmentFile(String inFile, @@ -73,30 +75,8 @@ public enum FileFormat implements FileFormatI } }, - SimpleBlast - { - @Override - public AlignmentFileI getAlignmentFile(String inFile, - DataSourceType sourceType) throws IOException - { - return new SimpleBlastFile(inFile, sourceType); - } - @Override - public AlignmentFileI getAlignmentFile(FileParse source) - throws IOException - { - return new SimpleBlastFile(source); - } - - @Override - public AlignmentFileI getAlignmentFile() - { - return new SimpleBlastFile(); - } - }, - - PIR + PIR("PIR", "pir", true, true) { @Override public AlignmentFileI getAlignmentFile(String inFile, @@ -117,7 +97,7 @@ public enum FileFormat implements FileFormatI return new PIRFile(); } }, - BLC + BLC("BLC", "BLC", true, true) { @Override public AlignmentFileI getAlignmentFile(String inFile, @@ -136,9 +116,8 @@ public enum FileFormat implements FileFormatI { return new BLCFile(); } - }, - Html + Html("HTML", "html", true, false) { @Override public AlignmentFileI getAlignmentFile(String inFile, @@ -165,7 +144,7 @@ public enum FileFormat implements FileFormatI } }, - Rnaml + Rnaml("RNAML", "xml,rnaml", true, false) { @Override public AlignmentFileI getAlignmentFile(String inFile, @@ -186,7 +165,7 @@ public enum FileFormat implements FileFormatI } }, - Json + Json("JSON","json", true, true) { @Override public AlignmentFileI getAlignmentFile(String inFile, @@ -213,7 +192,7 @@ public enum FileFormat implements FileFormatI } }, - Pileup + Pileup("PileUp", "?", false, false) { @Override public AlignmentFileI getAlignmentFile(String inFile, @@ -234,7 +213,7 @@ public enum FileFormat implements FileFormatI } }, - MSF + MSF("MSF", "msf", true, true) { @Override public AlignmentFileI getAlignmentFile(String inFile, @@ -255,7 +234,7 @@ public enum FileFormat implements FileFormatI } }, - Clustal + Clustal("CLUSTAL", "aln", true, true) { @Override public AlignmentFileI getAlignmentFile(String inFile, @@ -274,9 +253,8 @@ public enum FileFormat implements FileFormatI { return new ClustalFile(); } - }, - Phylip + Phylip("PHYLIP", "phy", true, true) { @Override public AlignmentFileI getAlignmentFile(String inFile, @@ -297,9 +275,8 @@ public enum FileFormat implements FileFormatI { return new PhylipFile(); } - }, - Jnet + Jnet("JnetFile", "", false, false) { @Override public AlignmentFileI getAlignmentFile(String inFile, @@ -326,7 +303,7 @@ public enum FileFormat implements FileFormatI } }, - Features + Features("GFF or Jalview features", "gff2,gff3", false, false) { @Override public AlignmentFileI getAlignmentFile(String inFile, @@ -348,7 +325,7 @@ public enum FileFormat implements FileFormatI return new FeaturesFile(); } }, - PDB + PDB("PDB", "", false, false) { @Override @@ -410,9 +387,8 @@ public enum FileFormat implements FileFormatI { return new JmolParser(); // todo or null? } - }, - MMCif + MMCif("mmCIF", "cif", false, false) { @Override @@ -443,7 +419,7 @@ public enum FileFormat implements FileFormatI return new JmolParser(); // todo or null? } }, - Jalview + Jalview("Jalview", "jar,jvp", true, false) { @Override @@ -467,6 +443,27 @@ public enum FileFormat implements FileFormatI } }; + /** + * A lookup map of enums by upper-cased name + */ + private static Map names; + static + { + names = new HashMap(); + for (FileFormat format : FileFormat.values()) + { + names.put(format.toString().toUpperCase(), format); + } + } + + private boolean writable; + + private boolean readable; + + private String extensions; + + private String name; + @Override public boolean isComplexAlignFile() { @@ -478,4 +475,55 @@ public enum FileFormat implements FileFormatI { return toString(); } + + /** + * Returns the file format with the given name, or null if format is null or + * invalid. Unlike valueOf(), this is not case-sensitive, to be kind to + * writers of javascript. + * + * @param format + * @return + */ + public static FileFormatI forName(String format) + { + // or could store format.getShortDescription().toUpperCase() + // in order to decouple 'given name' from enum name + return format == null ? null : names.get(format.toUpperCase()); + } + + @Override + public boolean isReadable() + { + return readable; + } + + @Override + public boolean isWritable() + { + return writable; + } + + /** + * Constructor + * + * @param shortName + * @param extensions + * comma-separated list of file extensions associated with the format + * @param isReadable + * @param isWritable + */ + private FileFormat(String shortName, String extensions, + boolean isReadable, boolean isWritable) + { + this.name = shortName; + this.extensions = extensions; + this.readable = isReadable; + this.writable = isWritable; + } + + @Override + public String getExtensions() + { + return extensions; + } } diff --git a/src/jalview/io/FileFormatI.java b/src/jalview/io/FileFormatI.java index c9d56ae..f594a36 100644 --- a/src/jalview/io/FileFormatI.java +++ b/src/jalview/io/FileFormatI.java @@ -16,4 +16,15 @@ public interface FileFormatI String getShortDescription(); + /** + * Returns a comma-separated list of file extensions associated with the + * format + * + * @return + */ + String getExtensions(); + + boolean isReadable(); + + boolean isWritable(); } diff --git a/src/jalview/io/FormatAdapter.java b/src/jalview/io/FormatAdapter.java index 7f8b007..1408cd1 100755 --- a/src/jalview/io/FormatAdapter.java +++ b/src/jalview/io/FormatAdapter.java @@ -30,6 +30,7 @@ import jalview.datamodel.ColumnSelection; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceGroup; import jalview.datamodel.SequenceI; +import jalview.util.Comparison; import java.io.IOException; @@ -79,7 +80,7 @@ public class FormatAdapter extends AppletFormatAdapter } } - public String formatSequences(String format, SequenceI[] seqs, + public String formatSequences(FileFormatI format, SequenceI[] seqs, String[] omitHiddenColumns, int[] exportRange) { @@ -115,14 +116,14 @@ public class FormatAdapter extends AppletFormatAdapter startIndex = startEnd[0]; endIndex = startEnd[1]; // get first non-gaped residue start position - while (jalview.util.Comparison.isGap(seqs[i] + while (Comparison.isGap(seqs[i] .getCharAt(startIndex)) && startIndex < endIndex) { startIndex++; } // get last non-gaped residue end position - while (jalview.util.Comparison.isGap(seqs[i].getCharAt(endIndex)) + while (Comparison.isGap(seqs[i].getCharAt(endIndex)) && endIndex > startIndex) { endIndex--; @@ -147,85 +148,86 @@ public class FormatAdapter extends AppletFormatAdapter * * * @param format - * Format string as givien in the AppletFormatAdaptor list (exact - * match to name of class implementing file io for that format) * @param seqs * vector of sequences to write * * @return String containing sequences in desired format */ - public String formatSequences(String format, SequenceI[] seqs) + public String formatSequences(FileFormatI format, SequenceI[] seqs) { + // + // try + // { + boolean withSuffix = getCacheSuffixDefault(format); + return format.getAlignmentFile().print(seqs, withSuffix); + // null; + // + // if (format.equalsIgnoreCase("FASTA")) + // { + // afile = new FastaFile(); + // afile.addJVSuffix(jalview.bin.Cache.getDefault("FASTA_JVSUFFIX", + // true)); + // } + // else if (format.equalsIgnoreCase("MSF")) + // { + // afile = new MSFfile(); + // afile.addJVSuffix(jalview.bin.Cache + // .getDefault("MSF_JVSUFFIX", true)); + // } + // else if (format.equalsIgnoreCase("PileUp")) + // { + // afile = new PileUpfile(); + // afile.addJVSuffix(jalview.bin.Cache.getDefault("PILEUP_JVSUFFIX", + // true)); + // } + // else if (format.equalsIgnoreCase("CLUSTAL")) + // { + // afile = new ClustalFile(); + // afile.addJVSuffix(jalview.bin.Cache.getDefault("CLUSTAL_JVSUFFIX", + // true)); + // } + // else if (format.equalsIgnoreCase("BLC")) + // { + // afile = new BLCFile(); + // afile.addJVSuffix(jalview.bin.Cache + // .getDefault("BLC_JVSUFFIX", true)); + // } + // else if (format.equalsIgnoreCase("PIR")) + // { + // afile = new PIRFile(); + // afile.addJVSuffix(jalview.bin.Cache + // .getDefault("PIR_JVSUFFIX", true)); + // } + // else if (format.equalsIgnoreCase("PFAM")) + // { + // afile = new PfamFile(); + // afile.addJVSuffix(jalview.bin.Cache.getDefault("PFAM_JVSUFFIX", + // true)); + // } + // /* + // * amsa is not supported by this function - it requires an alignment + // * rather than a sequence vector else if + // (format.equalsIgnoreCase("AMSA")) + // * { afile = new AMSAFile(); afile.addJVSuffix( + // * jalview.bin.Cache.getDefault("AMSA_JVSUFFIX", true)); } + // */ - try - { - AlignFile afile = null; - - if (format.equalsIgnoreCase("FASTA")) - { - afile = new FastaFile(); - afile.addJVSuffix(jalview.bin.Cache.getDefault("FASTA_JVSUFFIX", - true)); - } - else if (format.equalsIgnoreCase("MSF")) - { - afile = new MSFfile(); - afile.addJVSuffix(jalview.bin.Cache - .getDefault("MSF_JVSUFFIX", true)); - } - else if (format.equalsIgnoreCase("PileUp")) - { - afile = new PileUpfile(); - afile.addJVSuffix(jalview.bin.Cache.getDefault("PILEUP_JVSUFFIX", - true)); - } - else if (format.equalsIgnoreCase("CLUSTAL")) - { - afile = new ClustalFile(); - afile.addJVSuffix(jalview.bin.Cache.getDefault("CLUSTAL_JVSUFFIX", - true)); - } - else if (format.equalsIgnoreCase("BLC")) - { - afile = new BLCFile(); - afile.addJVSuffix(jalview.bin.Cache - .getDefault("BLC_JVSUFFIX", true)); - } - else if (format.equalsIgnoreCase("PIR")) - { - afile = new PIRFile(); - afile.addJVSuffix(jalview.bin.Cache - .getDefault("PIR_JVSUFFIX", true)); - } - else if (format.equalsIgnoreCase("PFAM")) - { - afile = new PfamFile(); - afile.addJVSuffix(jalview.bin.Cache.getDefault("PFAM_JVSUFFIX", - true)); - } - /* - * amsa is not supported by this function - it requires an alignment - * rather than a sequence vector else if (format.equalsIgnoreCase("AMSA")) - * { afile = new AMSAFile(); afile.addJVSuffix( - * jalview.bin.Cache.getDefault("AMSA_JVSUFFIX", true)); } - */ - - afile.setSeqs(seqs); - String afileresp = afile.print(); - if (afile.hasWarningMessage()) - { - System.err.println("Warning raised when writing as " + format - + " : " + afile.getWarningMessage()); - } - return afileresp; - } catch (Exception e) - { - System.err.println("Failed to write alignment as a '" + format - + "' file\n"); - e.printStackTrace(); - } - - return null; +// afile.setSeqs(seqs); +// String afileresp = afile.print(); +// if (afile.hasWarningMessage()) +// { +// System.err.println("Warning raised when writing as " + format +// + " : " + afile.getWarningMessage()); +// } +// return afileresp; +// } catch (Exception e) +// { +// System.err.println("Failed to write alignment as a '" + format +// + "' file\n"); +// e.printStackTrace(); +// } +// +// return null; } public boolean getCacheSuffixDefault(FileFormatI format) @@ -320,28 +322,6 @@ public class FormatAdapter extends AppletFormatAdapter } /** - * validate format is valid for IO in Application. This is basically the - * AppletFormatAdapter.isValidFormat call with additional checks for - * Application only formats like 'Jalview'. - * - * @param format - * a format string to be compared with list of readable or writable - * formats (READABLE_FORMATS or WRITABLE_FORMATS) - * @param forwriting - * when true, format is checked against list of writable formats. - * @return true if format is valid - */ - public static final boolean isValidIOFormat(String format, - boolean forwriting) - { - if (format.equalsIgnoreCase("jalview")) - { - return true; - } - return AppletFormatAdapter.isValidFormat(format, forwriting); - } - - /** * Create a flat file representation of a given view or selected region of a * view * diff --git a/src/jalview/io/HtmlFile.java b/src/jalview/io/HtmlFile.java index 32ae388..af3fb5d 100644 --- a/src/jalview/io/HtmlFile.java +++ b/src/jalview/io/HtmlFile.java @@ -120,7 +120,7 @@ public class HtmlFile extends AlignFile implements ComplexAlignFile } @Override - public String print() + public String print(SequenceI[] sqs, boolean jvsuffix) { throw new UnsupportedOperationException( "Print method of HtmlFile is not supported!"); diff --git a/src/jalview/io/JPredFile.java b/src/jalview/io/JPredFile.java index 451ece8..fd971fd 100755 --- a/src/jalview/io/JPredFile.java +++ b/src/jalview/io/JPredFile.java @@ -356,7 +356,7 @@ public class JPredFile extends AlignFile * @return String */ @Override - public String print() + public String print(SequenceI[] sqs, boolean jvsuffix) { return "Not Supported"; } diff --git a/src/jalview/io/JSONFile.java b/src/jalview/io/JSONFile.java index 60e48a9..ad44073 100644 --- a/src/jalview/io/JSONFile.java +++ b/src/jalview/io/JSONFile.java @@ -115,7 +115,7 @@ public class JSONFile extends AlignFile implements ComplexAlignFile } @Override - public String print() + public String print(SequenceI[] sqs, boolean jvsuffix) { String jsonOutput = null; try @@ -168,7 +168,7 @@ public class JSONFile extends AlignFile implements ComplexAlignFile } int count = 0; - for (SequenceI seq : seqs) + for (SequenceI seq : sqs) { StringBuilder name = new StringBuilder(); name.append(seq.getName()).append("/").append(seq.getStart()) @@ -225,7 +225,7 @@ public class JSONFile extends AlignFile implements ComplexAlignFile if (exportSettings.isExportFeatures()) { jsonAlignmentPojo - .setSeqFeatures(sequenceFeatureToJsonPojo(seqs, fr)); + .setSeqFeatures(sequenceFeatureToJsonPojo(sqs, fr)); } if (exportSettings.isExportGroups() && seqGroups != null @@ -315,11 +315,16 @@ public class JSONFile extends AlignFile implements ComplexAlignFile } public List sequenceFeatureToJsonPojo( - List seqs, FeatureRenderer fr) + SequenceI[] sqs, FeatureRenderer fr) { displayedFeatures = (fr == null) ? null : fr.getFeaturesDisplayed(); List sequenceFeaturesPojo = new ArrayList(); - for (SequenceI seq : seqs) + if (sqs == null) + { + return sequenceFeaturesPojo; + } + + for (SequenceI seq : sqs) { SequenceI dataSetSequence = seq.getDatasetSequence(); SequenceFeature[] seqFeatures = (dataSetSequence == null) ? null diff --git a/src/jalview/io/MSFfile.java b/src/jalview/io/MSFfile.java index 431544b..1f28f49 100755 --- a/src/jalview/io/MSFfile.java +++ b/src/jalview/io/MSFfile.java @@ -22,6 +22,7 @@ package jalview.io; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceI; +import jalview.util.Comparison; import jalview.util.Format; import java.io.IOException; @@ -202,22 +203,13 @@ public class MSFfile extends AlignFile return check % 10000; } - /** - * DOCUMENT ME! - * - * @param s - * DOCUMENT ME! - * @param is_NA - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - public String print(SequenceI[] seqs) + @Override + public String print(SequenceI[] sqs, boolean jvsuffix) { - boolean is_NA = jalview.util.Comparison.isNucleotide(seqs); + boolean is_NA = Comparison.isNucleotide(sqs); - SequenceI[] s = new SequenceI[seqs.length]; + SequenceI[] s = new SequenceI[sqs.length]; StringBuffer out = new StringBuffer("!!" + (is_NA ? "NA" : "AA") + "_MULTIPLE_ALIGNMENT 1.0"); @@ -228,11 +220,11 @@ public class MSFfile extends AlignFile int maxid = 0; int i = 0; - while ((i < seqs.length) && (seqs[i] != null)) + while ((i < sqs.length) && (sqs[i] != null)) { // Replace all internal gaps with . and external spaces with ~ - s[i] = new Sequence(seqs[i].getName(), seqs[i].getSequenceAsString() - .replace('-', '.'), seqs[i].getStart(), seqs[i].getEnd()); + s[i] = new Sequence(sqs[i].getName(), sqs[i].getSequenceAsString() + .replace('-', '.'), sqs[i].getStart(), sqs[i].getEnd()); StringBuffer sb = new StringBuffer(); sb.append(s[i].getSequence()); @@ -301,7 +293,7 @@ public class MSFfile extends AlignFile while ((i < s.length) && (s[i] != null)) { - nameBlock[i] = new String(" Name: " + printId(s[i]) + " "); + nameBlock[i] = new String(" Name: " + printId(s[i], jvsuffix) + " "); idBlock[i] = new String("Len: " + maxLenpad.form(s[i].getSequence().length) + " Check: " @@ -353,7 +345,7 @@ public class MSFfile extends AlignFile while ((j < s.length) && (s[j] != null)) { - String name = printId(s[j]); + String name = printId(s[j], jvsuffix); out.append(new Format("%-" + maxid + "s").form(name + " ")); @@ -401,15 +393,4 @@ public class MSFfile extends AlignFile return out.toString(); } - - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - @Override - public String print() - { - return print(getSeqsAsArray()); - } } diff --git a/src/jalview/io/PIRFile.java b/src/jalview/io/PIRFile.java index 8402d24..d9ed516 100755 --- a/src/jalview/io/PIRFile.java +++ b/src/jalview/io/PIRFile.java @@ -22,6 +22,7 @@ package jalview.io; import jalview.datamodel.Sequence; import jalview.datamodel.SequenceI; +import jalview.util.Comparison; import java.io.IOException; import java.util.Vector; @@ -103,14 +104,9 @@ public class PIRFile extends AlignFile } @Override - public String print() + public String print(SequenceI[] s, boolean jvsuffix) { - return print(getSeqsAsArray()); - } - - public String print(SequenceI[] s) - { - boolean is_NA = jalview.util.Comparison.isNucleotide(s); + boolean is_NA = Comparison.isNucleotide(s); int len = 72; StringBuffer out = new StringBuffer(); int i = 0; @@ -162,7 +158,7 @@ public class PIRFile extends AlignFile } else { - out.append(">P1;" + printId(s[i])); + out.append(">P1;" + printId(s[i], jvsuffix)); out.append(newline); if (s[i].getDescription() != null) { diff --git a/src/jalview/io/PfamFile.java b/src/jalview/io/PfamFile.java index 59ffbaa..c6c10bd 100755 --- a/src/jalview/io/PfamFile.java +++ b/src/jalview/io/PfamFile.java @@ -144,7 +144,8 @@ public class PfamFile extends AlignFile } } - public String print(SequenceI[] s) + @Override + public String print(SequenceI[] s, boolean jvsuffix) { StringBuffer out = new StringBuffer(""); @@ -155,7 +156,7 @@ public class PfamFile extends AlignFile while ((i < s.length) && (s[i] != null)) { - String tmp = printId(s[i]); + String tmp = printId(s[i], jvsuffix); if (s[i].getSequence().length > max) { @@ -179,7 +180,8 @@ public class PfamFile extends AlignFile while ((j < s.length) && (s[j] != null)) { - out.append(new Format("%-" + maxid + "s").form(printId(s[j]) + " ")); + out.append(new Format("%-" + maxid + "s") + .form(printId(s[j], jvsuffix) + " ")); out.append(s[j].getSequenceAsString()); out.append(newline); @@ -190,10 +192,4 @@ public class PfamFile extends AlignFile return out.toString(); } - - @Override - public String print() - { - return print(getSeqsAsArray()); - } } diff --git a/src/jalview/io/PhylipFile.java b/src/jalview/io/PhylipFile.java index 2c8beae..e8fe7e9 100644 --- a/src/jalview/io/PhylipFile.java +++ b/src/jalview/io/PhylipFile.java @@ -240,15 +240,15 @@ public class PhylipFile extends AlignFile * @see {@link AlignFile#print()} */ @Override - public String print() + public String print(SequenceI[] sqs, boolean jvsuffix) { - StringBuffer sb = new StringBuffer(Integer.toString(seqs.size())); + StringBuffer sb = new StringBuffer(Integer.toString(sqs.length)); sb.append(" "); // if there are no sequences, then define the number of characters as 0 sb.append( - (seqs.size() > 0) ? Integer - .toString(seqs.get(0).getSequence().length) : "0") + (sqs.length > 0) ? Integer.toString(sqs[0].getSequence().length) + : "0") .append(newline); // Due to how IO is handled, there doesn't appear to be a way to store @@ -260,7 +260,7 @@ public class PhylipFile extends AlignFile int numInterleavedColumns = 60; int sequenceLength = 0; - for (SequenceI s : seqs) + for (SequenceI s : sqs) { // ensure name is only 10 characters @@ -311,7 +311,7 @@ public class PhylipFile extends AlignFile // add blank line to separate this matrix from previous sb.append(newline); int start = i * numInterleavedColumns; - for (SequenceI s : seqs) + for (SequenceI s : sqs) { sb.append( s.getSequence(start, Math.min(start diff --git a/src/jalview/io/PileUpfile.java b/src/jalview/io/PileUpfile.java index 50ed805..84be72c 100755 --- a/src/jalview/io/PileUpfile.java +++ b/src/jalview/io/PileUpfile.java @@ -72,19 +72,8 @@ public class PileUpfile extends MSFfile super(source); } - /** - * DOCUMENT ME! - * - * @return DOCUMENT ME! - */ - @Override - public String print() - { - return print(getSeqsAsArray()); - } - @Override - public String print(SequenceI[] s) + public String print(SequenceI[] s, boolean jvsuffix) { StringBuffer out = new StringBuffer("PileUp"); out.append(newline); @@ -113,7 +102,8 @@ public class PileUpfile extends MSFfile while ((i < s.length) && (s[i] != null)) { String seq = s[i].getSequenceAsString(); - out.append(" Name: " + printId(s[i]) + " oo Len: " + seq.length() + out.append(" Name: " + printId(s[i], jvsuffix) + " oo Len: " + + seq.length() + " Check: " + checksums[i] + " Weight: 1.00"); out.append(newline); @@ -152,7 +142,7 @@ public class PileUpfile extends MSFfile while ((j < s.length) && (s[j] != null)) { - String name = printId(s[j]); + String name = printId(s[j], jvsuffix); out.append(new Format("%-" + maxid + "s").form(name + " ")); diff --git a/src/jalview/io/RnamlFile.java b/src/jalview/io/RnamlFile.java index 8fbe43c..2de14b6 100644 --- a/src/jalview/io/RnamlFile.java +++ b/src/jalview/io/RnamlFile.java @@ -196,16 +196,10 @@ public class RnamlFile extends AlignFile setSeqs(seqs); } - public static String print(SequenceI[] s) - { - return "not yet implemented"; - } - @Override - public String print() + public String print(SequenceI[] sqs, boolean jvsuffix) { - System.out.print("print :"); - return print(getSeqsAsArray()); + return "not yet implemented"; } public ArrayList getRNA() diff --git a/src/jalview/io/SimpleBlastFile.java b/src/jalview/io/SimpleBlastFile.java index a3fc716..1b72545 100644 --- a/src/jalview/io/SimpleBlastFile.java +++ b/src/jalview/io/SimpleBlastFile.java @@ -289,14 +289,9 @@ public class SimpleBlastFile extends AlignFile } } - public String print(SequenceI[] s) - { - return new String("Not Implemented."); - } - @Override - public String print() + public String print(SequenceI[] sqs, boolean jvsuffix) { - return print(getSeqsAsArray()); + return new String("Not Implemented."); } } diff --git a/src/jalview/io/StockholmFile.java b/src/jalview/io/StockholmFile.java index 813b184..cb4c786 100644 --- a/src/jalview/io/StockholmFile.java +++ b/src/jalview/io/StockholmFile.java @@ -884,8 +884,12 @@ public class StockholmFile extends AlignFile return annot; } - public String print(SequenceI[] s) + @Override + public String print(SequenceI[] s, boolean jvsuffix) { + // out.append("# STOCKHOLM 1.0"); + // out.append(newline); + // find max length of id int max = 0; int maxid = 0; @@ -893,7 +897,7 @@ public class StockholmFile extends AlignFile Hashtable dataRef = null; while ((in < s.length) && (s[in] != null)) { - String tmp = printId(s[in]); + String tmp = printId(s[in], jvsuffix); if (s[in].getSequence().length > max) { max = s[in].getSequence().length; @@ -990,7 +994,7 @@ public class StockholmFile extends AlignFile // out.append("#=GR "); out.append(new Format("%-" + maxid + "s").form("#=GR " - + printId(s[i]) + " " + key + " ")); + + printId(s[i], jvsuffix) + " " + key + " ")); ann = alAnot[j].annotations; boolean isrna = alAnot[j].isValidStruc(); String seq = ""; @@ -1004,7 +1008,8 @@ public class StockholmFile extends AlignFile } } - out.append(new Format("%-" + maxid + "s").form(printId(s[i]) + " ")); + out.append(new Format("%-" + maxid + "s") + .form(printId(s[i], jvsuffix) + " ")); out.append(s[i].getSequenceAsString()); out.append(newline); i++; @@ -1057,6 +1062,8 @@ public class StockholmFile extends AlignFile out.append(newline); } } + // out.append("//"); + // out.append(newline); return out.toString(); } @@ -1109,19 +1116,6 @@ public class StockholmFile extends AlignFile return seq; } - @Override - public String print() - { - out = new StringBuffer(); - out.append("# STOCKHOLM 1.0"); - out.append(newline); - print(getSeqsAsArray()); - - out.append("//"); - out.append(newline); - return out.toString(); - } - private static Hashtable typeIds = null; static { diff --git a/src/jalview/io/TCoffeeScoreFile.java b/src/jalview/io/TCoffeeScoreFile.java index ab573f3..c3ec951 100644 --- a/src/jalview/io/TCoffeeScoreFile.java +++ b/src/jalview/io/TCoffeeScoreFile.java @@ -645,7 +645,7 @@ public class TCoffeeScoreFile extends AlignFile } @Override - public String print() + public String print(SequenceI[] sqs, boolean jvsuffix) { // TODO Auto-generated method stub return "Not valid."; diff --git a/src/jalview/io/packed/ParsePackedSet.java b/src/jalview/io/packed/ParsePackedSet.java index 71999f0..138fef7 100644 --- a/src/jalview/io/packed/ParsePackedSet.java +++ b/src/jalview/io/packed/ParsePackedSet.java @@ -23,6 +23,7 @@ package jalview.io.packed; import jalview.api.FeatureColourI; import jalview.datamodel.AlignmentI; import jalview.io.AppletFormatAdapter; +import jalview.io.FileFormatI; import jalview.io.FileParse; import jalview.io.FormatAdapter; import jalview.io.IdentifyFile; @@ -64,7 +65,7 @@ public class ParsePackedSet FileParse src = dta.getDataSource(); if (dta.getType().equals(DataProvider.JvDataType.ALIGNMENT)) { - String fmt = null; + FileFormatI fmt = null; try { fmt = new IdentifyFile().identify(src, false); @@ -76,32 +77,24 @@ public class ParsePackedSet if (fmt != null) { - if (!FormatAdapter.isValidIOFormat(fmt, false)) + // parse the alignment + AlignmentI al = null; + try { - errmsg = fmt; - exerror = null; + al = new FormatAdapter().readFromFile(src, fmt); + } catch (Exception e) + { + errmsg = "Failed to parse alignment from result set"; + exerror = e; } - else + if (al != null) { - // parse the alignment - AlignmentI al = null; - try - { - al = new FormatAdapter().readFromFile(src, fmt); - } catch (Exception e) - { - errmsg = "Failed to parse alignment from result set"; - exerror = e; - } - if (al != null) - { - // deuniquify and construct/merge additional dataset entries if - // necessary. - context.addAlignment(al); - context.updateSetModified(true); - rslt.add(al); - deuniquify = true; - } + // deuniquify and construct/merge additional dataset entries if + // necessary. + context.addAlignment(al); + context.updateSetModified(true); + rslt.add(al); + deuniquify = true; } } } diff --git a/src/jalview/ws/jws1/JPredThread.java b/src/jalview/ws/jws1/JPredThread.java index 86bb56f..bb4fc37 100644 --- a/src/jalview/ws/jws1/JPredThread.java +++ b/src/jalview/ws/jws1/JPredThread.java @@ -38,6 +38,7 @@ import jalview.io.FormatAdapter; import jalview.io.IdentifyFile; import jalview.io.JPredFile; import jalview.io.JnetAnnotationMaker; +import jalview.io.PileUpfile; import jalview.util.Comparison; import jalview.util.MessageManager; import jalview.ws.AWsJob; @@ -363,7 +364,7 @@ class JPredThread extends JWS1Thread implements WSClientI if (msf.length > 1) { msa = new vamsas.objects.simple.Msfalignment(); - jalview.io.PileUpfile pileup = new jalview.io.PileUpfile(); + PileUpfile pileup = new PileUpfile(); msa.setMsf(pileup.print(msf)); } } diff --git a/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java b/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java index 5bed720..2fcf501 100644 --- a/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java +++ b/src/jalview/ws/seqfetcher/DbSourceProxyImpl.java @@ -22,6 +22,8 @@ package jalview.ws.seqfetcher; import jalview.api.FeatureSettingsModelI; import jalview.datamodel.AlignmentI; +import jalview.io.DataSourceType; +import jalview.io.FileFormatI; import jalview.io.FormatAdapter; import jalview.io.IdentifyFile; @@ -92,10 +94,12 @@ public abstract class DbSourceProxyImpl implements DbSourceProxy protected AlignmentI parseResult(String result) throws Exception { AlignmentI sequences = null; - String format = new IdentifyFile().identify(result, "Paste"); - if (FormatAdapter.isValidFormat(format)) + FileFormatI format = new IdentifyFile().identify(result, + DataSourceType.PASTE); + if (format != null) { - sequences = new FormatAdapter().readFile(result.toString(), "Paste", + sequences = new FormatAdapter().readFile(result.toString(), + DataSourceType.PASTE, format); } return sequences; diff --git a/test/jalview/analysis/DnaAlignmentGenerator.java b/test/jalview/analysis/DnaAlignmentGenerator.java index 69e5c23..9b7fec1 100644 --- a/test/jalview/analysis/DnaAlignmentGenerator.java +++ b/test/jalview/analysis/DnaAlignmentGenerator.java @@ -83,7 +83,7 @@ public class DnaAlignmentGenerator + " bases with " + gapPercentage + "% gaps and " + changePercentage + "% mutations (random seed = " + randomSeed + ")"); - System.out.println(new FastaFile().print(al.getSequencesArray())); + System.out.println(new FastaFile().print(al.getSequencesArray(), true)); } /** diff --git a/test/jalview/ext/paradise/TestAnnotate3D.java b/test/jalview/ext/paradise/TestAnnotate3D.java index c2be67e..3a3b4c2 100644 --- a/test/jalview/ext/paradise/TestAnnotate3D.java +++ b/test/jalview/ext/paradise/TestAnnotate3D.java @@ -158,11 +158,11 @@ public class TestAnnotate3D { AssertJUnit .fail("Couldn't find this sequence in original input:\n" - + new FastaFile() - .print(new SequenceI[] { sq }) + + new FastaFile().print( + new SequenceI[] { sq }, true) + "\n\nOriginal input:\n" - + new FastaFile().print(pdbf.getSeqsAsArray()) - + "\n"); + + new FastaFile().print( + pdbf.getSeqsAsArray(), true) + "\n"); } } } diff --git a/test/jalview/ws/jabaws/DisorderAnnotExportImport.java b/test/jalview/ws/jabaws/DisorderAnnotExportImport.java index 28a44d3..85c075b 100644 --- a/test/jalview/ws/jabaws/DisorderAnnotExportImport.java +++ b/test/jalview/ws/jabaws/DisorderAnnotExportImport.java @@ -129,8 +129,8 @@ public class DisorderAnnotExportImport { try { - String aligfileout = new FormatAdapter().formatSequences("PFAM", - al.getSequencesArray()); + String aligfileout = FileFormat.Pfam.getAlignmentFile().print( + al.getSequencesArray(), true); String anfileout = new AnnotationFile() .printAnnotationsForAlignment(al); assertTrue( diff --git a/test/jalview/ws/jabaws/JpredJabaStructExportImport.java b/test/jalview/ws/jabaws/JpredJabaStructExportImport.java index 25fb190..28fb052 100644 --- a/test/jalview/ws/jabaws/JpredJabaStructExportImport.java +++ b/test/jalview/ws/jabaws/JpredJabaStructExportImport.java @@ -179,8 +179,8 @@ public class JpredJabaStructExportImport try { // what format would be appropriate for RNAalifold annotations? - String aligfileout = new FormatAdapter().formatSequences("PFAM", - al.getSequencesArray()); + String aligfileout = FileFormat.Pfam.getAlignmentFile().print( + al.getSequencesArray(), true); String anfileout = new AnnotationFile() .printAnnotationsForAlignment(al); diff --git a/test/jalview/ws/jabaws/RNAStructExportImport.java b/test/jalview/ws/jabaws/RNAStructExportImport.java index 206930c..9dc5303 100644 --- a/test/jalview/ws/jabaws/RNAStructExportImport.java +++ b/test/jalview/ws/jabaws/RNAStructExportImport.java @@ -193,8 +193,8 @@ public class RNAStructExportImport try { // what format would be appropriate for RNAalifold annotations? - String aligfileout = new FormatAdapter().formatSequences("PFAM", - al.getSequencesArray()); + String aligfileout = FileFormat.Pfam.getAlignmentFile().print( + al.getSequencesArray(), true); String anfileout = new AnnotationFile() .printAnnotationsForAlignment(al); -- 1.7.10.2