Search in sources :

Example 6 with RuntimeIOException

use of htsjdk.samtools.util.RuntimeIOException in project jvarkit by lindenb.

the class VcfBiomart method doVcfToVcf.

@Override
protected int doVcfToVcf(final String inputName, final VcfIterator iter, final VariantContextWriter out) {
    HttpGet httpGet = null;
    final Pattern tab = Pattern.compile("[\t]");
    try {
        final TransformerFactory factory = TransformerFactory.newInstance();
        final Transformer transformer = factory.newTransformer();
        // transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
        final VCFHeader header = iter.getHeader();
        StringBuilder desc = new StringBuilder("Biomart query. Format: ");
        desc.append(this.attributes.stream().map(S -> this.printLabels ? S + "|" + S : S).collect(Collectors.joining("|")));
        header.addMetaDataLine(new VCFHeaderLine(getClass().getSimpleName() + "CmdLine", String.valueOf(getProgramCommandLine())));
        header.addMetaDataLine(new VCFHeaderLine(getClass().getSimpleName() + "Version", String.valueOf(getVersion())));
        header.addMetaDataLine(new VCFInfoHeaderLine(this.TAG, VCFHeaderLineCount.UNBOUNDED, VCFHeaderLineType.String, desc.toString()));
        out.writeHeader(header);
        final SAMSequenceDictionaryProgress progress = new SAMSequenceDictionaryProgress(header).logger(LOG);
        while (iter.hasNext()) {
            final VariantContext ctx = progress.watch(iter.next());
            final VariantContextBuilder vcb = new VariantContextBuilder(ctx);
            vcb.rmAttribute(this.TAG);
            this.filterColumnContig.set(ctx.getContig());
            this.filterColumnStart.set(String.valueOf(ctx.getStart()));
            this.filterColumnEnd.set(String.valueOf(ctx.getEnd()));
            final StringWriter domToStr = new StringWriter();
            transformer.transform(new DOMSource(this.domQuery), new StreamResult(domToStr));
            final URIBuilder builder = new URIBuilder(this.serviceUrl);
            builder.addParameter("query", domToStr.toString());
            // System.err.println("\nwget -O - 'http://grch37.ensembl.org/biomart/martservice?query="+escapedQuery+"'\n");
            // escapedQuery = URLEncoder.encode(escapedQuery,"UTF-8");
            httpGet = new HttpGet(builder.build());
            final CloseableHttpResponse httpResponse = httpClient.execute(httpGet);
            int responseCode = httpResponse.getStatusLine().getStatusCode();
            if (responseCode != 200) {
                throw new RuntimeIOException("Response code was not 200. Detected response was " + responseCode);
            }
            InputStream response = httpResponse.getEntity().getContent();
            if (this.teeResponse) {
                response = new TeeInputStream(response, stderr(), false);
            }
            final BufferedReader br = new BufferedReader(new InputStreamReader(response));
            final Set<String> infoAtts = br.lines().filter(L -> !StringUtil.isBlank(L)).filter(L -> !L.equals("[success]")).map(L -> tab.split(L)).map(T -> {
                final StringBuilder sb = new StringBuilder();
                for (int i = 0; i < this.attributes.size(); i++) {
                    if (i > 0)
                        sb.append("|");
                    if (this.printLabels)
                        sb.append(escapeInfo(this.attributes.get(i))).append("|");
                    sb.append(i < T.length ? escapeInfo(T[i]) : "");
                }
                return sb.toString();
            }).collect(Collectors.toCollection(LinkedHashSet::new));
            CloserUtil.close(br);
            CloserUtil.close(response);
            CloserUtil.close(httpResponse);
            if (!infoAtts.isEmpty()) {
                vcb.attribute(this.TAG, new ArrayList<>(infoAtts));
            }
            out.add(vcb.make());
        }
        progress.finish();
        return 0;
    } catch (final Exception err) {
        LOG.error(err);
        throw new RuntimeIOException(err);
    }
}
Also used : VCFHeaderLine(htsjdk.variant.vcf.VCFHeaderLine) Transformer(javax.xml.transform.Transformer) DOMSource(javax.xml.transform.dom.DOMSource) VCFUtils(com.github.lindenb.jvarkit.util.vcf.VCFUtils) Program(com.github.lindenb.jvarkit.util.jcommander.Program) Parameter(com.beust.jcommander.Parameter) VCFHeader(htsjdk.variant.vcf.VCFHeader) StreamResult(javax.xml.transform.stream.StreamResult) SAMSequenceDictionaryProgress(com.github.lindenb.jvarkit.util.picard.SAMSequenceDictionaryProgress) Attr(org.w3c.dom.Attr) ArrayList(java.util.ArrayList) StringUtil(htsjdk.samtools.util.StringUtil) RuntimeIOException(htsjdk.samtools.util.RuntimeIOException) Document(org.w3c.dom.Document) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) Node(org.w3c.dom.Node) Launcher(com.github.lindenb.jvarkit.util.jcommander.Launcher) LinkedHashSet(java.util.LinkedHashSet) CloserUtil(htsjdk.samtools.util.CloserUtil) TeeInputStream(com.github.lindenb.jvarkit.io.TeeInputStream) VCFHeaderLineType(htsjdk.variant.vcf.VCFHeaderLineType) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) URIBuilder(org.apache.http.client.utils.URIBuilder) StringWriter(java.io.StringWriter) Logger(com.github.lindenb.jvarkit.util.log.Logger) VcfIterator(com.github.lindenb.jvarkit.util.vcf.VcfIterator) Set(java.util.Set) InputStreamReader(java.io.InputStreamReader) Collectors(java.util.stream.Collectors) File(java.io.File) List(java.util.List) Element(org.w3c.dom.Element) HttpGet(org.apache.http.client.methods.HttpGet) VariantContextWriter(htsjdk.variant.variantcontext.writer.VariantContextWriter) DocumentBuilder(javax.xml.parsers.DocumentBuilder) VCFInfoHeaderLine(htsjdk.variant.vcf.VCFInfoHeaderLine) VariantContext(htsjdk.variant.variantcontext.VariantContext) BufferedReader(java.io.BufferedReader) Pattern(java.util.regex.Pattern) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) TransformerFactory(javax.xml.transform.TransformerFactory) VCFHeaderLineCount(htsjdk.variant.vcf.VCFHeaderLineCount) VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) HttpClients(org.apache.http.impl.client.HttpClients) InputStream(java.io.InputStream) VCFHeaderLine(htsjdk.variant.vcf.VCFHeaderLine) DOMSource(javax.xml.transform.dom.DOMSource) Transformer(javax.xml.transform.Transformer) HttpGet(org.apache.http.client.methods.HttpGet) VariantContext(htsjdk.variant.variantcontext.VariantContext) StringWriter(java.io.StringWriter) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse) VCFHeader(htsjdk.variant.vcf.VCFHeader) Pattern(java.util.regex.Pattern) RuntimeIOException(htsjdk.samtools.util.RuntimeIOException) TransformerFactory(javax.xml.transform.TransformerFactory) SAMSequenceDictionaryProgress(com.github.lindenb.jvarkit.util.picard.SAMSequenceDictionaryProgress) StreamResult(javax.xml.transform.stream.StreamResult) InputStreamReader(java.io.InputStreamReader) TeeInputStream(com.github.lindenb.jvarkit.io.TeeInputStream) InputStream(java.io.InputStream) TeeInputStream(com.github.lindenb.jvarkit.io.TeeInputStream) VCFInfoHeaderLine(htsjdk.variant.vcf.VCFInfoHeaderLine) RuntimeIOException(htsjdk.samtools.util.RuntimeIOException) URIBuilder(org.apache.http.client.utils.URIBuilder) VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) BufferedReader(java.io.BufferedReader)

Example 7 with RuntimeIOException

use of htsjdk.samtools.util.RuntimeIOException in project jvarkit by lindenb.

the class VcfEnsemblVepRest method callVepToDom.

/**
 * send a pool of variants to VEP, returns the DOM document
 */
private Document callVepToDom(final List<VariantContext> contexts, boolean xml_answer) throws IOException {
    LOG.info("Running VEP " + contexts.size());
    InputStream response = null;
    HttpPost httpPost = null;
    try {
        if (this.lastMillisec != -1L && this.lastMillisec + 5000 < System.currentTimeMillis()) {
            LOG.debug("waiting");
            try {
                Thread.sleep(1000);
            } catch (Exception err) {
            }
        }
        httpPost = new HttpPost(this.server + this.extension);
        final StringBuilder queryb = new StringBuilder();
        queryb.append("{ \"variants\" : [");
        for (int i = 0; i < contexts.size(); ++i) {
            final VariantContext ctx = contexts.get(i);
            if (i > 0)
                queryb.append(",");
            queryb.append("\"").append(createInputContext(ctx)).append("\"");
        }
        queryb.append("]");
        for (final String s : new String[] { "canonical", "ccds", "domains", "hgvs", "numbers", "protein", "xref_refseq", "tsl", "uniprot" }) {
            queryb.append(",\"").append(s).append("\":1");
        }
        queryb.append("}");
        final byte[] postBody = queryb.toString().getBytes();
        httpPost.setHeader("Content-Type", ContentType.APPLICATION_JSON.getMimeType());
        httpPost.setHeader("Accept", ContentType.TEXT_XML.getMimeType());
        // httpPost.setHeader("Content-Length", Integer.toString(postBody.length));
        httpPost.setEntity(new ByteArrayEntity(postBody, ContentType.APPLICATION_JSON));
        final CloseableHttpResponse httpResponse = httpClient.execute(httpPost);
        int responseCode = httpResponse.getStatusLine().getStatusCode();
        if (responseCode != 200) {
            throw new RuntimeIOException("Response code was not 200. Detected response was " + responseCode);
        }
        // response = new TeeInputStream( httpConnection.getInputStream(),System.err,false);
        response = httpResponse.getEntity().getContent();
        if (this.teeResponse) {
            stderr().println(queryb);
            response = new TeeInputStream(response, stderr(), false);
        }
        final Document dom = documentBuilder.parse(response);
        return dom;
    } catch (final Throwable err) {
        if (this.ignoreNetworkErrors) {
            LOG.error(err);
            return documentBuilder.newDocument();
        }
        throw new IOException(err);
    } finally {
        CloserUtil.close(response);
        if (httpPost != null)
            httpPost.releaseConnection();
        this.lastMillisec = System.currentTimeMillis();
    }
}
Also used : HttpPost(org.apache.http.client.methods.HttpPost) RuntimeIOException(htsjdk.samtools.util.RuntimeIOException) TeeInputStream(com.github.lindenb.jvarkit.io.TeeInputStream) InputStream(java.io.InputStream) VariantContext(htsjdk.variant.variantcontext.VariantContext) RuntimeIOException(htsjdk.samtools.util.RuntimeIOException) IOException(java.io.IOException) TeeInputStream(com.github.lindenb.jvarkit.io.TeeInputStream) Document(org.w3c.dom.Document) TransformerException(javax.xml.transform.TransformerException) RuntimeIOException(htsjdk.samtools.util.RuntimeIOException) IOException(java.io.IOException) ByteArrayEntity(org.apache.http.entity.ByteArrayEntity) CloseableHttpResponse(org.apache.http.client.methods.CloseableHttpResponse)

Example 8 with RuntimeIOException

use of htsjdk.samtools.util.RuntimeIOException in project jvarkit by lindenb.

the class VcfDerby01 method openDerby.

private void openDerby() {
    try {
        boolean create;
        final Properties props = new Properties();
        final File derbyDir = getDerbyDirectory();
        LOG.info("open derby :" + getDerbyDirectory());
        if (derbyDir.exists()) {
            if (!derbyDir.isDirectory()) {
                throw new RuntimeIOException("derby database is not a directory : " + derbyDir);
            }
            if (derbyDir.listFiles(new FileFilter() {

                @Override
                public boolean accept(File pathname) {
                    if (pathname.isFile()) {
                        if (pathname.getName().equals("service.properties"))
                            return true;
                        if (pathname.getName().equals("README_DO_NOT_TOUCH_FILES.txt"))
                            return true;
                    }
                    if (pathname.isDirectory()) {
                        if (pathname.getName().startsWith("log"))
                            return true;
                    }
                    return false;
                }
            }).length == 0) {
                throw new RuntimeIOException("derby database exist but doesn't look like a derby directory : " + derbyDir);
            }
            create = false;
        } else {
            create = true;
        }
        props.setProperty("create", String.valueOf(create));
        this.conn = DriverManager.getConnection("jdbc:derby:" + derbyDir, props);
        if (create) {
            final String tableId = "ID INTEGER NOT NULL GENERATED ALWAYS AS IDENTITY (START WITH 1, INCREMENT BY 1) PRIMARY KEY";
            final Statement stmt = this.conn.createStatement();
            final String[] sqls = { "CREATE TABLE ROWCONTENT(" + tableId + ",MD5SUM CHAR(32) UNIQUE,CONTENT CLOB,CONTIG VARCHAR(20),FILTERED SMALLINT NOT NULL,START INT,STOP INT,ALLELE_REF VARCHAR(" + MAX_REF_BASE_LENGTH + "))", "CREATE TABLE VCF(" + tableId + ",NAME VARCHAR(255))", "CREATE TABLE VCFROW(" + tableId + ",VCF_ID INTEGER CONSTRAINT row2vcf REFERENCES VCF,ROW_ID INTEGER CONSTRAINT row2content REFERENCES ROWCONTENT)" };
            for (final String sql : sqls) {
                LOG.warn(sql);
                stmt.execute(sql);
            }
            stmt.close();
        }
        this.conn.setAutoCommit(true);
    } catch (Exception e) {
        CloserUtil.close(this.conn);
        this.conn = null;
        throw new RuntimeException(e);
    }
}
Also used : RuntimeIOException(htsjdk.samtools.util.RuntimeIOException) PreparedStatement(java.sql.PreparedStatement) Statement(java.sql.Statement) Properties(java.util.Properties) FileFilter(java.io.FileFilter) File(java.io.File) SQLException(java.sql.SQLException) RuntimeIOException(htsjdk.samtools.util.RuntimeIOException)

Example 9 with RuntimeIOException

use of htsjdk.samtools.util.RuntimeIOException in project jvarkit by lindenb.

the class VcfAnnotWithBeacon method doVcfToVcf.

@Override
protected int doVcfToVcf(String inputName, final VcfIterator iter, final VariantContextWriter out) {
    CloseableHttpClient httpClient = null;
    InputStream contentInputStream = null;
    try {
        final org.apache.http.impl.client.HttpClientBuilder hb = HttpClients.custom();
        if (this.ignoreCertErrors) {
            // http://stackoverflow.com/questions/24720013/apache-http-client-ssl-certificate-error
            System.setProperty("jsse.enableSNIExtension", "false");
            final SSLContext sslContext = org.apache.http.conn.ssl.SSLContexts.custom().loadTrustMaterial(null, new org.apache.http.conn.ssl.TrustStrategy() {

                @Override
                public boolean isTrusted(final X509Certificate[] chain, final String authType) throws CertificateException {
                    return true;
                }
            }).useTLS().build();
            final org.apache.http.conn.ssl.SSLConnectionSocketFactory connectionFactory = new org.apache.http.conn.ssl.SSLConnectionSocketFactory(sslContext, new org.apache.http.conn.ssl.AllowAllHostnameVerifier());
            hb.setSSLSocketFactory(connectionFactory);
        }
        httpClient = hb.build();
        HttpGet httpGetRequest = null;
        final Set<String> available_chromosomes = new HashSet<>();
        try {
            httpGetRequest = new HttpGet(baseurl + "/chromosomes");
            httpGetRequest.setHeader("Accept", ContentType.APPLICATION_JSON.getMimeType());
            contentInputStream = httpClient.execute(httpGetRequest).getEntity().getContent();
            JsonParser jsonparser = new JsonParser();
            final JsonElement root = jsonparser.parse(new InputStreamReader(contentInputStream));
            Iterator<JsonElement> jsr = root.getAsJsonArray().iterator();
            while (jsr.hasNext()) {
                final String ctg = jsr.next().getAsString();
                available_chromosomes.add(ctg);
            }
            LOG.debug(available_chromosomes);
        } catch (final Exception err) {
            LOG.error(err);
            return -1;
        } finally {
            CloserUtil.close(contentInputStream);
        }
        final Set<String> available_alleles = new HashSet<>();
        try {
            httpGetRequest = new HttpGet(baseurl + "/alleles");
            httpGetRequest.setHeader("Accept", ContentType.APPLICATION_JSON.getMimeType());
            contentInputStream = httpClient.execute(httpGetRequest).getEntity().getContent();
            JsonParser jsonparser = new JsonParser();
            final JsonElement root = jsonparser.parse(new InputStreamReader(contentInputStream));
            Iterator<JsonElement> jsr = root.getAsJsonArray().iterator();
            while (jsr.hasNext()) {
                final String allele = jsr.next().getAsString();
                available_alleles.add(allele);
            }
            LOG.debug(available_alleles);
        } catch (final Exception err) {
            LOG.error(err);
            return -1;
        } finally {
            CloserUtil.close(contentInputStream);
        }
        final StoredResponseBinding storedResponseBinding = new StoredResponseBinding();
        final VCFHeader header = new VCFHeader(iter.getHeader());
        final VCFInfoHeaderLine infoHeaderLine = new VCFInfoHeaderLine(this.infoTag, VCFHeaderLineCount.UNBOUNDED, VCFHeaderLineType.String, "Tag inserted with " + getProgramName());
        header.addMetaDataLine(infoHeaderLine);
        DatabaseEntry key = new DatabaseEntry();
        DatabaseEntry data = new DatabaseEntry();
        out.writeHeader(header);
        while (iter.hasNext()) {
            final VariantContext ctx = iter.next();
            if (!ctx.isVariant() || ctx.getReference().isSymbolic()) {
                out.add(ctx);
                continue;
            }
            if (ctx.hasAttribute(infoHeaderLine.getID()) && this.dontUpdateIfInfoIsPresent) {
                out.add(ctx);
                continue;
            }
            String beaconContig = ctx.getContig();
            if (!available_chromosomes.contains(beaconContig)) {
                if (beaconContig.startsWith("chr")) {
                    beaconContig = beaconContig.substring(3);
                }
                if (!available_chromosomes.contains(beaconContig)) {
                    out.add(ctx);
                    continue;
                }
            }
            final List<Allele> altAlleles = ctx.getAlternateAlleles();
            if (altAlleles.isEmpty()) {
                out.add(ctx);
                continue;
            }
            final Set<String> newInfo = new HashSet<>();
            for (final Allele alt : altAlleles) {
                if (alt.isSymbolic() || alt.isNoCall())
                    continue;
                final StringBuilder buildUrl = new StringBuilder();
                buildUrl.append("chrom=");
                buildUrl.append(URLEncoder.encode(beaconContig, "UTF-8"));
                buildUrl.append("&pos=");
                /*
					 * "Coordinate within a chromosome. Position is a number and is 0-based"
					 * .
					 */
                buildUrl.append(ctx.getStart() - 1);
                buildUrl.append("&allele=");
                final String allele;
                if (ctx.getReference().length() > alt.length()) {
                    // del
                    allele = "D";
                } else if (ctx.getReference().length() > alt.length()) {
                    // ins
                    allele = "I";
                } else {
                    allele = alt.getDisplayString();
                }
                if (!available_alleles.contains(allele))
                    continue;
                buildUrl.append(allele);
                buildUrl.append("&ref=");
                buildUrl.append(URLEncoder.encode(this.genomeBuild, "UTF-8"));
                final String queryUrl = buildUrl.toString();
                boolean foundInBdb = false;
                Set<String> foundIn = null;
                if (this.beaconDatabase != null) {
                    StringBinding.stringToEntry(queryUrl, key);
                    if (this.beaconDatabase.get(this.txn, key, data, LockMode.DEFAULT) == OperationStatus.SUCCESS) {
                        StoredResponse response = storedResponseBinding.entryToObject(data);
                        if (// TODO check how old is
                        response.timeStamp < 0) // that data
                        {
                            response = null;
                            this.beaconDatabase.delete(this.txn, key);
                        }
                        if (response != null) {
                            foundInBdb = true;
                            foundIn = response.foundIn;
                        }
                    }
                }
                if (foundIn == null) {
                    foundIn = new HashSet<>();
                    try {
                        httpGetRequest = new HttpGet(baseurl + "/responses?" + queryUrl);
                        httpGetRequest.setHeader("Accept", ContentType.APPLICATION_JSON.getMimeType());
                        LOG.debug(httpGetRequest.getURI());
                        contentInputStream = httpClient.execute(httpGetRequest).getEntity().getContent();
                        JsonParser jsonparser = new JsonParser();
                        final JsonElement root = jsonparser.parse(new InputStreamReader(contentInputStream));
                        Iterator<JsonElement> jsr = root.getAsJsonArray().iterator();
                        while (jsr.hasNext()) {
                            final JsonObject b = jsr.next().getAsJsonObject();
                            if (!(b.has("beacon") && b.has("response")))
                                continue;
                            final String beacon_id = b.get("beacon").getAsJsonObject().get("id").getAsString();
                            final JsonElement response_prim = b.get("response");
                            if (response_prim.isJsonPrimitive() && response_prim.getAsBoolean()) {
                                foundIn.add(beacon_id);
                            }
                        }
                    } catch (final Exception err) {
                        LOG.error(err);
                        if (stopOnNetworkError) {
                            throw new RuntimeIOException(err);
                        }
                    } finally {
                        CloserUtil.close(contentInputStream);
                    }
                }
                if (this.beaconDatabase != null && !foundInBdb) {
                    StoredResponse response = new StoredResponse();
                    response.timeStamp = System.currentTimeMillis();
                    response.foundIn = foundIn;
                }
                // 17&pos=41244981&=G&ref=GRCh37")
                newInfo.addAll(foundIn.stream().map(S -> alt.getDisplayString() + "|" + S).collect(Collectors.toSet()));
            }
            if (newInfo.isEmpty()) {
                out.add(ctx);
                continue;
            }
            final VariantContextBuilder vcb = new VariantContextBuilder(ctx);
            vcb.attribute(infoHeaderLine.getID(), new ArrayList<String>(newInfo));
            out.add(vcb.make());
        }
        return 0;
    } catch (final Exception err) {
        LOG.error(err);
        return -1;
    } finally {
        CloserUtil.close(httpClient);
    }
}
Also used : HttpGet(org.apache.http.client.methods.HttpGet) VariantContext(htsjdk.variant.variantcontext.VariantContext) JsonObject(com.google.gson.JsonObject) CertificateException(java.security.cert.CertificateException) DatabaseEntry(com.sleepycat.je.DatabaseEntry) VCFHeader(htsjdk.variant.vcf.VCFHeader) HashSet(java.util.HashSet) JsonParser(com.google.gson.JsonParser) CloseableHttpClient(org.apache.http.impl.client.CloseableHttpClient) RuntimeIOException(htsjdk.samtools.util.RuntimeIOException) InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) SSLContext(javax.net.ssl.SSLContext) X509Certificate(java.security.cert.X509Certificate) RuntimeIOException(htsjdk.samtools.util.RuntimeIOException) CertificateException(java.security.cert.CertificateException) VCFInfoHeaderLine(htsjdk.variant.vcf.VCFInfoHeaderLine) Allele(htsjdk.variant.variantcontext.Allele) VariantContextBuilder(htsjdk.variant.variantcontext.VariantContextBuilder) JsonElement(com.google.gson.JsonElement)

Example 10 with RuntimeIOException

use of htsjdk.samtools.util.RuntimeIOException in project jvarkit by lindenb.

the class DefaultVcfFileList method get.

@Override
public VariantContext get(final int index) {
    if (index < 0 || index >= this.size())
        throw new IndexOutOfBoundsException("0<" + index + "<" + size() + " in " + vcfFile);
    try {
        final String line;
        if (this.last_list_index == -1 || this.last_list_index + 1 != index) {
            this.indexio.seek((long) VcfOffsetsIndexFactory.MAGIC.length + (long) index * (long) Long.BYTES);
            final long offset = this.indexio.readLong();
            if (this.bgzfin != null) {
                this.bgzfin.seek(offset);
                line = this.bgzfin.readLine();
            } else {
                this.vcfrandom.seek(offset);
                line = this.vcfrandom.readLine();
            }
        } else {
            if (this.bgzfin != null) {
                line = this.bgzfin.readLine();
            } else {
                line = this.vcfrandom.readLine();
            }
        }
        this.last_list_index = index;
        return this.codec.decode(line);
    } catch (final IOException err) {
        throw new RuntimeIOException(err);
    }
}
Also used : RuntimeIOException(htsjdk.samtools.util.RuntimeIOException) IOException(java.io.IOException) RuntimeIOException(htsjdk.samtools.util.RuntimeIOException)

Aggregations

RuntimeIOException (htsjdk.samtools.util.RuntimeIOException)21 IOException (java.io.IOException)11 File (java.io.File)6 List (java.util.List)5 VariantContext (htsjdk.variant.variantcontext.VariantContext)4 JvarkitException (com.github.lindenb.jvarkit.lang.JvarkitException)3 SAMSequenceDictionary (htsjdk.samtools.SAMSequenceDictionary)3 VariantContextBuilder (htsjdk.variant.variantcontext.VariantContextBuilder)3 VCFHeader (htsjdk.variant.vcf.VCFHeader)3 VCFInfoHeaderLine (htsjdk.variant.vcf.VCFInfoHeaderLine)3 InputStream (java.io.InputStream)3 ArrayList (java.util.ArrayList)3 Parameter (com.beust.jcommander.Parameter)2 TeeInputStream (com.github.lindenb.jvarkit.io.TeeInputStream)2 Launcher (com.github.lindenb.jvarkit.util.jcommander.Launcher)2 Program (com.github.lindenb.jvarkit.util.jcommander.Program)2 Logger (com.github.lindenb.jvarkit.util.log.Logger)2 SAMSequenceDictionaryProgress (com.github.lindenb.jvarkit.util.picard.SAMSequenceDictionaryProgress)2 VCFUtils (com.github.lindenb.jvarkit.util.vcf.VCFUtils)2 VcfIterator (com.github.lindenb.jvarkit.util.vcf.VcfIterator)2