bahuvrihi-data_explorer 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/MIT-LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ Copyright (c) 2006-2008, Regents of the University of Colorado.
2
+ Developer:: Simon Chiang, Biomolecular Structure Program, Hansen Lab
3
+ Support:: CU Denver School of Medicine Deans Academic Enrichment Fund
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this
6
+ software and associated documentation files (the "Software"), to deal in the Software
7
+ without restriction, including without limitation the rights to use, copy, modify, merge,
8
+ publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons
9
+ to whom the Software is furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all copies or
12
+ substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
18
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
19
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
21
+ OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,64 @@
1
+ require 'data_explorer'
2
+
3
+ module DataExplorer
4
+ module Convert
5
+
6
+ # :startdoc::manifest converts .dat file to ascii text
7
+ #
8
+ # Uses the Applied Biosystems DataExplorer software to extract an ASCII spectrum
9
+ # from a '.dat' file. Each input file should be a dat file; ascii files will be placed in
10
+ # the output directory, with a '.txt' extension.
11
+ #
12
+ # DatToAscii is based on the getdeascii.pl script.
13
+ class DatToAscii < Tap::FileTask
14
+ include DataExplorer
15
+
16
+ def process(output_dir, *input_files)
17
+ @updated_files = []
18
+ input_files.collect do |input_file|
19
+ output_file = File.join(output_dir, basename(input_file, ".txt"))
20
+
21
+ if uptodate?(output_file, input_file)
22
+ log_basename(:skip, input_file)
23
+ else
24
+ log_basename :ascii, input_file
25
+
26
+ prepare output_file
27
+
28
+ # This block of code raises an unexpected WIN32OLERuntimeError upon the 'close'
29
+ # operation. The error may be XP-related or DataExplorer 4.0-related as it is not raised on a
30
+ # Win2k computer using DataExplorer 4.9.
31
+ #
32
+ # I believe that the issue is with XP, however, due to articles I read online
33
+ # (see http://support.microsoft.com/kb/289737) as well as the fact that if you
34
+ # enact the open-close routine in irb multiple times, it will only raise the 0x80010105
35
+ # error the first time for any given document.
36
+ begin
37
+ spectrum = data_explorer.documents.open(File.expand_path(input_file))
38
+ spectrum.specview.exportasciispectrum(File.expand_path(output_file))
39
+ spectrum.close
40
+ rescue WIN32OLERuntimeError
41
+ end
42
+
43
+ @updated_files << output_file
44
+ end
45
+
46
+ output_file
47
+ end
48
+ end
49
+
50
+ protected
51
+
52
+ def after_execute
53
+ close_data_explorer
54
+
55
+ # Ensure de has time to close, then make sure all the output files are dated later than the inputs
56
+ # This rigmarole is necessary because the output file is created while the input file is open in
57
+ # DataExplorer, and apparently DataExplorer doesn't release the file until it completely exits.
58
+ sleep 1 unless updated_files.empty?
59
+ @updated_files.each {|file| FileUtils.touch(file) }
60
+ @updated_files = nil
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,52 @@
1
+ require 'win32ole'
2
+ require 'Win32API'
3
+
4
+ module DataExplorer
5
+ @@data_explorer_instance = nil
6
+
7
+ def data_explorer
8
+ @@data_explorer_instance = WIN32OLE.new('DataExplorer.Application') unless @@data_explorer_instance
9
+ @@data_explorer_instance
10
+ end
11
+
12
+ def close_data_explorer
13
+ if @@data_explorer_instance
14
+ data_explorer.quit
15
+ data_explorer.ole_free
16
+ @@data_explorer_instance = nil
17
+ end
18
+ end
19
+
20
+ def data_explorer_version
21
+ # Gets the version information for a windows executable
22
+ # trivially modified from: http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/161140
23
+ #fname = 'D:\ruby\bin\ruby.exe'
24
+ fname = data_explorer.fullname
25
+ get_file_version_info_size = Win32API.new('Version', 'GetFileVersionInfoSize', 'PP', 'L')
26
+ get_file_version_info = Win32API.new('Version', 'GetFileVersionInfo', 'PLLP', 'L')
27
+ ver_query_value = Win32API.new('Version', 'VerQueryValue', 'PPPP', 'I')
28
+ memcpy = Win32API.new('msvcrt', 'memcpy', 'PLL', 'L')
29
+
30
+ addr = "\0"*4
31
+
32
+ v_info_sz = get_file_version_info_size.call(fname, addr)
33
+
34
+ raise 'GFVIS failed' if v_info_sz == 0
35
+ v_info = "\0"*v_info_sz
36
+ get_file_version_info.call(fname, 0, v_info_sz, v_info)
37
+
38
+ v_val_sz = "\0"*4
39
+ ver_query_value.call(v_info, '\\', addr, v_val_sz)
40
+ v_bufsz = v_val_sz.unpack('L')[0]
41
+ v_buf = "\0" * v_bufsz
42
+ v_src = addr.unpack('L')[0]
43
+ ret = memcpy.call(v_buf, v_src, v_bufsz)
44
+ raise 'memcpy failed' if ret == 0
45
+
46
+ raise 'Oops' unless v_buf[0, 4].unpack('L')[0] == 0xFEEF04BD
47
+ #p v_buf[0x08, 8].unpack('S*').values_at(1,0,3,2) #-> [1, 8, 2, 0]
48
+ #p v_buf[0x10, 8].unpack('S*').values_at(1,0,3,2) #-> [1, 8, 2, 0]
49
+ v_buf[0x08, 8].unpack('S*').values_at(1,0,3,2).join('.')
50
+ end
51
+
52
+ end
data/tap.yml ADDED
File without changes
@@ -0,0 +1,5 @@
1
+ $:.unshift File.join(File.dirname(__FILE__), '../lib')
2
+
3
+ # runs all subsets (see Tap::Test::SubsetMethods)
4
+ ENV["ALL"] = "true"
5
+ Dir.glob("./**/*_test.rb").each {|test| require test}
metadata ADDED
@@ -0,0 +1,64 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bahuvrihi-data_explorer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Simon Chiang
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2008-07-08 00:00:00 -07:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: tap
17
+ version_requirement:
18
+ version_requirements: !ruby/object:Gem::Requirement
19
+ requirements:
20
+ - - ~>
21
+ - !ruby/object:Gem::Version
22
+ version: 0.10.0
23
+ version:
24
+ description:
25
+ email: simon.a.chiang@gmail.com
26
+ executables: []
27
+
28
+ extensions: []
29
+
30
+ extra_rdoc_files:
31
+ - MIT-LICENSE
32
+ files:
33
+ - lib/data_explorer.rb
34
+ - lib/data_explorer/convert/dat_to_ascii.rb
35
+ - tap.yml
36
+ - MIT-LICENSE
37
+ has_rdoc: true
38
+ homepage: http://hsc-proteomics.uchsc.edu/
39
+ post_install_message:
40
+ rdoc_options: []
41
+
42
+ require_paths:
43
+ - lib
44
+ required_ruby_version: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - ">="
47
+ - !ruby/object:Gem::Version
48
+ version: "0"
49
+ version:
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: "0"
55
+ version:
56
+ requirements: []
57
+
58
+ rubyforge_project: biomass
59
+ rubygems_version: 1.2.0
60
+ signing_key:
61
+ specification_version: 2
62
+ summary: data_explorer task library
63
+ test_files:
64
+ - test/tap_test_suite.rb