Sha256: e251164c21f3bc33e0601b14bd3af7bb9393a66aca7f490236b6edc00b0d7cb4

Contents?: true

Size: 1.38 KB

Versions: 4

Compression:

Stored size: 1.38 KB

Contents

require 'spec_helper'

require 'ms/mzml'

describe 'indexed, compressed peaks, mzML file' do

  describe MS::Mzml do

    describe 'reading a spectrum' do

      before do
        @file = TESTFILES + "/ms/mzml/j24z.idx_comp.3.mzML"
        @io = File.open(@file)
        @mzml = MS::Mzml.new(@io)
      end
      after do
        @io.close
      end

      it '#spectrum (or #[]) returns a spectrum when queried by index (Integer)' do
        spectrum = @mzml.spectrum(1) # getting the second spectrum
        spectrum1 = @mzml[1]
        spectrum.should == spectrum1
        spectrum.should be_a(MS::Spectrum)
        spectrum.should respond_to(:mzs)
        spectrum.should respond_to(:intensities)
        spectrum.mzs.size.should == 315
        spectrum.intensities.size.should == 315
        spectrum.mzs[2].should be_within(1e-10).of(164.32693481445312)
      end

      it '#spectrum (or #[]) returns a spectrum when queried by id (String)' do
        spectrum = @mzml.spectrum("controllerType=0 controllerNumber=1 scan=2")
        spectrum1 = @mzml["controllerType=0 controllerNumber=1 scan=2"]
        spectrum.should == spectrum1
        spectrum.should be_a(MS::Spectrum)
      end

      it 'goes through spectrum with #each or #each_spectrum' do
        mz_sizes = [20168, 315, 634]
        @mzml.each do |spec|
          spec.mzs.size.should == mz_sizes.shift
        end
      end

    end
  end
end


Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
mspire-0.6.7 spec/ms/mzml_spec.rb
mspire-0.6.6 spec/ms/mzml_spec.rb
mspire-0.6.2 spec/ms/mzml_spec.rb
mspire-0.6.1 spec/ms/mzml_spec.rb