Comment out start and end refs
[jalview.git] / src / jalview / io / AppletFormatAdapter.java
index f8b809e..8d2d796 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("PileUp");\r
             formats.addElement("PIR");\r
             formats.addElement("PFAM");\r
+            formats.addElement("PDB");\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
+        String inFile;\r
 \r
         /**\r
          * DOCUMENT ME!\r
          * @return DOCUMENT ME!\r
          */\r
         public SequenceI[] readFile(String inFile, String type, String format)\r
+            throws java.io.IOException\r
         {\r
+            this.inFile = inFile;\r
             try\r
             {\r
-                if (format.equals("FASTA"))\r
-                {\r
-                    afile = new FastaFile(inFile, type);\r
-                }\r
-                else if (format.equals("MSF"))\r
-                {\r
-                    afile = new MSFfile(inFile, type);\r
-                }\r
-                else if (format.equals("PileUp"))\r
-                {\r
-                    afile = new PileUpfile(inFile, type);\r
-                }\r
-                else if (format.equals("CLUSTAL"))\r
-                {\r
-                    afile = new ClustalFile(inFile, type);\r
-                }\r
-                else if (format.equals("BLC"))\r
-                {\r
-                    afile = new BLCFile(inFile, type);\r
-                }\r
-                else if (format.equals("PIR"))\r
-                {\r
-                    afile = new PIRFile(inFile, type);\r
-                }\r
-                else if (format.equals("PFAM"))\r
-                {\r
-                    afile = new PfamFile(inFile, type);\r
-                }\r
+              if (format.equals("FASTA"))\r
+              {\r
+                afile = new FastaFile(inFile, type);\r
+              }\r
+              else if (format.equals("MSF"))\r
+              {\r
+                afile = new MSFfile(inFile, type);\r
+              }\r
+              else if (format.equals("PileUp"))\r
+              {\r
+                afile = new PileUpfile(inFile, type);\r
+              }\r
+              else if (format.equals("CLUSTAL"))\r
+              {\r
+                afile = new ClustalFile(inFile, type);\r
+              }\r
+              else if (format.equals("BLC"))\r
+              {\r
+                afile = new BLCFile(inFile, type);\r
+              }\r
+              else if (format.equals("PIR"))\r
+              {\r
+                afile = new PIRFile(inFile, type);\r
+              }\r
+              else if (format.equals("PFAM"))\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
+              else if (format.equals("PDB"))\r
+              {\r
+                afile = new MCview.PDBfile(inFile, type);\r
+              }\r
 \r
-                return afile.getSeqsAsArray();\r
+              return afile.getSeqsAsArray();\r
             }\r
             catch (Exception e)\r
             {\r
+              e.printStackTrace();\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