File: rescale.pl

package info (click to toggle)
clonalorigin 1.0-8
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,800 kB
  • sloc: cpp: 10,488; perl: 349; xml: 130; makefile: 48; sh: 33
file content (20 lines) | stat: -rwxr-xr-x 543 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/perl
#This script edits the Newick string in the input file by rescaling all distances according to the factor given in the first argument

@ARGV==3 || die("Usage: rescale [SCALE] [INPUT] [OUTPUT]");

$scale=$ARGV[0];
open($file,$ARGV[1]) or die("Can't open file ",$ARGV[1],"\n");
$string=<$file>;
close($file);

while ($string =~ /:([0-9]+\.[0-9]+)/) {
$rep=$1*$scale;
$string =~ s/:([0-9]+\.[0-9]+)/!$rep/;
}

$string =~ s/!/:/g;

open($file,">",$ARGV[2]) or die("Can't open output file\n");
print $file "$string\n";
close($file);