Search in sources :

Example 6 with BBFileReader

use of org.broad.igv.bbfile.BBFileReader in project jvarkit by lindenb.

the class Biostar105754 method doWork.

@Override
public int doWork(final List<String> args) {
    if (this.bigWigFile == null) {
        LOG.error("Big wig file undefined option");
        return -1;
    }
    try {
        LOG.info("Opening " + this.bigWigFile);
        this.bbFileReader = new BBFileReader(this.bigWigFile);
        if (!this.bbFileReader.isBigWigFile()) {
            LOG.error("File " + this.bigWigFile + " is not a bigwig file");
            return -1;
        }
        this.out = super.openFileOrStdoutAsPrintWriter(outputFile);
        if (args.isEmpty()) {
            final BufferedReader r = IOUtils.openStdinForBufferedReader();
            run(r);
            CloserUtil.close(r);
        } else {
            for (final String filename : args) {
                final BufferedReader r = IOUtils.openURIForBufferedReading(filename);
                run(r);
                CloserUtil.close(r);
            }
        }
        this.out.flush();
        this.out.close();
        return RETURN_OK;
    } catch (final Exception err) {
        LOG.error(err);
        return -1;
    } finally {
        CloserUtil.close(bbFileReader);
        CloserUtil.close(this.out);
        bbFileReader = null;
        this.out = null;
    }
}
Also used : BBFileReader(org.broad.igv.bbfile.BBFileReader) BufferedReader(java.io.BufferedReader) IOException(java.io.IOException)

Aggregations

BBFileReader (org.broad.igv.bbfile.BBFileReader)6 BigWigIterator (org.broad.igv.bbfile.BigWigIterator)3 BedFeature (org.broad.igv.bbfile.BedFeature)2 BigBedIterator (org.broad.igv.bbfile.BigBedIterator)2 WigItem (org.broad.igv.bbfile.WigItem)2 SeekableStreamAdaptor (com.github.lindenb.jvarkit.util.igv.SeekableStreamAdaptor)1 VcfIterator (com.github.lindenb.jvarkit.util.vcf.VcfIterator)1 SeekableStream (htsjdk.samtools.seekablestream.SeekableStream)1 VariantContext (htsjdk.variant.variantcontext.VariantContext)1 VariantContextBuilder (htsjdk.variant.variantcontext.VariantContextBuilder)1 VariantContextWriter (htsjdk.variant.variantcontext.writer.VariantContextWriter)1 VCFHeader (htsjdk.variant.vcf.VCFHeader)1 VCFInfoHeaderLine (htsjdk.variant.vcf.VCFInfoHeaderLine)1 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 Test (org.junit.Test)1