Mercurial > repos > lionelguy > spades
view tools/spades_2_4/spades.pl @ 0:a407a6ed437d draft
Uploaded version 0.2, tested on the toolshed
author | lionelguy |
---|---|
date | Wed, 17 Jul 2013 06:07:29 -0400 |
parents | |
children |
line wrap: on
line source
#!/usr/bin/env perl ## A wrapper script to call spades.py and collect its output use strict; use warnings; use File::Temp qw/ tempfile tempdir /; use File::Copy; # Parse arguments my ($out_contigs_file, $out_scaffolds_file, $out_log_file, @sysargs) = @ARGV; # Create temporary folder to store files, delete after use #my $output_dir = tempdir( CLEANUP => 0 ); my $output_dir = tempdir( CLEANUP => 1 ); # Link "dat" files as fastq, otherwise spades complains about file format # Create log handle open my $log, '>', $out_log_file or die "Cannot write to $out_log_file: $?\n"; # Run program # To do: record time &runSpades(@sysargs); &collectOutput(); print $log "Done\n"; close $log; exit 0; # Run spades sub runSpades { my $cmd = join(" ", @_) . " -o $output_dir"; my $return_code = system($cmd); if ($return_code) { print $log "Failed with code $return_code\nCommand $cmd\nMessage: $?\n"; die "Failed with code $return_code\nCommand $cmd\nMessage: $?\n"; } return 0; } # Collect output sub collectOutput{ # To do: check that the files are there # Collects output move "$output_dir/contigs.fasta", $out_contigs_file; move "$output_dir/scaffolds.fasta", $out_scaffolds_file; open LOG, '<', "$output_dir/spades.log" or die "Cannot open log file $output_dir/spades.log: $?"; print $log $_ while (<LOG>); return 0; }