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.
In reply to Re: string complement question
by Art_XIV
in thread string complement question
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |