X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fws%2Frest%2Fparams%2FAlignment.java;h=4426c5f7e79d041e6e0589bdce37b77d21fe5f30;hb=3d0101179759ef157b088ea135423cd909512d9f;hp=08a242d5a49c38e8e5a35bf55d595e235ca2a5e8;hpb=74b531f56bbaad5c5e06a4744980256fe8110923;p=jalview.git diff --git a/src/jalview/ws/rest/params/Alignment.java b/src/jalview/ws/rest/params/Alignment.java index 08a242d..4426c5f 100644 --- a/src/jalview/ws/rest/params/Alignment.java +++ b/src/jalview/ws/rest/params/Alignment.java @@ -23,6 +23,7 @@ package jalview.ws.rest.params; import jalview.datamodel.AlignmentI; import jalview.io.FileFormat; import jalview.io.FileFormatI; +import jalview.io.FileFormats; import jalview.io.FormatAdapter; import jalview.ws.params.OptionI; import jalview.ws.params.simple.BooleanOption; @@ -78,11 +79,11 @@ public class Alignment extends InputType try { File fa = File.createTempFile("jvmime", ".fa"); - PrintWriter pw = new PrintWriter( - new OutputStreamWriter(new BufferedOutputStream( - new FileOutputStream(fa)), "UTF-8")); - pw.append(new FormatAdapter().formatSequences(format, - alignment, jvsuffix)); + PrintWriter pw = new PrintWriter(new OutputStreamWriter( + new BufferedOutputStream(new FileOutputStream(fa)), + "UTF-8")); + pw.append(new FormatAdapter().formatSequences(format, alignment, + jvsuffix)); pw.close(); return new FileBody(fa, "text/plain"); } catch (Exception ex) @@ -107,8 +108,8 @@ public class Alignment extends InputType @Override public List getURLEncodedParameter() { - ArrayList prms = new ArrayList(); - prms.add("format='" + format + "'"); + List prms = new ArrayList(); + prms.add("format='" + format.getName() + "'"); if (type != null) { prms.add("type='" + type.toString() + "'"); @@ -147,22 +148,19 @@ public class Alignment extends InputType if (tok.startsWith("format")) { - for (FileFormatI fmt : FileFormat.values()) + for (FileFormatI fmt : FileFormats.getInstance().getFormats()) { - if (fmt.isWritable() && val.equalsIgnoreCase(fmt.toString())) + if (fmt.isWritable() && val.equalsIgnoreCase(fmt.getName())) { format = fmt; return true; } } - warnings.append("Invalid alignment format '" + val - + "'. Must be one of ("); - for (FileFormatI fmt : FileFormat.values()) + warnings.append( + "Invalid alignment format '" + val + "'. Must be one of ("); + for (String fmt : FileFormats.getInstance().getWritableFormats(true)) { - if (fmt.isWritable()) - { - warnings.append(" " + fmt).toString(); - } + warnings.append(" ").append(fmt); } warnings.append(")\n"); } @@ -174,8 +172,8 @@ public class Alignment extends InputType return true; } catch (Exception x) { - warnings.append("Invalid molecule type '" + val - + "'. Must be one of ("); + warnings.append( + "Invalid molecule type '" + val + "'. Must be one of ("); for (molType v : molType.values()) { warnings.append(" " + v); @@ -197,28 +195,14 @@ public class Alignment extends InputType "Append jalview style /start-end suffix to ID", false, false, writeAsFile, null)); + List writable = FileFormats.getInstance() + .getWritableFormats(true); lst.add(new Option("format", "Alignment upload format", true, - FileFormat.Fasta.toString(), format.toString(), getWritableFormats(), + FileFormat.Fasta.toString(), format.getName(), writable, null)); + lst.add(createMolTypeOption("type", "Sequence type", false, type, null)); - lst.add(createMolTypeOption("type", "Sequence type", false, type, null)); return lst; } - /** - * @return - */ - protected List getWritableFormats() - { - List formats = new ArrayList(); - for (FileFormatI ff : FileFormat.values()) - { - if (ff.isWritable()) - { - formats.add(ff.toString()); - } - } - return formats; - } - }