I’m working on a bioinformatics project that involves piping together different scripts and input parameters for the analysis of Next-Gen Sequencing Illumina data. I need help with the wrapper script. Recall that a wrapper is a shell script that embeds a system command or utility, that accepts and passes a set of parameters to that command. Wrapping a script around a complex command-line simplifies invoking it.
Here’s a minimal representation of the code:
#!/usr/bin/perl
use strict; use warnings;
my $barcode_file= shift;
unless($barcode_file){
die "missing barcode file location, aborting.\n";
}
my $raw_data_location = '/data/local/samples/';
my $components_location= '~/read_cleanup/';
my $tmp_dir= '/tmp/';
open (FILEIN, $barcode_file) or die "couldn't open $barcode_file for read: $!\n";
while(<FILEIN>){
# input file format (tab delimited):
# Sample_Name barcode enzyme size paired seq_file
/^$/ and next; chomp;
my ($sample, $barcode, $enzyme, $size, $pe, $seq_file)= split;
$raw_file_data = "${raw_data_location}$seq_file"; #/data/local/samples/301.fq for instance
# final output file
my $final_output_file = "${tmp_dir}${sample}_reconciled_ends.fq"; # /tmp/D1_reconciled_ends.fq for instance
# if the sample is paired ( 1 - paired, 0 - unpaired)
if ($pe) {
my $pipe_cmd= "${components_location}script01.pl $raw_data_file $barcode | ${components_location}script02.pl $enzyme | ${components_location}script03.pl $size > $final_output_file";
}
system($pipe_cmd);
# at this point, $final_output_file should be saved in the
# tmp folder and contain the paired fastq data output
}
close (FILEIN);
Basically the wrapper reads the barcode.txt file and loops through each line (sample name) of the file. For each sample name, it generates the input parameters for each script in the the piped run. If the sample is paired data, then we do a piped run. The piping scheme goes like this:
# the input parameters are "fed" into the script and the output is piped
# as STDIN to the next script.
script01.pl [input parameters] | script02.pl [input parameters] | script03.pl [input parameters] > file.txt
system($piped_cmd) executes the piped run in the terminal.
Here’s where I’m getting trouble, when I try to run the wrapper script from the terminal:
./wrapper_example.pl barcode.txt
It returns the following error message:
sh: 1: /home/user/read_cleanup/script01.pl: not found
Does anyone know what’s wrong or how to fix this? thanks. Any suggestions are greatly appreciated.
Well,
system()syntax issystem("$command","$args1","$args2")ORsystem(@command)where@command=("$command","$arg1","$arg2"). I would rather use back ticks to run the whole chain of commands like-