public RegionCoverage coverage(Region region, int windowSize) throws IOException, AlignmentCoverageException {
        if (Paths.get(bamFile.toString() + ".bw").toFile().exists()) {
            return BamUtils.getCoverageFromBigWig(region, windowSize, Paths.get(bamFile.toString() + ".bw"));
        } else {
            if (Paths.get(bamFile.toString() + COVERAGE_BIGWIG_EXTENSION).toFile().exists()) {
                return BamUtils.getCoverageFromBigWig(region, windowSize, Paths.get(this.bamFile.toString() + COVERAGE_BIGWIG_EXTENSION));
            } else {
                // If BigWig file is not found and windowSize is 1 then we calculate it from the BAM file
                if (windowSize == 1) {
                    return coverage(region, null, new AlignmentOptions());
                } else {
                    throw new AlignmentCoverageException("No bigwig file has been found and windowSize is > 1");
                }
            }
        }
    }
public RegionCoverage coverage ( Region region , int windowSize ) throws IOException , AlignmentCoverageException { if ( Paths . get ( bamFile . toString ( ) + ".bw" ) . toFile ( ) . exists ( ) ) { return BamUtils . getCoverageFromBigWig ( region , windowSize , Paths . get ( bamFile . toString ( ) + ".bw" ) ) ; } else { if ( Paths . get ( bamFile . toString ( ) + COVERAGE_BIGWIG_EXTENSION ) . toFile ( ) . exists ( ) ) { return BamUtils . getCoverageFromBigWig ( region , windowSize , Paths . get ( this . bamFile . toString ( ) + COVERAGE_BIGWIG_EXTENSION ) ) ; } else { if ( windowSize == 1 ) { return coverage ( region , null , new AlignmentOptions ( ) ) ; } else { throw new AlignmentCoverageException ( "No bigwig file has been found and windowSize is > 1" ) ; } } } }
Return the coverage average given a window size from a BigWig file. This is expected to have the same name
that the BAM file with .coverage.bw or .bw suffix.
If no BigWig file is found and windowSize is 1 then we calculate te coverage from the BAM file.
@param region Region from which return the coverage
@param windowSize Window size to average
@return One average score per window size spanning the region
@throws IOException If any error happens reading BigWig file