/** Creates a {@link SamInputResource} reading from the provided resource, with no index, * and with a wrapper to apply to the SeekableByteChannel for custom prefetching/buffering. */ public static SamInputResource of(final Path path, Function<SeekableByteChannel, SeekableByteChannel> wrapper) { return new SamInputResource(new PathInputResource(path, wrapper)); }
/** Creates a {@link SamInputResource} reading from the provided resource, with no index, * and with a wrapper to apply to the SeekableByteChannel for custom prefetching/buffering. */ public static SamInputResource of(final Path path, Function<SeekableByteChannel, SeekableByteChannel> wrapper) { return new SamInputResource(new PathInputResource(path, wrapper)); }
/** Creates a {@link SamInputResource} reading from the provided resource, with no index. */ public static SamInputResource of(final URL url) { return new SamInputResource(new UrlInputResource(url)); }
/** Creates a {@link SamInputResource} reading from the provided resource, with no index. */ public static SamInputResource of(final Path path) { // in the case of named pipes and other non-seekable paths there's a bug in the implementation of // java's GZIPInputStream which inappropriately uses .available() and then gets confused with the result // of 0. For reference see: // https://bugs.java.com/view_bug.do?bug_id=7036144 // https://github.com/samtools/htsjdk/pull/1077 // https://github.com/samtools/htsjdk/issues/898 // This still doesn't support the case where someone is creating a named pipe in a non-default // file system and then using it as input and passing a GZIPed into the other end of the pipe. // To work around this bug, we fall back to using a FileInputResource rather than a PathInputResource // when we encounter a non-regular file using the default NIO filesystem (file://) if (path.getFileSystem() == FileSystems.getDefault() && !Files.isRegularFile(path)) { return of(path.toFile()); } else { return new SamInputResource(new PathInputResource(path)); } }
/** Creates a {@link SamInputResource} reading from the provided resource, with no index. */ public static SamInputResource of(final SeekableStream seekableStream) { return new SamInputResource(new SeekableStreamInputResource(seekableStream)); }
public static SamInputResource of(final SRAAccession acc) { return new SamInputResource(new SRAInputResource(acc)); }
/** Creates a {@link SamInputResource} reading from the provided resource, with no index. */ public static SamInputResource of(final InputStream inputStream) { return new SamInputResource(new InputStreamInputResource(inputStream)); }
/** Creates a {@link SamInputResource} reading from the provided resource, with no index. */ public static SamInputResource of(final File file) { return new SamInputResource(new FileInputResource(file)); }
/** Creates a {@link SamInputResource} reading from the provided resource, with no index. */ public static SamInputResource of(final URL url) { return new SamInputResource(new UrlInputResource(url)); }
/** Creates a {@link SamInputResource} reading from the provided resource, with no index. */ public static SamInputResource of(final URL url) { return new SamInputResource(new UrlInputResource(url)); }
/** Creates a {@link SamInputResource} reading from the provided resource, with no index. */ public static SamInputResource of(final SeekableStream seekableStream) { return new SamInputResource(new SeekableStreamInputResource(seekableStream)); }
/** Creates a {@link SamInputResource} reading from the provided resource, with no index. */ public static SamInputResource of(final Path path) { // in the case of named pipes and other non-seekable paths there's a bug in the implementation of // java's GZIPInputStream which inappropriately uses .available() and then gets confused with the result // of 0. For reference see: // https://bugs.java.com/view_bug.do?bug_id=7036144 // https://github.com/samtools/htsjdk/pull/1077 // https://github.com/samtools/htsjdk/issues/898 // This still doesn't support the case where someone is creating a named pipe in a non-default // file system and then using it as input and passing a GZIPed into the other end of the pipe. // To work around this bug, we fall back to using a FileInputResource rather than a PathInputResource // when we encounter a non-regular file using the default NIO filesystem (file://) if (path.getFileSystem() == FileSystems.getDefault() && !Files.isRegularFile(path)) { return of(path.toFile()); } else { return new SamInputResource(new PathInputResource(path)); } }
/** Creates a {@link SamInputResource} reading from the provided resource, with no index. */ public static SamInputResource of(final InputStream inputStream) { return new SamInputResource(new InputStreamInputResource(inputStream)); }
/** Creates a {@link SamInputResource} reading from the provided resource, with no index. */ public static SamInputResource of(final SeekableStream seekableStream) { return new SamInputResource(new SeekableStreamInputResource(seekableStream)); }
/** Creates a {@link SamInputResource} reading from the provided resource, with no index. */ public static SamInputResource of(final InputStream inputStream) { return new SamInputResource(new InputStreamInputResource(inputStream)); }
public static SamInputResource of(final SRAAccession acc) { return new SamInputResource(new SRAInputResource(acc)); }
private static SamInputResource createSamForIntAttr(long value) { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream ps = new PrintStream(baos); ps.println("@HD\tVN:1.0"); ps.print("1\t4\t*\t0\t0\t*\t*\t0\t0\tA\t<\tUI:i:"); ps.println(value); ps.close(); return new SamInputResource(new InputStreamInputResource(new ByteArrayInputStream(baos.toByteArray()))); }
@Test public void queryStreamingPathBamWithFileIndex() throws IOException { InputResource bam = new NeverFilePathInputResource(localBam.toPath()); InputResource index = new FileInputResource(localBamIndex); final SamInputResource resource = new SamInputResource(bam, index); queryInputResourcePermutation(new SamInputResource(bam, index)); }
@Test public void checkHasIndexForStreamingPathBamWithFileIndex() throws IOException { InputResource bam = new NeverFilePathInputResource(localBam.toPath()); InputResource index = new FileInputResource(localBamIndex); // ensure that the index is being used, not checked in queryInputResourcePermutation try (final SamReader reader = SamReaderFactory.makeDefault().open(new SamInputResource(bam, index))) { Assert.assertTrue(reader.hasIndex()); } }
@DataProvider public Object[][] composeAllPermutationsOfSamInputResource() { final List<SamInputResource> sources = new ArrayList<>(); for (final InputResource.Type dataType : InputResource.Type.values()) { if (dataType.equals(InputResource.Type.SRA_ACCESSION)) continue; sources.add(new SamInputResource(composeInputResourceForType(dataType, false))); for (final InputResource.Type indexType : InputResource.Type.values()) { if (indexType.equals(InputResource.Type.SRA_ACCESSION)) continue; sources.add(new SamInputResource( composeInputResourceForType(dataType, false), composeInputResourceForType(indexType, true) )); } } final Object[][] data = new Object[sources.size()][]; for (final SamInputResource source : sources) { data[sources.indexOf(source)] = new Object[]{source}; } return data; }