bin/seqtrimnext in seqtrimnext-2.0.51 vs bin/seqtrimnext in seqtrimnext-2.0.52

- old
+ new

@@ -1,6 +1,8 @@ #!/usr/bin/env ruby +# encoding: utf-8 + # SeqTrimNext: Next generation sequencing preprocessor # Copyright (C) <2011> # Authors: Almudena Bocinos Rioboo, Diego Dario Guerrero Fernandez, # Rocio Bautista Moreno, Juan Falgueras Cano & M. Gonzalo Claros # email: soporte@scbi.uma.es - http://www.scbi.uma.es @@ -55,14 +57,40 @@ # $: << File.expand_path('~/progs/ruby/gems/scbi_drb/lib/') # $: << File.expand_path(ROOT_PATH) $: << File.expand_path('~/progs/ruby/gems/seqtrimnext/lib/') -$: << File.expand_path('~/progs/ruby/gems/scbi_mapreduce/lib/') +# $: << File.expand_path('~/progs/ruby/gems/scbi_mapreduce/lib/') require 'seqtrimnext' +require 'scbi_headers' + +def put_header + header = ScbiHeader.new('SeqTrimNEXT',Seqtrimnext::SEQTRIM_VERSION) + + header.description="SeqtrimNEXT is a customizable and distributed pre-processing software for NGS (Next Generation Sequencing) biological data. It makes use of scbi_mapreduce gem to be able to run in parallel and distributed environments. It is specially suited for Roche 454 (normal and paired-end) & Ilumina datasets, although it could be easyly adapted to any other situation." + + header.copyright='2011' + + header.authors<< "Darío Guerrero" + header.authors<< "Almudena Bocinos" + header.authors<< "Rocío Bautista" + header.authors<< "Noé Fernández" + header.authors<< "Juan Falgueras" + header.authors<< "M. Gonzalo Claros" + + # header.articles<< "Article one: with one description line" + # header.articles<< "Article two: with one description line" + + # To output the header + puts header + +end + +put_header + ############ PATHS ####################### $SEQTRIM_PATH = ROOT_PATH if ENV['SEQTRIMNEXT_INIT'] && File.exists?(ENV['SEQTRIMNEXT_INIT']) $SEQTRIMNEXT_INIT=File.expand_path(ENV['SEQTRIMNEXT_INIT']) @@ -190,11 +218,11 @@ STDERR.puts "ERROR:Invalid workers parameter #{options[:workers]}" exit end end - + end options[:only_workers] = false @@ -209,17 +237,17 @@ options[:use_checkpoint] = false opts.on( '-C', '--use_checkpoint', 'Restore at checkpoint if scbi_mapreduce_checkpoint file is available' ) do options[:use_checkpoint] = true end - + # options[:skip_initial_stats] = false # opts.on( '-k', '--skip_initial_stats', 'Skip initial stats' ) do # options[:skip_initial_stats] = true # end - + options[:install_db] = nil opts.on( '-i', '--install_databases TYPE', 'Install base databases and reformat them if necessary') do |db_type| options[:install_db] = db_type end @@ -227,24 +255,26 @@ opts.on( '-l', '--logfile FILE', 'Write log to FILE' ) do |file| options[:logfile] = file end options[:fastq] = nil - opts.on( '-Q', '--fastq FILE', 'Fastq input file. Use - for <STDIN>' ) do |file| + opts.on( '-Q', '--fastq FILE1,FILE2',Array, 'Fastq input file. Use - for <STDIN>' ) do |file| options[:fastq] = file + puts "FILES:",file,file.class + end - + options[:format] = nil opts.on( '-F', '--fastq_quality_format FORMAT', 'Fastq input quality format use sanger or illumina18 for phred+33 based scores. Use illumina15 for phred+64 based scores (default is sanger) file. Use - for <STDIN>' ) do |value| options[:format] = value if !['sanger','illumina15', 'illumina18'].include?(value) STDERR.puts "ERROR: Invalid FASTQ format parameter #{value}" exit end end - + options[:fasta] = nil opts.on( '-f', '--fasta FILE', 'Fasta input file' ) do |file| options[:fasta] = file end @@ -253,11 +283,11 @@ options[:qual] = file end options[:list_db] = nil options[:list_db_name] = 'ALL' - + opts.on( '-L', '--list_db [DB_NAME]', 'List entries IDs in DB_NAME. Use "-L all" to view all available databases' ) do |value| options[:list_db] = true options[:list_db_name] = value if value end @@ -279,16 +309,16 @@ options[:json] = nil opts.on( '-j', '--json', 'Save results in json file' ) do options[:json] = true end - + options[:skip_output] = false opts.on( '-K', '--no-verbose', 'Change to no verbose mode. Every sequence will not be written to output log' ) do options[:skip_output] = true end - + options[:skip_report] = false opts.on( '-R', '--no-report', 'Do not generate final PDF report (gem scbi_seqtrimnext_report required if you want to generate PDF report).' ) do options[:skip_report] = true end @@ -333,11 +363,11 @@ $LOG.info("Using options: "+ options.to_json) if options[:install_db] then #install databases InstallDatabase.new(options[:install_db],$DB_PATH) - + # reformat databases MakeBlastDb.new($DB_PATH) exit end @@ -374,18 +404,22 @@ end end $LOG.info "Using init file: #{$SEQTRIMNEXT_INIT}" $LOG.info "Using params file: #{options[:template]}" -# fastq file -if (!options[:fastq].nil? && options[:fastq]!='-' && !File.exists?(options[:fastq])) - $LOG.error "Input file: #{options[:fasta]} doesn't exists" - exit +# check file existence + +if options[:fastq] + options[:fastq].each do |fastq_file| + # fastq file + if (!fastq_file.nil? && fastq_file!='-' && !File.exists?(File.expand_path(fastq_file))) + $LOG.error "Input file: #{fastq_file} doesn't exists" + exit + end + end end - - # fasta file if (!options[:fasta].nil? && !File.exists?(options[:fasta])) $LOG.error "Input file: #{options[:fasta]} doesn't exists" exit end @@ -396,22 +430,20 @@ exit end s = Seqtrim.new(options) - - #generate report if !options[:skip_report] && system("which generate_report.rb > /dev/null ") cmd="generate_report.rb output_files 2> report_generation_errors.log" $LOG.info "Generating report #{cmd}" `#{cmd}` else skip_text='.' - + if options[:skip_report] skip_text=' and remove the -R option from the command line.' end - + $LOG.info "If you want a detailed report in PDF format, be sure you have installed the optional seqtrimnext_report gem (gem install seqtrimnext_report)#{skip_text}" end