[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[FWP] More Simplification



Problem: Convert all characters not in the set [AaTtCcGg] to [Nn],
preserving case

Solution A (presented to me)

       $seq =~ s/([^ACTGNactgn])/chr(ord(N) - (ord(uc($1)) - ord($1)))/eg;

There were a few problems with this, not the least of which was that
it didn't work under Perl 4.18 (and some of the code running around
the place was still running under Perl 4!)

Solution B (mine)

         $seq =~ tr/[A-Zatcgn]/n/c;
         $seq =~ tr/[a-zATCGN]/N/c;


I thought this was reasonably elegant, especially because the solution
came to me as I was heading up the on-ramp onto the freeway on the
way home (good solutions are the ones you don't _need_ the computer for)

Anyone have a nicer solution?

-- --
        |\      _,,,---,,_       Vicki Brown <vlb@cfcl.com>
  ZZZzz /,`.-'`'    -.  ;-;;,_   Journeyman Sourceror: Scripts & Philtres
       |,4-  ) )-,_. ,\ (  `'-'  P.O. Box 1269  San Bruno  CA  94066
      '---''(_/--'  `-'\_) http://www.cfcl.com/~vlb  http://www.macperl.org

==== Want to unsubscribe from this list? (Don't you love us anymore?)
==== Well, if you insist... Send mail with body "unsubscribe" to
==== fwp-request@technofile.org

</x-flowed>