comparison runMapping_cDNA_wrapper.pl @ 2:2d86d5b112e8

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