comparison NGSrich_0.5.5/src/datastructures/GenomeFrame.java @ 0:89ad0a9cca52 default tip

Uploaded
author pfrommolt
date Mon, 21 Nov 2011 08:12:19 -0500
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:89ad0a9cca52
1 package datastructures;
2
3 import java.util.Vector;
4
5 /**
6 * @author Ali Abdallah
7 * @version 01.2011
8 * @since jdk 1.6.0
9 */
10
11 public class GenomeFrame extends Frame{
12
13 int limit;
14 Vector<Integer> hits;
15
16 public GenomeFrame(int start, int length) {
17 super(start, length);
18 limit = end;
19 hits = new Vector<Integer>(length);
20 hits.setSize(length);
21 for(int i = 0; i < length; i++){
22 hits.set(i, 0);
23 }
24 }
25
26 public int getHit(int base){
27 if(base-start < hits.size())
28 return hits.get(base-start);
29 else
30 return -1;
31 }
32
33 public void setHit(int base, int bhits){
34 if(base-start < hits.size()){
35 hits.set(base-start, bhits);
36 }
37 }
38
39 public boolean contains(ReadFrame r){
40 return (start <= r.start() && end >= r.end());
41 }
42
43 public boolean overlaps(ReadFrame r){
44 return (end >= r.start() && end < r.end());
45 }
46
47
48
49 public void addBases(int nr){
50 for(int i = 0; i < nr; i++){
51 hits.add(1);
52 }
53 }
54
55 public String toString(){
56 return start+":"+end+" ("+limit+")";
57 }
58
59
60 public void updateHits(ReadFrame read) {
61 for(int base = read.start(); base <= read.end(); base++){
62 setHit(base, getHit(base)+1);
63 }
64 }
65
66 public void updateFrameFromRightEnd(ReadFrame readF) {
67 // TODO Auto-generated method stub
68 for(int i = end+1; i <= readF.end(); i++)
69 hits.add(0);
70 end = readF.end();
71 }
72
73 public boolean limitExceeded(ReadFrame readF) {
74 return readF.start() > limit;
75 }
76
77 public void updateFrameFromBothEnds(ReadFrame readF, int length) {
78 for(int i = end-readF.start()+1; i < length; i++ )
79 hits.add(0);
80 for(int i = 0; i < readF.start()-start; i++)
81 hits.remove(0);
82 start = readF.start();
83 end = start+length-1;
84 limit = end;
85 }
86
87 }