Mercurial > repos > nml > bundle_collections
comparison bundle_collection.pl @ 0:bae199dc511f draft
planemo upload commit 75c510cf71217015f3f83baf61a4a54a3a1f4bfd
author | nml |
---|---|
date | Fri, 20 Nov 2015 10:23:17 -0500 |
parents | |
children | 705ebd286b57 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:bae199dc511f |
---|---|
1 #!/usr/bin/perl | |
2 | |
3 use strict; | |
4 use warnings; | |
5 use File::Copy; | |
6 use File::Basename; | |
7 use Getopt::Long; | |
8 use Pod::Usage; | |
9 | |
10 my ($html_file, $html_path, @args, %information, $folder); | |
11 | |
12 Getopt::Long::Configure('bundling'); | |
13 GetOptions( | |
14 'i|input=s' => \@args, | |
15 'h|html=s' => \$html_file, | |
16 'p|path=s' => \$html_path | |
17 ); | |
18 | |
19 pod2usage(1) unless @args && $html_file && $html_path; | |
20 | |
21 #At this point, the output directory does not exist yet. So we have to make it | |
22 mkdir $html_path or die "Could not make directory $!"; | |
23 | |
24 #Now make a folder for all our files | |
25 my $data_folder = $html_path."/Bundled_Collection"; | |
26 mkdir $data_folder or die "Could not make directory $!"; | |
27 | |
28 #Go through each list item | |
29 foreach my $entry (@args) | |
30 { | |
31 #Get key and value. Remove any spaces | |
32 my ($info, $file) = split /=/, $entry; | |
33 my ($name, $ext) = split /,/, $info; | |
34 $name=~s/ /_/g; | |
35 my $full_name = $name.".".$ext; | |
36 | |
37 #We store this for later to make the html file | |
38 $information{$name}{$ext}=1; | |
39 | |
40 #copy each file to its directory | |
41 | |
42 my $file_path = $data_folder."/".$full_name; | |
43 | |
44 copy($file,$file_path) or die "Could not copy $file to $file_path: $!"; | |
45 } | |
46 | |
47 #Write out the html file | |
48 open my $out, ">", $html_file or die "Could not open html file: $!"; | |
49 | |
50 my $num_keys = scalar(keys %information); | |
51 my $num_vals = scalar(@args); | |
52 | |
53 printf $out "<!DOCTYPE html> | |
54 <html> | |
55 <style type=\"text/css\"> | |
56 | |
57 body { | |
58 font-family: sans-serif; | |
59 color: #000; | |
60 } | |
61 | |
62 table { | |
63 margin-left: 3em; | |
64 text-align: center; | |
65 } | |
66 th { | |
67 text-align:center; | |
68 background-color: #000080; | |
69 color: #FFF; | |
70 padding: 0.4em; | |
71 } | |
72 td { | |
73 font-family: monospace; | |
74 text-align: left; | |
75 background-color: #EEE; | |
76 color: #000; | |
77 padding: 0.4em; | |
78 } | |
79 h2 { | |
80 color: #800000; | |
81 padding-bottom: 0; | |
82 margin-bottom: 0; | |
83 clear: left; | |
84 } | |
85 </style></head> | |
86 | |
87 <body> | |
88 | |
89 <h2 id=\"M0\">Bundle Collection Summary</h2><br><br> | |
90 | |
91 Number of keys: $num_keys<br> | |
92 Number of values: $num_vals<br><br> | |
93 | |
94 <table border=\"1\"><tr><th>File name</th><th>File type</th></tr>"; | |
95 | |
96 foreach my $key (sort(keys %information)) | |
97 { | |
98 | |
99 foreach my $val (keys %{$information{$key}} ) | |
100 { | |
101 printf $out "<tr><td>$key</td><td>$val</td></tr>"; | |
102 } | |
103 } | |
104 | |
105 printf $out "</table></body></html>"; | |
106 | |
107 close $out; | |
108 | |
109 __END__ | |
110 | |
111 =head1 name | |
112 | |
113 bundle_collection.pl - Downloads a collection from Galaxy | |
114 | |
115 =head1 SYNOPSIS | |
116 | |
117 bundle_collection.pl -h html_file -p output_path -o "key=value" | |
118 | |
119 =back | |
120 =cut |