annotate Contra/contra_wrapper.pl @ 0:7564f3b1e675

Uploaded
author fcaramia
date Thu, 13 Sep 2012 02:31:43 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
1 use strict;
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
2 use warnings;
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
3 use File::Basename;
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
4 use Cwd;
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
5 use File::Path qw(make_path remove_tree);
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
6 die qq(
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
7 Bad numbr of inputs
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
8
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
9 ) if(!@ARGV);
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
10
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
11
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
12 my $player_options = "";
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
13 my $contra_output;
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
14 my $contra_dir;
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
15
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
16 my $dir = getcwd;
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
17 my $variable;
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
18
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
19 foreach my $input (@ARGV)
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
20 {
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
21 my @tmp = split "::", $input;
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
22
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
23 if($tmp[0] eq "PLAYEROPTION")
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
24 {
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
25 $variable = $tmp[1];
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
26 $variable =~ s/=/ /g;
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
27 print "$variable\n";
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
28 $player_options = "$player_options $variable";
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
29 }
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
30 elsif($tmp[0] eq "CONTRAOUTPUT")
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
31 {
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
32 $contra_output = $tmp[1];
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
33 }
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
34 elsif($tmp[0] eq "CONTRADIR")
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
35 {
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
36 $contra_dir = $tmp[1];
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
37 }
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
38 else
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
39 {
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
40 die("Unknown Input: $input\n");
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
41 }
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
42 }
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
43
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
44
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
45 my $working_dir = "CONTRA_OUTPUT";
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
46 make_path($contra_dir);
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
47 #remove extension
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
48
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
49 #run contra
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
50 system ("contra.py -o $working_dir $player_options > /dev/null 2>&1");
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
51
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
52
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
53 #set html
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
54 #print "$contra_output - $working_dir\n";
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
55 open(HTML, ">$contra_output");
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
56 print HTML "<html><head><title>Contra: Copy Number Analysis for Targeted Resequencing</title></head><body><h3>Contra Output Files:</h3><p><ul>\n";
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
57 move_files($working_dir);
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
58 print HTML "</ul></p>\n";
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
59 close(HTML);
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
60
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
61 sub move_files
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
62 {
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
63 my $local_dir = $_[0];
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
64 opendir(DIR, $local_dir);
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
65 #print ("Openning: $local_dir\n");
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
66 my @FILES= readdir(DIR);
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
67 closedir(DIR);
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
68 foreach my $file (@FILES)
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
69 {
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
70 if ($file eq "." || $file eq "..")
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
71 {
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
72 #print ("./ or ../ skipped\n");
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
73 }
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
74 elsif (-d "$local_dir/$file")
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
75 {
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
76 #print ("moving to: $local_dir/$file\n");
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
77 move_files("$local_dir/$file");
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
78 }
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
79 elsif (-f "$local_dir/$file")
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
80 {
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
81 #print ("mv $local_dir/$file $contra_dir\n");
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
82 print HTML "<li><a href=$file>$file</a></li>\n";
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
83 system ("mv $local_dir/$file $contra_dir");
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
84 }
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
85 else
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
86 {
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
87 die("Unrecognized file generated: $file\n");
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
88 }
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
89
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
90
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
91 }
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
92
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
93 }
7564f3b1e675 Uploaded
fcaramia
parents:
diff changeset
94