From 5079f35e40de480cd593b7e8fb673ac2f5c0dd31 Mon Sep 17 00:00:00 2001 From: aaron Date: Wed, 24 Mar 2010 16:13:31 +0000 Subject: [PATCH] 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 --- .../gatk/refdata/ReadMetaDataTracker.java | 34 +++++++++---------- .../ReadBasedReferenceOrderedViewTest.java | 31 +++++++++-------- .../gatk/refdata/ReadMetaDataTrackerTest.java | 29 ++++++++-------- 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/java/src/org/broadinstitute/sting/gatk/refdata/ReadMetaDataTracker.java b/java/src/org/broadinstitute/sting/gatk/refdata/ReadMetaDataTracker.java index 103abc0a4..4019e96d3 100644 --- a/java/src/org/broadinstitute/sting/gatk/refdata/ReadMetaDataTracker.java +++ b/java/src/org/broadinstitute/sting/gatk/refdata/ReadMetaDataTracker.java @@ -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 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> createReadAlignment(SAMRecord record, TreeMap 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> getPositionMapping() { + public Map> 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> getGenomeLocMapping() { + public Map> 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> getPositionMapping(String name) { + public Map> 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> getGenomeLocMapping(String name) { + public Map> 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> getPositionMapping(Class cl) { + public Map> 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> getGenomeLocMapping(Class cl) { + public Map> getContigOffsetMapping(Class cl) { return createGenomeLocAlignment(record, mapping, cl, null); } } diff --git a/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReadBasedReferenceOrderedViewTest.java b/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReadBasedReferenceOrderedViewTest.java index 7f05ccd59..62c40c178 100644 --- a/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReadBasedReferenceOrderedViewTest.java +++ b/java/test/org/broadinstitute/sting/gatk/datasources/providers/ReadBasedReferenceOrderedViewTest.java @@ -43,12 +43,11 @@ import java.util.*; /** - * - * @author aaron - * - * Class ReadBasedReferenceOrderedViewTest - * - * test out the ReadBasedReferenceOrderedView class + * @author aaron + *

+ * Class ReadBasedReferenceOrderedViewTest + *

+ * test out the ReadBasedReferenceOrderedView class */ public class ReadBasedReferenceOrderedViewTest extends BaseTest { @@ -73,20 +72,20 @@ public class ReadBasedReferenceOrderedViewTest extends BaseTest { // make ten reads, List records = new ArrayList(); 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 list = new ArrayList(); - 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> map = tracker.getPositionMapping(); + Map> 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; diff --git a/java/test/org/broadinstitute/sting/gatk/refdata/ReadMetaDataTrackerTest.java b/java/test/org/broadinstitute/sting/gatk/refdata/ReadMetaDataTrackerTest.java index 1d4093777..117d33f59 100644 --- a/java/test/org/broadinstitute/sting/gatk/refdata/ReadMetaDataTrackerTest.java +++ b/java/test/org/broadinstitute/sting/gatk/refdata/ReadMetaDataTrackerTest.java @@ -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> map = tracker.getPositionMapping("default"); + Map> 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> map = tracker.getPositionMapping(FakeRODatum.class); + Map> 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> map = tracker.getPositionMapping(FakeRODatum.class); + Map> 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> map = tracker.getPositionMapping(Fake2RODatum.class); + Map> 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) {