annotate Rooting/Rooting.pl @ 1:420b57c3c185 draft

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