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;
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)
@Override
public List<String> getURLEncodedParameter()
{
- ArrayList<String> prms = new ArrayList<String>();
- prms.add("format='" + format + "'");
+ List<String> prms = new ArrayList<String>();
+ prms.add("format='" + format.getName() + "'");
if (type != null)
{
prms.add("type='" + type.toString() + "'");
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");
}
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);
"Append jalview style /start-end suffix to ID", false, false,
writeAsFile, null));
+ List<String> 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<String> getWritableFormats()
- {
- List<String> formats = new ArrayList<String>();
- for (FileFormatI ff : FileFormat.values())
- {
- if (ff.isWritable())
- {
- formats.add(ff.toString());
- }
- }
- return formats;
- }
-
}