annotate contra_wrapper.pl @ 23:2770f49cb0dc

re-uploading contra
author Franco Caramia <franco.caramia@petermac.org>
date Tue, 20 May 2014 09:59:00 +1000
parents
children c361b3fb806e
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
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
4 use FindBin;
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;
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
25 print "$variable\n";
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
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
43 my $working_dir = "CONTRA_OUTPUT";
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
44 make_path($contra_dir);
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
45 #remove extension
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
46
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
47 #run contra
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
48 system(File::Spec->catfile($FindBin::Bin, 'contra.py') . " -o $working_dir $player_options > /dev/null 2>&1");
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
49
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
50 #set html
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
51 #print "$contra_output - $working_dir\n";
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
52 open(HTML, ">$contra_output");
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
53 print HTML "<html><head><title>Contra: Copy Number Analysis for Targeted Resequencing</title></head><body><h3>Contra Output Files:</h3><p><ul>\n";
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
54 move_files($working_dir);
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
55 print HTML "</ul></p>\n";
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
56 close(HTML);
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
57
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
58 sub move_files
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
59 {
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
60 my $local_dir = $_[0];
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
61 opendir(DIR, $local_dir);
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
62 #print ("Openning: $local_dir\n");
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
63 my @FILES= readdir(DIR);
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
64 closedir(DIR);
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
65 foreach my $file (@FILES)
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 if ($file eq "." || $file eq "..")
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
68 {
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
69 #print ("./ or ../ skipped\n");
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
70 }
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
71 elsif (-d "$local_dir/$file")
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
72 {
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
73 #print ("moving to: $local_dir/$file\n");
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
74 move_files("$local_dir/$file");
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
75 }
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
76 elsif (-f "$local_dir/$file")
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
77 {
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
78 #print ("mv $local_dir/$file $contra_dir\n");
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
79 print HTML "<li><a href=$file>$file</a></li>\n";
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
80 system ("mv $local_dir/$file $contra_dir");
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
81 }
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
82 else
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
83 {
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
84 die("Unrecognized file generated: $file\n");
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
85 }
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
86
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
87
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
88 }
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
89
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
90 }
2770f49cb0dc re-uploading contra
Franco Caramia <franco.caramia@petermac.org>
parents:
diff changeset
91