0
|
1 #!/usr/bin/env perl
|
|
2
|
|
3 # Execute CoNIFER plotcalls and
|
|
4 # returns a HTML page with links to PNG plots
|
|
5
|
|
6 use strict;
|
|
7 use warnings;
|
|
8 use Getopt::Long;
|
|
9 use File::Basename;
|
|
10 use File::Path qw(make_path remove_tree);
|
|
11
|
|
12 my $command;
|
|
13 my $dir=$ENV{'CONIFER_PATH'};
|
|
14
|
|
15 our ($multiple, $input, $regions, $sample, $window, $html_file, $html_folder, $verbose);
|
|
16
|
|
17 GetOptions('multiple'=>\$multiple, 'input=s'=>\$input, 'regions=s'=>\$regions,
|
|
18 'sample:s'=>\$sample, 'window:i'=>\$window, 'verbose'=>\$verbose,
|
|
19 'html_file=s'=>\$html_file, 'html_folder=s'=>\$html_folder);
|
|
20
|
|
21 make_path($html_folder);
|
|
22
|
|
23 # Build command
|
|
24 if ($multiple){
|
|
25 # Reformat file with regions as required by CoNIFER plotcalls
|
|
26 system("awk '{print \$5,\$1,\$2,\$3,\$4}' OFS=\"\t\" $regions > regions_sorted");
|
|
27
|
|
28 $command = "python ".$dir."/conifer.py plotcalls --input $input --calls regions_sorted --window $window --outputdir $html_folder 2>&1";
|
|
29 }else{
|
|
30 my $sample_command = ($sample eq "") ? "" : "--sample $sample";
|
|
31 my $plot_name = $regions;
|
|
32 $plot_name =~ s/[:-]/_/g;
|
|
33 $command = "python ".$dir."/conifer.py plot --input $input --region $regions $sample_command --output $html_folder/$plot_name.png 2>&1";
|
|
34 }
|
|
35
|
|
36 # Run CoNIFER
|
|
37 system($command);
|
|
38 $verbose and print $command,"\n";
|
|
39
|
|
40 # Write HTML file
|
|
41 open(HTML, ">$html_file");
|
|
42 print HTML "<html><head><title>CoNIFER: Copy Number Analysis for Targeted Resequencing</title></head><body><h3>CoNIFER Output Files:</h3><p><ul>\n";
|
|
43 opendir(DIR, $html_folder);
|
|
44
|
|
45 my @FILES= grep { /png$/ } readdir(DIR);
|
|
46 closedir(DIR);
|
|
47 foreach my $file (@FILES) {
|
|
48 print HTML "<li><a href=$file>$file</a><img src=\"$file\" height=\"50\" width=\"100\"></li>\n";
|
|
49 }
|
|
50 print HTML "</ul></p></body></html>\n";
|
|
51 close(HTML);
|