in reply to Create the reverse complement DNA sequence without pattern matching and reverse built-in function?
Sure there is. You could even reimplement an entire regular expression engine using substr, though I wouldn't recommend it. However, you're not using a regular expression here, you're using transliteration: tr///.
my $seq="ACGGGAGGACGGGAAAATTACTACGGCATTAGC"; my %xref = ( A => 'T', C => 'G', G => 'C', T => 'A', a => 't', c => 'g', g => 'c', t => 'a', ); for(my $ix = 0; $ix < length $seq; ++$ix ) { substr( $seq, $ix, 1, $xref{ substr( $seq, $ix, 1 ) } ); } my $reverse = reverse($seq); print $reverse, "\n";
Proof you can write "almost C" in Perl.
I would expect this to be tremendously slower than using tr/// on large data sets.
Dave
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Create the reverse complement DNA sequence without pattern matching and reverse built-in function?
by atcroft (Abbot) on Feb 19, 2014 at 15:13 UTC |