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