Search in sources :

Example 1 with LineIteratorImpl

use of htsjdk.tribble.readers.LineIteratorImpl in project gatk by broadinstitute.

the class TableCodecUnitTest method testDecodeFailsNoHeader.

@Test(expectedExceptions = UserException.MalformedFile.class)
public void testDecodeFailsNoHeader() {
    TableCodec tc = new TableCodec();
    LineReader reader = makeReader(asList("1:1  1   2   3"));
    LineIterator li = new LineIteratorImpl(reader);
    tc.readActualHeader(li);
}
Also used : LineReader(htsjdk.tribble.readers.LineReader) LineIteratorImpl(htsjdk.tribble.readers.LineIteratorImpl) LineIterator(htsjdk.tribble.readers.LineIterator) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 2 with LineIteratorImpl

use of htsjdk.tribble.readers.LineIteratorImpl in project gatk by broadinstitute.

the class TableCodecUnitTest method testDecodeOnlyComments.

@Test
public void testDecodeOnlyComments() {
    TableCodec tc = new TableCodec();
    LineReader reader = makeReader(asList("#HEADER a b c", "#HEADER d e f"));
    LineIterator li = new LineIteratorImpl(reader);
    final List<String> strings = tc.readActualHeader(li);
    Assert.assertEquals(strings, emptyList());
}
Also used : LineReader(htsjdk.tribble.readers.LineReader) LineIteratorImpl(htsjdk.tribble.readers.LineIteratorImpl) LineIterator(htsjdk.tribble.readers.LineIterator) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 3 with LineIteratorImpl

use of htsjdk.tribble.readers.LineIteratorImpl in project gatk by broadinstitute.

the class TableCodecUnitTest method testTwoHeaders.

@Test
public void testTwoHeaders() {
    TableCodec tc = new TableCodec();
    LineReader reader = makeReader(asList("HEADER a b c", "HEADER d e f"));
    LineIterator li = new LineIteratorImpl(reader);
    final List<String> strings = tc.readActualHeader(li);
    Assert.assertEquals(strings, asList("HEADER", "a", "b", "c"));
}
Also used : LineReader(htsjdk.tribble.readers.LineReader) LineIteratorImpl(htsjdk.tribble.readers.LineIteratorImpl) LineIterator(htsjdk.tribble.readers.LineIterator) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 4 with LineIteratorImpl

use of htsjdk.tribble.readers.LineIteratorImpl in project gatk by broadinstitute.

the class TableCodecUnitTest method testDecodeHeader.

@Test
public void testDecodeHeader() {
    TableCodec tc = new TableCodec();
    LineReader reader = makeReader(asList("HEADER a b c"));
    LineIterator li = new LineIteratorImpl(reader);
    List<String> hd = tc.readActualHeader(li);
    Assert.assertEquals(hd, asList("HEADER", "a", "b", "c"));
}
Also used : LineReader(htsjdk.tribble.readers.LineReader) LineIteratorImpl(htsjdk.tribble.readers.LineIteratorImpl) LineIterator(htsjdk.tribble.readers.LineIterator) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 5 with LineIteratorImpl

use of htsjdk.tribble.readers.LineIteratorImpl in project gatk by broadinstitute.

the class TableCodecUnitTest method testDecodeHeader2.

@Test
public void testDecodeHeader2() {
    TableCodec tc = new TableCodec();
    final String str2 = "1:1  1   2   3";
    LineReader reader = makeReader(asList("HEADER a b c", str2));
    LineIterator li = new LineIteratorImpl(reader);
    List<String> hd = tc.readActualHeader(li);
    Assert.assertEquals(hd, asList("HEADER", "a", "b", "c"));
    final TableFeature decode = tc.decode(str2);
    Assert.assertEquals(decode.get("a"), "1");
    Assert.assertEquals(decode.get("b"), "2");
    Assert.assertEquals(decode.get("c"), "3");
    Assert.assertEquals(decode.getLocation().getContig(), "1");
    Assert.assertEquals(decode.getContig(), "1");
    Assert.assertEquals(decode.getLocation().getStart(), 1);
    Assert.assertEquals(decode.getLocation().getEnd(), 1);
}
Also used : LineReader(htsjdk.tribble.readers.LineReader) LineIteratorImpl(htsjdk.tribble.readers.LineIteratorImpl) LineIterator(htsjdk.tribble.readers.LineIterator) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Aggregations

LineIteratorImpl (htsjdk.tribble.readers.LineIteratorImpl)14 LineIterator (htsjdk.tribble.readers.LineIterator)13 LineReader (htsjdk.tribble.readers.LineReader)9 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)7 Test (org.testng.annotations.Test)7 SynchronousLineReader (htsjdk.tribble.readers.SynchronousLineReader)5 IOException (java.io.IOException)5 VariantContext (htsjdk.variant.variantcontext.VariantContext)4 HashSet (java.util.HashSet)4 VCFHeader (htsjdk.variant.vcf.VCFHeader)3 PrintWriter (java.io.PrintWriter)3 ArrayList (java.util.ArrayList)3 TreeSet (java.util.TreeSet)3 VariantContextWriter (htsjdk.variant.variantcontext.writer.VariantContextWriter)2 AbstractVCFCodec (htsjdk.variant.vcf.AbstractVCFCodec)2 VCFHeaderLine (htsjdk.variant.vcf.VCFHeaderLine)2 DataInputStream (java.io.DataInputStream)2 InputStream (java.io.InputStream)2 JvarkitException (com.github.lindenb.jvarkit.lang.JvarkitException)1 Counter (com.github.lindenb.jvarkit.util.Counter)1