X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FStockholmFile.java;h=2183f2d58f5cbfa18b647cf77b09cd3c4f0df3b9;hb=506d60f0e188723ddc91c26824b41ac7034df3fe;hp=945b8c5d0757849722257d0ce8c3b0e0b5feafea;hpb=b8984b54ec8f43a46ddd7eabc11100ab810866ef;p=jalview.git diff --git a/src/jalview/io/StockholmFile.java b/src/jalview/io/StockholmFile.java index 945b8c5..2183f2d 100644 --- a/src/jalview/io/StockholmFile.java +++ b/src/jalview/io/StockholmFile.java @@ -1,17 +1,17 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer - * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle - * + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.4) + * Copyright (C) 2008 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle + * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA @@ -30,13 +30,13 @@ import jalview.datamodel.*; // import org.apache.log4j.*; /** - * This class is supposed to parse a Stockholm format file into Jalview - * There are TODOs in this class: we do not know what the database source and - * version is for the file when parsing the #GS= AC tag which associates accessions - * with sequences. - * Database references are also not parsed correctly: a separate reference string - * parser must be added to parse the database reference form into Jalview's local - * representation. + * This class is supposed to parse a Stockholm format file into Jalview There + * are TODOs in this class: we do not know what the database source and version + * is for the file when parsing the #GS= AC tag which associates accessions with + * sequences. Database references are also not parsed correctly: a separate + * reference string parser must be added to parse the database reference form + * into Jalview's local representation. + * * @author bsb at sanger.ac.uk * @version 0.3 + jalview mods * @@ -54,6 +54,11 @@ public class StockholmFile extends AlignFile super(inFile, type); } + public StockholmFile(FileParse source) throws IOException + { + super(source); + } + public void initData() { super.initData(); @@ -64,7 +69,7 @@ public class StockholmFile extends AlignFile * be passed at construction time * * @throws IOException - * If there is an error with the input file + * If there is an error with the input file */ public void parse() throws IOException { @@ -96,7 +101,7 @@ public class StockholmFile extends AlignFile // We define some Regexes here that will be used regularily later rend = new Regex("\\/\\/"); // Find the end of an alignment p = new Regex("(\\S+)\\/(\\d+)\\-(\\d+)"); // split sequence id in - // id/from/to + // id/from/to s = new Regex("(\\S+)\\s+(\\S*)\\s+(.*)"); // Parses annotation subtype r = new Regex("#=(G[FSRC]?)\\s+(.*)"); // Finds any annotation line x = new Regex("(\\S+)\\s+(\\S+)"); // split id from sequence @@ -165,7 +170,7 @@ public class StockholmFile extends AlignFile String src = dbr.substring(0, dbr.indexOf(";")); String acn = dbr.substring(dbr.indexOf(";") + 1); jalview.util.DBRefUtils.parseToDbRef(seqO, src, "0", acn); - //seqO.addDBRef(dbref); + // seqO.addDBRef(dbref); } } Hashtable features = null; @@ -201,9 +206,15 @@ public class StockholmFile extends AlignFile for (int k = 0; k < byChar.length; k++) { char c = byChar[k]; - if (!(c == ' ' || c == '_' || c == '-' || c == '.')) // PFAM uses '.' for feature background + if (!(c == ' ' || c == '_' || c == '-' || c == '.')) // PFAM + // uses + // '.' + // for + // feature + // background { - int new_pos = posmap[k]; // look up nearest seqeunce position to this column + int new_pos = posmap[k]; // look up nearest seqeunce + // position to this column SequenceFeature feat = new SequenceFeature(type, desc, new_pos, new_pos, 0f, null); @@ -213,14 +224,15 @@ public class StockholmFile extends AlignFile } } - + } // garbage collect - + // logger.debug("Adding seq " + acc + " from " + start + " to " + end // + ": " + seq); this.seqs.addElement(seqO); } + return; // finished parsing this segment of source } else if (!r.search(line)) { @@ -375,13 +387,15 @@ public class StockholmFile extends AlignFile String seq = new String(s.stringMatched(3)); String description = null; // Check for additional information about the current annotation - // We use a simple string tokenizer here for speed - StringTokenizer sep = new StringTokenizer(seq," \t"); + // We use a simple string tokenizer here for speed + StringTokenizer sep = new StringTokenizer(seq, " \t"); description = sep.nextToken(); if (sep.hasMoreTokens()) { seq = sep.nextToken(); - } else { + } + else + { seq = description; description = new String(); } @@ -438,7 +452,9 @@ public class StockholmFile extends AlignFile } else { - System.err.println("Warning - couldn't parse sequence annotation row line:\n"+line); + System.err + .println("Warning - couldn't parse sequence annotation row line:\n" + + line); // throw new IOException("Error parsing " + line); } } @@ -476,18 +492,19 @@ public class StockholmFile extends AlignFile { String pos = annots.substring(i, i + 1); Annotation ann; - ann = new Annotation(pos, "", ' ', Float.NaN); + ann = new Annotation(pos, "", ' ', 0f); // 0f is 'valid' null - will not + // be written out if (ss) { ann.secondaryStructure = jalview.schemes.ResidueProperties .getDssp3state(pos).charAt(0); if (ann.secondaryStructure == pos.charAt(0) || pos.charAt(0) == 'C') { - ann.displayCharacter = ""; + ann.displayCharacter = ""; // null; // " "; } else { - ann.displayCharacter += " "; + ann.displayCharacter = " " + ann.displayCharacter; } }