use of htsjdk.variant.variantcontext.VariantContextBuilder in project gatk by broadinstitute.
the class TandemRepeatUnitTest method testUsingVC.
@Test
public void testUsingVC() {
// - [ref] / ATC from 20-20
final String insLoc = "chr1";
final int insLocStart = 2;
final int insLocStop = 2;
final byte[] refBytes = "GTATCATCATCGGA".getBytes();
final Allele nullR = Allele.create("A", true);
final Allele atc = Allele.create("AATC", false);
// A*,ATC, context = ATC ATC ATC : (ATC)3 -> (ATC)4
final VariantContext vc = new VariantContextBuilder("foo", insLoc, insLocStart, insLocStop, Arrays.asList(nullR, atc)).make();
// we test that the interval from which the ReferenceContext is constructed does not need to exactly overlap
// the VariantContext. The annotation should be able to handle this.
final SimpleInterval interval = new SimpleInterval(insLoc, insLocStart + 3, insLocStop + 4);
final SimpleInterval interval1 = new SimpleInterval(insLoc, 1, refBytes.length);
final ReferenceBases ref1 = new ReferenceBases(refBytes, interval1);
final SAMSequenceDictionary dict = new SAMSequenceDictionary(Arrays.asList(new SAMSequenceRecord(insLoc, refBytes.length)));
final ReferenceContext ref = new ReferenceContext(ReferenceDataSource.of(ref1, dict), interval, 20, 20);
final InfoFieldAnnotation ann = new TandemRepeat();
final Map<String, Object> a = ann.annotate(ref, vc, null);
Assert.assertEquals(a.size(), 3);
Assert.assertEquals(a.get(GATKVCFConstants.STR_PRESENT_KEY), true);
Assert.assertEquals(a.get(GATKVCFConstants.REPEAT_UNIT_KEY), "ATC");
//3 repeats in the reference, 4 in the variant
Assert.assertEquals(a.get(GATKVCFConstants.REPEATS_PER_ALLELE_KEY), Arrays.asList(3, 4));
}
use of htsjdk.variant.variantcontext.VariantContextBuilder in project gatk by broadinstitute.
the class TandemRepeatUnitTest method testUsingVCNoRepeat.
@Test
public void testUsingVCNoRepeat() {
// - [ref] / ATC from 20-20
final String insLoc = "chr1";
final int insLocStart = 6;
final int insLocStop = 6;
final byte[] refBytes = "GTATCATCATCGGA".getBytes();
final Allele nullR = Allele.create("A", true);
final Allele atc = Allele.create("AATC", false);
// A*,ATC, context = ATC ATC ATC : (ATC)3 -> (ATC)4
final VariantContext vc = new VariantContextBuilder("foo", insLoc, insLocStart, insLocStop, Arrays.asList(nullR, atc)).make();
final SimpleInterval interval = new SimpleInterval(insLoc, insLocStart, insLocStop);
final SimpleInterval interval1 = new SimpleInterval(insLoc, 1, refBytes.length);
final ReferenceBases ref1 = new ReferenceBases(refBytes, interval1);
final SAMSequenceDictionary dict = new SAMSequenceDictionary(Arrays.asList(new SAMSequenceRecord(insLoc, refBytes.length)));
final ReferenceContext ref = new ReferenceContext(ReferenceDataSource.of(ref1, dict), interval, 0, 20);
final InfoFieldAnnotation ann = new TandemRepeat();
final Map<String, Object> a = ann.annotate(ref, vc, null);
Assert.assertTrue(a.isEmpty());
}
use of htsjdk.variant.variantcontext.VariantContextBuilder in project gatk by broadinstitute.
the class TandemRepeatUnitTest method testUsingVCNotIndel.
@Test
public void testUsingVCNotIndel() {
// - [ref] / ATC from 20-20
String insLoc = "chr1";
int insLocStart = 2;
int insLocStop = 2;
byte[] refBytes = "GTATCATCATCGGA".getBytes();
Allele nullR = Allele.create("A", true);
Allele atc = Allele.create("C", false);
// A*,ATC, context = ATC ATC ATC : (ATC)3 -> (ATC)4
VariantContext vc = new VariantContextBuilder("foo", insLoc, insLocStart, insLocStop, Arrays.asList(nullR, atc)).make();
final SimpleInterval interval = new SimpleInterval("chr1", insLocStart, insLocStop);
final String contigName = "chr1";
final SimpleInterval interval1 = new SimpleInterval(contigName, 1, refBytes.length);
final ReferenceBases ref1 = new ReferenceBases(refBytes, interval1);
final SAMSequenceDictionary dict = new SAMSequenceDictionary(Arrays.asList(new SAMSequenceRecord(contigName, refBytes.length)));
final ReferenceContext ref = new ReferenceContext(ReferenceDataSource.of(ref1, dict), interval, 0, 20);
final InfoFieldAnnotation ann = new TandemRepeat();
final Map<String, Object> a = ann.annotate(ref, vc, null);
Assert.assertTrue(a.isEmpty());
}
use of htsjdk.variant.variantcontext.VariantContextBuilder in project gatk by broadinstitute.
the class VariantOverlapAnnotatorUnitTest method makeAnnotateRsIDData.
@DataProvider(name = "AnnotateRsIDData")
public Object[][] makeAnnotateRsIDData() {
List<Object[]> tests = new ArrayList<>();
// this functionality can be adapted to provide input data for whatever you might want in your data
final VariantContext callNoIDAC = makeVC("call", VCFConstants.EMPTY_ID_FIELD, Arrays.asList("A", "C"));
final VariantContext callNoIDAT = makeVC("call", VCFConstants.EMPTY_ID_FIELD, Arrays.asList("A", "T"));
final VariantContext callIDAC = makeVC("call", "foo", Arrays.asList("A", "C"));
final VariantContext callExistingIDAC = makeVC("call", "rsID1", Arrays.asList("A", "C"));
final VariantContext dbSNP_AC = makeVC("DBSNP", "rsID1", Arrays.asList("A", "C"));
final VariantContext dbSNP_AT = makeVC("DBSNP", "rsID2", Arrays.asList("A", "T"));
final VariantContext dbSNP_AG = makeVC("DBSNP", "rsID3", Arrays.asList("A", "G"));
final VariantContext dbSNP_AC_AT = makeVC("DBSNP", "rsID1;rsID2", Arrays.asList("A", "C", "T"));
final VariantContext dbSNP_AC_AG = makeVC("DBSNP", "rsID1;rsID3", Arrays.asList("A", "C", "G"));
tests.add(new Object[] { callNoIDAC, Arrays.asList(dbSNP_AC), dbSNP_AC.getID(), true });
tests.add(new Object[] { callNoIDAC, Arrays.asList(dbSNP_AT), VCFConstants.EMPTY_ID_FIELD, false });
tests.add(new Object[] { callIDAC, Arrays.asList(dbSNP_AC), "foo" + ";" + dbSNP_AC.getID(), true });
tests.add(new Object[] { callIDAC, Arrays.asList(dbSNP_AT), "foo", false });
tests.add(new Object[] { callExistingIDAC, Arrays.asList(dbSNP_AC), "rsID1", true });
tests.add(new Object[] { callExistingIDAC, Arrays.asList(dbSNP_AT), "rsID1", false });
final VariantContext callNoIDACT = makeVC("call", VCFConstants.EMPTY_ID_FIELD, Arrays.asList("A", "C", "T"));
tests.add(new Object[] { callNoIDACT, Arrays.asList(dbSNP_AC), dbSNP_AC.getID(), true });
tests.add(new Object[] { callNoIDACT, Arrays.asList(dbSNP_AT), dbSNP_AT.getID(), true });
tests.add(new Object[] { callNoIDACT, Arrays.asList(dbSNP_AG), VCFConstants.EMPTY_ID_FIELD, false });
tests.add(new Object[] { callNoIDACT, Arrays.asList(dbSNP_AC_AT), dbSNP_AC_AT.getID(), true });
tests.add(new Object[] { callNoIDACT, Arrays.asList(dbSNP_AC_AG), dbSNP_AC_AG.getID(), true });
// multiple options
tests.add(new Object[] { callNoIDAC, Arrays.asList(dbSNP_AC, dbSNP_AT), "rsID1", true });
tests.add(new Object[] { callNoIDAC, Arrays.asList(dbSNP_AT, dbSNP_AC), "rsID1", true });
tests.add(new Object[] { callNoIDAC, Arrays.asList(dbSNP_AC_AT), "rsID1;rsID2", true });
tests.add(new Object[] { callNoIDAT, Arrays.asList(dbSNP_AC_AT), "rsID1;rsID2", true });
tests.add(new Object[] { callNoIDAC, Arrays.asList(dbSNP_AC_AG), "rsID1;rsID3", true });
tests.add(new Object[] { callNoIDAT, Arrays.asList(dbSNP_AC_AG), VCFConstants.EMPTY_ID_FIELD, false });
final VariantContext dbSNP_AC_FAIL = new VariantContextBuilder(makeVC("DBSNP", "rsID1", Arrays.asList("A", "C"))).filter("FAIL").make();
tests.add(new Object[] { callNoIDAC, Arrays.asList(dbSNP_AC_FAIL), VCFConstants.EMPTY_ID_FIELD, false });
return tests.toArray(new Object[][] {});
}
use of htsjdk.variant.variantcontext.VariantContextBuilder in project gatk by broadinstitute.
the class GenomeLocParserUnitTest method testCreationFromVariantContext.
@Test
public void testCreationFromVariantContext() {
final VariantContext feature = new VariantContextBuilder("x", "1", 1, 5, Arrays.asList(Allele.create("AAAAA", true))).make();
final GenomeLoc loc = genomeLocParser.createGenomeLoc(feature);
Assert.assertEquals(loc.getContig(), feature.getContig());
Assert.assertEquals(loc.getStart(), feature.getStart());
Assert.assertEquals(loc.getStop(), feature.getEnd());
}
Aggregations