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