ugly RG encoding
This commit is contained in:
parent
4409293b5d
commit
486712bfc2
|
|
@ -3,6 +3,7 @@ package org.broadinstitute.sting.gatk.walkers.bqsr;
|
||||||
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
import org.broadinstitute.sting.utils.sam.GATKSAMRecord;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 2009 The Broad Institute
|
* Copyright (c) 2009 The Broad Institute
|
||||||
|
|
@ -39,6 +40,10 @@ import java.util.Arrays;
|
||||||
|
|
||||||
public class ReadGroupCovariate implements RequiredCovariate {
|
public class ReadGroupCovariate implements RequiredCovariate {
|
||||||
|
|
||||||
|
private final HashMap<String, Short> readGroupLookupTable = new HashMap<String, Short>();
|
||||||
|
private final HashMap<Short, String> readGroupReverseLookupTable = new HashMap<Short, String>();
|
||||||
|
private short nextId = 0;
|
||||||
|
|
||||||
// Initialize any member variables using the command-line arguments passed to the walkers
|
// Initialize any member variables using the command-line arguments passed to the walkers
|
||||||
@Override
|
@Override
|
||||||
public void initialize(final RecalibrationArgumentCollection RAC) {
|
public void initialize(final RecalibrationArgumentCollection RAC) {
|
||||||
|
|
@ -48,8 +53,17 @@ public class ReadGroupCovariate implements RequiredCovariate {
|
||||||
public CovariateValues getValues(final GATKSAMRecord read) {
|
public CovariateValues getValues(final GATKSAMRecord read) {
|
||||||
final int l = read.getReadLength();
|
final int l = read.getReadLength();
|
||||||
final String readGroupId = read.getReadGroup().getReadGroupId();
|
final String readGroupId = read.getReadGroup().getReadGroupId();
|
||||||
String [] readGroups = new String[l];
|
short shortId;
|
||||||
Arrays.fill(readGroups, readGroupId);
|
if (readGroupLookupTable.containsKey(readGroupId))
|
||||||
|
shortId = readGroupLookupTable.get(readGroupId);
|
||||||
|
else {
|
||||||
|
shortId = nextId;
|
||||||
|
readGroupLookupTable.put(readGroupId, nextId);
|
||||||
|
readGroupReverseLookupTable.put(nextId, readGroupId);
|
||||||
|
nextId++;
|
||||||
|
}
|
||||||
|
Short [] readGroups = new Short[l];
|
||||||
|
Arrays.fill(readGroups, shortId);
|
||||||
return new CovariateValues(readGroups, readGroups, readGroups);
|
return new CovariateValues(readGroups, readGroups, readGroups);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -58,6 +72,10 @@ public class ReadGroupCovariate implements RequiredCovariate {
|
||||||
public final Object getValue(final String str) {
|
public final Object getValue(final String str) {
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final String decodeReadGroup(final short id) {
|
||||||
|
return readGroupReverseLookupTable.get(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue