bin/fasta_util in fasta_util-0.5.1 vs bin/fasta_util in fasta_util-0.5.2

- old
+ new

@@ -58,18 +58,21 @@ long_desc "Impose a filter or set of filters on entries in a fasta file where each sequence in the file has to pass all of the filters to be printed." method_option :length_cutoff, :aliases => '-l', :type => :numeric, :default => 0, :desc => 'Only entries with length >= cutoff will be returned.' method_option :inverse_match, :aliases => '-v', :type => :boolean, :desc => "Return the inverse of the match after all the other filters have been applied." method_option :defline_grep, :aliases => '-d', :type => :string, :default => '', :desc => "A regular expression, used to search the entry's definition line." method_option :definitions_file, :aliases => '-f', :type => :string, :default => '', :desc => "A file with definitions to match, one per line." + method_option :entry_id_file, :aliases => '-e', :type => :string, :default => '', :desc => "A file with entry_ids to match, one per line." def filter(filename) invoke :filecheck invoke :filecheck, [options.definitions_file] requested_definitions = File.open(options.definitions_file).map{|definition| definition.strip} unless options.definitions_file == '' + entry_ids = File.open(options.entry_id_file).map{|id| id.strip} unless options.entry_id_file == '' Bio::FlatFile.open(filename).each do |entry| passed = true passed &&= (entry.length >= options.length_cutoff) passed &&= (entry.definition.match(Regexp.new(options.defline_grep))) passed &&= (requested_definitions.include? entry.definition) unless options.definitions_file == '' + passed &&= (entry_ids.include? entry.entry_id) unless options.entry_id_file == '' passed = !passed if options.inverse_match puts entry if passed end end