annotate contra_wrapper.pl @ 27:0bf826f62f04 default tip

fixed toolshed not filling fields
author Franco Caramia <franco.caramia@petermac.org>
date Wed, 04 Jun 2014 11:04:17 +1000
parents 00278c5fe014
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
23
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
1 use strict;
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
2 use warnings;
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
3
26
00278c5fe014 fixed typo
Franco Caramia <franco.caramia@petermac.org>
parents: 25
diff changeset
4 use File::Find;
23
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
5 use File::Path qw(make_path);
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
6 use File::Spec;
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
7
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
8
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
9 die "Bad number of inputs" if(!@ARGV);
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
10
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
11 my $player_options = "";
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
12 my $contra_output;
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
13 my $contra_dir;
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
14
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
15
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
16
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
17 foreach my $input (@ARGV)
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
18 {
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
19 my @tmp = split "::", $input;
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
20
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
21 if($tmp[0] eq "PLAYEROPTION")
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
22 {
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
23 my $variable = $tmp[1];
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
24 $variable =~ s/=/ /g;
25
c361b3fb806e added Nicola Path 2.0
Franco Caramia <franco.caramia@petermac.org>
parents: 23
diff changeset
25
23
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
26 $player_options = "$player_options $variable";
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
27 }
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
28 elsif($tmp[0] eq "CONTRAOUTPUT")
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
29 {
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
30 $contra_output = $tmp[1];
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
31 }
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
32 elsif($tmp[0] eq "CONTRADIR")
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
33 {
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
34 $contra_dir = $tmp[1];
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
35 }
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
36 else
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
37 {
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
38 die("Unknown input: $input\n");
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
39 }
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
40 }
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
41
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
42
25
c361b3fb806e added Nicola Path 2.0
Franco Caramia <franco.caramia@petermac.org>
parents: 23
diff changeset
43
c361b3fb806e added Nicola Path 2.0
Franco Caramia <franco.caramia@petermac.org>
parents: 23
diff changeset
44 my $working_dir = File::Spec->catfile($contra_dir, 'CONTRA_OUTPUT');
23
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
45 make_path($contra_dir);
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
46 #remove extension
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
47
25
c361b3fb806e added Nicola Path 2.0
Franco Caramia <franco.caramia@petermac.org>
parents: 23
diff changeset
48 my $cmd = "contra.py -o $working_dir $player_options";
c361b3fb806e added Nicola Path 2.0
Franco Caramia <franco.caramia@petermac.org>
parents: 23
diff changeset
49 print "Command to be executed: $cmd\n";
c361b3fb806e added Nicola Path 2.0
Franco Caramia <franco.caramia@petermac.org>
parents: 23
diff changeset
50 system($cmd);
23
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
51
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
52 #set html
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
53 #print "$contra_output - $working_dir\n";
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
54 open(HTML, ">$contra_output");
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
55 print HTML "<html><head><title>Contra: Copy Number Analysis for Targeted Resequencing</title></head><body><h3>Contra Output Files:</h3><p><ul>\n";
25
c361b3fb806e added Nicola Path 2.0
Franco Caramia <franco.caramia@petermac.org>
parents: 23
diff changeset
56 find({wanted => \&add_file, preprocess => sub {sort @_}}, $working_dir);
23
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
57 print HTML "</ul></p>\n";
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
58 close(HTML);
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
59
25
c361b3fb806e added Nicola Path 2.0
Franco Caramia <franco.caramia@petermac.org>
parents: 23
diff changeset
60 sub add_file {
c361b3fb806e added Nicola Path 2.0
Franco Caramia <franco.caramia@petermac.org>
parents: 23
diff changeset
61 if (-f $File::Find::name) {
c361b3fb806e added Nicola Path 2.0
Franco Caramia <franco.caramia@petermac.org>
parents: 23
diff changeset
62 my $rel_path = File::Spec->abs2rel($File::Find::name, $working_dir);
c361b3fb806e added Nicola Path 2.0
Franco Caramia <franco.caramia@petermac.org>
parents: 23
diff changeset
63 print ("adding $rel_path\n");
c361b3fb806e added Nicola Path 2.0
Franco Caramia <franco.caramia@petermac.org>
parents: 23
diff changeset
64 print HTML "<li><a href=\"CONTRA_OUTPUT/$rel_path\">$rel_path</a></li>\n";
c361b3fb806e added Nicola Path 2.0
Franco Caramia <franco.caramia@petermac.org>
parents: 23
diff changeset
65 }
23
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
66 }
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
67