X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FStockholmFile.java;h=d5f3cc2d70a188d9c18c9826a225019304085afc;hb=f49e86c9f8e7c0301f2b8824d0c033a3df291e6a;hp=bac191643d4a312e20e17d64170357c71f88177e;hpb=a1115830030081f29593da857b28ec46581b6e09;p=jalview.git diff --git a/src/jalview/io/StockholmFile.java b/src/jalview/io/StockholmFile.java index bac1916..d5f3cc2 100644 --- a/src/jalview/io/StockholmFile.java +++ b/src/jalview/io/StockholmFile.java @@ -53,7 +53,10 @@ public class StockholmFile extends AlignFile { super(inFile, type); } - + public StockholmFile(FileParse source) throws IOException + { + super(source); + } public void initData() { super.initData(); @@ -124,7 +127,7 @@ public class StockholmFile extends AlignFile { String acc = (String) accs.nextElement(); // logger.debug("Processing sequence " + acc); - String seq = (String) seqs.get(acc); + String seq = (String) seqs.remove(acc); if (maxLength < seq.length()) { maxLength = seq.length(); @@ -137,7 +140,7 @@ public class StockholmFile extends AlignFile if (seqAnn != null && seqAnn.containsKey(acc)) { - accAnnotations = (Hashtable) seqAnn.get(acc); + accAnnotations = (Hashtable) seqAnn.remove(acc); } // Split accession in id and from/to @@ -172,7 +175,7 @@ public class StockholmFile extends AlignFile // We need to adjust the positions of all features to account for gaps try { - features = (Hashtable) accAnnotations.get("features"); + features = (Hashtable) accAnnotations.remove("features"); } catch (java.lang.NullPointerException e) { // loggerwarn("Getting Features for " + acc + ": " + @@ -182,6 +185,7 @@ public class StockholmFile extends AlignFile // if we have features if (features != null) { + int posmap[] = seqO.findPositionMap(); Enumeration i = features.keys(); while (i.hasMoreElements()) { @@ -190,8 +194,7 @@ public class StockholmFile extends AlignFile // TODO: parse out scores as annotation row // TODO: map coding region to core jalview feature types String type = i.nextElement().toString(); - Hashtable content = (Hashtable) features.get(type); - + Hashtable content = (Hashtable) features.remove(type); Enumeration j = content.keys(); while (j.hasMoreElements()) { @@ -201,9 +204,9 @@ public class StockholmFile extends AlignFile for (int k = 0; k < byChar.length; k++) { char c = byChar[k]; - if (!(c == ' ' || c == '_' || c == '-')) + if (!(c == ' ' || c == '_' || c == '-' || c == '.')) // PFAM uses '.' for feature background { - int new_pos = seqO.findPosition(k); + 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,12 +216,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)) { @@ -370,14 +376,18 @@ public class StockholmFile extends AlignFile { String acc = s.stringMatched(1); String type = s.stringMatched(2); - String seq = s.stringMatched(3); - String description = new String(); - + String seq = new String(s.stringMatched(3)); + String description = null; // Check for additional information about the current annotation - if (x.search(seq)) + // We use a simple string tokenizer here for speed + StringTokenizer sep = new StringTokenizer(seq," \t"); + description = sep.nextToken(); + if (sep.hasMoreTokens()) { - description = x.stringMatched(1); - seq = x.stringMatched(2); + seq = sep.nextToken(); + } else { + seq = description; + description = new String(); } // sequence id with from-to fields