in reply to Re: merging dna sequences
in thread merging dna sequences

I too thought "bitwise string" but ended up with a different mix of operators:
my $s = 'AYGTACTAGACTACAGACTACAGACATCTACAGACTCATCAGCAGCATATTTA'; my $t = 'ACGTACTAGACTACAGACTACAGACATCTACAGACTCATCAGCAGCATATTKA'; tr/ACGTA-Z/\0\0\0\0_/ for my ($s_, $t_) = ($s, $t); my $merged = ($s | $t_) & ($t | $s_); say $merged;

Replies are listed 'Best First'.
Re^3: merging dna sequences
by Anonymous Monk on Nov 10, 2011 at 23:35 UTC
    This one is inspired by moritz's solution, which only replaced the last "T" with a "K" in the first string. It has one less bit-op than my original, so should be a bit faster. (LOL... that one snuck up on me while typing)
    my $s = 'AYGTACTAGACTACAGACTACAGACATCTACAGACTCATCAGCAGCATATTTA'; my $t = 'ACGTACTAGACTACAGACTACAGACATCTACAGACTCATCAGCAGCATATTKA'; (my $del = $t) =~ tr/ACGTA-Z/\0\0\0\0_/; (my $add = $t) =~ tr/ACGT/_/; my $merged = ($s | $del) & $add; say $merged;