/*\r
- * Jalview - A Sequence Alignment Editor and Viewer\r
- * Copyright (C) 2007 AM Waterhouse, J Procter, G Barton, M Clamp, S Searle\r
- *\r
- * This program is free software; you can redistribute it and/or\r
- * modify it under the terms of the GNU General Public License\r
- * as published by the Free Software Foundation; either version 2\r
- * of the License, or (at your option) any later version.\r
- *\r
- * This program is distributed in the hope that it will be useful,\r
- * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
- * GNU General Public License for more details.\r
- *\r
- * You should have received a copy of the GNU General Public License\r
- * along with this program; if not, write to the Free Software\r
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA\r
+ * Jalview - A Sequence Alignment Editor and Viewer (Version 2.6)\r
+ * Copyright (C) 2010 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle\r
+ * \r
+ * This file is part of Jalview.\r
+ * \r
+ * Jalview is free software: you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License \r
+ * as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.\r
+ * \r
+ * Jalview is distributed in the hope that it will be useful, but \r
+ * WITHOUT ANY WARRANTY; without even the implied warranty \r
+ * of MERCHANTABILITY or FITNESS FOR A PARTICULAR \r
+ * PURPOSE. See the GNU General Public License for more details.\r
+ * \r
+ * You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.\r
*/\r
/*\r
* This extension was written by Benjamin Schuster-Boeckler at sanger.ac.uk\r
// import org.apache.log4j.*;\r
\r
/**\r
- * This class is supposed to parse a Stockholm format file into Jalview\r
- * There are TODOs in this class: we do not know what the database source and\r
- * version is for the file when parsing the #GS= AC tag which associates accessions\r
- * with sequences. \r
- * Database references are also not parsed correctly: a separate reference string\r
- * parser must be added to parse the database reference form into Jalview's local\r
- * representation.\r
+ * This class is supposed to parse a Stockholm format file into Jalview There\r
+ * are TODOs in this class: we do not know what the database source and version\r
+ * is for the file when parsing the #GS= AC tag which associates accessions with\r
+ * sequences. Database references are also not parsed correctly: a separate\r
+ * reference string parser must be added to parse the database reference form\r
+ * into Jalview's local representation.\r
+ * \r
* @author bsb at sanger.ac.uk\r
* @version 0.3 + jalview mods\r
* \r
{\r
super(inFile, type);\r
}\r
+\r
public StockholmFile(FileParse source) throws IOException\r
{\r
super(source);\r
}\r
+\r
public void initData()\r
{\r
super.initData();\r
}\r
\r
// We define some Regexes here that will be used regularily later\r
- rend = new Regex("\\/\\/"); // Find the end of an alignment\r
+ rend = new Regex("^\\s*\\/\\/"); // Find the end of an alignment\r
p = new Regex("(\\S+)\\/(\\d+)\\-(\\d+)"); // split sequence id in\r
- // id/from/to\r
+ // id/from/to\r
s = new Regex("(\\S+)\\s+(\\S*)\\s+(.*)"); // Parses annotation subtype\r
r = new Regex("#=(G[FSRC]?)\\s+(.*)"); // Finds any annotation line\r
x = new Regex("(\\S+)\\s+(\\S+)"); // split id from sequence\r
String src = dbr.substring(0, dbr.indexOf(";"));\r
String acn = dbr.substring(dbr.indexOf(";") + 1);\r
jalview.util.DBRefUtils.parseToDbRef(seqO, src, "0", acn);\r
- //seqO.addDBRef(dbref);\r
+ // seqO.addDBRef(dbref);\r
}\r
}\r
Hashtable features = null;\r
for (int k = 0; k < byChar.length; k++)\r
{\r
char c = byChar[k];\r
- if (!(c == ' ' || c == '_' || c == '-' || c == '.')) // PFAM uses '.' for feature background\r
+ if (!(c == ' ' || c == '_' || c == '-' || c == '.')) // PFAM\r
+ // uses\r
+ // '.'\r
+ // for\r
+ // feature\r
+ // background\r
{\r
- int new_pos = posmap[k]; // look up nearest seqeunce position to this column\r
+ int new_pos = posmap[k]; // look up nearest seqeunce\r
+ // position to this column\r
SequenceFeature feat = new SequenceFeature(type, desc,\r
new_pos, new_pos, 0f, null);\r
\r
}\r
\r
}\r
- \r
+\r
}\r
// garbage collect\r
- \r
+\r
// logger.debug("Adding seq " + acc + " from " + start + " to " + end\r
// + ": " + seq);\r
this.seqs.addElement(seqO);\r
if (x.search(annContent))\r
{\r
// parse out and create alignment annotation directly.\r
- parseAnnotationRow(annotations, x.stringMatched(1), x\r
- .stringMatched(2));\r
+ parseAnnotationRow(annotations, x.stringMatched(1),\r
+ x.stringMatched(2));\r
}\r
}\r
else if (annType.equals("GR"))\r
String seq = new String(s.stringMatched(3));\r
String description = null;\r
// Check for additional information about the current annotation\r
- // We use a simple string tokenizer here for speed\r
- StringTokenizer sep = new StringTokenizer(seq," \t");\r
+ // We use a simple string tokenizer here for speed\r
+ StringTokenizer sep = new StringTokenizer(seq, " \t");\r
description = sep.nextToken();\r
if (sep.hasMoreTokens())\r
{\r
seq = sep.nextToken();\r
- } else {\r
+ }\r
+ else\r
+ {\r
seq = description;\r
description = new String();\r
}\r
}\r
else\r
{\r
- System.err.println("Warning - couldn't parse sequence annotation row line:\n"+line);\r
+ System.err\r
+ .println("Warning - couldn't parse sequence annotation row line:\n"\r
+ + line);\r
// throw new IOException("Error parsing " + line);\r
}\r
}\r
{\r
String pos = annots.substring(i, i + 1);\r
Annotation ann;\r
- ann = new Annotation(pos, "", ' ', Float.NaN);\r
+ ann = new Annotation(pos, "", ' ', 0f); // 0f is 'valid' null - will not\r
+ // be written out\r
if (ss)\r
{\r
ann.secondaryStructure = jalview.schemes.ResidueProperties\r
.getDssp3state(pos).charAt(0);\r
if (ann.secondaryStructure == pos.charAt(0) || pos.charAt(0) == 'C')\r
{\r
- ann.displayCharacter = "";\r
+ ann.displayCharacter = ""; // null; // " ";\r
}\r
else\r
{\r
- ann.displayCharacter += " ";\r
+ ann.displayCharacter = " " + ann.displayCharacter;\r
}\r
}\r
\r