annotate Rooting/Rooting.pl @ 15:31c23d943c29 draft default tip

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