Open phaverty opened 6 years ago
Thats very interesting that record
should be of type ANY
. At first glance, I think that should not be happening. Thanks for flagging this!
Perhaps your iterator has the same trouble as those mentioned here: https://github.com/JuliaLang/julia/pull/26852
?
Pete
Peter M. Haverty, Ph.D. Genentech, Inc. phaverty@gene.com
On Wed, Apr 18, 2018 at 2:37 PM, Ben J. Ward notifications@github.com wrote:
Thats very interesting that record should be of type ANY. At first glance, I think that should not be happening. Thanks for flagging this!
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/BioJulia/BioAlignments.jl/issues/10#issuecomment-382537541, or mute the thread https://github.com/notifications/unsubscribe-auth/AH02K9Rt27dTdXcvOW_uHdyZVZMMI4i0ks5tp7IVgaJpZM4TaWLV .
When following the iteration suggestion in the "Performance Tips" section, no type instability is observed. e.g. for:
reader = open(BAM.Reader, "data.bam") record = BAM.Record() while !eof(reader) read!(reader, record)
end
Variables:
genome_name::String
reader::BioAlignments.BAM.Reader{IOStream}
info::GenomicVectors.GenomeInfo{Int64}
chr::Array{String,1}
left_pos::Array{Int64,1}
right_pos::Array{Int64,1}
record::BioAlignments.BAM.Record
itemT@_9
itemT@_10
Body:
Maybe just update the docs to make this the standard way of looping over a BAM?
I don't know if this is a significant bottleneck, but I noticed some type instability when looping over BAM file records:
function read_bam(bam_file)
iterate over BAM records
end
@code_warntype read_bam(some_file)
!julia> @code_warntype read_bam(bam_file) Variables:
self#
bam_file
record::ANY
temp#::ANY
chr::Array{String,1} left_pos::Array{Int64,1} right_pos::Array{Int64,1} itemT
Body: begin chr::Array{String,1} = $(Expr(:foreigncall, :(:jl_alloc_array_1d), Array{String,1}, svec(Any, Int64), Array{String,1}, 0, 0, 0)) # line 4:
left_pos::Array{Int64,1} = $(Expr(:foreigncall, :(:jl_alloc_array_1d), Array{Int64,1}, svec(Any, Int64), Array{Int64,1}, 0, 0, 0)) # line 5:
right_pos::Array{Int64,1} = $(Expr(:foreigncall, :(:jl_alloc_array_1d), Array{Int64,1}, svec(Any, Int64), Array{Int64,1}, 0, 0, 0)) # line 6:
SSAValue(0) = Main.reader
temp#::ANY = (Base.start)(SSAValue(0))::ANY
end::DataFrames.DataFrame
I think the ANY type for record and temp indicate some type instability