annotate snippy_core_wrapper.pl @ 21:0e733df972b5 draft

planemo upload commit d65fe6718a4e9a9fa6dba28e6702335222c3e221-dirty
author dfornika
date Tue, 12 Mar 2019 17:37:29 -0400
parents 3bbfe41787af
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
1 #!/usr/bin/env perl
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
2
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
3 #--------------------------------------
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
4 #
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
5 # snippy_core_wrapper.pl
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
6 #
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
7 # This is an intermediary script between snippy-core.xml and snippy-core
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
8 # It:
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
9 # - Copys the supplied zipped snippy output files to the working dir
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
10 # - Untars them to their datafile name
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
11 # - Builds the snippy-core command
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
12 # - Runs the snippy-core command
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
13 #
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
14 #--------------------------------------
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
15
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
16 use warnings;
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
17 use strict;
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
18 use File::Copy;
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
19 use File::Basename;
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
20
20
3bbfe41787af planemo upload commit bf653fc1bf39312caf070843fbde7b2570330917-dirty
dfornika
parents: 19
diff changeset
21 my(@Options, $indirs, $ref);
0
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
22 setOptions();
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
23
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
24 my @list_of_dirs = split /\s+/, $indirs;
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
25
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
26 #The list of final directories to be passed to snippy-core will be stored here.
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
27 my @snippy_outs;
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
28
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
29 foreach my $d (@list_of_dirs){
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
30 print STDERR "$d\n";
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
31 my $bn = basename($d);
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
32 my ($name, $dir, $ext) = fileparse($d, '\..*');
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
33 copy($d, $bn);
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
34 print STDERR "$d, $bn, $name, $dir, $ext\n";
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
35 `tar -xf $bn`;
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
36 }
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
37
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
38 my $test_list = `ls -d */`;
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
39 $test_list =~ s/\///g;
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
40 print STDERR "$test_list\n";
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
41
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
42 @snippy_outs = split /\s+/, $test_list;
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
43
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
44
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
45 my $commandline = "snippy-core ";
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
46
20
3bbfe41787af planemo upload commit bf653fc1bf39312caf070843fbde7b2570330917-dirty
dfornika
parents: 19
diff changeset
47 $commandline .= " --ref $ref " if $ref;
0
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
48 $commandline .= join(" ", @snippy_outs);
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
49 print STDERR "snippy-core commandline: $commandline\n";
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
50
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
51 my $ok = system($commandline);
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
52
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
53 #----------------------------------------------------------------------
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
54 # Option setting routines
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
55
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
56 sub setOptions {
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
57 use Getopt::Long;
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
58
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
59 @Options = (
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
60 {OPT=>"help", VAR=>\&usage, DESC=>"This help"},
20
3bbfe41787af planemo upload commit bf653fc1bf39312caf070843fbde7b2570330917-dirty
dfornika
parents: 19
diff changeset
61 {OPT=>"ref=s", VAR=>\$ref, DEFAULT=>"", DESC=>"Reference genome."},
0
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
62 {OPT=>"indirs=s", VAR=>\$indirs, DEFAULT=>"", DESC=>"A whitespace delimited list of the snippy output zipped dirs."},
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
63 );
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
64
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
65 &GetOptions(map {$_->{OPT}, $_->{VAR}} @Options) || usage();
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
66
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
67 # Now setup default values.
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
68 foreach (@Options) {
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
69 if (defined($_->{DEFAULT}) && !defined(${$_->{VAR}})) {
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
70 ${$_->{VAR}} = $_->{DEFAULT};
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
71 }
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
72 }
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
73 }
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
74
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
75 sub usage {
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
76 print "Usage: $0 [options] -i inputfile > ... \n";
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
77 foreach (@Options) {
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
78 printf " --%-13s %s%s.\n",$_->{OPT},$_->{DESC},
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
79 defined($_->{DEFAULT}) ? " (default '$_->{DEFAULT}')" : "";
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
80 }
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
81 exit(1);
0276bb8bd561 planemo upload for repository https://github.com/tseemann/snippy commit d9e4e18619d5b9378f4fcbe518856fc1fa202d73-dirty
dfornika
parents:
diff changeset
82 }