2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2005 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle
\r
5 * This program is free software; you can redistribute it and/or
\r
6 * modify it under the terms of the GNU General Public License
\r
7 * as published by the Free Software Foundation; either version 2
\r
8 * of the License, or (at your option) any later version.
\r
10 * This program is distributed in the hope that it will be useful,
\r
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 * GNU General Public License for more details.
\r
15 * You should have received a copy of the GNU General Public License
\r
16 * along with this program; if not, write to the Free Software
\r
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
\r
21 import jalview.datamodel.*;
\r
23 import java.util.Vector;
\r
30 * @version $Revision$
\r
32 public class AppletFormatAdapter
\r
34 /** DOCUMENT ME!! */
\r
35 public static final Vector formats = new Vector();
\r
39 formats.addElement("BLC");
\r
40 formats.addElement("CLUSTAL");
\r
41 formats.addElement("FASTA");
\r
42 formats.addElement("MSF");
\r
43 formats.addElement("PileUp");
\r
44 formats.addElement("PIR");
\r
45 formats.addElement("PFAM");
\r
48 AlignFile afile = null;
\r
53 * @param inFile DOCUMENT ME!
\r
54 * @param type DOCUMENT ME!
\r
55 * @param format DOCUMENT ME!
\r
57 * @return DOCUMENT ME!
\r
59 public SequenceI[] readFile(String inFile, String type, String format)
\r
63 if (format.equals("FASTA"))
\r
65 afile = new FastaFile(inFile, type);
\r
67 else if (format.equals("MSF"))
\r
69 afile = new MSFfile(inFile, type);
\r
71 else if (format.equals("PileUp"))
\r
73 afile = new PileUpfile(inFile, type);
\r
75 else if (format.equals("CLUSTAL"))
\r
77 afile = new ClustalFile(inFile, type);
\r
79 else if (format.equals("BLC"))
\r
81 afile = new BLCFile(inFile, type);
\r
83 else if (format.equals("PIR"))
\r
85 afile = new PIRFile(inFile, type);
\r
87 else if (format.equals("PFAM"))
\r
89 afile = new PfamFile(inFile, type);
\r
92 return afile.getSeqsAsArray();
\r
96 System.err.println("Failed to read alignment using the '" + format +
\r
99 // Finally test if the user has pasted just the sequence, no id
\r
100 if(type.equalsIgnoreCase("Paste"))
\r
103 // Possible sequence is just residues with no label
\r
104 afile = new FastaFile(">UNKNOWN\n" + inFile, "Paste");
\r
105 return afile.getSeqsAsArray();
\r
106 }catch(Exception ex)
\r
108 System.err.println("Failed to read alignment using the 'FASTA' reader.\n"+e);
\r
109 ex.printStackTrace();
\r
122 * @param format DOCUMENT ME!
\r
123 * @param seqs DOCUMENT ME!
\r
125 * @return DOCUMENT ME!
\r
127 public String formatSequences(String format,
\r
131 SequenceI[] s = new SequenceI[seqs.size()];
\r
133 for (int i = 0; i < seqs.size(); i++)
\r
134 s[i] = (SequenceI) seqs.elementAt(i);
\r
138 AlignFile afile = null;
\r
140 if (format.equalsIgnoreCase("FASTA"))
\r
142 afile = new FastaFile();
\r
144 else if (format.equalsIgnoreCase("MSF"))
\r
146 afile = new MSFfile();
\r
148 else if (format.equalsIgnoreCase("PileUp"))
\r
150 afile = new PileUpfile();
\r
152 else if (format.equalsIgnoreCase("CLUSTAL"))
\r
154 afile = new ClustalFile();
\r
156 else if (format.equalsIgnoreCase("BLC"))
\r
158 afile = new BLCFile();
\r
160 else if (format.equalsIgnoreCase("PIR"))
\r
162 afile = new PIRFile();
\r
164 else if (format.equalsIgnoreCase("PFAM"))
\r
166 afile = new PfamFile();
\r
169 afile.addJVSuffix(jvsuffix);
\r
173 return afile.print();
\r
175 catch (Exception e)
\r
177 System.err.println("Failed to write alignment as a '" + format +
\r
179 e.printStackTrace();
\r