Generalized deletions in pileup

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1739 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2009-09-29 15:58:43 +00:00
parent 6134f49e3c
commit 8bd345ba00
2 changed files with 19 additions and 9 deletions

View File

@ -15,6 +15,15 @@ import java.util.Random;
* To change this template use File | Settings | File Templates.
*/
abstract public class BasicPileup implements Pileup {
public static final char DELETION_CHAR = 'D';
protected boolean includeDeletions = false;
public void setIncludeDeletionsInPileupString(boolean value) {
includeDeletions = value;
}
public String getPileupString()
{
return String.format("%s: %s %s %s", getLocation(), getRef(), getBases(), getQuals());
@ -29,8 +38,12 @@ abstract public class BasicPileup implements Pileup {
}
public static String basePileupAsString( List<SAMRecord> reads, List<Integer> offsets ) {
return basePileupAsString( reads, offsets, false );
}
public static String basePileupAsString( List<SAMRecord> reads, List<Integer> offsets, boolean includeDeletions ) {
StringBuilder bases = new StringBuilder();
for ( byte base : basePileup(reads, offsets)) {
for ( byte base : basePileup(reads, offsets, includeDeletions)) {
bases.append((char)base);
}
return bases.toString();
@ -50,7 +63,7 @@ abstract public class BasicPileup implements Pileup {
char base;
if ( offset == -1 ) {
if ( includeDeletions )
base = 'D';
base = DELETION_CHAR;
else
continue;
} else {
@ -79,7 +92,7 @@ abstract public class BasicPileup implements Pileup {
int offset = offsets.get(i);
if ( offset == -1 ) {
if ( includeDeletions )
bases.add((byte)'D');
bases.add((byte)DELETION_CHAR);
} else {
bases.add(read.getReadBases()[offset]);
}

View File

@ -17,7 +17,6 @@ public class ReadBackedPileup extends BasicPileup {
char ref;
List<SAMRecord> reads;
List<Integer> offsets;
boolean includeDeletions = false;
public ReadBackedPileup(char ref, AlignmentContext context ) {
this(context.getLocation(), ref, context.getReads(), context.getOffsets());
@ -38,8 +37,6 @@ public class ReadBackedPileup extends BasicPileup {
public List<SAMRecord> getReads() { return reads; }
public List<Integer> getOffsets() { return offsets; }
public void includeDeletionsInPileupString() { includeDeletions = true; }
public GenomeLoc getLocation() {
return loc;
}
@ -49,11 +46,11 @@ public class ReadBackedPileup extends BasicPileup {
}
public String getBases() {
return basePileupAsString(reads, offsets);
return basePileupAsString(reads, offsets, includeDeletions);
}
public String getBasesWithStrand() {
return baseWithStrandPileupAsString(reads, offsets);
return baseWithStrandPileupAsString(reads, offsets, includeDeletions);
}
public String getQuals() {
@ -82,7 +79,7 @@ public class ReadBackedPileup extends BasicPileup {
}
public String getBasePileupAsCountsString() {
String bases = basePileupAsString(reads, offsets);
String bases = basePileupAsString(reads, offsets, includeDeletions);
int[] counts = new int[4];
for (int i = 0; i < reads.size(); i++)