#! /usr/bin/ruby # # Author:: Pjotr Prins # Copyright:: August 2010 # License:: Ruby License # # Copyright (C) 2010,2011 Pjotr Prins USAGE = < EOM rootpath = File.dirname(File.dirname(__FILE__)) $: << rootpath+'/lib' $: << rootpath+'/../bioruby/lib' require 'bio-gff3' $stderr.print "BioRuby GFF3 Plugin Copyright (C) 2010,2011 Pjotr Prins \n\n" if ARGV.size == 0 print USAGE end gfftype = ARGV.shift caching = true if gfftype == "--no-cache" caching = false gfftype = ARGV.shift end raise "Unknown GFF type '#{gfftype}'" if gfftype !~ /mrna|cds|exon/i fastafn = nil ARGV.each do | fn | if File.extname(fn) =~ /fa|fas|fasta/i fastafn = fn next end options = {:validate => false} options = {:validate => false, :cache_components => :cache_none, :cache_records => :cache_none} if caching == false options[:fasta_filename] = fastafn if fastafn gffdb = Bio::GFFbrowser::GFFdb.new(fn,options) gff = gffdb.assembler case gfftype.downcase when 'mrna' gff.each_mRNA_seq do | id, seq | puts ">"+id puts seq end when 'exon' gff.each_exon_seq do | id, seq | puts ">"+id puts seq end when 'cds' gff.each_CDS_seq do | id, seq | puts ">"+id puts seq end else raise "Unknown action <#{gfftype}>" end end