comparison contra_wrapper.pl @ 25:c361b3fb806e

added Nicola Path 2.0
author Franco Caramia <franco.caramia@petermac.org>
date Tue, 03 Jun 2014 17:31:28 +1000
parents 2770f49cb0dc
children 00278c5fe014
comparison
equal deleted inserted replaced
24:6bcf47cc272a 25:c361b3fb806e
1 use strict; 1 use strict;
2 use warnings; 2 use warnings;
3 3
4 use FindBin; 4 use Find;
5 use File::Path qw(make_path); 5 use File::Path qw(make_path);
6 use File::Spec; 6 use File::Spec;
7 7
8 8
9 die "Bad number of inputs" if(!@ARGV); 9 die "Bad number of inputs" if(!@ARGV);
20 20
21 if($tmp[0] eq "PLAYEROPTION") 21 if($tmp[0] eq "PLAYEROPTION")
22 { 22 {
23 my $variable = $tmp[1]; 23 my $variable = $tmp[1];
24 $variable =~ s/=/ /g; 24 $variable =~ s/=/ /g;
25 print "$variable\n"; 25
26 $player_options = "$player_options $variable"; 26 $player_options = "$player_options $variable";
27 } 27 }
28 elsif($tmp[0] eq "CONTRAOUTPUT") 28 elsif($tmp[0] eq "CONTRAOUTPUT")
29 { 29 {
30 $contra_output = $tmp[1]; 30 $contra_output = $tmp[1];
38 die("Unknown input: $input\n"); 38 die("Unknown input: $input\n");
39 } 39 }
40 } 40 }
41 41
42 42
43 my $working_dir = "CONTRA_OUTPUT"; 43
44 my $working_dir = File::Spec->catfile($contra_dir, 'CONTRA_OUTPUT');
44 make_path($contra_dir); 45 make_path($contra_dir);
45 #remove extension 46 #remove extension
46 47
47 #run contra 48 my $cmd = "contra.py -o $working_dir $player_options";
48 system(File::Spec->catfile($FindBin::Bin, 'contra.py') . " -o $working_dir $player_options > /dev/null 2>&1"); 49 print "Command to be executed: $cmd\n";
50 system($cmd);
49 51
50 #set html 52 #set html
51 #print "$contra_output - $working_dir\n"; 53 #print "$contra_output - $working_dir\n";
52 open(HTML, ">$contra_output"); 54 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"; 55 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); 56 find({wanted => \&add_file, preprocess => sub {sort @_}}, $working_dir);
55 print HTML "</ul></p>\n"; 57 print HTML "</ul></p>\n";
56 close(HTML); 58 close(HTML);
57 59
58 sub move_files 60 sub add_file {
59 { 61 if (-f $File::Find::name) {
60 my $local_dir = $_[0]; 62 my $rel_path = File::Spec->abs2rel($File::Find::name, $working_dir);
61 opendir(DIR, $local_dir); 63 print ("adding $rel_path\n");
62 #print ("Openning: $local_dir\n"); 64 print HTML "<li><a href=\"CONTRA_OUTPUT/$rel_path\">$rel_path</a></li>\n";
63 my @FILES= readdir(DIR); 65 }
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 } 66 }
91 67