1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package org.utgenome.gwt.utgb.client.bio;
26
27 import java.util.ArrayList;
28 import java.util.HashMap;
29
30 public class CompactWIGData implements GraphData {
31
32
33
34 private static final long serialVersionUID = 1L;
35
36
37
38 int trackId = -1;
39 float maxValue = Float.MIN_VALUE;
40 float minValue = Float.MAX_VALUE;
41
42 ArrayList<String> browser = null;
43 HashMap<String, String> track = null;
44 float[] data;
45 int start;
46 int span = 1;
47
48 public ReadCoverage toReadCoverage(ChrLoc loc) {
49 int[] coverage = new int[data.length];
50 for (int i = 0; i < data.length; ++i)
51 coverage[i] = (int) data[i];
52 ReadCoverage c = new ReadCoverage(loc.start, loc.end, data.length, coverage);
53 c.minHeight = (int) minValue;
54 c.maxHeight = (int) maxValue;
55 c.pixelWidth = data.length;
56 return c;
57 }
58
59 public int getPixelSize() {
60 return data.length;
61 }
62
63 public void setSpan(int span) {
64 this.span = span;
65 }
66
67 public int getSpan() {
68 return span;
69 }
70
71 public void setStart(int start) {
72 this.start = start;
73 }
74
75 public int getStart() {
76 return start;
77 }
78
79 public int getTrack_id() {
80 return trackId;
81 }
82
83 public void setTrack_id(int track_id) {
84 this.trackId = track_id;
85 }
86
87 public float getMinValue() {
88 return minValue;
89 }
90
91 public void setMinValue(float minValue) {
92 this.minValue = minValue;
93 }
94
95 public float getMaxValue() {
96 return maxValue;
97 }
98
99 public void setMaxValue(float maxValue) {
100 this.maxValue = maxValue;
101 }
102
103 public ArrayList<String> getBrowser() {
104 return browser;
105 }
106
107 public void setBrowser(ArrayList<String> browser) {
108 this.browser = browser;
109 }
110
111 public HashMap<String, String> getTrack() {
112 return track;
113 }
114
115 public void setTrack(HashMap<String, String> track) {
116 this.track = track;
117 }
118
119 public float[] getData() {
120 return data;
121 }
122
123 public void setData(float[] data) {
124 this.data = data;
125 }
126
127 @Override
128 public String toString() {
129 StringBuilder sb = new StringBuilder();
130
131 if (track.isEmpty())
132 return null;
133
134 sb.append("TrackID:" + trackId + "(");
135 if (!browser.isEmpty()) {
136 for (String s : browser) {
137 sb.append(s + ", ");
138 }
139 sb.delete(sb.lastIndexOf(","), sb.length()).append("), (");
140 }
141
142 if (!track.isEmpty()) {
143 for (String s : track.keySet()) {
144 sb.append(s + "=" + track.get(s) + ", ");
145 }
146 sb.delete(sb.lastIndexOf(","), sb.length()).append("), (");
147 }
148 if (data != null) {
149 sb.append(data + ", ");
150 }
151 if (!sb.equals(""))
152 sb.delete(sb.lastIndexOf(","), sb.length()).append(")");
153
154 return sb.toString();
155 }
156
157 public void accept(OnGenomeDataVisitor visitor) {
158 visitor.visitGraph(this);
159 }
160
161 public int getEnd() {
162
163 return 0;
164 }
165
166 public String getName() {
167
168 return null;
169 }
170
171 public int length() {
172 return 0;
173 }
174
175 }