@Test (expectedExceptions = Throwable.class) public void testBadPError() { new VariantContextBuilder("test", insLoc, insLocStart, insLocStop, Arrays.asList(delRef, ATCref)).log10PError(0.5).make(); }
.stop(end) .log10PError(qual) .filters(filters);
public enum GenotypeAssignmentMethod { /** * set all of the genotype GT values to NO_CALL */ SET_TO_NO_CALL, /** * set all of the genotype GT values to NO_CALL and remove annotations */ SET_TO_NO_CALL_NO_ANNOTATIONS, /** * Use the subsetted PLs to greedily assigned genotypes */ USE_PLS_TO_ASSIGN, /** * Try to match the original GT calls, if at all possible * * Suppose I have 3 alleles: A/B/C and the following samples: * * original_GT best_match to A/B best_match to A/C * S1 => A/A A/A A/A * S2 => A/B A/B A/A * S3 => B/B B/B A/A * S4 => B/C A/B A/C * S5 => C/C A/A C/C * * Basically, all alleles not in the subset map to ref. It means that het-alt genotypes
public VariantContext createVariantContextFromEvent() { return new VariantContextBuilder("event", loc.getContig(), loc.getStart(), loc.getStop(), alleles) .log10PError(0.0).make(); } }
public VariantContext toVariantContext() { GenotypesContext gc = GenotypesContext.copy(this.genotypes.values()); return new VariantContextBuilder(name, contig, start, stop, alleles).id(id) .genotypes(gc).log10PError(log10PError).filters(filters).attributes(attributes).make(); }
/** * @return a generic one-based position variant context with a heterozygous genotype having no attributes. */ private VariantContext buildVariantContext(int chr, int pos, String ref, String alt, double qual, String sampleName) { Allele refAllele = Allele.create(ref, true); Allele altAllele = Allele.create(alt); List<Allele> alleles = Arrays.asList(refAllele, altAllele); VariantContextBuilder vcBuilder = new VariantContextBuilder(); // build Genotype GenotypeBuilder gtBuilder = new GenotypeBuilder(sampleName).noAttributes(); //default to HETEROZYGOUS gtBuilder.alleles(alleles); // build VariantContext vcBuilder.loc("chr" + chr, pos, pos - 1L + ref.length()); vcBuilder.alleles(alleles); vcBuilder.genotypes(gtBuilder.make()); vcBuilder.log10PError(-0.1 * qual); return vcBuilder.make(); }
builder = new VariantContextBuilder(initialContext.getSource(), initialContext.getContig(), initialContext.getStart(), initialContext.getEnd(), siteAlleles); builder.computeEndFromAlleles(allAlleles, initialContext.getStart()); builder.log10PError(initialContext.getLog10PError());
builder = new VariantContextBuilder(initialContext.getSource(), initialContext.getContig(), initialContext.getStart(), initialContext.getEnd(), siteAlleles); builder.computeEndFromAlleles(allAlleles, initialContext.getStart()); builder.log10PError(initialContext.getLog10PError());
@DataProvider(name = "UsingAD") public Object[][] makeUsingADData() { List<Object[]> tests = new ArrayList<>(); final Allele A = Allele.create("A", true); final Allele C = Allele.create("C"); final Allele G = Allele.create("G"); final List<Allele> AA = Arrays.asList(A,A); final List<Allele> AC = Arrays.asList(A,C); final List<Allele> GG = Arrays.asList(G,G); final List<Allele> ACG = Arrays.asList(A,C,G); final Genotype gAC = new GenotypeBuilder("1", AC).DP(10).AD(new int[]{5,5}).make(); final Genotype gAA = new GenotypeBuilder("2", AA).DP(10).AD(new int[]{10,0}).make(); final Genotype gACerror = new GenotypeBuilder("3", AC).DP(10).AD(new int[]{9,1}).make(); final Genotype gGG = new GenotypeBuilder("4", GG).DP(10).AD(new int[]{1,9}).make(); tests.add(new Object[]{new VariantContextBuilder("test", "20", 10, 10, AC).log10PError(-5).genotypes(Arrays.asList(gAC)).make(), 5.0}); tests.add(new Object[]{new VariantContextBuilder("test", "20", 10, 10, AC).log10PError(-5).genotypes(Arrays.asList(gACerror)).make(), 5.0}); tests.add(new Object[]{new VariantContextBuilder("test", "20", 10, 10, AC).log10PError(-5).genotypes(Arrays.asList(gAA, gAC)).make(), 5.0}); tests.add(new Object[]{new VariantContextBuilder("test", "20", 10, 10, AC).log10PError(-5).genotypes(Arrays.asList(gAC, gACerror)).make(), 5.0}); tests.add(new Object[]{new VariantContextBuilder("test", "20", 10, 10, ACG).log10PError(-5).genotypes(Arrays.asList(gAA, gAC, gACerror, gGG)).make(), 2.5}); return tests.toArray(new Object[][]{}); }
VariantContextBuilder vcb = new VariantContextBuilder("DiagnoseTargets", interval.getContig(), interval.getStart(), interval.getStop(), alleles); vcb = vcb.log10PError(VariantContext.NO_LOG10_PERROR); vcb.filters(new LinkedHashSet<>(statusToStrings(stats.callableStatuses(), true)));
@Test public void testSimple() throws Exception { VariantContextBuilder vctx_builder = new VariantContextBuilder(); ArrayList<Allele> alleles = new ArrayList<Allele>(); alleles.add(Allele.create("A", false)); alleles.add(Allele.create("C", true)); vctx_builder.alleles(alleles); GenotypesContext genotypes = GenotypesContext.NO_GENOTYPES; vctx_builder.genotypes(genotypes); HashSet<String> filters = new HashSet<String>(); vctx_builder.filters(filters); HashMap<String, Object> attributes = new HashMap<String, Object>(); attributes.put("NS", new Integer(4)); vctx_builder.attributes(attributes); vctx_builder.loc("20", 2, 2); vctx_builder.log10PError(-8.0); String[] expected = new String[]{"20", "2", ".", "C", "A", "80", "PASS", "NS=4"}; VariantContext ctx = vctx_builder.make(); writable.set(ctx); writer.write(1L, writable); writer.close(taskAttemptContext); LineNumberReader reader = new LineNumberReader(new FileReader(test_vcf_output)); skipHeader(reader); String[] fields = Arrays.copyOf(reader.readLine().split("\t"), expected.length); Assert.assertArrayEquals("comparing VCF single line", expected, fields); }
final VariantContextBuilder baseVC = new VariantContextBuilder().chr("1").start(1).stop(1).noID().passFilters().log10PError(1).alleles("A", "C"); final GenotypeBuilder baseGT = new GenotypeBuilder("Sample1").alleles(Arrays.asList(Allele.NO_CALL, Allele.NO_CALL)); final Map<Allele, String> alleleMap = new HashMap<Allele, String>(3);
/** * Decode the sites level data from this classes decoder * * @param builder * @return */ private final SitesInfoForDecoding decodeSitesExtendedInfo(final VariantContextBuilder builder) throws IOException { final Object qual = decoder.decodeSingleValue(BCF2Type.FLOAT); if ( qual != null ) { builder.log10PError(((Double)qual) / -10.0); } final int nAlleleInfo = decoder.decodeInt(BCF2Type.INT32); final int nFormatSamples = decoder.decodeInt(BCF2Type.INT32); final int nAlleles = nAlleleInfo >> 16; final int nInfo = nAlleleInfo & 0x0000FFFF; final int nFormatFields = nFormatSamples >> 24; final int nSamples = nFormatSamples & 0x00FFFFF; if ( header.getNGenotypeSamples() != nSamples ) error("Reading BCF2 files with different numbers of samples per record " + "is not currently supported. Saw " + header.getNGenotypeSamples() + " samples in header but have a record with " + nSamples + " samples"); decodeID(builder); final List<Allele> alleles = decodeAlleles(builder, pos, nAlleles); decodeFilter(builder); decodeInfo(builder, nInfo); final SitesInfoForDecoding info = new SitesInfoForDecoding(nFormatFields, nSamples, alleles); if ( ! info.isValid() ) error("Sites info is malformed: " + info); return info; }
/** * Decode the sites level data from this classes decoder * * @param builder * @return */ private final SitesInfoForDecoding decodeSitesExtendedInfo(final VariantContextBuilder builder) throws IOException { final Object qual = decoder.decodeSingleValue(BCF2Type.FLOAT); if ( qual != null ) { builder.log10PError(((Double)qual) / -10.0); } final int nAlleleInfo = decoder.decodeInt(BCF2Type.INT32); final int nFormatSamples = decoder.decodeInt(BCF2Type.INT32); final int nAlleles = nAlleleInfo >> 16; final int nInfo = nAlleleInfo & 0x0000FFFF; final int nFormatFields = nFormatSamples >> 24; final int nSamples = nFormatSamples & 0x00FFFFF; if ( header.getNGenotypeSamples() != nSamples ) error("Reading BCF2 files with different numbers of samples per record " + "is not currently supported. Saw " + header.getNGenotypeSamples() + " samples in header but have a record with " + nSamples + " samples"); decodeID(builder); final List<Allele> alleles = decodeAlleles(builder, pos, nAlleles); decodeFilter(builder); decodeInfo(builder, nInfo); final SitesInfoForDecoding info = new SitesInfoForDecoding(nFormatFields, nSamples, alleles); if ( ! info.isValid() ) error("Sites info is malformed: " + info); return info; }
snp.getPos(), alleles) .log10PError(VariantContext.NO_LOG10_PERROR) .genotypes(gt) .unfiltered().make();
snp.getPos(), alleles) .log10PError(VariantContext.NO_LOG10_PERROR) .genotypes(gt) .unfiltered().make();
final Object qual = decoder.decodeSingleValue(BCF2Type.FLOAT); if ( qual != null ) { builder.log10PError(((Double)qual) / -10.0);
vctx_builder.log10PError(-8.0);
builder.log10PError(source.getLog10PError()); builder.attributes(source.getAttributes());
builder.log10PError(source.getLog10PError()); builder.attributes(source.getAttributes());