All walkers now use read.getReadGroup()

git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1839 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
ebanks 2009-10-14 19:27:40 +00:00
parent 0a09fa4d5c
commit 52d2e0ca07
8 changed files with 15 additions and 37 deletions

View File

@ -25,11 +25,8 @@ public class PlatformUnitFilter implements SamRecordFilter {
Object pu_attr = samRecord.getAttribute("PU");
if ( pu_attr == null ) {
// no platform unit in the record, go get the header if we have at least read group
final String rgId = (String)samRecord.getAttribute("RG");
if (rgId == null) return false; // we do not have read group either, can not filter
SAMReadGroupRecord rgr = samRecord.getHeader().getReadGroup(rgId);
// no platform unit in the record, go get from read group
SAMReadGroupRecord rgr = samRecord.getReadGroup();
pu_attr = rgr.getAttribute("PU") ;
}

View File

@ -97,14 +97,13 @@ public class SplitSamFileWalker extends ReadWalker<SAMRecord, Map<String, SAMFil
* Write out the read
*/
public Map<String, SAMFileWriter> reduce(SAMRecord read, Map<String, SAMFileWriter> outputs) {
final String readGroup = read.getAttribute("RG").toString();
final String sample = read.getHeader().getReadGroup(readGroup).getSample();
final String sample = read.getReadGroup().getSample();
SAMFileWriter output = outputs.get(sample);
if ( output != null ) {
output.addAlignment(read);
} else {
throw new RuntimeException(String.format("Read group %s not present in header but found in read %s", readGroup, read.getReadName()));
throw new RuntimeException(String.format("Read group %s not present in header but found in read %s", read.getReadGroup().getReadGroupId(), read.getReadName()));
}
return outputs;

View File

@ -203,8 +203,7 @@ public abstract class EMGenotypeCalculationModel extends GenotypeCalculationMode
if ( POOLED_INPUT ) {
sample = "POOL";
} else {
String readGroup = read.getAttribute("RG").toString(); // can't be null because those are filtered out
sample = read.getHeader().getReadGroup(readGroup).getSample();
sample = read.getReadGroup().getSample();
}
// create a new context object if this is the first time we're seeing a read for this sample

View File

@ -819,16 +819,7 @@ public class IndelGenotyperWalker extends ReadWalker<Integer,Integer> {
indels.set(pos, indelsAtSite);
}
String sample = null;
Object readGroupAttr = r.getAttribute("RG");
if ( readGroupAttr != null ) {
SAMReadGroupRecord readGroup = r.getHeader().getReadGroup(readGroupAttr.toString());
if ( readGroup != null ) {
Object readSampleAttr = readGroup.getAttribute("SM");
if ( readSampleAttr != null )
sample = readSampleAttr.toString();
}
}
String sample = r.getReadGroup().getSample();
boolean found = false;
for ( IndelVariant v : indelsAtSite ) {

View File

@ -119,17 +119,16 @@ public class CovariateCounterWalker extends LocusWalker<Integer, PrintStream> {
throw new RuntimeException("Expectedly long read, please increase maxium read len with maxReadLen parameter: " + read.format());
}
final String readGroupString = ((String)read.getAttribute("RG"));
SAMReadGroupRecord readGroup = read.getHeader().getReadGroup(readGroupString);
SAMReadGroupRecord readGroup = read.getReadGroup();
if ( readGroupString == null ) {
if ( readGroup == null ) {
throw new RuntimeException("No read group annotation found for read " + read.format());
}
if ((read.getMappingQuality() >= MIN_MAPPING_QUALITY && isSupportedReadGroup(readGroup) )) {
int offset = offsets.get(i);
if ( offset > 0 && offset < (read.getReadLength() - 1) ) { // skip first and last bases because they suck and they don't have a dinuc count
counted_bases += covariateCounter.updateDataFromRead(readGroupString, read, offset, ref.getBase(), useOriginalQuals);
counted_bases += covariateCounter.updateDataFromRead(readGroup.getReadGroupId(), read, offset, ref.getBase(), useOriginalQuals);
}
}
}

View File

@ -95,8 +95,7 @@ public class CoverageBySample extends LocusWalker<String, String>
for (int i = 0; i < context.getReads().size(); i++)
{
SAMRecord read = context.getReads().get(i);
String RG = (String)(read.getAttribute("RG"));
String sample = header.getReadGroup(RG).getSample();
String sample = read.getReadGroup().getSample();
counts.put(sample, counts.get(sample)+1);
}
return counts;
@ -124,12 +123,11 @@ public class CoverageBySample extends LocusWalker<String, String>
{
SAMRecord read = context.getReads().get(i);
Integer offset = context.getOffsets().get(i);
String RG = (String)(read.getAttribute("RG"));
assert(header != null);
assert(header.getReadGroup(RG) != null);
assert(read.getReadGroup() != null);
String sample = header.getReadGroup(RG).getSample();
String sample = read.getReadGroup().getSample();
//if (SAMPLE_NAME_REGEX != null) { sample = sample.replaceAll(SAMPLE_NAME_REGEX, "$1"); }
reads[index.get(sample)].add(read);
offsets[index.get(sample)].add(offset);

View File

@ -35,9 +35,7 @@ public class ListSampleIds extends LocusWalker<Boolean, Boolean>
for ( int i = 0; i < reads.size(); i++ )
{
SAMRecord read = reads.get(i);
String rg = (String) read.getAttribute("RG");
SAMFileHeader header = read.getHeader();
SAMReadGroupRecord readGroup = header.getReadGroup(rg);
SAMReadGroupRecord readGroup = read.getReadGroup();
if (readGroup == null) { System.out.printf("."); return false; }
String sample = readGroup.getSample();
System.out.printf("FROM_MAP %s\n", sample);

View File

@ -203,14 +203,11 @@ public class Utils {
}
public static boolean is454Read(SAMRecord read) {
Object readGroupAttr = read.getAttribute("RG");
if ( readGroupAttr != null ) {
SAMReadGroupRecord readGroup = read.getHeader().getReadGroup(readGroupAttr.toString());
if ( readGroup != null ) {
SAMReadGroupRecord readGroup = read.getReadGroup();
if ( readGroup != null ) {
Object readPlatformAttr = readGroup.getAttribute("PL");
if ( readPlatformAttr != null )
return readPlatformAttr.toString().toUpperCase().contains("454");
}
}
return false;
}