Created
September 12, 2014 10:49
-
-
Save gisleDK/009f6cf3b524f4557ae8 to your computer and use it in GitHub Desktop.
Ruby script to blat search fasta sequence using qsub
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# qsub parametres: | |
# Specify Ruby | |
#$ -S /usr/bin/ruby | |
# name for job | |
#$ -N blat | |
# pe request for slots, means processors, with | |
# minimum to maximum. | |
# e.g. 2 means two processors | |
# 2- means 2 upto number of processor restricted by pe | |
# 2-8 means 2 upto 8 processors | |
# | |
# The number of slots / processors restriction can be retrieved by | |
# qmon under Parallel Environment Configuration choosing scampi and | |
# there by the number of Slots. | |
# | |
# ATTENTION: If the number of slots ist exceeded by single or | |
# maximum number, the job does not run. | |
# | |
#$ -pe hmp 6 | |
# | |
# Written by Gisle Vestergaard | |
require 'pp' | |
require 'optparse' | |
ARGV << "--help" if ARGV.empty? | |
cmd_init = File.basename($0) + " " + ARGV.join(" ") | |
options = {} | |
OptionParser.new do |opts| | |
opts.banner = "Usage: #{File.basename(__FILE__)} [options]" | |
opts.on("-h", "--help", "Display this screen" ) do | |
$stderr.puts opts | |
exit | |
end | |
opts.on("-i", "--input_fasta <file>", String, "Input fasta sequence") do |o| | |
options[:input_fasta] = o | |
end | |
opts.on("-d", "--database <file>", String, "Input database to search") do |o| | |
options[:database] = o | |
end | |
opts.on("-t", "--type <file>", String, "Select blastp, blastn or blastx (default is blastn)") do |o| | |
options[:type] = o | |
end | |
opts.on("-o", "--output directory <directory>", String, "Output directory") do |o| | |
options[:out_lib] = o | |
end | |
opts.on("-f", "--outformat <string>", String, "blast8 for tabulated or blast for flat output for MEGAN et al. (default=flat)") do |o| | |
options[:outfmt] = o | |
end | |
end.parse! | |
options[:database] ||= '~/genomics/NCBI/Refseq/complete.nonredundant_protein.faa' | |
options[:out_lib] ||= File.basename(options[:input_fasta], ".*") + ".blat" | |
options[:type] ||= "blastn" | |
options[:outfmt] ||= blast | |
if options[:type] == "blastp" | |
system 'blat -prot -out=' + options[:outfmt].to_s + ' ' + options[:database].to_s + ' ' + options[:input_fasta].to_s + ' ' + options[:out_lib].to_s | |
elsif options[:type] == "blastn" | |
system 'blat -prot -out=' + options[:outfmt].to_s + ' ' + options[:database].to_s + ' ' + options[:input_fasta].to_s + ' ' + options[:out_lib].to_s | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment