Renamed InferredGeneticContext to CommonInfo
-- I have no idea why I named this InferredGeneticContext, a totally meaningless term -- Renamed to CommonInfo. -- Made package protected, as no one should use this outside of VariantContext and Genotype -- UGEngine was using IGC constant, but it's now using the public one in VariantContext.
This commit is contained in:
parent
077397cb4b
commit
9b5c79b49d
|
|
@ -229,7 +229,7 @@ public class UnifiedGenotyperEngine {
|
|||
VariantContext vcInput = UnifiedGenotyperEngine.getVCFromAllelesRod(tracker, ref, rawContext.getLocation(), false, logger, UAC.alleles);
|
||||
if ( vcInput == null )
|
||||
return null;
|
||||
vc = new VariantContext("UG_call", vcInput.getChr(), vcInput.getStart(), vcInput.getEnd(), vcInput.getAlleles(), InferredGeneticContext.NO_NEG_LOG_10PERROR, null, null, ref.getBase());
|
||||
vc = new VariantContext("UG_call", vcInput.getChr(), vcInput.getStart(), vcInput.getEnd(), vcInput.getAlleles(), VariantContext.NO_NEG_LOG_10PERROR, null, null, ref.getBase());
|
||||
|
||||
} else {
|
||||
// deal with bad/non-standard reference bases
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ import java.util.*;
|
|||
*
|
||||
* @author depristo
|
||||
*/
|
||||
public final class InferredGeneticContext {
|
||||
final class CommonInfo {
|
||||
public static final double NO_NEG_LOG_10PERROR = -1.0;
|
||||
|
||||
private static Set<String> NO_FILTERS = Collections.unmodifiableSet(new HashSet<String>());
|
||||
|
|
@ -22,7 +22,7 @@ public final class InferredGeneticContext {
|
|||
private Set<String> filters = NO_FILTERS;
|
||||
private Map<String, Object> attributes = NO_ATTRIBUTES;
|
||||
|
||||
public InferredGeneticContext(String name, double negLog10PError, Set<String> filters, Map<String, Object> attributes) {
|
||||
public CommonInfo(String name, double negLog10PError, Set<String> filters, Map<String, Object> attributes) {
|
||||
this.name = name;
|
||||
setNegLog10PError(negLog10PError);
|
||||
if ( filters != null && ! filters.isEmpty() )
|
||||
|
|
@ -17,8 +17,8 @@ public class Genotype {
|
|||
public final static String PHASED_ALLELE_SEPARATOR = "|";
|
||||
public final static String UNPHASED_ALLELE_SEPARATOR = "/";
|
||||
|
||||
protected InferredGeneticContext commonInfo;
|
||||
public final static double NO_NEG_LOG_10PERROR = InferredGeneticContext.NO_NEG_LOG_10PERROR;
|
||||
protected CommonInfo commonInfo;
|
||||
public final static double NO_NEG_LOG_10PERROR = CommonInfo.NO_NEG_LOG_10PERROR;
|
||||
protected List<Allele> alleles = null; // new ArrayList<Allele>();
|
||||
protected Type type = null;
|
||||
|
||||
|
|
@ -32,7 +32,7 @@ public class Genotype {
|
|||
public Genotype(String sampleName, List<Allele> alleles, double negLog10PError, Set<String> filters, Map<String, Object> attributes, boolean isPhased, double[] log10Likelihoods) {
|
||||
if ( alleles != null )
|
||||
this.alleles = Collections.unmodifiableList(alleles);
|
||||
commonInfo = new InferredGeneticContext(sampleName, negLog10PError, filters, attributes);
|
||||
commonInfo = new CommonInfo(sampleName, negLog10PError, filters, attributes);
|
||||
if ( log10Likelihoods != null )
|
||||
commonInfo.putAttribute(VCFConstants.PHRED_GENOTYPE_LIKELIHOODS_KEY, GenotypeLikelihoods.fromLog10Likelihoods(log10Likelihoods));
|
||||
filtersWereAppliedToContext = filters != null;
|
||||
|
|
|
|||
|
|
@ -162,8 +162,8 @@ import java.util.*;
|
|||
* @author depristo
|
||||
*/
|
||||
public class VariantContext implements Feature { // to enable tribble intergration
|
||||
protected InferredGeneticContext commonInfo = null;
|
||||
public final static double NO_NEG_LOG_10PERROR = InferredGeneticContext.NO_NEG_LOG_10PERROR;
|
||||
protected CommonInfo commonInfo = null;
|
||||
public final static double NO_NEG_LOG_10PERROR = CommonInfo.NO_NEG_LOG_10PERROR;
|
||||
public final static String UNPARSED_GENOTYPE_MAP_KEY = "_UNPARSED_GENOTYPE_MAP_";
|
||||
public final static String UNPARSED_GENOTYPE_PARSER_KEY = "_UNPARSED_GENOTYPE_PARSER_";
|
||||
public final static String ID_KEY = "ID";
|
||||
|
|
@ -293,7 +293,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
|
|||
* @param alleles alleles
|
||||
*/
|
||||
public VariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles) {
|
||||
this(source, contig, start, stop, alleles, NO_GENOTYPES, InferredGeneticContext.NO_NEG_LOG_10PERROR, null, null, null, false);
|
||||
this(source, contig, start, stop, alleles, NO_GENOTYPES, CommonInfo.NO_NEG_LOG_10PERROR, null, null, null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -307,7 +307,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
|
|||
* @param genotypes genotypes
|
||||
*/
|
||||
public VariantContext(String source, String contig, long start, long stop, Collection<Allele> alleles, Collection<Genotype> genotypes) {
|
||||
this(source, contig, start, stop, alleles, genotypes, InferredGeneticContext.NO_NEG_LOG_10PERROR, null, null);
|
||||
this(source, contig, start, stop, alleles, genotypes, CommonInfo.NO_NEG_LOG_10PERROR, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -350,7 +350,7 @@ public class VariantContext implements Feature { // to enable tribble intergrati
|
|||
attributes.remove(UNPARSED_GENOTYPE_PARSER_KEY);
|
||||
}
|
||||
|
||||
this.commonInfo = new InferredGeneticContext(source, negLog10PError, filters, attributes);
|
||||
this.commonInfo = new CommonInfo(source, negLog10PError, filters, attributes);
|
||||
filtersWereAppliedToContext = filters != null;
|
||||
REFERENCE_BASE_FOR_INDEL = referenceBaseForIndel;
|
||||
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ public class VariantContextUtils {
|
|||
* @return VariantContext object
|
||||
*/
|
||||
public static VariantContext toVC(String name, GenomeLoc loc, Collection<Allele> alleles) {
|
||||
return new VariantContext (name, loc.getContig(), loc.getStart(), loc.getStop(), alleles, VariantContext.NO_GENOTYPES, InferredGeneticContext.NO_NEG_LOG_10PERROR, null, null);
|
||||
return new VariantContext (name, loc.getContig(), loc.getStart(), loc.getStop(), alleles, VariantContext.NO_GENOTYPES, CommonInfo.NO_NEG_LOG_10PERROR, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -93,7 +93,7 @@ public class VariantContextUtils {
|
|||
* @return VariantContext object
|
||||
*/
|
||||
public static VariantContext toVC(String name, GenomeLoc loc, Collection<Allele> alleles, Collection<Genotype> genotypes) {
|
||||
return new VariantContext(name, loc.getContig(), loc.getStart(), loc.getStop(), alleles, genotypes, InferredGeneticContext.NO_NEG_LOG_10PERROR, null, null);
|
||||
return new VariantContext(name, loc.getContig(), loc.getStart(), loc.getStop(), alleles, genotypes, CommonInfo.NO_NEG_LOG_10PERROR, null, null);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -330,7 +330,7 @@ public class VariantContextUtils {
|
|||
return pruneVariantContext(vc, null);
|
||||
}
|
||||
|
||||
private final static Map<String, Object> subsetAttributes(final InferredGeneticContext igc, final Collection<String> keysToPreserve) {
|
||||
private final static Map<String, Object> subsetAttributes(final CommonInfo igc, final Collection<String> keysToPreserve) {
|
||||
Map<String, Object> attributes = new HashMap<String, Object>(keysToPreserve.size());
|
||||
for ( final String key : keysToPreserve ) {
|
||||
if ( igc.hasAttribute(key) )
|
||||
|
|
|
|||
|
|
@ -90,45 +90,45 @@ public class VariantContextUnitTest extends BaseTest {
|
|||
|
||||
// test INDELs
|
||||
alleles = Arrays.asList(Aref, ATC);
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop, alleles, null, InferredGeneticContext.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
Assert.assertEquals(vc.getType(), VariantContext.Type.INDEL);
|
||||
|
||||
alleles = Arrays.asList(ATCref, A);
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop+2, alleles, null, InferredGeneticContext.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop+2, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
Assert.assertEquals(vc.getType(), VariantContext.Type.INDEL);
|
||||
|
||||
alleles = Arrays.asList(Tref, TA, TC);
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop, alleles, null, InferredGeneticContext.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
Assert.assertEquals(vc.getType(), VariantContext.Type.INDEL);
|
||||
|
||||
alleles = Arrays.asList(ATCref, A, AC);
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop+2, alleles, null, InferredGeneticContext.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop+2, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
Assert.assertEquals(vc.getType(), VariantContext.Type.INDEL);
|
||||
|
||||
alleles = Arrays.asList(ATCref, A, Allele.create("ATCTC"));
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop+2, alleles, null, InferredGeneticContext.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop+2, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
Assert.assertEquals(vc.getType(), VariantContext.Type.INDEL);
|
||||
|
||||
// test MIXED
|
||||
alleles = Arrays.asList(TAref, T, TC);
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop+1, alleles, null, InferredGeneticContext.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop+1, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
Assert.assertEquals(vc.getType(), VariantContext.Type.MIXED);
|
||||
|
||||
alleles = Arrays.asList(TAref, T, AC);
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop+1, alleles, null, InferredGeneticContext.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop+1, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
Assert.assertEquals(vc.getType(), VariantContext.Type.MIXED);
|
||||
|
||||
alleles = Arrays.asList(ACref, ATC, AT);
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop+1, alleles, null, InferredGeneticContext.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop+1, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
Assert.assertEquals(vc.getType(), VariantContext.Type.MIXED);
|
||||
|
||||
alleles = Arrays.asList(Aref, T, symbolic);
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop, alleles, null, InferredGeneticContext.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
Assert.assertEquals(vc.getType(), VariantContext.Type.MIXED);
|
||||
|
||||
// test SYMBOLIC
|
||||
alleles = Arrays.asList(Tref, symbolic);
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop, alleles, null, InferredGeneticContext.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
Assert.assertEquals(vc.getType(), VariantContext.Type.SYMBOLIC);
|
||||
}
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ public class VariantContextUnitTest extends BaseTest {
|
|||
@Test
|
||||
public void testCreatingDeletionVariantContext() {
|
||||
List<Allele> alleles = Arrays.asList(ATCref, del);
|
||||
VariantContext vc = new VariantContext("test", delLoc, delLocStart, delLocStop, alleles, null, InferredGeneticContext.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
VariantContext vc = new VariantContext("test", delLoc, delLocStart, delLocStop, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
|
||||
Assert.assertEquals(vc.getChr(), delLoc);
|
||||
Assert.assertEquals(vc.getStart(), delLocStart);
|
||||
|
|
@ -226,7 +226,7 @@ public class VariantContextUnitTest extends BaseTest {
|
|||
@Test
|
||||
public void testCreatingInsertionVariantContext() {
|
||||
List<Allele> alleles = Arrays.asList(delRef, ATC);
|
||||
VariantContext vc = new VariantContext("test", insLoc, insLocStart, insLocStop, alleles, null, InferredGeneticContext.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
VariantContext vc = new VariantContext("test", insLoc, insLocStart, insLocStop, alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
|
||||
Assert.assertEquals(vc.getChr(), insLoc);
|
||||
Assert.assertEquals(vc.getStart(), insLocStart);
|
||||
|
|
@ -514,7 +514,7 @@ public class VariantContextUnitTest extends BaseTest {
|
|||
@Test(dataProvider = "getAlleles")
|
||||
public void testMergeAlleles(GetAllelesTest cfg) {
|
||||
final List<Allele> altAlleles = cfg.alleles.subList(1, cfg.alleles.size());
|
||||
final VariantContext vc = new VariantContext("test", snpLoc, snpLocStart, snpLocStop, cfg.alleles, null, InferredGeneticContext.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
final VariantContext vc = new VariantContext("test", snpLoc, snpLocStart, snpLocStop, cfg.alleles, null, CommonInfo.NO_NEG_LOG_10PERROR, null, null, (byte)'A');
|
||||
|
||||
Assert.assertEquals(vc.getAlleles(), cfg.alleles, "VC alleles not the same as input alleles");
|
||||
Assert.assertEquals(vc.getNAlleles(), cfg.alleles.size(), "VC getNAlleles not the same as input alleles size");
|
||||
|
|
|
|||
Loading…
Reference in New Issue