-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathStrandedBaseCount.java
More file actions
73 lines (61 loc) · 2.17 KB
/
StrandedBaseCount.java
File metadata and controls
73 lines (61 loc) · 2.17 KB
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
package org.seqcode.deepseq;
import org.seqcode.genome.Genome;
import org.seqcode.genome.location.ScoredStrandedPoint;
import org.seqcode.genome.location.ScoredStrandedRegion;
/**
* StrandedBaseCount represents the sum of hit weights at a stranded base position in the genome.
* The same class was called StrandedBase previously (renaming to reduce confusion)
* Coordinate is the 5' end of the read.
* We do not store chromomosome info here because this class is always used
* in the context of a chromosome or a region, no need to differentiate.
* It records the number of reads mapped to this base position.
*
* @author yguo
*
*/
public class StrandedBaseCount implements Comparable<StrandedBaseCount>{
private char strand;
private int coordinate;
private float count;
public StrandedBaseCount(char strand, int coord, float count){
this.setStrand(strand);
this.setCoordinate(coord);
this.setCount(count);
}
public void setStrand(char strand) {
this.strand = strand;
}
public char getStrand() {
return strand;
}
public void setCoordinate(int coordinate) {
this.coordinate = coordinate;
}
public int getCoordinate() {
return coordinate;
}
public void setCount(float count) {
this.count = count;
}
public float getCount() {
return count;
}
// sort according to coordinate, considering strand
public int compareTo(StrandedBaseCount b) {
double diff = coordinate-b.coordinate;
return diff==0?
(strand==b.strand?0:strand=='+'?1:-1): // same coord, compare strand
(diff<0?-1:1); // diff coord
}
public String toString(){
return coordinate+" "+strand+" "+count;
}
//Makes this into a regular Region-derived object
public ScoredStrandedPoint toScoredStrandedPoint(Genome g, String chr){
return new ScoredStrandedPoint(g, chr, coordinate, count, strand);
}
//Makes the pseudo extended read into a regular Region-derived object
public ScoredStrandedRegion expandToScoredStrandedRegion(Genome g, String chr, int upstreamext, int downstreamext){
return (new ScoredStrandedPoint(g, chr, coordinate, count, strand).expand(upstreamext, downstreamext));
}
}