Module: Ms::Msrun::Sha1

Defined in:
lib/ms/msrun/sha1.rb

Overview

the mzXML digest is from the start of the document to the end of the first sha1 tag: ‘…<sha1>’

Class Method Summary collapse

Class Method Details

.digest_mzxml_file(file) ⇒ Object

returns [calculated digest, recorded digest] for an mzXML file



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/ms/msrun/sha1.rb', line 11

def digest_mzxml_file(file)
  recorded_digest = nil

  incr_digest = ""
  #incr_digest = Digest::SHA1.new
  endpos = nil
  File.open(file, 'rb') do |io|
    while line = io.gets
      if line.include?("<sha1>")  
        incr_digest << line[0, line.index("<sha1>") + 6]
        if line =~ %r{<sha1>(.*)</sha1>}
          recorded_digest = $1.dup
          break
        else
          incr_digest << line
        end
      end
    end
  end

  [Digest::SHA1.hexdigest(incr_digest), recorded_digest]
  #[incr_digest.hexdigest, recorded_digest]
end