Class: Bio::BigWig
- Inherits:
-
Object
- Object
- Bio::BigWig
- Defined in:
- lib/bio/bigwig.rb,
lib/bio/bigwig/version.rb,
ext/bio/bigwig/bigwigext.c
Overview
BigWig/BigBed file reader for Ruby
Constant Summary collapse
- VERSION =
"0.1.0"
Class Method Summary collapse
-
.open(*args, **kwargs) {|BigWig| ... } ⇒ BigWig
Open a BigWig/BigBed file.
Instance Method Summary collapse
-
#chroms(*args) ⇒ Hash, ...
Get chromosome information.
-
#close ⇒ nil
Close the file handle.
-
#closed? ⇒ Boolean
Check if the file is closed.
-
#entries(chrom, start = 0, stop = -1,, with_string: true) ⇒ Array<Array>
Get entries for a genomic region (BigBed files only).
-
#file_type ⇒ String
Get file type.
-
#header ⇒ Hash
Get file header information.
-
#initialize(fname, mode = "r") ⇒ BigWig
constructor
Initialize a BigWig/BigBed file handle.
-
#intervals(chrom, start = 0, stop = -1)) ⇒ Array<Array>
Get intervals for a genomic region.
-
#is_bigbed? ⇒ Boolean
0 = BigWig.
-
#is_bigwig? ⇒ Boolean
Check if file is BigWig format.
-
#path ⇒ String
Get the file path.
-
#sql ⇒ String?
Get SQL schema (BigBed files only).
-
#stats(chrom, start = nil, stop = nil, nbins: nil, type: nil, exact: nil) ⇒ Array<Float>
Get statistics for a genomic region.
-
#values(chrom, start, stop) ⇒ Array<Float>
Get values for a genomic region.
Constructor Details
#initialize(fname, mode = "r") ⇒ BigWig
Initialize a BigWig/BigBed file handle
42 43 44 45 46 47 |
# File 'lib/bio/bigwig.rb', line 42 def initialize(fname, mode = "r") raise "BigWig::new() does not take block; use BigWig::open() instead" if block_given? @fname = fname initialize_raw(fname, mode) end |
Class Method Details
.open(*args, **kwargs) {|BigWig| ... } ⇒ BigWig
Open a BigWig/BigBed file
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/bio/bigwig.rb', line 26 def self.open(*args, **kwargs) file = new(*args, **kwargs) return file unless block_given? begin yield file ensure file.close end file end |
Instance Method Details
#chroms(*args) ⇒ Hash, ...
Get chromosome information
|
# File 'lib/bio/bigwig.rb', line 108
|
#close ⇒ nil
Close the file handle
|
# File 'lib/bio/bigwig.rb', line 100
|
#closed? ⇒ Boolean
Check if the file is closed
|
# File 'lib/bio/bigwig.rb', line 104
|
#entries(chrom, start = 0, stop = -1,, with_string: true) ⇒ Array<Array>
Get entries for a genomic region (BigBed files only)
96 97 98 |
# File 'lib/bio/bigwig.rb', line 96 def entries(chrom, start = 0, stop = -1, with_string: true) entries_raw(chrom, start, stop, with_string) end |
#file_type ⇒ String
Get file type
|
# File 'lib/bio/bigwig.rb', line 117
|
#header ⇒ Hash
Get file header information
|
# File 'lib/bio/bigwig.rb', line 113
|
#intervals(chrom, start = 0, stop = -1)) ⇒ Array<Array>
Get intervals for a genomic region
85 86 87 |
# File 'lib/bio/bigwig.rb', line 85 def intervals(chrom, start = 0, stop = -1) intervals_raw(chrom, start, stop) end |
#is_bigbed? ⇒ Boolean
0 = BigWig
|
# File 'lib/bio/bigwig.rb', line 125
|
#is_bigwig? ⇒ Boolean
Check if file is BigWig format
|
# File 'lib/bio/bigwig.rb', line 121
|
#path ⇒ String
Get the file path
52 53 54 |
# File 'lib/bio/bigwig.rb', line 52 def path @fname end |
#sql ⇒ String?
Get SQL schema (BigBed files only)
|
# File 'lib/bio/bigwig.rb', line 129
|
#stats(chrom, start = nil, stop = nil, nbins: nil, type: nil, exact: nil) ⇒ Array<Float>
Get statistics for a genomic region
65 66 67 |
# File 'lib/bio/bigwig.rb', line 65 def stats(chrom, start = nil, stop = nil, nbins: nil, type: nil, exact: nil) stats_raw(chrom, start, stop, nbins, type&.to_s, exact) end |
#values(chrom, start, stop) ⇒ Array<Float>
Get values for a genomic region
75 76 77 |
# File 'lib/bio/bigwig.rb', line 75 def values(chrom, start, stop) values_raw(chrom, start, stop) end |