comparison 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
comparison
equal deleted inserted replaced
22:e8a98923965e 23:2770f49cb0dc
1 use strict;
2 use warnings;
3
4 use FindBin;
5 use File::Path qw(make_path);
6 use File::Spec;
7
8
9 die "Bad number of inputs" if(!@ARGV);
10
11 my $player_options = "";
12 my $contra_output;
13 my $contra_dir;
14
15
16
17 foreach my $input (@ARGV)
18 {
19 my @tmp = split "::", $input;
20
21 if($tmp[0] eq "PLAYEROPTION")
22 {
23 my $variable = $tmp[1];
24 $variable =~ s/=/ /g;
25 print "$variable\n";
26 $player_options = "$player_options $variable";
27 }
28 elsif($tmp[0] eq "CONTRAOUTPUT")
29 {
30 $contra_output = $tmp[1];
31 }
32 elsif($tmp[0] eq "CONTRADIR")
33 {
34 $contra_dir = $tmp[1];
35 }
36 else
37 {
38 die("Unknown input: $input\n");
39 }
40 }
41
42
43 my $working_dir = "CONTRA_OUTPUT";
44 make_path($contra_dir);
45 #remove extension
46
47 #run contra
48 system(File::Spec->catfile($FindBin::Bin, 'contra.py') . " -o $working_dir $player_options > /dev/null 2>&1");
49
50 #set html
51 #print "$contra_output - $working_dir\n";
52 open(HTML, ">$contra_output");
53 print HTML "<html><head><title>Contra: Copy Number Analysis for Targeted Resequencing</title></head><body><h3>Contra Output Files:</h3><p><ul>\n";
54 move_files($working_dir);
55 print HTML "</ul></p>\n";
56 close(HTML);
57
58 sub move_files
59 {
60 my $local_dir = $_[0];
61 opendir(DIR, $local_dir);
62 #print ("Openning: $local_dir\n");
63 my @FILES= readdir(DIR);
64 closedir(DIR);
65 foreach my $file (@FILES)
66 {
67 if ($file eq "." || $file eq "..")
68 {
69 #print ("./ or ../ skipped\n");
70 }
71 elsif (-d "$local_dir/$file")
72 {
73 #print ("moving to: $local_dir/$file\n");
74 move_files("$local_dir/$file");
75 }
76 elsif (-f "$local_dir/$file")
77 {
78 #print ("mv $local_dir/$file $contra_dir\n");
79 print HTML "<li><a href=$file>$file</a></li>\n";
80 system ("mv $local_dir/$file $contra_dir");
81 }
82 else
83 {
84 die("Unrecognized file generated: $file\n");
85 }
86
87
88 }
89
90 }
91