Bonjour
Je travaille sur des analyses evolutives phylogenetiques de type bayesienne avec notamment des software comme beast et j'aurais besoin d'aide pour adapter un script perl afin de retravailler un des fichiers obtenus (fichier txt).
A partir de ce type de fichier en PJ 'history.txt'
Je souhaiterais obtenir un fichier final organisé de la sorte (4 colonnes: from - to - time - states)
from to time states
A B 69.381812150211935 500000
Mais le script supprime la colonne 'states'???
Le script en question:
#!/usr/bin/perl
$num_args = $#ARGV + 1;
if (($num_args != 1) && ($num_args != 3)) {
print "Usage: collect_times <burning #> [from_state] [to_state]\n";
exit(-1);
}
$burn_in = $ARGV[0];
$print_all = 1;
if ($num_args == 3) {
$print_all = 0;
$from = $ARGV[1];
$to = $ARGV[2];
} else {
$from = "ALL";
$to = "ALL";
}
print STDERR "Removing states < $burn_in as burn in.\n";
print STDERR "Recording jumps from $from to $to.\n";
for ($i = 0; $i < 3; $i++) {
$line = <STDIN>;
}
print "from\tto\ttime\n";
while($line = <STDIN>) {
chomp($line);
($state, $count, $jumpf) = split('\t',$line,3);
if ($state >= $burn_in) {
$jumpf =~ s/\{//;
$jumpf =~ s/\}//;
@jumps = split(',',$jumpf);
$n_jumps = scalar(@jumps);
for ($i = 0; $i < $n_jumps; $i++) {
$tmp = $jumps[$i];
$tmp =~ s/\[//;
$tmp =~ s/\]//;
@info = split(':',$tmp);
$info[2] =~ s/\s\d+$//;
if (
($print_all == 1) ||
(($info[0] eq $from) && ($info[1] eq $to))
) {
print "$info[0]\t$info[1]\t$info[2]\n";
}
}
}
}
Merci beaucoup pour votre aide!!!
Amicalement,
Partager