lib/bio/pipengine/job.rb
# perform substitutions on all the placeholders
perform substitutions on all the placeholders
perform substitutions on all the placeholders
def sub_placeholders(cmd,sample,step=nil)	
				tmp_cmd = cmd.gsub(/<sample>/,sample.name)
				if tmp_cmd =~/<sample_path>/
					sample_path_glob = (tmp_cmd.scan(/<sample_path>(\S+)/).map {|e| e.first})
					unless sample_path_glob.empty?
						sample_path_glob.each do |append|
							tmp_cmd.gsub!(/<sample_path>#{Regexp.quote(append)}/,(sample.path.map {|s| s+append}).join("\s"))
						end
					end
					tmp_cmd.gsub!(/<sample_path>/,sample.path.join("\s"))
				end
				if tmp_cmd =~/<sample_group>/
					sample_group_glob = (tmp_cmd.scan(/<sample_group>(\S+)/).map {|e| e.first})
					unless sample_group_glob.empty?
						sample_group_glob.each do |append|
							tmp_cmd.gsub!(/<sample_group>#{Regexp.quote(append)}/,(sample.group+append))
						end
					end
					tmp_cmd.gsub!(/<sample_group>/,sample.group)
				end
				if tmp_cmd =~/<sample_group\/>/
					tmp_cmd = tmp_cmd.gsub(/<sample_group\/>/,self.output+"/")
				end
				tmp_cmd = sub_resources_and_cpu(tmp_cmd,step)
				tmp_cmd.scan(/<(\S+)\/sample>/).map {|e| e.first}.each do |input_folder|
					@@logger.info "Directory #{self.output+"/"+sample.name+"/"+input_folder} not found".magenta unless Dir.exists? self.output+"/"+sample.name+"/"+input_folder
					tmp_cmd = tmp_cmd.gsub(/<#{input_folder}\/sample>/,self.output+"/"+sample.name+"/"+input_folder+"/"+sample.name)
				end
				tmp_cmd.scan(/<(\S+)\/>/).map {|e| e.first}.each do |input_folder|
					@@logger.info "Directory #{self.output+"/"+sample.name+"/"+input_folder} not found".magenta unless Dir.exists? self.output+"/"+sample.name+"/"+input_folder
					tmp_cmd = tmp_cmd.gsub(/<#{input_folder}\/>/,self.output+"/"+sample.name+"/"+input_folder+"/")
				end
				return tmp_cmd
			end
def sub_placeholders ( cmd , sample , step = nil ) tmp_cmd = cmd . gsub ( / <sample> / , sample . name ) if tmp_cmd =~ / <sample_path> / sample_path_glob = ( tmp_cmd . scan ( / <sample_path>( \S +) / ) . map { | e | e . first } ) unless sample_path_glob . empty? sample_path_glob . each do | append | tmp_cmd . gsub! ( / <sample_path> #{ Regexp . quote ( append ) } / , ( sample . path . map { | s | s + append } ) . join ( "\s" ) ) end end tmp_cmd . gsub! ( / <sample_path> / , sample . path . join ( "\s" ) ) end if tmp_cmd =~ / <sample_group> / sample_group_glob = ( tmp_cmd . scan ( / <sample_group>( \S +) / ) . map { | e | e . first } ) unless sample_group_glob . empty? sample_group_glob . each do | append | tmp_cmd . gsub! ( / <sample_group> #{ Regexp . quote ( append ) } / , ( sample . group + append ) ) end end tmp_cmd . gsub! ( / <sample_group> / , sample . group ) end if tmp_cmd =~ / <sample_group \/ > / tmp_cmd = tmp_cmd . gsub ( / <sample_group \/ > / , self . output + "/" ) end tmp_cmd = sub_resources_and_cpu ( tmp_cmd , step ) tmp_cmd . scan ( / <( \S +) \/ sample> / ) . map { | e | e . first } . each do | input_folder | @@logger . info "Directory #{self.output+"/"+sample.name+"/"+input_folder} not found" . magenta unless Dir . exists? self . output + "/" + sample . name + "/" + input_folder tmp_cmd = tmp_cmd . gsub ( / < #{ input_folder } \/ sample> / , self . output + "/" + sample . name + "/" + input_folder + "/" + sample . name ) end tmp_cmd . scan ( / <( \S +) \/ > / ) . map { | e | e . first } . each do | input_folder | @@logger . info "Directory #{self.output+"/"+sample.name+"/"+input_folder} not found" . magenta unless Dir . exists? self . output + "/" + sample . name + "/" + input_folder tmp_cmd = tmp_cmd . gsub ( / < #{ input_folder } \/ > / , self . output + "/" + sample . name + "/" + input_folder + "/" ) end return tmp_cmd end
perform substitutions on all the placeholders
perform substitutions on all the placeholders
# for resourcers and cpus # for placeholders like <mapping/sample> # for placeholders like <mapping/>
cmd
<not_specific>
sample
<not_specific>
step
<not_specific>