# HG changeset patch # User nml # Date 1448032997 18000 # Node ID bae199dc511f15605d157c7d32c236487bfebc7e planemo upload commit 75c510cf71217015f3f83baf61a4a54a3a1f4bfd diff -r 000000000000 -r bae199dc511f bundle_collection.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bundle_collection.pl Fri Nov 20 10:23:17 2015 -0500 @@ -0,0 +1,120 @@ +#!/usr/bin/perl + +use strict; +use warnings; +use File::Copy; +use File::Basename; +use Getopt::Long; +use Pod::Usage; + +my ($html_file, $html_path, @args, %information, $folder); + +Getopt::Long::Configure('bundling'); +GetOptions( + 'i|input=s' => \@args, + 'h|html=s' => \$html_file, + 'p|path=s' => \$html_path + ); + +pod2usage(1) unless @args && $html_file && $html_path; + +#At this point, the output directory does not exist yet. So we have to make it +mkdir $html_path or die "Could not make directory $!"; + +#Now make a folder for all our files +my $data_folder = $html_path."/Bundled_Collection"; +mkdir $data_folder or die "Could not make directory $!"; + +#Go through each list item +foreach my $entry (@args) +{ + #Get key and value. Remove any spaces + my ($info, $file) = split /=/, $entry; + my ($name, $ext) = split /,/, $info; + $name=~s/ /_/g; + my $full_name = $name.".".$ext; + + #We store this for later to make the html file + $information{$name}{$ext}=1; + + #copy each file to its directory + + my $file_path = $data_folder."/".$full_name; + + copy($file,$file_path) or die "Could not copy $file to $file_path: $!"; +} + +#Write out the html file +open my $out, ">", $html_file or die "Could not open html file: $!"; + +my $num_keys = scalar(keys %information); +my $num_vals = scalar(@args); + +printf $out " + + + + + +

Bundle Collection Summary



+ +Number of keys: $num_keys
+Number of values: $num_vals

+ +"; + +foreach my $key (sort(keys %information)) +{ + + foreach my $val (keys %{$information{$key}} ) + { + printf $out ""; + } +} + +printf $out "
File nameFile type
$key$val
"; + +close $out; + +__END__ + +=head1 name + + bundle_collection.pl - Downloads a collection from Galaxy + +=head1 SYNOPSIS + + bundle_collection.pl -h html_file -p output_path -o "key=value" + +=back +=cut \ No newline at end of file diff -r 000000000000 -r bae199dc511f bundle_collection.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/bundle_collection.xml Fri Nov 20 10:23:17 2015 -0500 @@ -0,0 +1,28 @@ + + Download a collection of files + bundle_collection.pl -h $html_file -p $html_file.files_path + #for $f in $input.keys + -i "$f,$input[$f].ext=$input[$f]" + #if $input[$f].metadata.bam_index and $input[$f].metadata.bam_index != "None" + #set $bamind = $f+","+$input[$f].ext+".bai="+$input[$f].metadata.bam_index + -i "$bamind" + #end if + #end for + + + + + + + + + + + ***What it does** + + This tool will bundle up files in a list collection into a downloadable zip file + + Author: Mariam Iskander and Jen Cabral + + +