public static VariantContextContainer readAllVCs(final File input, final BCF2Codec codec)
      throws IOException {
    PositionalBufferedStream headerPbs = new PositionalBufferedStream(new FileInputStream(input));
    FeatureCodecHeader header = codec.readHeader(headerPbs);
    headerPbs.close();

    final PositionalBufferedStream pbs = new PositionalBufferedStream(new FileInputStream(input));
    pbs.skip(header.getHeaderEnd());

    final VCFHeader vcfHeader = (VCFHeader) header.getHeaderValue();
    return new VariantContextTestProvider.VariantContextContainer(
        vcfHeader,
        new VariantContextTestProvider.VCIterable(codec, vcfHeader) {
          @Override
          public boolean hasNext() {
            try {
              return !pbs.isDone();
            } catch (IOException e) {
              throw new RuntimeException(e);
            }
          }

          @Override
          public Object nextSource() {
            return pbs;
          }
        });
  }
Ejemplo n.º 2
0
 /**
  * Utility class to read all of the VC records from a file
  *
  * @param file
  * @param codec
  * @return
  * @throws java.io.IOException
  */
 public static final <SOURCE> Pair<VCFHeader, VCIterable<SOURCE>> readAllVCs(
     final File file, final FeatureCodec<VariantContext, SOURCE> codec) throws IOException {
   // read in the features
   SOURCE source = codec.makeSourceFromStream(new FileInputStream(file));
   FeatureCodecHeader header = codec.readHeader(source);
   final VCFHeader vcfHeader = (VCFHeader) header.getHeaderValue();
   return new Pair<>(vcfHeader, new VCIterable<>(source, codec, vcfHeader));
 }