Leser: 25
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
my @array1=( [qw(small_motif_b 789 799)], [qw(small_motif_a 811 821)], [qw(small_motif_i 822 832)], [qw(tall_motif_a 833 880)], [qw(small_motif_a 881 891)], [qw(small_motif_b 892 902)], [qw(small_motif_a 903 913)], [qw(tall_motif_b 914 961)], [qw(small_motif_a 962 972)], [qw(tall_motif_c 973 1020)], ); my @array2=( [qw(NC_010109.1 NTRFinder . . . ID=NTR-a1;Parent=NTR-a;Name=motif_small_b)], [qw(NC_010109.1 NTRFinder . . . ID=NTR-a2;Parent=NTR-a;Name=motif_small_a)], [qw(NC_010109.1 NTRFinder . . . ID=NTR-a3;Parent=NTR-a;Name=motif_small_i)], [qw(NC_010109.1 NTRFinder . . . ID=NTR-a4;Parent=NTR-a;Name=tall_motif_a)], [qw(NC_010109.1 NTRFinder . . . ID=NTR-a5;Parent=NTR-a;Name=motif_small_a)], [qw(NC_010109.1 NTRFinder . . . ID=NTR-a6;Parent=NTR-a;Name=motif_small_b)], [qw(NC_010109.1 NTRFinder . . . ID=NTR-a7;Parent=NTR-a;Name=motif_small_a)], [qw(NC_010109.1 NTRFinder . . . ID=NTR-a8;Parent=NTR-a;Name=tall_motif_b)], [qw(NC_010109.1 NTRFinder . . . ID=NTR-a9;Parent=NTR-a;Name=motif_small_a)], [qw(NC_010109.1 NTRFinder . . . ID=NTR-a10;Parent=NTR-a;Name=tall_motif_c)], );
1 2 3 4
for my $pos (0..$#array2) { splice(@{$array2[$pos]},2,0,@{$array1[$pos]}); }
1
2
3
4
5
6
7
8
9
foreach (@var)
{
($name,$score) = split; # get score
$score{$_} = $score; # record it
}
print sort {
$score{$a} <=> $score{$b};
}
#@var;
1 2 3 4 5 6
print sort { $score{$a} <=> $score{$b}; } #@var; for my $pos (0..$#gff)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my @array1=( 'small_motif_b 789 799', 'small_motif_a 811 821', 'small_motif_i 822 832', 'tall_motif_a 833 880', 'small_motif_a 881 891', 'small_motif_b 892 902', 'small_motif_a 903 913', 'tall_motif_b 914 961', 'small_motif_a 962 972', 'tall_motif_c 973 1020', ); my @array2=( 'NC_010109.1 NTRFinder . . . ID=NTR-a1;Parent=NTR-a;Name=motif_small_b', 'NC_010109.1 NTRFinder . . . ID=NTR-a2;Parent=NTR-a;Name=motif_small_a', 'NC_010109.1 NTRFinder . . . ID=NTR-a3;Parent=NTR-a;Name=motif_small_i', 'NC_010109.1 NTRFinder . . . ID=NTR-a4;Parent=NTR-a;Name=tall_motif_a', 'NC_010109.1 NTRFinder . . . ID=NTR-a5;Parent=NTR-a;Name=motif_small_a', 'NC_010109.1 NTRFinder . . . ID=NTR-a6;Parent=NTR-a;Name=motif_small_b', 'NC_010109.1 NTRFinder . . . ID=NTR-a7;Parent=NTR-a;Name=motif_small_a', 'NC_010109.1 NTRFinder . . . ID=NTR-a8;Parent=NTR-a;Name=tall_motif_b', 'NC_010109.1 NTRFinder . . . ID=NTR-a9;Parent=NTR-a;Name=motif_small_a', 'NC_010109.1 NTRFinder . . . ID=NTR-a10;Parent=NTR-a;Name=tall_motif_c', ); for my $pos (0..$#array2) { my @l=split(/ /,$array2[$pos],3); splice(@l,2,0,$array1[$pos]); $array2[$pos]=join(' ',@l); } print Dumper(\@array2);
1 2 3 4 5 6
#... for my $pos (0..$#array2) { $array2[$pos]=~s/^(\S+\s+\S+\s+)/$1$array1[$pos] /; } #...
1 2 3 4 5 6 7 8 9
use Data::Dumper; my @array=( [0..2], [0..2], [0..2], ); print Dumper(\@ARRAY);
1 2 3 4 5 6 7 8 9 10 11 12 13 14
use Data::Dumper; my $txt=<<EOT; Das ist ein Test mit mehreren Zeilen Text, der einzelne Wörter enthält, welche Leerzeichen voneinander Trennen. EOT my @data; push(@data,[split(/\s+/,$_)]) for(split(/\n/,$txt)); # @data ist nun ein AoA print Dumper(\@data);
1 2 3 4 5 6
for my $pos (0..$#array2) { my @l=split(/\t/,$array2[$pos],3); splice(@l,2,0,$array1[$pos]); $array2[$pos]=join("\t",@l); }