Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
my @labels = ('1', '1', '1', '2', '3', '4', '5', '6', '6', '7'); my @seqs = ('a', 'ctgc', 'tggattgactgtg', 'atgcatg' , 'ctgctgcatgtgatg +actgtg', 'tgatg', 'gtgt', 'gcgccggactatgattgagctagcgtatgctgcatgctgat' +, 'gggtttttttttttccccccccccc', 'aaaaaagggggg'); # where the $labels[0] .. [2] all correspond to number 1, so $seqs[0] +.. [2] are concatenated to make actgctggattgactgtg etc. I have tried the following code but the problem is that if there are t +hree or more consecutive elements in @labels that have the same value +, my code only gets the sequences of two in a row, not all of them on +ce only (meaning that sequences will be redundant). for (my $i=0; $i< @labels; $i++) { if ($labels[$i] == $labels[$i+1]) { # print "$labels[$i] == $labels[$i+1]\n"; push @window_int_seqs, "$seqs[$i]$seqs[$i+1] "; } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: two array comparisons
by beable (Friar) on Jul 16, 2004 at 10:31 UTC | |
|
Re: two array comparisons
by murugu (Curate) on Jul 16, 2004 at 10:39 UTC |