2010/8/30 Martin Hansen <mail / maasha.dk>: > >> #{ (0..(BASE_SOLEXA + cutoff)).map {|ch| >> Regexp.escape(ch.chr)}.join("|") } >> >> This gives shorter and more readable strings. > > OK, so for the right range that is equal to: > > regex = Regexp.union((-5 .. cutoff).collect { |n| (n + BASE_SOLEXA).chr > } ) > > Which returns: > > (?-mix:;|<|=|>|\?|@|A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T) > > But I dont get how the substitution will scan one string (scores) an > make changes to the other (seq): > > seq 'TTGGTCGCTCGCTCCGCGACCTCAGATCAGACGTGGGCGAT' > scores = '@ABCDEFGHIJK?MNOPQRSTUVWhgfedcba`_^]\[ZYX' > > ? It doesn't. Somehow I must have missed an important detail... :-) You could do this though seq.gsub! /./ do |m| scores[$`.length].ord - BASE_SOLEXA < cutoff ? m.downcase! : m end Not too nice though. You could however do some preparation, e.g. store scores as an Array of Fixnum instead of using #ord. >> AFAIK there are none. > > That is actually strange. In Perl you can do this: > > perl -le 'print "ABCDEFG" | " ¨Â°Ü> => abCDefg > > Which I believe is very efficient. And the mask with " " and "\0" can be > constructed with transliterate efficiently too. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/