Module: Bio::PL::GFF3
- Defined in:
- lib/bio-gff3-pltools/filtering.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.
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.
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 29 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 gff3_ffetch = IO.popen("gff3-ffetch --filter #{filter_string} - #{output_option} #{at_most_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 and :at_most.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/bio-gff3-pltools/filtering.rb', line 6 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 gff3_ffetch = IO.popen("gff3-ffetch --filter #{filter_string} #{filename} #{output_option} #{at_most_option}") if output_option.nil? output = gff3_ffetch.read end gff3_ffetch.close output end |