-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathRead.java
More file actions
48 lines (41 loc) · 1.26 KB
/
Read.java
File metadata and controls
48 lines (41 loc) · 1.26 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
package org.seqcode.deepseq;
import java.util.ArrayList;
import java.util.List;
/**
* Read represents the sequence tag which is generated by a short read sequencer. <br>
* Each <tt>Read</tt> can map to different locations (<tt>ReadHits</tt>) on
* the genome (if non-unique hits are supported)
*
* Read and ReadHit are only used as a convenient way to represent multiply mapping reads when reading from certain file formats.
* @author mahony
*
*/
public class Read {
protected List<ReadHit> hits = new ArrayList<ReadHit>();
protected float numHits=0; //have to store this separately because we can't always trust the size of the hits list
public Read(){
}
//Accessor
public double getNumHits(){return (double)hits.size();}
public void setNumHits(float n){
numHits=n;
float w = 1/numHits;
for(ReadHit x : hits){
x.setWeight(w);
}
}
public void addHit(ReadHit h){addHit(h, true);}
public void addHit(ReadHit h, boolean updateWeight){
//First add the hit
hits.add(h);
numHits++;
if(updateWeight){
//Now propagate the effect of adding the hit to the read weights
float w = 1/numHits;
for(ReadHit x : hits){
x.setWeight(w);
}
}
}
public List<ReadHit> getHits(){return hits;}
}