1 Clazz.declarePackage ("jalview.io");
\r
2 Clazz.load (["jalview.io.FileParse"], "jalview.io.AlignFile", ["jalview.datamodel.Sequence", "jalview.util.MessageManager", "java.io.IOException", "java.lang.Error", "java.util.ArrayList", "$.Hashtable", "$.Vector"], function () {
\r
3 c$ = Clazz.decorateAsClass (function () {
\r
7 this.annotations = null;
\r
8 this.seqGroups = null;
\r
9 this.properties = null;
\r
12 this.jvSuffix = true;
\r
13 this.parseCalled = false;
\r
14 this.newickStrings = null;
\r
15 Clazz.instantialize (this, arguments);
\r
16 }, jalview.io, "AlignFile", jalview.io.FileParse);
\r
17 Clazz.makeConstructor (c$,
\r
19 Clazz.superConstructor (this, jalview.io.AlignFile, []);
\r
22 Clazz.makeConstructor (c$,
\r
23 function (inFile, type) {
\r
24 this.construct (true, inFile, type);
\r
26 Clazz.makeConstructor (c$,
\r
27 function (parseImmediately, inFile, type) {
\r
28 Clazz.superConstructor (this, jalview.io.AlignFile, [inFile, type]);
\r
30 if (parseImmediately) {
\r
33 Clazz.makeConstructor (c$,
\r
35 this.construct (true, source);
\r
36 }, "jalview.io.FileParse");
\r
37 Clazz.makeConstructor (c$,
\r
38 function (parseImmediately, source) {
\r
39 Clazz.superConstructor (this, jalview.io.AlignFile, [source]);
\r
41 if (parseImmediately) {
\r
43 }}, "~B,jalview.io.FileParse");
\r
44 Clazz.defineMethod (c$, "doParse",
\r
46 if (this.parseCalled) {
\r
47 throw new java.io.IOException ("Implementation error: Parser called twice for same data.\nNeed to call initData() again before parsing can be reattempted.");
\r
48 }this.parseCalled = true;
\r
50 for (var i = 0, c = this.seqs.size (); i < c; i++) {
\r
51 this.seqs.get (i).setIndex (i);
\r
54 Clazz.defineMethod (c$, "getSeqs",
\r
58 Clazz.defineMethod (c$, "getSeqGroups",
\r
60 return this.seqGroups;
\r
62 Clazz.defineMethod (c$, "getSeqsAsArray",
\r
64 var s = new Array (this.seqs.size ());
\r
65 for (var i = 0; i < this.seqs.size (); i++) {
\r
66 s[i] = this.seqs.elementAt (i);
\r
70 Clazz.defineMethod (c$, "addAnnotations",
\r
72 this.addProperties (al);
\r
73 for (var i = 0; i < this.annotations.size (); i++) {
\r
74 var an = this.annotations.elementAt (i);
\r
75 an.validateRangeAndDisplay ();
\r
76 al.addAnnotation (an);
\r
78 }, "jalview.datamodel.AlignmentI");
\r
79 Clazz.defineMethod (c$, "addSeqGroups",
\r
81 this.seqGroups = al.getGroups ();
\r
82 }, "jalview.datamodel.AlignmentI");
\r
83 Clazz.defineMethod (c$, "addProperties",
\r
85 if (this.properties != null && this.properties.size () > 0) {
\r
86 var keys = this.properties.keys ();
\r
87 var vals = this.properties.elements ();
\r
88 while (keys.hasMoreElements ()) {
\r
89 al.setProperty (keys.nextElement (), vals.nextElement ());
\r
91 }}, "jalview.datamodel.AlignmentI");
\r
92 Clazz.defineMethod (c$, "setAlignmentProperty",
\r
93 function (key, value) {
\r
95 throw new Error (jalview.util.MessageManager.getString ("error.implementation_error_cannot_have_null_alignment"));
\r
96 }if (value == null) {
\r
98 }if (this.properties == null) {
\r
99 this.properties = new java.util.Hashtable ();
\r
100 }this.properties.put (key, value);
\r
102 Clazz.defineMethod (c$, "getAlignmentProperty",
\r
104 if (this.properties != null && key != null) {
\r
105 return this.properties.get (key);
\r
108 Clazz.defineMethod (c$, "initData",
\r
110 this.seqs = new java.util.Vector ();
\r
111 this.annotations = new java.util.Vector ();
\r
112 this.seqGroups = new java.util.ArrayList ();
\r
113 this.parseCalled = false;
\r
115 Clazz.defineMethod (c$, "setSeqs",
\r
117 this.seqs = new java.util.Vector ();
\r
118 for (var i = 0; i < s.length; i++) {
\r
119 this.seqs.addElement (s[i]);
\r
122 Clazz.defineMethod (c$, "addJVSuffix",
\r
126 Clazz.defineMethod (c$, "parseId",
\r
130 var space = id.indexOf (" ");
\r
132 seq = new jalview.datamodel.Sequence (id.substring (0, space), "");
\r
133 seq.setDescription (id.substring (space + 1));
\r
135 seq = new jalview.datamodel.Sequence (id, "");
\r
138 Clazz.defineMethod (c$, "printId",
\r
140 return seq.getDisplayId (this.jvSuffix);
\r
141 }, "jalview.datamodel.SequenceI");
\r
142 Clazz.defineMethod (c$, "addNewickTree",
\r
143 function (treeName, newickString) {
\r
144 if (this.newickStrings == null) {
\r
145 this.newickStrings = new java.util.Vector ();
\r
146 }this.newickStrings.addElement ( Clazz.newArray (-1, [treeName, newickString]));
\r
148 Clazz.defineMethod (c$, "getTreeCount",
\r
150 return this.newickStrings == null ? 0 : this.newickStrings.size ();
\r
152 Clazz.defineMethod (c$, "addGroups",
\r
154 for (var sg, $sg = this.getSeqGroups ().iterator (); $sg.hasNext () && ((sg = $sg.next ()) || true);) {
\r
157 }, "jalview.datamodel.AlignmentI");
\r