in reply to Re^2: deleting a particular character and its coresponding score in 2 different files!!!
in thread deleting a particular character and its coresponding score in 2 different files!!!
No. It is because you are being silly. Some important lines of code are:
my @new = split ('>', $joi1); ... my @new; .. foreach (@new) {
Which of the two @new variables do you expect will be used by the for loop?
Why didn't you show us the '"my" variable @new masks earlier declaration in same scope at ...' errors you received or the errors about @alp and @num? Have you actually run the code you've shown us?
It helps us a lot to help you if you give use sample code we can actually run and if you show us the result you get and the result you would like from running the code. Oh, and the sample code and results should be short. For example cleaning up your code a little including fixing all stricture warnings and errors:
use warnings; use strict; my $seq = <<DATA; >s1 AGCTTTTCGGGCAAT >s2 GCTGCCCCCCATCTT >s3 TCGTAGCTGAAAATC DATA my $num = <<DATA; >s1 23 43 45 65 76 54 3 34 54 65 7 45 56 87 56 >s2 23 43 23 45 65 45 76 78 34 8 12 32 65 23 25 >s3 12 23 34 45 56 54 43 32 65 43 12 34 75 76 45 DATA open FH1, '<', \$seq; open FH2, '<', \$num; my @arr1 = <FH1>; my @arr2 = <FH2>; my $joi1 = join (' ', @arr1); my $joi2 = join (' ', @arr2); my @new = grep length, split ('>', $joi1); my @numbers = grep length, split ('>', $joi2); my @seqid; my @alp; foreach (@new) { my ($seq_id, $seq) = split (/\n/, $_); push (@alp, grep /[ACGT]/, split ('', $seq)); push (@seqid, $seq_id); } my @num; my @numid; foreach (@numbers) { my ($num_id, $numb) = split (/\n/, $_); push (@num, split (' ', $numb)); push ( @numid, $num_id ); } my @keep = grep {$_ < 1 || $num[$_] >= 10 || $alp[$_ - 1] ne $alp[$_ - 0]} 0 +.. $#num; print (join (' ', @alp[@keep]), "\n"); print (join (' ', map {sprintf '%2d', $_} @num[@keep]), "\n");
prints:
A G C T T T C G G C A A T G C T G C C C C C A T + C T T T C G T A G C T G A A A A T C 23 43 45 65 76 54 34 54 65 45 56 87 56 23 43 23 45 65 45 76 78 34 12 3 +2 65 23 25 12 23 34 45 56 54 43 32 65 43 12 34 75 76 45
|
|---|