Class: Ms::Sequest::Srf::DTA
- Inherits:
-
Object
- Object
- Ms::Sequest::Srf::DTA
- Defined in:
- lib/ms/sequest/srf.rb
Constant Summary collapse
- Unpack_32 =
original Unpack = “EeIvvvv”
"EeIvvvv"
- Unpack_35 =
"Ex8eVx2vvvv"
Instance Method Summary collapse
- #from_io(fh, unpack_35) ⇒ Object
- #inspect ⇒ Object
- #round(float, decimal_places) ⇒ Object
- #to_dta_file_data ⇒ Object
-
#write_dta_file(io) ⇒ Object
write a class dta file to the io object.
Instance Method Details
#from_io(fh, unpack_35) ⇒ Object
482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 |
# File 'lib/ms/sequest/srf.rb', line 482 def from_io(fh, unpack_35) if unpack_35 @unpack = Unpack_35 @read_header = 34 @read_spacer = 22 else @unpack = Unpack_32 @read_header = 24 @read_spacer = 24 end st = fh.read(@read_header) # get the bulk of the data in single unpack self[0,7] = st.unpack(@unpack) # Scan numbers are given at the end in an index! st2 = fh.read(@read_spacer) num_bytes_to_read = num_peaks * 8 st3 = fh.read(num_bytes_to_read) self[7] = st3 self end |
#inspect ⇒ Object
476 477 478 479 480 |
# File 'lib/ms/sequest/srf.rb', line 476 def inspect peaks_st = 'nil' if self[7] ; peaks_st = "[#{self[7].size} bytes]" end "<Ms::Sequest::Srf::DTA @mh=#{mh} @dta_tic=#{dta_tic} @num_peaks=#{num_peaks} @charge=#{charge} @ms_level=#{ms_level} @total_num_possible_charge_states=#{total_num_possible_charge_states} @peaks=#{peaks_st} >" end |
#round(float, decimal_places) ⇒ Object
522 523 524 |
# File 'lib/ms/sequest/srf.rb', line 522 def round(float, decimal_places) sprintf("%.#{decimal_places}f", float) end |
#to_dta_file_data ⇒ Object
506 507 508 509 510 511 512 513 514 515 |
# File 'lib/ms/sequest/srf.rb', line 506 def to_dta_file_data string = "#{round(mh, 6)} #{charge}\r\n" peak_ar = peaks.unpack('e*') (0...(peak_ar.size)).step(2) do |i| # %d is equivalent to floor, so we round by adding 0.5! string << "#{round(peak_ar[i], 4)} #{(peak_ar[i+1] + 0.5).floor}\r\n" #string << peak_ar[i,2].join(' ') << "\r\n" end string end |
#write_dta_file(io) ⇒ Object
write a class dta file to the io object
518 519 520 |
# File 'lib/ms/sequest/srf.rb', line 518 def write_dta_file(io) io.print to_dta_file_data end |