Tooltips for features, links for features added
[jalview.git] / src / jalview / io / AppletFormatAdapter.java
index f8b809e..5f228fb 100755 (executable)
         /** DOCUMENT ME!! */\r
         public static final Vector formats = new Vector();\r
 \r
+        public static String INVALID_CHARACTERS = "Contains invalid characters";\r
+\r
+        public static String SUPPORTED_FORMATS = "Formats currently supported are\n" +\r
+                                                 "Fasta, MSF, Clustal, BLC, PIR, MSP, and PFAM";\r
+\r
         static\r
         {\r
             formats.addElement("BLC");\r
             formats.addElement("PFAM");\r
         }\r
 \r
+\r
+        public static String FILE = "File";\r
+        public static String URL = "URL";\r
+        public static String PASTE = "Paste";\r
+        public static String CLASSLOADER = "ClassLoader";\r
+\r
         AlignFile afile = null;\r
 \r
         /**\r
@@ -57,6 +68,7 @@
          * @return DOCUMENT ME!\r
          */\r
         public SequenceI[] readFile(String inFile, String type, String format)\r
+            throws java.io.IOException\r
         {\r
             try\r
             {\r
                 {\r
                     afile = new PfamFile(inFile, type);\r
                 }\r
+                else if (format.equals("JnetFile"))\r
+                {\r
+                  afile = new JPredFile(inFile, type);\r
+                  ((JPredFile)afile).removeNonSequences();\r
+                }\r
 \r
                 return afile.getSeqsAsArray();\r
             }\r
               System.err.println("Failed to read alignment using the '" + format +\r
                                  "' reader.\n"+e);\r
 \r
+              if(e.getMessage()!=null && e.getMessage().startsWith(INVALID_CHARACTERS))\r
+                throw new java.io.IOException(e.getMessage());\r
+\r
               // Finally test if the user has pasted just the sequence, no id\r
               if(type.equalsIgnoreCase("Paste"))\r
               {\r
                   // Possible sequence is just residues with no label\r
                   afile = new FastaFile(">UNKNOWN\n" + inFile, "Paste");\r
                   return afile.getSeqsAsArray();\r
-                }catch(Exception ex)\r
+                }\r
+                catch(Exception ex)\r
                 {\r
-                  System.err.println("Failed to read alignment using the 'FASTA' reader.\n"+e);\r
+                  if(ex.toString().startsWith(INVALID_CHARACTERS))\r
+                    throw new java.io.IOException(e.getMessage());\r
+\r
                   ex.printStackTrace();\r
                 }\r
-\r
               }\r
-            }\r
 \r
-            return null;\r
+              // If we get to this stage, the format was not supported\r
+              throw new java.io.IOException(SUPPORTED_FORMATS);\r
+            }\r
         }\r
 \r
 \r