Module: Bio::PL::GFF3
- Defined in:
- lib/bio-gff3-pltools/filtering.rb,
lib/bio-gff3-pltools/validation.rb
Class Method Summary collapse
-
.filter_data(data, filter_string, options = {}) ⇒ Object
Runs the gff3-ffetch utility with the specified parameters while passing data to its stdin.
-
.filter_file(filename, filter_string, options = {}) ⇒ Object
Runs the gff3-ffetch utility with the specified parameters on an external file.
-
.validate_file(filename) ⇒ Object
Runs the gff3-validate utility with the specified filename as argument.
Class Method Details
.filter_data(data, filter_string, options = {}) ⇒ Object
Runs the gff3-ffetch utility with the specified parameters while passing data to its stdin. Options include :output and :at_most, :keep_fasta, :keep_comments, :keep_pragmas, :gtf_output, :json_output, :select
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/bio-gff3-pltools/filtering.rb', line 52 def self.filter_data data, filter_string, = {} output_option = nil output = nil if ![:output].nil? output_option = "--output #{[:output]}" end if ![:at_most].nil? at_most_option = "--at-most #{[:at_most]}" end if [:keep_fasta] fasta_option = "--keep-fasta" end if [:keep_comments] comments_option = "--keep-comments" end if [:keep_pragmas] pragmas_option = "--keep-pragmas" end if [:gtf_output] gtf_output_option = "--gtf-output" end if [:json_output] json_output_option = "--json" end if ![:select].nil? select_option = "--select \"#{[:select]}\"" end gff3_ffetch = IO.popen("gff3-ffetch --filter \"#{filter_string}\" - #{output_option} #{at_most_option} #{fasta_option} #{comments_option} #{pragmas_option} #{gtf_output_option} #{json_output_option} #{select_option}", "r+") gff3_ffetch.write data gff3_ffetch.close_write if output_option.nil? output = gff3_ffetch.read end gff3_ffetch.close output end |
.filter_file(filename, filter_string, options = {}) ⇒ Object
Runs the gff3-ffetch utility with the specified parameters on an external file. Options include :output, :at_most, :keep_fasta, :keep_comments, :keep_pragmas, :gtf_output, :json_output, :select
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/bio-gff3-pltools/filtering.rb', line 8 def self.filter_file filename, filter_string, = {} if !File.exists?(filename) raise Exception.new("No such file - #{filename}") end output_option = nil output = nil if ![:output].nil? output_option = "--output #{[:output]}" end if ![:at_most].nil? at_most_option = "--at-most #{[:at_most]}" end if [:keep_fasta] fasta_option = "--keep-fasta" end if [:keep_comments] comments_option = "--keep-comments" end if [:keep_pragmas] pragmas_option = "--keep-pragmas" end if [:gtf_output] gtf_output_option = "--gtf-output" end if [:json_output] json_output_option = "--json" end if ![:select].nil? select_option = "--select \"#{[:select]}\"" end puts "gff3-ffetch --filter \"#{filter_string}\" #{filename} #{output_option} #{at_most_option} #{fasta_option} #{comments_option} #{pragmas_option} #{gtf_output_option} #{json_output_option} #{select_option}" gff3_ffetch = IO.popen("gff3-ffetch --filter \"#{filter_string}\" #{filename} #{output_option} #{at_most_option} #{fasta_option} #{comments_option} #{pragmas_option} #{gtf_output_option} #{json_output_option} #{select_option}") if output_option.nil? output = gff3_ffetch.read end gff3_ffetch.close output end |
.validate_file(filename) ⇒ Object
Runs the gff3-validate utility with the specified filename as argument. Returns error messages if the utility found issues in the file.
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/bio-gff3-pltools/validation.rb', line 7 def self.validate_file filename if !File.exists?(filename) raise Exception.new("No such file - #{filename}") end gff3_validate = IO.popen(["gff3-validate", "#{filename}", :err=>[:child, :out]]) output = gff3_validate.read gff3_validate.close output end |