annotate snippy_core_wrapper.pl @ 7:93d294cd4d59 draft default tip

Added snippy core
author simon-gladman
date Fri, 10 Jun 2016 00:10:22 -0400
parents 15f5a3074012
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
1 #!/usr/bin/env perl
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
2
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
3 #--------------------------------------
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
4 #
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
5 # snippy_core_wrapper.pl
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
6 #
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
7 # This is an intermediary script between snippy-core.xml and snippy-core
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
8 # It:
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
9 # - Copys the supplied zipped snippy output files to the working dir
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
10 # - Untars them to their datafile name
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
11 # - Builds the snippy-core command and captures the stdout and stderr to files
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
12 # - Runs the snippy-core command
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
13 #
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
14 #--------------------------------------
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
15
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
16 use warnings;
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
17 use strict;
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
18 use File::Copy;
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
19 use File::Basename;
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
20
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
21 my(@Options, $indirs, $mincov, $noref);
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
22 setOptions();
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
23
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
24 my @list_of_dirs = split /\s+/, $indirs;
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
25
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
26 #The list of final directories to be passed to snippy-core will be stored here.
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
27 my @snippy_outs;
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
28
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
29 foreach my $d (@list_of_dirs){
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
30 #print STDERR "$d\n";
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
31 my $bn = basename($d);
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
32 my ($name, $dir, $ext) = fileparse($d, '\..*');
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
33 copy($d, $bn);
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
34 #print STDERR "$d, $bn, $name, $dir, $ext\n";
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
35 `tar -xf $bn`;
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
36 move("./out", "./$name");
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
37 unlink($bn);
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
38 push @snippy_outs, $name;
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
39 }
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
40
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
41 my $commandline = "snippy-core ";
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
42
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
43 $commandline .= "--noref " if $noref;
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
44 $commandline .= "--mincov $mincov " if $mincov;
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
45 $commandline .= join(" ", @snippy_outs);
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
46 print STDERR "snippy-core commandline: $commandline\n";
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
47
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
48 my $ok = system($commandline);
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
49
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
50 #----------------------------------------------------------------------
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
51 # Option setting routines
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
52
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
53 sub setOptions {
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
54 use Getopt::Long;
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
55
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
56 @Options = (
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
57 {OPT=>"help", VAR=>\&usage, DESC=>"This help"},
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
58 {OPT=>"mincov=i", VAR=>\$mincov, DEFAULT=>'10.0', DESC=>"The minimum coverage to consider."},
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
59 {OPT=>"noref!", VAR=>\$noref, DEFAULT=>0, DESC=>"Don't include the reference in the alignment."},
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
60 {OPT=>"indirs=s", VAR=>\$indirs, DEFAULT=>"", DESC=>"A whitespace delimited list of the snippy output zipped dirs."},
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
61 );
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
62
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
63 &GetOptions(map {$_->{OPT}, $_->{VAR}} @Options) || usage();
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
64
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
65 # Now setup default values.
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
66 foreach (@Options) {
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
67 if (defined($_->{DEFAULT}) && !defined(${$_->{VAR}})) {
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
68 ${$_->{VAR}} = $_->{DEFAULT};
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
69 }
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
70 }
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
71 }
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
72
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
73 sub usage {
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
74 print "Usage: $0 [options] -i inputfile > ... \n";
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
75 foreach (@Options) {
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
76 printf " --%-13s %s%s.\n",$_->{OPT},$_->{DESC},
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
77 defined($_->{DEFAULT}) ? " (default '$_->{DEFAULT}')" : "";
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
78 }
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
79 exit(1);
15f5a3074012 Added snippy core and static binaries for linux and mac.
simon-gladman
parents:
diff changeset
80 }