Ok mais je n'arrive pas à avoir ce que je souhaite (avec un hash ou un tableau).
J'ai essayé comme ceci :
Mais je n'arrive pas à gérer le cas ou l'on change de chromosome, il faut que je reinisialise mes valeurs et que je recommence avec l'histoire des 15 nt, mais comment puis je faire ??
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 #!/usr/bin/perl use strict; use warnings; my %hash; my ($current_start,$current_stop,$current_chr); my $infile=shift or die "give me a infile\n"; open (IN,"$infile"); my $i=1; while(<IN>){ if( $_ !~ m/^$/){ chomp; my($chr,$start,$stop,$id,$nb,$sens)=split /\t/,$_; if($i==1){ $current_chr=$chr; $current_start = $start; $current_stop = $stop; } else{ if(($chr eq "$current_chr")&& ($start-$current_stop<=15)){ $current_stop = $stop; } elsif (($chr eq "$current_chr") && $start-$current_stop>=15 ){ push(@{$hash{$current_chr}->{'coord'}},$current_start); push(@{$hash{$current_chr}->{'coord'}},$current_stop); #print "$current_chr\t$current_start\t$current_stop\n"; $current_start = $start; $current_stop = $stop; } else{ $current_chr=$chr; $current_start = $start; $current_stop = $stop; } } $i++; } } push(@{$hash{$current_chr}->{'coord'}},$current_stop); push(@{$hash{$current_chr}->{'coord'}},$current_start); #print "$current_chr\t$current_start\t$current_stop\n"; foreach my $value (keys %hash){ print "$value\t@{$hash{$value}->{'coord'}}\n" }
Partager