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  // ChrLoc.java
20  // Since: 2009/10/02
21  //
22  // $URL$ 
23  // $Author$
24  //--------------------------------------
25  package org.utgenome.gwt.utgb.client.bio;
26  
27  import java.io.Serializable;
28  
29  public class ChrLoc implements Serializable {
30  	/**
31  	 * 
32  	 */
33  	private static final long serialVersionUID = 1L;
34  
35  	public int start;
36  	public int end;
37  	public String chr;
38  
39  	public ChrLoc() {
40  	}
41  
42  	public ChrLoc(String chr, int start, int end) {
43  		this.chr = chr;
44  		this.start = start;
45  		this.end = end;
46  	}
47  
48  	public ChrLoc getLocForPositiveStrand() {
49  		if (start < end)
50  			return new ChrLoc(chr, start, end);
51  		else
52  			return new ChrLoc(chr, end, start);
53  	}
54  
55  	public int length() {
56  		return viewEnd() - viewStart();
57  	}
58  
59  	public int viewStart() {
60  		if (isSense())
61  			return start;
62  		else
63  			return end;
64  	}
65  
66  	public int viewEnd() {
67  		if (isSense())
68  			return end;
69  		else
70  			return start;
71  	}
72  
73  	public boolean isSense() {
74  		return start <= end;
75  	}
76  
77  	public boolean isAntiSense() {
78  		return !isSense();
79  	}
80  
81  	@Override
82  	public String toString() {
83  		return chr + ":" + start + "-" + end;
84  	}
85  }