Class: DataExplorer::Convert::DatToAscii

Inherits:
Tap::FileTask
  • Object
show all
Includes:
DataExplorer
Defined in:
lib/data_explorer/convert/dat_to_ascii.rb

Overview

:startdoc::manifest converts .dat file to ascii text

Uses the Applied Biosystems DataExplorer software to extract an ASCII spectrum from a ‘.dat’ file. Each input file should be a dat file; ascii files will be placed in the output directory, with a ‘.txt’ extension.

DatToAscii is based on the getdeascii.pl script.

Instance Method Summary collapse

Methods included from DataExplorer

#close_data_explorer, #data_explorer, #data_explorer_version

Instance Method Details

#process(*input_files) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/data_explorer/convert/dat_to_ascii.rb', line 18

def process(*input_files)
  @updated_files = []
  input_files.collect do |input_file|
    output_file = if output_dir
      File.join(output_dir, basename(input_file, ".txt"))
    else
      input_file.chomp(File.extname(input_file)) + ".txt"
    end
    
    if uptodate?(output_file, input_file)
      log_basename(:skip, input_file)
    else
      log_basename :ascii, input_file

      prepare output_file

      # This block of code raises an unexpected WIN32OLERuntimeError upon the 'close'

      # operation.  The error may be XP-related or DataExplorer 4.0-related as it is not raised on a 

      # Win2k computer using DataExplorer 4.9.  

      # 

      # I believe that the issue is with XP, however, due to articles I read online 

      # (see http://support.microsoft.com/kb/289737) as well as the fact that if you 

      # enact the open-close routine in irb multiple times, it will only raise the 0x80010105

      # error the first time for any given document.

      begin
        spectrum = data_explorer.documents.open(File.expand_path(input_file))
        spectrum.specview.exportasciispectrum(File.expand_path(output_file))
        spectrum.close
      rescue WIN32OLERuntimeError
      end

      @updated_files << output_file
    end
    
    output_file
  end
end