annotate peptide_prophet_wrapper.rb @ 3:4c2e97f928d7

Uploaded
author iracooke
date Mon, 04 Mar 2013 18:41:22 -0500
parents 25261529840c
children a67a5d30bb80
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2
25261529840c Uploaded
iracooke
parents:
diff changeset
1 require 'pathname'
25261529840c Uploaded
iracooke
parents:
diff changeset
2
25261529840c Uploaded
iracooke
parents:
diff changeset
3 $VERBOSE=nil
25261529840c Uploaded
iracooke
parents:
diff changeset
4
25261529840c Uploaded
iracooke
parents:
diff changeset
5 actual_output_path_string=ARGV.shift
25261529840c Uploaded
iracooke
parents:
diff changeset
6
25261529840c Uploaded
iracooke
parents:
diff changeset
7 # Second argument is the original input file name ... we'll change this below
25261529840c Uploaded
iracooke
parents:
diff changeset
8 original_input_file=ARGV[0]
25261529840c Uploaded
iracooke
parents:
diff changeset
9
25261529840c Uploaded
iracooke
parents:
diff changeset
10 # Before doing anything we append create a link to the input file in our working dir with ".pep.xml" appended to the input
25261529840c Uploaded
iracooke
parents:
diff changeset
11 # name because peptide prophet can't handle anything else
25261529840c Uploaded
iracooke
parents:
diff changeset
12
25261529840c Uploaded
iracooke
parents:
diff changeset
13 wd= Dir.pwd
25261529840c Uploaded
iracooke
parents:
diff changeset
14
25261529840c Uploaded
iracooke
parents:
diff changeset
15 original_input_path=Pathname.new("#{original_input_file}")
25261529840c Uploaded
iracooke
parents:
diff changeset
16 actual_input_path_string="#{wd}/#{original_input_path.basename}.pep.xml"
25261529840c Uploaded
iracooke
parents:
diff changeset
17 full_tmp_output_path_string="#{wd}/peptide_prophet_output.pep.xml"
25261529840c Uploaded
iracooke
parents:
diff changeset
18
25261529840c Uploaded
iracooke
parents:
diff changeset
19 cmd = "ln -s #{original_input_file} #{actual_input_path_string};"
25261529840c Uploaded
iracooke
parents:
diff changeset
20
25261529840c Uploaded
iracooke
parents:
diff changeset
21 cmd << "rvm 1.9.3@protk-1.1.9 do peptide_prophet.rb"
25261529840c Uploaded
iracooke
parents:
diff changeset
22
25261529840c Uploaded
iracooke
parents:
diff changeset
23
25261529840c Uploaded
iracooke
parents:
diff changeset
24 ARGV[0]="#{actual_input_path_string}"
25261529840c Uploaded
iracooke
parents:
diff changeset
25
25261529840c Uploaded
iracooke
parents:
diff changeset
26 ARGV.each { |a|
25261529840c Uploaded
iracooke
parents:
diff changeset
27 cmd << " #{a}"
25261529840c Uploaded
iracooke
parents:
diff changeset
28 }
25261529840c Uploaded
iracooke
parents:
diff changeset
29
25261529840c Uploaded
iracooke
parents:
diff changeset
30 cmd << " -o peptide_prophet_output.pep.xml"
25261529840c Uploaded
iracooke
parents:
diff changeset
31
25261529840c Uploaded
iracooke
parents:
diff changeset
32 # Finally we need to fix up the output file so any references to the temporary working file are changed to refs to the original input file
25261529840c Uploaded
iracooke
parents:
diff changeset
33 cmd << ";ruby -pi -e \"gsub('#{actual_input_path_string}', '#{original_input_file}')\" peptide_prophet_output.pep.xml"
25261529840c Uploaded
iracooke
parents:
diff changeset
34 cmd << ";ruby -pi -e \"gsub('#{full_tmp_output_path_string}', '#{actual_output_path_string}')\" peptide_prophet_output.pep.xml"
25261529840c Uploaded
iracooke
parents:
diff changeset
35
25261529840c Uploaded
iracooke
parents:
diff changeset
36 %x[#{cmd}]