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