Bug fixes to VariantContext and GenotypeCollection
This commit is contained in:
parent
4ff8225d78
commit
6e1a86bc3e
|
|
@ -74,7 +74,7 @@ public class GenotypeCollection implements List<Genotype> {
|
||||||
// todo -- create constructor (Genotype ... genotypes)
|
// todo -- create constructor (Genotype ... genotypes)
|
||||||
|
|
||||||
public static final GenotypeCollection create(final ArrayList<Genotype> genotypes) {
|
public static final GenotypeCollection create(final ArrayList<Genotype> genotypes) {
|
||||||
return new GenotypeCollection(genotypes, false);
|
return genotypes == null ? NO_GENOTYPES : new GenotypeCollection(genotypes, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final GenotypeCollection create(final Genotype... genotypes) {
|
public static final GenotypeCollection create(final Genotype... genotypes) {
|
||||||
|
|
@ -86,7 +86,7 @@ public class GenotypeCollection implements List<Genotype> {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final GenotypeCollection copy(final Collection<Genotype> toCopy) {
|
public static final GenotypeCollection copy(final Collection<Genotype> toCopy) {
|
||||||
return create(new ArrayList<Genotype>(toCopy));
|
return toCopy == null ? NO_GENOTYPES : create(new ArrayList<Genotype>(toCopy));
|
||||||
}
|
}
|
||||||
|
|
||||||
// public static final GenotypeMap create(final Collection<Genotype> genotypes) {
|
// public static final GenotypeMap create(final Collection<Genotype> genotypes) {
|
||||||
|
|
|
||||||
|
|
@ -360,8 +360,11 @@ public class VariantContext implements Feature { // to enable tribble intergrati
|
||||||
// we need to make this a LinkedHashSet in case the user prefers a given ordering of alleles
|
// we need to make this a LinkedHashSet in case the user prefers a given ordering of alleles
|
||||||
this.alleles = makeAlleles(alleles);
|
this.alleles = makeAlleles(alleles);
|
||||||
|
|
||||||
if ( genotypes == null ) { genotypes = NO_GENOTYPES; }
|
if ( genotypes == null ) {
|
||||||
this.genotypes = genotypes;
|
genotypes = NO_GENOTYPES;
|
||||||
|
} else {
|
||||||
|
this.genotypes = genotypes.immutable();
|
||||||
|
}
|
||||||
|
|
||||||
// cache the REF and ALT alleles
|
// cache the REF and ALT alleles
|
||||||
int nAlleles = alleles.size();
|
int nAlleles = alleles.size();
|
||||||
|
|
|
||||||
|
|
@ -249,16 +249,14 @@ public class VariantContextUtilsUnitTest extends BaseTest {
|
||||||
final List<VariantContext> inputs = new ArrayList<VariantContext>();
|
final List<VariantContext> inputs = new ArrayList<VariantContext>();
|
||||||
|
|
||||||
for ( final String id : cfg.inputs ) {
|
for ( final String id : cfg.inputs ) {
|
||||||
if ( id.equals(".") )
|
inputs.add(VariantContext.modifyID(snpVC1, id));
|
||||||
snpVC1 = VariantContext.modifyID(snpVC1, id);
|
|
||||||
inputs.add(snpVC1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final VariantContext merged = VariantContextUtils.simpleMerge(genomeLocParser,
|
final VariantContext merged = VariantContextUtils.simpleMerge(genomeLocParser,
|
||||||
inputs, null,
|
inputs, null,
|
||||||
VariantContextUtils.FilteredRecordMergeType.KEEP_IF_ANY_UNFILTERED,
|
VariantContextUtils.FilteredRecordMergeType.KEEP_IF_ANY_UNFILTERED,
|
||||||
VariantContextUtils.GenotypeMergeType.UNSORTED, false, false, "set", false, false);
|
VariantContextUtils.GenotypeMergeType.UNSORTED, false, false, "set", false, false);
|
||||||
Assert.assertEquals(merged.getID(), cfg.expected.equals(".") ? null : cfg.expected);
|
Assert.assertEquals(merged.getID(), cfg.expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --------------------------------------------------------------------------------
|
// --------------------------------------------------------------------------------
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue