Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
lbergelson committed Jan 30, 2023
1 parent 900cd5c commit 0e6e942
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions src/test/java/htsjdk/variant/vcf/VCFEncoderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
Expand Down Expand Up @@ -150,6 +151,26 @@ public void testEncodeGT(){
Assert.assertEquals(VCFEncoder.encodeGtField(vc, g2), "1/2");
}

@Test
public void testsWriteGtField() throws IOException {
final VariantContextBuilder vcb = new VariantContextBuilder("test",
"chr?", 100, 100,
Arrays.asList(Allele.REF_A, Allele.ALT_T, Allele.create("TC")));
final Genotype g1 = new GenotypeBuilder("s1", Arrays.asList(Allele.REF_A, Allele.REF_A)).make();
final Genotype g2 = new GenotypeBuilder("s2", Arrays.asList(Allele.ALT_T, Allele.create("TC"))).make();
vcb.genotypes(g1, g2);
final VariantContext vc = vcb.make();
final Map<Allele, String> alleleStringMap = VCFEncoder.buildAlleleStrings(vc);

final StringBuilder b1 = new StringBuilder();
VCFEncoder.writeGtField(alleleStringMap, b1, g1 );
Assert.assertEquals(b1.toString(), "0/0");

final StringBuilder b2 = new StringBuilder();
VCFEncoder.writeGtField(alleleStringMap, b2, g2);
Assert.assertEquals(b2.toString(), "1/2");
}

@Test(dataProvider = "MissingFormatTestData")
public void testMissingFormatFields(final VCFEncoder encoder, final VariantContext vc, final String expectedLastColumn, final Map<Allele, String> alleleMap, final List<String> genotypeFormatKeys) {
final StringBuilder sb = new StringBuilder();
Expand Down

0 comments on commit 0e6e942

Please sign in to comment.