in reply to string complement question
Will this help?
use strict; my %sequences; while (<DATA>) { chomp; $sequences{$_} = $.; } for my $seq (keys %sequences) { my $rev_compl = get_rev_compl($seq); print "$seq matches $rev_compl on line $sequences{$rev_compl}\n" if exists $sequences{$rev_compl}; } sub get_rev_compl { my ($seq) = @_; $seq =~ tr/GCAT/CGTA/; return reverse $seq; } 1; __DATA__ GATTACA TTAGCAA CATCATC TTGCTAA TGTAATC GATGATG
I put the sequences into a hash instead of an array to (hopefully) increase the lookup speed. This won't work if the sequences aren't unique, though.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: string complement question
by thospel (Hermit) on Nov 21, 2003 at 16:44 UTC |