comparison roche454/runMapping_wrapper.pl @ 0:f036c7107601

Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
author edward-kirton
date Tue, 07 Jun 2011 17:50:32 -0400
parents
children 368a6ebebdde
comparison
equal deleted inserted replaced
-1:000000000000 0:f036c7107601
1 #!/jgi/tools/bin/perl -w
2
3 use strict;
4 use File::Copy;
5
6 # EXPECT 21 FILE HANDLES, SOME OF WHICH MAY BE 'None'
7 my $outdir=shift @ARGV;
8 my $alignment_info=shift @ARGV;
9 my $all_contigs_fasta=shift @ARGV;
10 my $all_contigs_qual=shift @ARGV;
11 my $all_diffs=shift @ARGV
12 my $all_struct_vars=shift @ARGV
13 my $hc_diff=shift @ARGV
14 my $hc_struct_vars=shift @ARGV
15 my $mapping_qc=shift @ARGV
16 my $newbler_metrics=shift @ARGV;
17 my $pair_align=shift @ARGV;
18 my $read_status=shift @ARGV;
19 my $ref_status=shift @ARGV;
20 my $tag_pair_align=shift @ARGV;
21 my $trim_status=shift @ARGV;
22 my $trimmed_reads_fasta=shift @ARGV;
23 my $trimmed_reads_qual=shift @ARGV;
24 my $contigs_ace=shift @ARGV;
25 my $large_contigs_fasta=shift @ARGV;
26 my $large_contigs_qual=shift @ARGV;
27 my $gene_status=shift @ARGV;
28
29 # REMOVE PARAMETERS FOR OPTIONAL FILES WHICH WERE NOT PROVIDED
30
31 my @cmd=removeUnusedOptions(@ARGV);
32
33 # RUN COMMAND
34 # NOTE: FIRST ARG EXPECTED TO BE EXECUTABLE
35 my $stderr;
36 eval { $stderr=`@cmd 2>&1`; };
37 if ( $@ ) {
38 print STDERR "Newbler ERROR: $stderr\n";
39 `cat $outdir/assembly/454NewblerProgress.txt 1>&2`;
40 die($@);
41 }
42
43 get_outfile("$outdir/454AlignmentInfo.tsv", $alignment_info);
44 get_outfile("$outdir/454AllContigs.fna", $all_contigs_fasta);
45 get_outfile("$outdir/454AllContigs.qual", $all_contigs_qual);
46 get_outfile("$outdir/454AllDiffs.txt", $all_diffs);
47 get_outfile("$outdir/454AllStructVars.txt", $all_struct_vars);
48 get_outfile("$outdir/454HCDiff.txt", $hc_diff);
49 get_outfile("$outdir/454HCStructVars.txt", $hc_struct_vars);
50 get_outfile("$outdir/454MappingQC.xls", $mapping_qc);
51 get_outfile("$outdir/454NewblerMetrics.txt", $newbler_metrics);
52 get_outfile("$outdir/454PairAlign.txt", $pair_align);
53 get_outfile("$outdir/454ReadStatus.txt", $read_status);
54 get_outfile("$outdir/454RefStatus.txt", $ref_status);
55 get_outfile("$outdir/454TagPairAlign.txt", $tag_pair_align);
56 get_outfile("$outdir/454TrimStatus.txt", $trim_status);
57 get_outfile("$outdir/454TrimmedReads.fna", $trimmed_reads_fasta);
58 get_outfile("$outdir/454TrimmedReads.qual", $trimmed_reads_qual);
59 get_outfile("$outdir/454Contigs.ace", $contigs_ace);
60 get_outfile("$outdir/454LargeContigs.fna", $large_contigs_fasta);
61 get_outfile("$outdir/454LargeContigs.qual", $large_contigs_qual);
62 get_outfile("$outdir/454GeneStatus.txt", $gene_status);
63 exit;
64
65 # EVERY 'None' ARG AND IT'S PRECEEDING OPTION TAG ARE DISCARDED
66 sub removeUnusedOptions {
67 my @cmd=();
68 my $prev;
69 foreach (@_) {
70 unless ($_ eq 'None') {
71 push @cmd, $prev if defined($prev);
72 $prev=$_;
73 } else {
74 $prev=undef;
75 }
76 }
77 push @cmd, $prev if defined($prev);
78 return @cmd;
79 }
80
81 sub get_outfile {
82 my ($src, $dest)=@_;
83 # make sure dest defined and src exist; skip if dest is 'None'
84 if ( $dest and $dest ne 'None' and $src and -f $src ) {
85 move($src,$dest);
86 }
87 }
88
89 __END__