/*
Copyright Hiroki Ueda

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package jp.ac.utokyo.rcast.karkinos.readssummary;

public class Interval implements java.io.Serializable{
	
	
	public String getGeneSymbol() {
		return geneSymbol;
	}

	public Interval(String chr,int pos,int depth){
		this.chr = chr;
		this.start = pos;
		this.end = pos;
		this.depth = depth;
	}
	
	public Interval(String chr,int start,int end,String refseqid,String geneSymbol){
		this.chr = chr;
		this.start = start;
		this.end = end;
		this.refseqid = refseqid;
		this.geneSymbol = geneSymbol;
	}
	
	String refseqid = null;
	public int getExonidx() {
		return exonidx;
	}

	String geneSymbol= null;
	int exonidx = 0;
	
	public String getRefseqid() {
		return refseqid;
	}

	public void setRefseqid(String refseqid) {
		this.refseqid = refseqid;
	}

	public boolean extendInterval(String chr,int pos,int depth){
		
		if(!chr.equals(this.chr)){
			return false;
		}
		if(pos-this.end>1){
			return false;
		}
		if(this.depth!=depth){
			return false;
		}
		////
		this.end = pos;
		return true;		
	}
	
	public String getChr() {
		return chr;
	}

	public int getStart() {
		return start;
	}

	public int getEnd() {
		return end;
	}

	public int getDepth() {
		return depth;
	}

	String chr;
	int start;
	int end;
	int depth;
	public boolean contain(String chr2, int pos) {
		
		boolean bool = chr.equals(chr2)&& (pos>=start && pos<=end);
		return bool;
	}
	
	
}

@@ -1323,32 +1323,38 @@
  extendInterval(
+final 
 String chr,int p
@@ -1344,32 +1344,46 @@
  String chr,
-int pos,
+ final int end, final 
 int depth)%7B%0A
@@ -1384,19 +1384,23 @@
 pth)
+ 
 %7B%0A
-%09%09%0A
 %09%09if
+ 
 (!
+this.
 chr.
@@ -1410,18 +1410,14 @@
 als(
-this.
 chr))
+ 
 %7B%0A%09%09
@@ -1443,21 +1443,25 @@
 %09%09if
-(pos-
+ (end %3C= 
 this.end
 %3E1)%7B
@@ -1460,11 +1460,10 @@
 .end
-%3E1
 )
+ 
 %7B%0A%09%09
@@ -1485,16 +1485,17 @@
 %09%09%7D%0A%09%09if
+ 
 (this.de
@@ -1501,16 +1501,19 @@
 epth
+ 
 !=
+ 
 depth)
+ 
 %7B%0A%09%09
@@ -1535,15 +1535,8 @@
 %09%09%7D%0A
-%09%09////%0A
 %09%09th
@@ -1540,27 +1540,27 @@
 %09this.end = 
-pos
+end
 ;%0A%09%09return t
@@ -1567,15 +1567,12 @@
 rue;
-%09%09
 %0A%09%7D%0A
-%09
 %0A%09pu

Fix updating the end point to extend interval