add convenience methods for RODs-for-reads: the ability to get all the RODs covering the read, regardless of their type or position on the read.

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@4912 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
aaron 2010-12-29 20:46:03 +00:00
parent d7e74f8be6
commit 85f2968104
2 changed files with 24 additions and 7 deletions

View File

@ -40,14 +40,14 @@ import java.util.*;
* stores both the name and the class for each ROD. This class assumes that:
*
* -Names must be unique
* -Classes are allowed to have dupplicates
* -Classes are allowed to have duplicates
*
* This class encapsulates the ref data associations, and provides lookup by name and by
* class type.
*
*/
public class RODMetaDataContainer {
// we only allow non-dupplicate ROD names, a HashMap is fine
// we only allow non-duplicate ROD names, a HashMap is fine
private final HashMap<String, GATKFeature> nameMap = new HashMap<String, GATKFeature>();
// we do allow duplicate class entries, so we need to store pairs of data
@ -59,11 +59,20 @@ public class RODMetaDataContainer {
}
public Collection<GATKFeature> getSet(String name) {
if (name == null) return nameMap.values();
if (name == null) return getSet();
Set<GATKFeature> set = new HashSet<GATKFeature>();
if (nameMap.containsKey(name)) set.add(nameMap.get(name));
return set;
}
/**
* get the feature contents of this container; the unfiltered set without their name association
* @return
*/
public Collection<GATKFeature> getSet() {
return new ArrayList<GATKFeature>(nameMap.values());
}
// the brute force (n) search ended up being faster than sorting and binary search in all but the most extreme cases (thousands of RODs at a location).
public Collection<GATKFeature> getSet(Class cls) {
Collection<GATKFeature> ret = new ArrayList<GATKFeature>();

View File

@ -29,10 +29,7 @@ import org.broadinstitute.sting.gatk.refdata.utils.GATKFeature;
import org.broadinstitute.sting.utils.GenomeLoc;
import org.broadinstitute.sting.utils.GenomeLocParser;
import java.util.Collection;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.TreeMap;
import java.util.*;
/**
@ -168,4 +165,15 @@ public class ReadMetaDataTracker {
public Map<Integer, Collection<GATKFeature>> getContigOffsetMapping(Class cl) {
return createGenomeLocAlignment(record, mapping, cl, null);
}
/**
* get the list of all the RODS overlapping this read, without any information about their position
* @return a Collection (no order guaranteed), of all the RODs covering this read
*/
public List<GATKFeature> getAllCoveringRods() {
List<GATKFeature> ret = new ArrayList<GATKFeature>();
for (Map.Entry<Integer, RODMetaDataContainer> entry : mapping.entrySet())
ret.addAll(entry.getValue().getSet());
return ret;
}
}