Module: Bio::PL::GTF
- Defined in:
- lib/bio-gff3-pltools/filtering.rb
Class Method Summary collapse
-
.filter_data(data, filter_string, options = {}) ⇒ Object
Runs the gtf-ffetch utility with the specified parameters while passing data to its stdin.
-
.filter_file(filename, filter_string, options = {}) ⇒ Object
Runs the gtf-ffetch utility with the specified parameters on an external file.
Class Method Details
.filter_data(data, filter_string, options = {}) ⇒ Object
Runs the gtf-ffetch utility with the specified parameters while passing data to its stdin. Options include :output and :at_most, :keep_fasta, :keep_comments, :keep_pragmas, :gff3_output, :json_output, :select
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 |
# File 'lib/bio-gff3-pltools/filtering.rb', line 138 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 [:gff3_output] gff3_output_option = "--gff3-output" end if [:json_output] json_output_option = "--json" end if ![:select].nil? select_option = "--select \"#{[:select]}\"" end gtf_ffetch = IO.popen("gtf-ffetch --filter \"#{filter_string}\" - #{output_option} #{at_most_option} #{fasta_option} #{comments_option} #{pragmas_option} #{gff3_output_option} #{json_output_option} #{select_option}", "r+") gtf_ffetch.write data gtf_ffetch.close_write if output_option.nil? output = gtf_ffetch.read end gtf_ffetch.close output end |
.filter_file(filename, filter_string, options = {}) ⇒ Object
Runs the gtf-ffetch utility with the specified parameters on an external file. Options include :output, :at_most, :keep_fasta, :keep_comments, :keep_pragmas, :gff3_output, :json_output, :select
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/bio-gff3-pltools/filtering.rb', line 95 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 [:gff3_output] gff3_output_option = "--gff3-output" end if [:json_output] json_output_option = "--json" end if ![:select].nil? select_option = "--select \"#{[:select]}\"" end gff3_ffetch = IO.popen("gtf-ffetch --filter \"#{filter_string}\" #{filename} #{output_option} #{at_most_option} #{fasta_option} #{comments_option} #{pragmas_option} #{gff3_output_option} #{json_output_option} #{select_option}") if output_option.nil? output = gtf_ffetch.read end gtf_ffetch.close output end |