+ if (line.length() == 0)\r
+ {\r
+ continue;\r
+ }\r
+ if (rend.search(line))\r
+ {\r
+ // End of the alignment, pass stuff back\r
+\r
+ this.noSeqs = seqs.size();\r
+ // logger.debug("Number of sequences: " + this.noSeqs);\r
+ Enumeration accs = seqs.keys();\r
+ while (accs.hasMoreElements())\r
+ {\r
+ String acc = (String) accs.nextElement();\r
+ // logger.debug("Processing sequence " + acc);\r
+ String seq = (String) seqs.remove(acc);\r
+ if (maxLength < seq.length())\r
+ {\r
+ maxLength = seq.length();\r
+ }\r
+ int start = 1;\r
+ int end = -1;\r
+ String sid = acc;\r
+ /*\r
+ * Retrieve hash of annotations for this accession\r
+ * Associate Annotation with accession\r
+ */\r
+ Hashtable accAnnotations = null;\r
+\r
+ if (seqAnn != null && seqAnn.containsKey(acc))\r
+ {\r
+ accAnnotations = (Hashtable) seqAnn.remove(acc);\r
+ //TODO: add structures to sequence\r
+ }\r
+\r
+ // Split accession in id and from/to\r
+ if (p.search(acc))\r
+ {\r
+ sid = p.stringMatched(1);\r
+ start = Integer.parseInt(p.stringMatched(2));\r
+ end = Integer.parseInt(p.stringMatched(3));\r
+ }\r
+ // logger.debug(sid + ", " + start + ", " + end);\r
+\r
+ Sequence seqO = new Sequence(sid, seq, start, end);\r
+ // Add Description (if any)\r
+ if (accAnnotations != null && accAnnotations.containsKey("DE"))\r
+ {\r
+ String desc = (String) accAnnotations.get("DE");\r
+ seqO.setDescription((desc == null) ? "" : desc);\r
+ }\r
+ // Add DB References (if any)\r
+ if (accAnnotations != null && accAnnotations.containsKey("DR"))\r
+ {\r
+ String dbr = (String) accAnnotations.get("DR");\r
+ if (dbr != null && dbr.indexOf(";") > -1)\r
+ {\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
+ }\r
+ } \r
+ if (accAnnotations != null && accAnnotations.containsKey("SS"))\r
+ {\r
+ Vector v = (Vector) accAnnotations.get("SS");\r
+ \r
+ for (int i = 0; i < v.size(); i++)\r
+ {\r
+ AlignmentAnnotation an = (AlignmentAnnotation) v.elementAt(i);\r
+ seqO.addAlignmentAnnotation(an);\r
+ //annotations.add(an);\r
+ }\r
+ }\r
+ \r
+ Hashtable features = null;\r
+ // We need to adjust the positions of all features to account for gaps\r
+ try\r
+ {\r
+ features = (Hashtable) accAnnotations.remove("features");\r
+ } catch (java.lang.NullPointerException e)\r
+ {\r
+ // loggerwarn("Getting Features for " + acc + ": " +\r
+ // e.getMessage());\r
+ // continue;\r
+ }\r
+ // if we have features\r
+ if (features != null)\r
+ {\r
+ int posmap[] = seqO.findPositionMap();\r
+ Enumeration i = features.keys();\r
+ while (i.hasMoreElements())\r
+ {\r
+ // TODO: parse out secondary structure annotation as annotation\r
+ // row\r
+ // TODO: parse out scores as annotation row\r
+ // TODO: map coding region to core jalview feature types\r
+ String type = i.nextElement().toString();\r
+ Hashtable content = (Hashtable) features.remove(type);\r
+ Enumeration j = content.keys();\r
+ while (j.hasMoreElements())\r
+ {\r
+ String desc = j.nextElement().toString();\r
+ String ns = content.get(desc).toString();\r
+ char[] byChar = ns.toCharArray();\r
+ for (int k = 0; k < byChar.length; k++)\r
+ {\r
+ char c = byChar[k];\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\r
+ // position to this column\r
+ SequenceFeature feat = new SequenceFeature(type, desc,\r
+ new_pos, new_pos, 0f, null);\r
+\r
+ seqO.addSequenceFeature(feat);\r
+ }\r
+ }\r
+ }\r