lib/bio/util/restriction_enzyme/single_strand.rb in bio-1.2.1 vs lib/bio/util/restriction_enzyme/single_strand.rb in bio-1.3.0
- old
+ new
@@ -3,11 +3,11 @@
#
# Author:: Trevor Wennblom <mailto:trevor@corevx.com>
# Copyright:: Copyright (c) 2005-2007 Midwinter Laboratories, LLC (http://midwinterlabs.com)
# License:: The Ruby License
#
-# $Id: single_strand.rb,v 1.7 2007/07/16 19:28:48 k Exp $
+# $Id:$
#
require 'bio/util/restriction_enzyme'
require 'bio/sequence'
@@ -131,11 +131,11 @@
return stripped if @cut_locations_in_enzyme_notation.min == nil
left = (@cut_locations_in_enzyme_notation.min < 0 ? 'n' * @cut_locations_in_enzyme_notation.min.abs : '')
# Add one more 'n' if a cut is at the last position
right = ( (@cut_locations_in_enzyme_notation.max >= @stripped.length) ? ('n' * (@cut_locations_in_enzyme_notation.max - @stripped.length + 1)) : '')
- [left, stripped, right].to_s
+ [left, stripped, right].join('')
end
# The sequence with 'n' pads, cut symbols, and spacing for alignment.
# * <code>SingleStrand.new('garraxt', [-2, 1, 7]).with_spaces # => "n^n g^a r r a x t^n"</code>
#
@@ -181,17 +181,18 @@
# Tadayoshi Funaba's method as discussed in Programming Ruby 2ed, p390
def self.once(*ids)
for id in ids
module_eval <<-"end;"
- alias_method :__#{id.to_i}__, :#{id.to_s}
- private :__#{id.to_i}__
+ alias_method :__#{id.__id__}__, :#{id.to_s}
+ private :__#{id.__id__}__
def #{id.to_s}(*args, &block)
- (@__#{id.to_i}__ ||= [__#{id.to_i}__(*args, &block)])[0]
+ (@__#{id.__id__}__ ||= [__#{id.__id__}__(*args, &block)])[0]
end
end;
end
end
+ private_class_method :once
once :pattern, :with_cut_symbols, :with_spaces, :to_re
end # SingleStrand
end # RestrictionEnzyme