Examples of SeekableStream


Examples of htsjdk.samtools.seekablestream.SeekableStream

        //long fileLength = Integer.MAX_VALUE / 2;
        long bytesToRead = fileLength;

        String path = "/dev/zero";

        SeekableStream ss = null;
        //Path doesn't exist on windows
        try{
            ss = new MaxLengthSeekableStream(path, fileLength);
        }catch(FileNotFoundException e){
            Assume.assumeNoException(e);
View Full Code Here

Examples of htsjdk.samtools.seekablestream.SeekableStream


    @Test
    public void testReadStreamUnknownLength() throws Exception{
        File inFile = testFile;
        SeekableStream ss = new UnknownLengthSeekableStream(inFile);

    }
View Full Code Here

Examples of htsjdk.samtools.seekablestream.SeekableStream

     *
     * @throws IOException
     */
    private byte[] readBytes(long posStart, long posEnd) throws IOException {

        SeekableStream ss = null;
        try {
            ss = IGVSeekableStreamFactory.getInstance().getStreamFor(path);
            int nBytes = (int) (posEnd - posStart);
            byte[] bytes = new byte[nBytes];
            ss.seek(posStart);
            ss.readFully(bytes);
            return bytes;
        } finally {
            if (ss != null) {
                ss.close();
            }
        }
    }
View Full Code Here

Examples of htsjdk.samtools.seekablestream.SeekableStream

    public byte[] getSequence(String chr, int start, int end) {

        String fn = getChrFileName(chr);
        String seqFile = dirPath + fn;

        SeekableStream is = null;
        try {


            is = IGVSeekableStreamFactory.getInstance().getStreamFor(seqFile);

            byte[] bytes = new byte[end - start];
            is.seek(start);
            is.read(bytes);
            return bytes;

        } catch (Exception ex) {
            log.error("Error reading genome sequence from: " + seqFile, ex);
            return null;
        } finally {
            if (is != null) {
                try {
                    is.close();
                } catch (IOException ex) {
                    log.error("Error closing sequence file.", ex);
                }
            }
        }
View Full Code Here

Examples of htsjdk.samtools.seekablestream.SeekableStream

            final String host = url.getHost();

            if (byteRangeTestMap.containsKey(host)) {
                return byteRangeTestMap.get(host);
            } else {
                SeekableStream str = null;
                try {
                    boolean byteRangeTestSuccess = true;

                    if (host.contains("broadinstitute.org")) {
                        byteRangeTestSuccess = testBroadHost(host);
                    } else {
                        // Non-broad URL
                        int l = (int) Math.min(1000, HttpUtils.getInstance().getContentLength(url));
                        if (l > 100) {

                            byte[] firstBytes = new byte[l];
                            str = new IGVSeekableHTTPStream(url);
                            str.readFully(firstBytes);

                            int end = firstBytes.length;
                            int start = end - 100;
                            str.seek(start);
                            int len = end - start;
                            byte[] buffer = new byte[len];
                            int n = 0;
                            while (n < len) {
                                int count = str.read(buffer, n, len - n);
                                if (count < 0)
                                    throw new EOFException();
                                n += count;
                            }

                            for (int i = 0; i < len; i++) {
                                if (buffer[i] != firstBytes[i + start]) {
                                    byteRangeTestSuccess = false;
                                    break;
                                }
                            }
                        } else {
                            // Too small a sample to test, or unknown content length.  Return "true" but don't record
                            // this host as tested.
                            return true;
                        }
                    }

                    if (byteRangeTestSuccess) {
                        log.info("Range-byte request succeeded");
                    } else {
                        log.info("Range-byte test failed -- problem with client network environment.");
                    }

                    byteRangeTestMap.put(host, byteRangeTestSuccess);
                    return byteRangeTestSuccess;


                } catch (IOException e) {
                    log.error("Error while testing byte range " + e.getMessage());
                    // We could not reach the test server, so we can't know if this client can do byte-range tests or
                    // not.  Take the "optimistic" view.
                    return true;
                } finally {
                    if (str != null) try {
                        str.close();
                    } catch (IOException e) {
                        log.error("Error closing stream (" + url.toExternalForm() + ")", e);
                    }
                }
            }
View Full Code Here

Examples of net.sf.samtools.util.SeekableStream

    }

    if (filePointers == null || filePointers.length == 0)
      return emptyIterator;

    SeekableStream s = null;
    if (file != null) {
      try {
        s = new SeekableFileStream(file);
      } catch (FileNotFoundException e) {
        throw new RuntimeException(e);
      }
    } else if (is instanceof SeekableStream)
      s = (SeekableStream) is;

    SAMIterator si = null;
    try {
      s.seek(0);
      si = new SAMIterator(s, referenceSequenceFile);
      si.setValidationStringency(validationStringency);
      it = si;
    } catch (IOException e) {
      throw new RuntimeEOFException(e);
    }

    Container c = null;
    for (int i = 0; i < filePointers.length; i += 2) {
      long containerOffset = filePointers[i] >>> 16;
      int sliceIndex = (int) ((filePointers[i] << 48) >>> 48);
      try {
        s.seek(containerOffset);
        // the following is not optimal because this is container-level
        // access, not slice:

        // CountingInputStream cis = new CountingInputStream(s) ;
        c = ReadWrite.readContainerHeader(s);
        // long headerSize = cis.getCount() ;
        // int sliceOffset = c.landmarks[sliceIndex] ;
        if (c.alignmentStart + c.alignmentSpan > start) {
          s.seek(containerOffset);
          // s.seek(containerOffset + headerSize + sliceOffset);
          return si;
        }
      } catch (IOException e) {
        throw new RuntimeException(e);
View Full Code Here

Examples of org.apache.batik.ext.awt.image.codec.SeekableStream

        Thread t = new Thread() {
                public void run() {
                    Filter filt;
                    try {
                        TIFFDecodeParam param = new TIFFDecodeParam();
                        SeekableStream ss =
                            SeekableStream.wrapInputStream(is, true);
                        CachableRed cr = new TIFFImage(ss, param, 0);
                        cr = new Any2sRGBRed(cr);
                        filt = new RedRable(cr);
                    } catch (IOException ioe) {
View Full Code Here

Examples of org.apache.batik.ext.awt.image.codec.SeekableStream

        Thread t = new Thread() {
                public void run() {
                    Filter filt;
                    try {
                        TIFFDecodeParam param = new TIFFDecodeParam();
                        SeekableStream ss =
                            SeekableStream.wrapInputStream(is, true);
                        CachableRed cr = new TIFFImage(ss, param, 0);
                        cr = new Any2sRGBRed(cr);
                        filt = new RedRable(cr);
                    } catch (IOException ioe) {
View Full Code Here

Examples of org.apache.batik.ext.awt.image.codec.util.SeekableStream

        Thread t = new Thread() {
                public void run() {
                    Filter filt;
                    try {
                        TIFFDecodeParam param = new TIFFDecodeParam();
                        SeekableStream ss =
                            SeekableStream.wrapInputStream(is, true);
                        CachableRed cr = new TIFFImage(ss, param, 0);
                        cr = new Any2sRGBRed(cr);
                        filt = new RedRable(cr);
                    } catch (IOException ioe) {
View Full Code Here

Examples of org.apache.flex.forks.batik.ext.awt.image.codec.SeekableStream

        Thread t = new Thread() {
                public void run() {
                    Filter filt;
                    try {
                        TIFFDecodeParam param = new TIFFDecodeParam();
                        SeekableStream ss =
                            SeekableStream.wrapInputStream(is, true);
                        CachableRed cr = new TIFFImage(ss, param, 0);
                        cr = new Any2sRGBRed(cr);
                        filt = new RedRable(cr);
                    } catch (IOException ioe) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.