Package htsjdk.samtools.seekablestream

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


            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

                        URL url = new URL(path);
                        listFileName = (new File(url.getPath())).getName();
                    } else {
                        listFileName = (new File(path)).getName();
                    }
                    SeekableStream stream = IGVSeekableStreamFactory.getInstance().getStreamFor(path.replace(listFileName, p));

                    long length = Long.parseLong(tokens[1]);
                    descriptors.add(new SeekableSplitStream.PartDescriptor(length, stream));
                } else {
                    // TODO -- throw exception, or warning?
View Full Code Here

        for (Interval iv : intervals) {
            startPosition = Math.min(startPosition, iv.getValue());
        }


        SeekableStream is = null;


        is = IGVSeekableStreamFactory.getInstance().getStreamFor(path);
        is.seek(startPosition);

        BufferedReader reader = new BufferedReader(new InputStreamReader(is), 256000);

        List<MultipleAlignmentBlock> alignments = new ArrayList<MultipleAlignmentBlock>();
View Full Code Here

        if (path.endsWith(".list")) {
            return new SeekableSplitStream(path);

        } else {
            SeekableStream is = null;
            if (path.toLowerCase().startsWith("http:") || path.toLowerCase().startsWith("https:")) {
                final URL url = new URL(path);
                boolean useByteRange = HttpUtils.getInstance().useByteRange(url);
                if (useByteRange) {
                    is = new IGVSeekableHTTPStream(url);
View Full Code Here

            int skipColumns = hasCalls ? 2 : 1;

            // Get an estimate of the number of snps (rows).  THIS IS ONLY AN ESTIMATE
            int nRowsEst = chrSummary.getNDataPts();

            SeekableStream is = IGVSeekableStreamFactory.getInstance().getStreamFor(dataResourceLocator.getPath());
            is.seek(chrSummary.getStartPosition());
            AsciiLineReader reader = new AsciiLineReader(is);


            // Create containers to hold data
            IntArrayList startLocations = new IntArrayList(nRowsEst);
View Full Code Here

TOP

Related Classes of htsjdk.samtools.seekablestream.SeekableStream

Copyright © 2018 www.massapicom. 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.