View Javadoc

1   /*--------------------------------------------------------------------------
2    *  Copyright 2009 utgenome.org
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *--------------------------------------------------------------------------*/
16  //--------------------------------------
17  // utgb-core Project
18  //
19  // CompactWIGData.java
20  // Since: 2010/05/29
21  //
22  // $URL$ 
23  // $Author$
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 		// TODO Auto-generated method stub
163 		return 0;
164 	}
165 
166 	public String getName() {
167 		// TODO Auto-generated method stub
168 		return null;
169 	}
170 
171 	public int length() {
172 		return 0;
173 	}
174 
175 }