X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FAppletFormatAdapter.java;h=5f228fb79e3bd7711952f60393a39f3e224196e4;hb=f441357783f32298b738d32d5c87000ac0e33768;hp=f8b809ea2a4b6cf77c608c628a2ef5ff1f7c2e80;hpb=55e2e9b22b133db8b9ff0979b0338a33081fc8fd;p=jalview.git diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index f8b809e..5f228fb 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -34,6 +34,11 @@ /** DOCUMENT ME!! */ public static final Vector formats = new Vector(); + public static String INVALID_CHARACTERS = "Contains invalid characters"; + + public static String SUPPORTED_FORMATS = "Formats currently supported are\n" + + "Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM"; + static { formats.addElement("BLC"); @@ -45,6 +50,12 @@ formats.addElement("PFAM"); } + + public static String FILE = "File"; + public static String URL = "URL"; + public static String PASTE = "Paste"; + public static String CLASSLOADER = "ClassLoader"; + AlignFile afile = null; /** @@ -57,6 +68,7 @@ * @return DOCUMENT ME! */ public SequenceI[] readFile(String inFile, String type, String format) + throws java.io.IOException { try { @@ -88,6 +100,11 @@ { afile = new PfamFile(inFile, type); } + else if (format.equals("JnetFile")) + { + afile = new JPredFile(inFile, type); + ((JPredFile)afile).removeNonSequences(); + } return afile.getSeqsAsArray(); } @@ -96,6 +113,9 @@ System.err.println("Failed to read alignment using the '" + format + "' reader.\n"+e); + if(e.getMessage()!=null && e.getMessage().startsWith(INVALID_CHARACTERS)) + throw new java.io.IOException(e.getMessage()); + // Finally test if the user has pasted just the sequence, no id if(type.equalsIgnoreCase("Paste")) { @@ -103,16 +123,19 @@ // Possible sequence is just residues with no label afile = new FastaFile(">UNKNOWN\n" + inFile, "Paste"); return afile.getSeqsAsArray(); - }catch(Exception ex) + } + catch(Exception ex) { - System.err.println("Failed to read alignment using the 'FASTA' reader.\n"+e); + if(ex.toString().startsWith(INVALID_CHARACTERS)) + throw new java.io.IOException(e.getMessage()); + ex.printStackTrace(); } - } - } - return null; + // If we get to this stage, the format was not supported + throw new java.io.IOException(SUPPORTED_FORMATS); + } }