2 * Jalview - A Sequence Alignment Editor and Viewer
\r
3 * Copyright (C) 2007 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
24 import jalview.datamodel.*;
\r
30 * @version $Revision$
\r
32 public abstract class AlignFile
\r
41 boolean jvSuffix = true;
\r
44 * Creates a new AlignFile object.
\r
51 * Constructor which parses the data from a file of some specified type.
\r
52 * @param inFile Filename to read from.
\r
53 * @param type What type of file to read from (File, URL)
\r
55 public AlignFile(String inFile, String type)
\r
58 super(inFile, type);
\r
66 * Return the seqs Vector
\r
68 public Vector getSeqs()
\r
74 * Return the Sequences in the seqs Vector as an array of Sequences
\r
76 public SequenceI[] getSeqsAsArray()
\r
78 SequenceI[] s = new SequenceI[seqs.size()];
\r
80 for (int i = 0; i < seqs.size(); i++)
\r
82 s[i] = (SequenceI) seqs.elementAt(i);
\r
88 public void addAnnotations(Alignment al)
\r
90 for (int i = 0; i < annotations.size(); i++)
\r
93 (AlignmentAnnotation) annotations.elementAt(i)
\r
100 * Initialise objects to store sequence data in.
\r
102 protected void initData()
\r
104 seqs = new Vector();
\r
105 annotations = new Vector();
\r
111 * @param s DOCUMENT ME!
\r
113 protected void setSeqs(SequenceI[] s)
\r
115 seqs = new Vector();
\r
117 for (int i = 0; i < s.length; i++)
\r
119 seqs.addElement(s[i]);
\r
124 * This method must be implemented to parse the contents of the file.
\r
126 public abstract void parse()
\r
127 throws IOException;
\r
130 * Print out in alignment file format the Sequences in the seqs Vector.
\r
132 public abstract String print();
\r
134 public void addJVSuffix(boolean b)
\r
140 * A general parser for ids.
\r
142 * @String id Id to be parsed
\r
144 Sequence parseId(String id)
\r
146 Sequence seq = null;
\r
148 int space = id.indexOf(" ");
\r
151 seq = new Sequence(id.substring(0, space), "");
\r
152 seq.setDescription(id.substring(space + 1));
\r
156 seq = new Sequence(id, "");
\r
163 * Creates the output id.
\r
164 * Adds prefix Uniprot format source|id
\r
165 * And suffix Jalview /start-end
\r
167 * @String id Id to be parsed
\r
169 String printId(SequenceI seq)
\r
171 return seq.getDisplayId(jvSuffix);
\r