Skip to content
This repository has been archived by the owner on Aug 26, 2023. It is now read-only.

Commit

Permalink
extract BigBed types from .rl (#241)
Browse files Browse the repository at this point in the history
  • Loading branch information
bicycle1885 authored Jul 30, 2016
1 parent d1c6071 commit b8e991b
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 97 deletions.
47 changes: 0 additions & 47 deletions src/intervals/bigbed-parser.jl
Original file line number Diff line number Diff line change
@@ -1,22 +1,4 @@
# WARNING: This file was generated from bigbed-parser.rl using ragel. Do not edit!
type BigBedData <: IntervalStream{BEDMetadata}
stream::BufferedInputStream
header::BigBedHeader
zoom_headers::Vector{BigBedZoomHeader}
autosql::AbstractString
summary::BigBedTotalSummary
btree_header::BigBedBTreeHeader
rtree_header::BigBedRTreeHeader
data_count::UInt32

# preallocated space for reading and searching the B-tree
btree_internal_nodes::Vector{BigBedBTreeInternalNode}
btree_leaf_nodes::Vector{BigBedBTreeLeafNode}
key::Vector{UInt8}
node_keys::Vector{Vector{UInt8}}
uncompressed_data::Vector{UInt8}
end


# Parser for data blocks in a BigBed file. This is very similar
# to the BED parser in bed.rl, with the following exceptions:
Expand All @@ -33,35 +15,6 @@ const __bigbedparser_nfa_targs = Int8[ 0, 0 , ]
const __bigbedparser_nfa_offsets = Int8[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , ]
const __bigbedparser_nfa_push_actions = Int8[ 0, 0 , ]
const __bigbedparser_nfa_pop_trans = Int8[ 0, 0 , ]
typealias StringFieldVector Vector{StringField}
typealias NullableStringFieldVector Nullable{StringFieldVector}
typealias NullableStringField Nullable{StringField}

type BigBedDataParser <: AbstractParser
state::Ragel.State

# intermediate values used during parsing
chrom_id::UInt32
red::Float32
green::Float32
blue::Float32
block_size_idx::Int
block_first_idx::Int
seq_names::Nullable{StringFieldVector}
assumed_seqname::Nullable{StringField}

function BigBedDataParser(input::BufferedInputStream;
seq_names::NullableStringFieldVector=NullableStringFieldVector(),
assumed_seqname::NullableStringField=NullableStringField())

begin
cs = convert( Int , _bigbedparser_start );

end
return new(Ragel.State(cs, input), 0, 0.0, 0.0, 0.0, 1, 1, seq_names, assumed_seqname)
end
end


Ragel.@generate_read!_function("_bigbedparser", BigBedDataParser, BEDInterval,
begin
Expand Down
50 changes: 0 additions & 50 deletions src/intervals/bigbed-parser.rl
Original file line number Diff line number Diff line change
@@ -1,23 +1,3 @@

type BigBedData <: IntervalStream{BEDMetadata}
stream::BufferedInputStream
header::BigBedHeader
zoom_headers::Vector{BigBedZoomHeader}
autosql::AbstractString
summary::BigBedTotalSummary
btree_header::BigBedBTreeHeader
rtree_header::BigBedRTreeHeader
data_count::UInt32

# preallocated space for reading and searching the B-tree
btree_internal_nodes::Vector{BigBedBTreeInternalNode}
btree_leaf_nodes::Vector{BigBedBTreeLeafNode}
key::Vector{UInt8}
node_keys::Vector{Vector{UInt8}}
uncompressed_data::Vector{UInt8}
end


# Parser for data blocks in a BigBed file. This is very similar
# to the BED parser in bed.rl, with the following exceptions:
#
Expand Down Expand Up @@ -122,38 +102,8 @@ end
main := (bed_entry %finish_match)*;
}%%


%%write data;

# because brackets can fuck with ragel's parsing in unpredictable ways
typealias StringFieldVector Vector{StringField}
typealias NullableStringFieldVector Nullable{StringFieldVector}
typealias NullableStringField Nullable{StringField}

type BigBedDataParser <: AbstractParser
state::Ragel.State

# intermediate values used during parsing
chrom_id::UInt32
red::Float32
green::Float32
blue::Float32
block_size_idx::Int
block_first_idx::Int
seq_names::Nullable{StringFieldVector}
assumed_seqname::Nullable{StringField}

function BigBedDataParser(input::BufferedInputStream;
seq_names::NullableStringFieldVector=NullableStringFieldVector(),
assumed_seqname::NullableStringField=NullableStringField())

%% write init;

return new(Ragel.State(cs, input), 0, 0.0, 0.0, 0.0, 1, 1, seq_names, assumed_seqname)
end
end


Ragel.@generate_read!_function("_bigbedparser", BigBedDataParser, BEDInterval,
begin
%%write exec;
Expand Down
39 changes: 39 additions & 0 deletions src/intervals/bigbed.jl
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,45 @@ end
immutable BigBed <: FileFormat end
immutable BigWig <: FileFormat end

type BigBedData <: IntervalStream{BEDMetadata}
stream::BufferedInputStream
header::BigBedHeader
zoom_headers::Vector{BigBedZoomHeader}
autosql::AbstractString
summary::BigBedTotalSummary
btree_header::BigBedBTreeHeader
rtree_header::BigBedRTreeHeader
data_count::UInt32

# preallocated space for reading and searching the B-tree
btree_internal_nodes::Vector{BigBedBTreeInternalNode}
btree_leaf_nodes::Vector{BigBedBTreeLeafNode}
key::Vector{UInt8}
node_keys::Vector{Vector{UInt8}}
uncompressed_data::Vector{UInt8}
end

type BigBedDataParser <: AbstractParser
state::Ragel.State

# intermediate values used during parsing
chrom_id::UInt32
red::Float32
green::Float32
blue::Float32
block_size_idx::Int
block_first_idx::Int
seq_names::Nullable{Vector{StringField}}
assumed_seqname::Nullable{StringField}

function BigBedDataParser(input::BufferedInputStream;
seq_names::Nullable{Vector{StringField}}=Nullable{Vector{StringField}}(),
assumed_seqname::Nullable{StringField}=Nullable{StringField}())
cs = _bigbedparser_start
return new(Ragel.State(cs, input), 0, 0.0, 0.0, 0.0, 1, 1, seq_names, assumed_seqname)
end
end

include("bigbed-parser.jl")

"""
Expand Down

0 comments on commit b8e991b

Please sign in to comment.