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
| #!/usr/bin/perl
use strict;
use warnings;
use Carp qw(confess);
use Getopt::Long;
use List::Util qw(sum);
use Benchmark;
# supprime les pi en double,et leur assigne un identifiant unique
# format de sortie : .fasta
# command line : perl create_bank_pi.pl --in banque_embryon_02h.txt --out fasta.txt
my ($AF_class, $AF_out);
my %hash;
my $i=0;
GetOptions("in=s" => \$AF_class, "out=s" => \$AF_out);
open(my $fh,'<',$AF_class) or die "$AF_class : $!\n\n";
open(my $fh_out,'>',$AF_out) or die "$AF_out : $!\n\n";
sub load() {
while (<$fh>){
if (/^[ATGC]/){
chomp;
my ($seq,$count) = split /\s+/,$_;
my $length = length($seq);
#$hash{$seq}++;
push(@{$hash{$seq}->{'count'}},$count);
}
}
}
timethis(1, \&load, "Load bank");
sub save() {
foreach my $ID (keys(%hash)) {
#print ("ID=$ID\tcount=\t".join("\t", @{$hash{$ID}->{'count'}})."\n");
my $length = length($ID);
my $somme = sum(@{$hash{$ID}->{'count'}});
print { $fh_out } ">dme_pi_".$i."_".$length."_".$somme."\n".$ID."\n";
$i++;
}
}
timethis(1, \&save, , "Save fasta");
close($fh);
close($fh_out); |
Partager