Mercurial > repos > edward-kirton > abyss_toolsuite
annotate abyss/abyss-pe_wrapper.pl @ 0:f955d9559654 default tip
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:21:54 -0400 |
parents | |
children |
rev | line source |
---|---|
0
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
1 #!/usr/bin/env perl |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
2 |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
3 use strict; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
4 use warnings; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
5 use File::Copy; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
6 |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
7 die("ERROR: Expected at least 8 arguments; got: @ARGV\n") unless @ARGV >= 8; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
8 |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
9 # GET ARGS |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
10 my $kmer_size=shift @ARGV; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
11 my $min_num_pairs=shift @ARGV; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
12 my $outdir=shift @ARGV; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
13 my $outfile=shift @ARGV; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
14 my $contigs_outfile=shift @ARGV; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
15 my $sam_outfile=shift @ARGV; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
16 my $hist_outfile=shift @ARGV; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
17 |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
18 # ALL FILES GO IN THIS extra_files_path |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
19 unless (-d $outdir) { |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
20 mkdir $outdir or die("Unable to make dir, $outdir\n"); |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
21 } |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
22 chdir $outdir; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
23 |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
24 # RUN COMMAND |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
25 `abyss-pe k=$kmer_size n=$min_num_pairs in='@ARGV' name=abyss 2> $outdir/abyss.stderr > $outdir/abyss.stdout`; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
26 if ($? != 0) { |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
27 unless ( -s "$outdir/abyss-3.hist") { print STDERR "NO CONTIGS WERE PRODUCED!\n" } |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
28 open(IN, "<$outdir/abyss.stdout") or die($!); |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
29 while (<IN>) { print STDERR $_ } |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
30 close IN; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
31 die("ABORTING\n"); |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
32 } |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
33 |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
34 # FILTER HISTOGRAM |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
35 open (IN, "<$outdir/abyss.stderr") or die($!); |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
36 open (OUT, ">$outfile") or die($!); |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
37 while (my $line=<IN>) { |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
38 my @chars=split(//, $line); |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
39 my $filter=0; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
40 foreach my $char (@chars) { |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
41 if (ord($char) >= 129) { |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
42 $filter=1; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
43 last; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
44 } |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
45 } |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
46 print OUT $line unless $filter; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
47 } |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
48 close IN; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
49 close OUT; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
50 unlink("$outdir/abyss.stderr"); |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
51 |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
52 # OUTPUT INFO LINE TEXT |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
53 open(IN, "<$outdir/abyss.stdout") or die($!); |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
54 while (<IN>) { |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
55 if (/^Assembled \d+ k\-mer in \d+ contigs/) { |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
56 print; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
57 last; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
58 } |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
59 } |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
60 close IN; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
61 |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
62 # GALAXY DOESN'T WANT GZIPPED DATAFILES |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
63 run("gunzip $outdir/abyss-3.sam.gz"); |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
64 |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
65 # MOVE OUTFILES |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
66 mv_outfile("$outdir/abyss-contigs.fa", $contigs_outfile); |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
67 mv_outfile("$outdir/abyss-3.sam", $sam_outfile); |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
68 mv_outfile("$outdir/coverage.hist", $hist_outfile); |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
69 exit; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
70 |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
71 sub run { |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
72 my $cmd=shift; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
73 my $output=`$cmd 2>&1`; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
74 if ($? != 0) { |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
75 print STDERR "ERROR RUNNING COMMAND: $cmd\n"; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
76 die($output); |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
77 } |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
78 return $output; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
79 } |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
80 |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
81 |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
82 sub mv_outfile { |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
83 my ($src,$dest)=@_; |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
84 # if dest defined and src exist, then move outfiles to galaxy-specified location |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
85 if ( $dest ne 'None' and -f $src ) { |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
86 unlink($dest); |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
87 move($src,$dest); |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
88 } |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
89 } |
f955d9559654
Migrated tool version 1.0.0 from old tool shed archive to new tool shed repository
edward-kirton
parents:
diff
changeset
|
90 __END__ |