GenotypeMap -> GenotypeCollection part 3
-- Test code actually builds
This commit is contained in:
parent
f0234ab67f
commit
4ff8225d78
|
|
@ -117,7 +117,7 @@ public class TestVariantContextWalker extends RodWalker<Integer, Integer> {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static VCFHeader createVCFHeader(VariantContext vc) {
|
private static VCFHeader createVCFHeader(VariantContext vc) {
|
||||||
return new VCFHeader(new HashSet<VCFHeaderLine>(), vc.getGenotypes().getSampleNamesSorted());
|
return new VCFHeader(new HashSet<VCFHeaderLine>(), vc.getGenotypes().getSampleNamesOrderedByName());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer reduceInit() {
|
public Integer reduceInit() {
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ public class VariantContextBenchmark extends SimpleBenchmark {
|
||||||
@Param({"READ", "READ_SUBSET"})
|
@Param({"READ", "READ_SUBSET"})
|
||||||
Operation operation; // set automatically by framework
|
Operation operation; // set automatically by framework
|
||||||
|
|
||||||
@Param({"OF_GENOTYPES", "OF_SAMPLES"})
|
@Param({"OF_SAMPLES"})
|
||||||
SubContextOp subContextOp; // set automatically by framework
|
SubContextOp subContextOp; // set automatically by framework
|
||||||
|
|
||||||
private String INPUT_STRING;
|
private String INPUT_STRING;
|
||||||
|
|
@ -60,7 +60,6 @@ public class VariantContextBenchmark extends SimpleBenchmark {
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum SubContextOp {
|
public enum SubContextOp {
|
||||||
OF_GENOTYPES,
|
|
||||||
OF_SAMPLES
|
OF_SAMPLES
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -91,7 +90,7 @@ public class VariantContextBenchmark extends SimpleBenchmark {
|
||||||
codec.readHeader(lineReader);
|
codec.readHeader(lineReader);
|
||||||
|
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
List<String> samples = null;
|
Set<String> samples = null;
|
||||||
while (counter++ < linesToRead ) {
|
while (counter++ < linesToRead ) {
|
||||||
String line = lineReader.readLine();
|
String line = lineReader.readLine();
|
||||||
if ( line == null )
|
if ( line == null )
|
||||||
|
|
@ -99,7 +98,7 @@ public class VariantContextBenchmark extends SimpleBenchmark {
|
||||||
|
|
||||||
VariantContext vc = (VariantContext)codec.decode(line);
|
VariantContext vc = (VariantContext)codec.decode(line);
|
||||||
if ( samples == null ) {
|
if ( samples == null ) {
|
||||||
samples = new ArrayList<String>(vc.getSampleNames()).subList(0, nSamplesToTake);
|
samples = new HashSet<String>(new ArrayList<String>(vc.getSampleNames()).subList(0, nSamplesToTake));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( op == Operation.READ_SUBSET)
|
if ( op == Operation.READ_SUBSET)
|
||||||
|
|
@ -119,13 +118,10 @@ public class VariantContextBenchmark extends SimpleBenchmark {
|
||||||
CaliperMain.main(VariantContextBenchmark.class, args);
|
CaliperMain.main(VariantContextBenchmark.class, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final void processOneVC(VariantContext vc, List<String> samples, SubContextOp subop) {
|
private static final void processOneVC(VariantContext vc, Set<String> samples, SubContextOp subop) {
|
||||||
VariantContext sub;
|
VariantContext sub;
|
||||||
|
|
||||||
switch ( subop ) {
|
switch ( subop ) {
|
||||||
case OF_GENOTYPES:
|
|
||||||
sub = vc.subContextFromGenotypes(vc.getGenotypes(samples).values(), vc.getAlleles());
|
|
||||||
break;
|
|
||||||
case OF_SAMPLES:
|
case OF_SAMPLES:
|
||||||
sub = vc.subContextFromSamples(samples, vc.getAlleles());
|
sub = vc.subContextFromSamples(samples, vc.getAlleles());
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -431,12 +431,12 @@ public class VariantContextUnitTest extends BaseTest {
|
||||||
Genotype g5 = new Genotype("--", Arrays.asList(del, del), 10);
|
Genotype g5 = new Genotype("--", Arrays.asList(del, del), 10);
|
||||||
VariantContext vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop , alleles, Arrays.asList(g1,g2,g3,g4,g5));
|
VariantContext vc = new VariantContext("test", snpLoc,snpLocStart, snpLocStop , alleles, Arrays.asList(g1,g2,g3,g4,g5));
|
||||||
|
|
||||||
VariantContext vc12 = vc.subContextFromGenotypes(Arrays.asList(g1,g2));
|
VariantContext vc12 = vc.subContextFromSamples(new HashSet<String>(Arrays.asList(g1.getSampleName(),g2.getSampleName())));
|
||||||
VariantContext vc1 = vc.subContextFromGenotypes(Arrays.asList(g1));
|
VariantContext vc1 = vc.subContextFromSamples(new HashSet<String>(Arrays.asList(g1.getSampleName())));
|
||||||
VariantContext vc23 = vc.subContextFromGenotypes(Arrays.asList(g2, g3));
|
VariantContext vc23 = vc.subContextFromSamples(new HashSet<String>(Arrays.asList(g2.getSampleName(), g3.getSampleName())));
|
||||||
VariantContext vc4 = vc.subContextFromGenotypes(Arrays.asList(g4));
|
VariantContext vc4 = vc.subContextFromSamples(new HashSet<String>(Arrays.asList(g4.getSampleName())));
|
||||||
VariantContext vc14 = vc.subContextFromGenotypes(Arrays.asList(g1, g4));
|
VariantContext vc14 = vc.subContextFromSamples(new HashSet<String>(Arrays.asList(g1.getSampleName(), g4.getSampleName())));
|
||||||
VariantContext vc5 = vc.subContextFromGenotypes(Arrays.asList(g5));
|
VariantContext vc5 = vc.subContextFromSamples(new HashSet<String>(Arrays.asList(g5.getSampleName())));
|
||||||
|
|
||||||
Assert.assertTrue(vc12.isPolymorphic());
|
Assert.assertTrue(vc12.isPolymorphic());
|
||||||
Assert.assertTrue(vc23.isPolymorphic());
|
Assert.assertTrue(vc23.isPolymorphic());
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue