comparison Rooting/Rooting.pl @ 9:98c37a5d67f4 draft

Uploaded
author dereeper
date Wed, 07 Feb 2018 22:08:47 -0500
parents
children
comparison
equal deleted inserted replaced
8:6bf69b40365c 9:98c37a5d67f4
1 #!/usr/bin/perl
2
3 use strict;
4 use Getopt::Long;
5 use Bio::SeqIO;
6 use Cwd ;
7 use FindBin qw ( $Bin $Script );
8
9 my $CURRENT_DIR = $Bin;
10
11 my $ROOTING_EXE = "java -jar ". $CURRENT_DIR . "/Rootings_54.jar";
12
13 my $usage = qq~Usage:$0 <args> [<opts>]
14 where <args> are:
15 -i, --input <newick input>
16 -o, --output <newick output>
17 ~;
18 $usage .= "\n";
19
20 my ($input,$outfile);
21
22
23 GetOptions(
24 "input=s" => \$input,
25 "output=s" => \$outfile
26 );
27
28
29 die $usage
30 if ( !$input || !$outfile);
31
32 my $treefile = $input;
33
34
35 # replace negative values by 0
36 open(T,$treefile);
37 open(T2,">$treefile.2");
38 while(<T>)
39 {
40 my $line = $_;
41 $line =~s/\-\d+\.*\d*\,/0,/g;
42 $line =~s/\-\d+\.*\d*\)/0\)/g;
43 print T2 $line;
44 }
45 close(T);
46 close(T2);
47
48 my $rooting_command = $ROOTING_EXE . " -input $treefile.2 -output $treefile.all -midpoint $treefile.midpoint >>$treefile.rooting.log 2>&1";
49 system($rooting_command);
50
51 unlink("$treefile.all");
52 unlink("$treefile.2");
53 rename("$treefile.midpoint",$outfile);
54
55
56
57
58