@Override public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String FamilyName) { if (eval != null) { return Arrays.asList((Object)"all", eval.getChr()); } else { return Collections.emptyList(); } } }
private void fieldIsMissingFromHeaderError(final VariantContext vc, final String id, final String field) { if ( ! allowMissingFieldsInHeader) throw new IllegalStateException("Key " + id + " found in VariantContext field " + field + " at " + vc.getChr() + ":" + vc.getStart() + " but this key isn't defined in the VCFHeader. We require all VCFs to have" + " complete VCF headers by default."); }
@Override public int compare(final VariantContext firstVariantContext, final VariantContext secondVariantContext) { // Will throw NullPointerException -- happily -- if either of the chromosomes/contigs aren't // present. This error checking should already have been done in the constructor but it's left // in as defence anyway. final int contigCompare = this.contigIndexLookup.get(firstVariantContext.getChr()) - this.contigIndexLookup.get(secondVariantContext.getChr()); return contigCompare != 0 ? contigCompare : firstVariantContext.getStart() - secondVariantContext.getStart(); }
public VariantContextMissingRequiredField(String field, VariantContext vc) { super(String.format("Variant at %s:%d is is missing the required field %s.", vc.getChr(), vc.getStart(), field)); } }
/** * Throws a meaningful error message when a field (INFO or FORMAT) is found when writing out a file * but there's no header line for it. * * @param vc * @param field * @param fieldType */ private void errorUnexpectedFieldToWrite(final VariantContext vc, final String field, final String fieldType) { throw new IllegalStateException("Found field " + field + " in the " + fieldType + " fields of VariantContext at " + vc.getChr() + ":" + vc.getStart() + " from " + vc.getSource() + " but this hasn't been defined in the VCFHeader"); }
protected void noteCurrentRecord(VariantContext vc) { // did the user break the contract by giving a record too late? if (mostUpstreamWritableLoc != null && vc.getStart() < mostUpstreamWritableLoc) // went too far back, since may have already written anything that is <= mostUpstreamWritableLoc throw new IllegalArgumentException("Permitted to write any record upstream of position " + mostUpstreamWritableLoc + ", but a record at " + vc.getChr() + ":" + vc.getStart() + " was just added."); }
@Requires({"vc != null", "variable != null", "key != null", "value != null", "callReport != null"}) private void printCallElement(final VariantContext vc, final Object variable, final Object key, final Object value) { final String loc = String.format("%s:%d", vc.getChr(), vc.getStart()); callReport.println(Utils.join("\t", Arrays.asList(loc, variable, key, value))); }
@Override public String toString() { final StringBuilder b = new StringBuilder("EventMap{"); for ( final VariantContext vc : getVariantContexts() ) b.append(String.format("%s:%d-%d %s,", vc.getChr(), vc.getStart(), vc.getEnd(), vc.getAlleles())); b.append("}"); return b.toString(); }
public void validateRSIDs(Set<String> rsIDs) { if ( rsIDs != null && hasID() ) { for ( String id : getID().split(VCFConstants.ID_FIELD_SEPARATOR) ) { if ( id.startsWith("rs") && !rsIDs.contains(id) ) throw new TribbleException.InternalCodecException(String.format("the rsID %s for the record at position %s:%d is not in dbSNP", id, getChr(), getStart())); } } }
private static String getID(VariantContext v) { if ( v.hasID() ) { return v.getID(); } else { return String.format("Var-%s-%d",v.getChr(),v.getStart()); } }
/** * create a genome location, given a variant context * @param genomeLocParser parser * @param vc the variant context * @return the genomeLoc */ public static final GenomeLoc getLocation(GenomeLocParser genomeLocParser,VariantContext vc) { return genomeLocParser.createGenomeLoc(vc.getChr(), vc.getStart(), vc.getEnd(), true); }
@DataProvider(name = "ContiguousData") public Object[][] makeContiguousData() { List<Object[]> tests = new ArrayList<>(); for ( final String chrMod : Arrays.asList("", ".mismatch") ) { for ( final int offset : Arrays.asList(-10, -1, 0, 1, 10) ) { final boolean equals = chrMod.equals("") && offset == 0; tests.add(new Object[]{vc.getChr() + chrMod, vc.getStart() + offset, equals}); } } return tests.toArray(new Object[][]{}); }
public VariantContext createEmptyContext(VariantContext other, List<String> samples) { VariantContextBuilder builder = new VariantContextBuilder(); // set the alleles to be the same builder.alleles(other.getAlleles()); builder.loc(other.getChr(),other.getStart(),other.getEnd()); // set all genotypes to empty List<Genotype> genotypes = new ArrayList<Genotype>(samples.size()); for ( String sample : samples ) genotypes.add(GenotypeBuilder.create(sample, new ArrayList<Allele>(0))); builder.genotypes(genotypes); return builder.make(); }
private void validateVariantSite(VariantContext vc, ReferenceContext ref, AlignmentContext context) { final Allele reportedRefAllele = vc.getReference(); final int refLength = reportedRefAllele.length(); if ( refLength > 100 ) { //TODO: get rid of this hardcoded limit? logger.info(String.format("Reference allele is too long (%d) at position %s:%d; skipping that record.", refLength, vc.getChr(), vc.getStart())); return; } final byte[] observedRefBases = new byte[refLength]; System.arraycopy(ref.getBases(), 0, observedRefBases, 0, refLength); final Allele observedRefAllele = Allele.create(observedRefBases); vc.validateReferenceBases(reportedRefAllele, observedRefAllele); if ( checkAlternateAlleles ) vc.validateAlternateAlleles(); }
public void validateReferenceBases(final Allele reportedReference, final Allele observedReference) { if ( reportedReference != null && !reportedReference.basesMatch(observedReference) ) { throw new TribbleException.InternalCodecException(String.format("the REF allele is incorrect for the record at position %s:%d, fasta says %s vs. VCF says %s", getChr(), getStart(), observedReference.getBaseString(), reportedReference.getBaseString())); } }
@Override public void start(final BCF2Encoder encoder, final VariantContext vc) throws IOException { if ( vc.getNAlleles() > BCF2Utils.MAX_ALLELES_IN_GENOTYPES ) throw new IllegalStateException("Current BCF2 encoder cannot handle sites " + "with > " + BCF2Utils.MAX_ALLELES_IN_GENOTYPES + " alleles, but you have " + vc.getNAlleles() + " at " + vc.getChr() + ":" + vc.getStart()); encodingType = BCF2Type.INT8; buildAlleleMap(vc); nValuesPerGenotype = vc.getMaxPloidy(2); super.start(encoder, vc); }
@Override public String toString() { return String.format("ExactCall %s:%d alleles=%s nSamples=%s orig.pNonRef=%.2f orig.runtime=%s", vc.getChr(), vc.getStart(), vc.getAlleles(), vc.getNSamples(), originalCall.getLog10PosteriorOfAFGT0(), new AutoFormattingTime(runtime).toString()); } }
@Test public void testCreationFromVariantContext() { final VariantContext feature = new VariantContextBuilder("x", "chr1", 1, 5, Arrays.asList(Allele.create("AAAAA", true))).make(); final GenomeLoc loc = genomeLocParser.createGenomeLoc(feature); Assert.assertEquals(loc.getContig(), feature.getChr()); Assert.assertEquals(loc.getStart(), feature.getStart()); Assert.assertEquals(loc.getStop(), feature.getEnd()); }
/** * Copy constructor * * @param other the VariantContext to copy */ protected VariantContext(VariantContext other) { this(other.getSource(), other.getID(), other.getChr(), other.getStart(), other.getEnd(), other.getAlleles(), other.getGenotypes(), other.getLog10PError(), other.getFiltersMaybeNull(), other.getAttributes(), other.fullyDecoded, NO_VALIDATION); }