edmundhighcock / hdf5

A ruby wrapper for the HDF5 library
MIT License
6 stars 4 forks source link

narray_all error #3

Closed jpearl01 closed 2 years ago

jpearl01 commented 5 years ago

Hello,

I'm trying to loop through some values in an hdf5 file, but running into some issues. I'm able to read the file fine, and load the dataset(s) I'm interested in, but I'm having trouble with the conversion into an array of values.

Here is a link to the file I'm opening: https://www.dropbox.com/s/d8u7d3zaszcgn0m/m151002_181152_42168_c100863312550000001823190302121650_s1_p0.2.ccs.h5?dl=0

I'm essentially trying to convert this python code into ruby:

    for hole_num, num_passes in zip(hf['/PulseData/ConsensusBaseCalls/ZMW/HoleNumber'].value, hf['/PulseData/ConsensusBaseCalls/Passes/NumPasses'].value):
        if num_passes > 0:
            print '%s/%d/ccs' % (basename, hole_num), num_passes

And here's what I get to (just testing this out in irb):

require 'hdf5'

file = Hdf5::H5File.new('data/m151002_181152_42168_c100863312550000001823190302121650_s1_p0.3.ccs.h5')
p = file.dataset('/PulseData/ConsensusBaseCalls/Passes/NumPasses')
 => #<Hdf5::H5Dataset:0x0000000108a3a8 @id=83886083>
p.narray_all
NoMethodError: undefined method `integer' for NArray:Class
Did you mean?  Integer
    from /home/jearl/.rvm/gems/ruby-2.4.1/gems/hdf5-0.3.5/lib/hdf5.rb:207:in `narray_all'
    from (irb):34
    from /home/jearl/.rvm/rubies/ruby-2.4.1/bin/irb:11:in `<main>'

I'm thinking that I'm just doing something very silly, and that you might know just off the top of your head what I'm doing wrong. I haven't worked with hdf5 files much at all. shrug

Thanks, ~josh

edmundhighcock commented 5 years ago

Hi josh,

First, just a basic comment... p is a kernel function in ruby so I wouldn't use it as a variable name (p thing means puts thing.inspect.

Second, it looks as though NArray has been updated: what version are you using?

jpearl01 commented 5 years ago

Ugh, how embarrassing, rookie mistake

Narray version: narray (0.6.1.2)

The dataset should just be a single vector of values, from what I can ascertain (looking at it with HDFView) hdf5_fileview hdf5_vector

Thanks for getting back to me!

~josh