better method names for read based reference ordered data access.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3069 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
49117819f5
commit
5079f35e40
|
|
@ -47,8 +47,8 @@ public class ReadMetaDataTracker {
|
|||
/**
|
||||
* create a read meta data tracker, given the read and a queue of RODatum positions
|
||||
*
|
||||
* @param record the read to create offset from
|
||||
* @param mapping the mapping of reference ordered datum
|
||||
* @param record the read to create offset from
|
||||
* @param mapping the mapping of reference ordered datum
|
||||
*/
|
||||
public ReadMetaDataTracker(SAMRecord record, TreeMap<Long, RODMetaDataContainer> mapping) {
|
||||
this.record = record;
|
||||
|
|
@ -59,10 +59,10 @@ public class ReadMetaDataTracker {
|
|||
* create an alignment of read position to reference ordered datum
|
||||
*
|
||||
* @param record the SAMRecord
|
||||
* @param queue the queue (as a tree set)
|
||||
* @param cl the class name, null if not filtered by classname
|
||||
* @param name the datum track name, null if not filtered by name
|
||||
*
|
||||
* @param queue the queue (as a tree set)
|
||||
* @param cl the class name, null if not filtered by classname
|
||||
* @param name the datum track name, null if not filtered by name
|
||||
*
|
||||
* @return a mapping from the position in the read to the reference ordered datum
|
||||
*/
|
||||
private Map<Long, Collection<ReferenceOrderedDatum>> createReadAlignment(SAMRecord record, TreeMap<Long, RODMetaDataContainer> queue, Class cl, String name) {
|
||||
|
|
@ -79,11 +79,11 @@ public class ReadMetaDataTracker {
|
|||
else
|
||||
set = queue.get(loc).getSet(name);
|
||||
if (set != null && set.size() > 0)
|
||||
ret.put(position,set);
|
||||
ret.put(position, set);
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -98,9 +98,9 @@ public class ReadMetaDataTracker {
|
|||
for (Long location : mapping.keySet()) {
|
||||
if (location >= start && location <= stop)
|
||||
if (cl != null)
|
||||
ret.put(location,mapping.get(location).getSet(cl));
|
||||
else
|
||||
ret.put(location,mapping.get(location).getSet(name));
|
||||
ret.put(location, mapping.get(location).getSet(cl));
|
||||
else
|
||||
ret.put(location, mapping.get(location).getSet(name));
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
|
@ -110,7 +110,7 @@ public class ReadMetaDataTracker {
|
|||
*
|
||||
* @return a mapping of read offset to ROD(s)
|
||||
*/
|
||||
public Map<Long, Collection<ReferenceOrderedDatum>> getPositionMapping() {
|
||||
public Map<Long, Collection<ReferenceOrderedDatum>> getReadOffsetMapping() {
|
||||
return createReadAlignment(record, mapping, null, null);
|
||||
}
|
||||
|
||||
|
|
@ -119,7 +119,7 @@ public class ReadMetaDataTracker {
|
|||
*
|
||||
* @return a mapping of genome loc position to ROD(s)
|
||||
*/
|
||||
public Map<Long, Collection<ReferenceOrderedDatum>> getGenomeLocMapping() {
|
||||
public Map<Long, Collection<ReferenceOrderedDatum>> getContigOffsetMapping() {
|
||||
return createGenomeLocAlignment(record, mapping, null, null);
|
||||
}
|
||||
|
||||
|
|
@ -128,7 +128,7 @@ public class ReadMetaDataTracker {
|
|||
*
|
||||
* @return a mapping of read offset to ROD(s)
|
||||
*/
|
||||
public Map<Long, Collection<ReferenceOrderedDatum>> getPositionMapping(String name) {
|
||||
public Map<Long, Collection<ReferenceOrderedDatum>> getReadOffsetMapping(String name) {
|
||||
return createReadAlignment(record, mapping, null, name);
|
||||
}
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ public class ReadMetaDataTracker {
|
|||
*
|
||||
* @return a mapping of genome loc position to ROD(s)
|
||||
*/
|
||||
public Map<Long, Collection<ReferenceOrderedDatum>> getGenomeLocMapping(String name) {
|
||||
public Map<Long, Collection<ReferenceOrderedDatum>> getContigOffsetMapping(String name) {
|
||||
return createGenomeLocAlignment(record, mapping, null, name);
|
||||
}
|
||||
|
||||
|
|
@ -146,7 +146,7 @@ public class ReadMetaDataTracker {
|
|||
*
|
||||
* @return a mapping of read offset to ROD(s)
|
||||
*/
|
||||
public Map<Long, Collection<ReferenceOrderedDatum>> getPositionMapping(Class cl) {
|
||||
public Map<Long, Collection<ReferenceOrderedDatum>> getReadOffsetMapping(Class cl) {
|
||||
return createReadAlignment(record, mapping, cl, null);
|
||||
}
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ public class ReadMetaDataTracker {
|
|||
*
|
||||
* @return a mapping of genome loc position to ROD(s)
|
||||
*/
|
||||
public Map<Long, Collection<ReferenceOrderedDatum>> getGenomeLocMapping(Class cl) {
|
||||
public Map<Long, Collection<ReferenceOrderedDatum>> getContigOffsetMapping(Class cl) {
|
||||
return createGenomeLocAlignment(record, mapping, cl, null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -43,12 +43,11 @@ import java.util.*;
|
|||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author aaron
|
||||
*
|
||||
* Class ReadBasedReferenceOrderedViewTest
|
||||
*
|
||||
* test out the ReadBasedReferenceOrderedView class
|
||||
* @author aaron
|
||||
* <p/>
|
||||
* Class ReadBasedReferenceOrderedViewTest
|
||||
* <p/>
|
||||
* test out the ReadBasedReferenceOrderedView class
|
||||
*/
|
||||
public class ReadBasedReferenceOrderedViewTest extends BaseTest {
|
||||
|
||||
|
|
@ -73,20 +72,20 @@ public class ReadBasedReferenceOrderedViewTest extends BaseTest {
|
|||
// make ten reads,
|
||||
List<SAMRecord> records = new ArrayList<SAMRecord>();
|
||||
for (int x = 1; x < 11; x++) {
|
||||
SAMRecord rec = ArtificialSAMUtils.createArtificialRead(header, "name", 0, x, 10);
|
||||
SAMRecord rec = ArtificialSAMUtils.createArtificialRead(header, "name", 0, x, 10);
|
||||
}
|
||||
GenomeLoc start = GenomeLocParser.createGenomeLoc(0,0,0);
|
||||
GenomeLoc start = GenomeLocParser.createGenomeLoc(0, 0, 0);
|
||||
List<RMDDataState> list = new ArrayList<RMDDataState>();
|
||||
list.add(new RMDDataState(null, new FakePeekingRODIterator(start,"fakeName")));
|
||||
list.add(new RMDDataState(null, new FakePeekingRODIterator(start, "fakeName")));
|
||||
ReadBasedReferenceOrderedView view = new ReadBasedReferenceOrderedView(new WindowedData(list));
|
||||
|
||||
for (SAMRecord rec : records) {
|
||||
ReadMetaDataTracker tracker = view.getReferenceOrderedDataForRead(rec);
|
||||
Map<Long, Collection<ReferenceOrderedDatum>> map = tracker.getPositionMapping();
|
||||
Map<Long, Collection<ReferenceOrderedDatum>> map = tracker.getReadOffsetMapping();
|
||||
for (Long i : map.keySet()) {
|
||||
Assert.assertEquals(1,map.get(i).size());
|
||||
Assert.assertEquals(1, map.get(i).size());
|
||||
}
|
||||
Assert.assertEquals(10,map.keySet().size());
|
||||
Assert.assertEquals(10, map.keySet().size());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -100,9 +99,11 @@ class FakePeekingRODIterator implements LocationAwareSeekableRODIterator {
|
|||
private GenomeLoc location;
|
||||
private ReadMetaDataTrackerTest.FakeRODatum curROD;
|
||||
private final String name;
|
||||
|
||||
public FakePeekingRODIterator(GenomeLoc startingLoc, String name) {
|
||||
this.name = name;
|
||||
this.location = GenomeLocParser.createGenomeLoc(startingLoc.getContigIndex(),startingLoc.getStart()+1,startingLoc.getStop()+1);;
|
||||
this.location = GenomeLocParser.createGenomeLoc(startingLoc.getContigIndex(), startingLoc.getStart() + 1, startingLoc.getStop() + 1);
|
||||
;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -131,8 +132,8 @@ class FakePeekingRODIterator implements LocationAwareSeekableRODIterator {
|
|||
@Override
|
||||
public RODRecordList next() {
|
||||
System.err.println("Next -> " + location);
|
||||
curROD = new ReadMetaDataTrackerTest.FakeRODatum(location,name);
|
||||
location = GenomeLocParser.createGenomeLoc(location.getContigIndex(),location.getStart()+1,location.getStop()+1);
|
||||
curROD = new ReadMetaDataTrackerTest.FakeRODatum(location, name);
|
||||
location = GenomeLocParser.createGenomeLoc(location.getContigIndex(), location.getStart() + 1, location.getStop() + 1);
|
||||
FakeRODRecordList list = new FakeRODRecordList();
|
||||
list.add(curROD);
|
||||
return list;
|
||||
|
|
|
|||
|
|
@ -75,9 +75,9 @@ public class ReadMetaDataTrackerTest extends BaseTest {
|
|||
|
||||
// count the positions
|
||||
int count = 0;
|
||||
for (Long x : tracker.getPositionMapping().keySet()) {
|
||||
for (Long x : tracker.getReadOffsetMapping().keySet()) {
|
||||
count++;
|
||||
Assert.assertEquals(2, tracker.getPositionMapping().get(x).size());
|
||||
Assert.assertEquals(2, tracker.getReadOffsetMapping().get(x).size());
|
||||
}
|
||||
Assert.assertEquals(10, count);
|
||||
}
|
||||
|
|
@ -89,9 +89,9 @@ public class ReadMetaDataTrackerTest extends BaseTest {
|
|||
|
||||
// count the positions
|
||||
int count = 0;
|
||||
for (Long x : tracker.getPositionMapping().keySet()) {
|
||||
for (Long x : tracker.getReadOffsetMapping().keySet()) {
|
||||
count++;
|
||||
Assert.assertEquals(1, tracker.getPositionMapping().get(x).size());
|
||||
Assert.assertEquals(1, tracker.getReadOffsetMapping().get(x).size());
|
||||
}
|
||||
Assert.assertEquals(10, count);
|
||||
}
|
||||
|
|
@ -103,7 +103,7 @@ public class ReadMetaDataTrackerTest extends BaseTest {
|
|||
|
||||
// count the positions
|
||||
int count = 0;
|
||||
Map<Long, Collection<ReferenceOrderedDatum>> map = tracker.getPositionMapping("default");
|
||||
Map<Long, Collection<ReferenceOrderedDatum>> map = tracker.getReadOffsetMapping("default");
|
||||
for (Long x : map.keySet()) {
|
||||
count++;
|
||||
Assert.assertEquals(1, map.get(x).size());
|
||||
|
|
@ -117,7 +117,7 @@ public class ReadMetaDataTrackerTest extends BaseTest {
|
|||
ReadMetaDataTracker tracker = getRMDT(1, nameSet, false); // create both RODs of the same type
|
||||
// count the positions
|
||||
int count = 0;
|
||||
Map<Long, Collection<ReferenceOrderedDatum>> map = tracker.getPositionMapping(FakeRODatum.class);
|
||||
Map<Long, Collection<ReferenceOrderedDatum>> map = tracker.getReadOffsetMapping(FakeRODatum.class);
|
||||
for (Long x : map.keySet()) {
|
||||
count++;
|
||||
Assert.assertEquals(2, map.get(x).size());
|
||||
|
|
@ -126,6 +126,7 @@ public class ReadMetaDataTrackerTest extends BaseTest {
|
|||
}
|
||||
|
||||
// @Test this test can be uncommented to determine the speed impacts of any changes to the RODs for reads system
|
||||
|
||||
public void filterByMassiveDupType() {
|
||||
|
||||
for (int y = 0; y < 20; y++) {
|
||||
|
|
@ -135,7 +136,7 @@ public class ReadMetaDataTrackerTest extends BaseTest {
|
|||
ReadMetaDataTracker tracker = getRMDT(1, nameSet, false); // create both RODs of the same type
|
||||
// count the positions
|
||||
int count = 0;
|
||||
Map<Long, Collection<ReferenceOrderedDatum>> map = tracker.getPositionMapping(FakeRODatum.class);
|
||||
Map<Long, Collection<ReferenceOrderedDatum>> map = tracker.getReadOffsetMapping(FakeRODatum.class);
|
||||
for (Long x : map.keySet()) {
|
||||
count++;
|
||||
Assert.assertEquals(y + 2, map.get(x).size());
|
||||
|
|
@ -154,7 +155,7 @@ public class ReadMetaDataTrackerTest extends BaseTest {
|
|||
|
||||
// count the positions
|
||||
int count = 0;
|
||||
Map<Long, Collection<ReferenceOrderedDatum>> map = tracker.getPositionMapping(Fake2RODatum.class);
|
||||
Map<Long, Collection<ReferenceOrderedDatum>> map = tracker.getReadOffsetMapping(Fake2RODatum.class);
|
||||
for (long x : map.keySet()) {
|
||||
count++;
|
||||
Assert.assertEquals(1, map.get(x).size());
|
||||
|
|
@ -168,9 +169,9 @@ public class ReadMetaDataTrackerTest extends BaseTest {
|
|||
|
||||
// count the positions
|
||||
int count = 0;
|
||||
for (Long x : tracker.getPositionMapping().keySet()) {
|
||||
for (Long x : tracker.getReadOffsetMapping().keySet()) {
|
||||
count++;
|
||||
Assert.assertEquals(1, tracker.getPositionMapping().get(x).size());
|
||||
Assert.assertEquals(1, tracker.getReadOffsetMapping().get(x).size());
|
||||
}
|
||||
Assert.assertEquals(2, count);
|
||||
}
|
||||
|
|
@ -181,9 +182,9 @@ public class ReadMetaDataTrackerTest extends BaseTest {
|
|||
|
||||
// count the positions
|
||||
int count = 0;
|
||||
for (Long x : tracker.getGenomeLocMapping().keySet()) {
|
||||
for (Long x : tracker.getContigOffsetMapping().keySet()) {
|
||||
count++;
|
||||
Assert.assertEquals(1, tracker.getGenomeLocMapping().get(x).size());
|
||||
Assert.assertEquals(1, tracker.getContigOffsetMapping().get(x).size());
|
||||
}
|
||||
Assert.assertEquals(10, count);
|
||||
}
|
||||
|
|
@ -219,9 +220,7 @@ public class ReadMetaDataTrackerTest extends BaseTest {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* for testing, we want a fake rod with a different classname, for the get-by-class-name functions
|
||||
*/
|
||||
/** for testing, we want a fake rod with a different classname, for the get-by-class-name functions */
|
||||
static public class Fake2RODatum extends FakeRODatum {
|
||||
|
||||
public Fake2RODatum(GenomeLoc location, String name) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue