Added a copy() method for ReadBackedPileups
necessary to create new alignment contexts with hard-copies of the pileup.
This commit is contained in:
parent
6feda540a4
commit
30f013aeb0
|
|
@ -1054,6 +1054,11 @@ public abstract class AbstractReadBackedPileup<RBP extends AbstractReadBackedPil
|
||||||
public FragmentCollection<PileupElement> toFragments() {
|
public FragmentCollection<PileupElement> toFragments() {
|
||||||
return FragmentUtils.create(this);
|
return FragmentUtils.create(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ReadBackedPileup copy() {
|
||||||
|
return new ReadBackedPileupImpl(loc, (PileupElementTracker<PileupElement>) pileupElementTracker.copy());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -34,11 +34,20 @@ import java.util.*;
|
||||||
*/
|
*/
|
||||||
abstract class PileupElementTracker<PE extends PileupElement> implements Iterable<PE> {
|
abstract class PileupElementTracker<PE extends PileupElement> implements Iterable<PE> {
|
||||||
public abstract int size();
|
public abstract int size();
|
||||||
|
public abstract PileupElementTracker<PE> copy();
|
||||||
}
|
}
|
||||||
|
|
||||||
class UnifiedPileupElementTracker<PE extends PileupElement> extends PileupElementTracker<PE> {
|
class UnifiedPileupElementTracker<PE extends PileupElement> extends PileupElementTracker<PE> {
|
||||||
private final List<PE> pileup;
|
private final List<PE> pileup;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public UnifiedPileupElementTracker<PE> copy() {
|
||||||
|
UnifiedPileupElementTracker<PE> result = new UnifiedPileupElementTracker<PE>();
|
||||||
|
for(PE element : pileup)
|
||||||
|
result.add(element);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
public UnifiedPileupElementTracker() { pileup = new LinkedList<PE>(); }
|
public UnifiedPileupElementTracker() { pileup = new LinkedList<PE>(); }
|
||||||
public UnifiedPileupElementTracker(List<PE> pileup) { this.pileup = pileup; }
|
public UnifiedPileupElementTracker(List<PE> pileup) { this.pileup = pileup; }
|
||||||
|
|
||||||
|
|
@ -65,6 +74,14 @@ class PerSamplePileupElementTracker<PE extends PileupElement> extends PileupElem
|
||||||
pileup = new HashMap<String,PileupElementTracker<PE>>();
|
pileup = new HashMap<String,PileupElementTracker<PE>>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public PerSamplePileupElementTracker<PE> copy() {
|
||||||
|
PerSamplePileupElementTracker<PE> result = new PerSamplePileupElementTracker<PE>();
|
||||||
|
for (Map.Entry<String, PileupElementTracker<PE>> entry : pileup.entrySet())
|
||||||
|
result.addElements(entry.getKey(), entry.getValue());
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets a list of all the samples stored in this pileup.
|
* Gets a list of all the samples stored in this pileup.
|
||||||
* @return List of samples in this pileup.
|
* @return List of samples in this pileup.
|
||||||
|
|
|
||||||
|
|
@ -283,4 +283,12 @@ public interface ReadBackedPileup extends Iterable<PileupElement>, HasGenomeLoca
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public FragmentCollection<PileupElement> toFragments();
|
public FragmentCollection<PileupElement> toFragments();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a full copy (not shallow) of the ReadBacked Pileup
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public ReadBackedPileup copy();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue