From a497899139b0ac56806d4eedf03814c84299b3a7 Mon Sep 17 00:00:00 2001 From: kbseah Date: Wed, 27 May 2015 13:28:43 +0200 Subject: [PATCH] fixed bug with filenames that have path component --- phyloFlash.pl | 50 ++++++++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 20 deletions(-) diff --git a/phyloFlash.pl b/phyloFlash.pl index 690c451..e147aeb 100755 --- a/phyloFlash.pl +++ b/phyloFlash.pl @@ -4,7 +4,6 @@ =head1 NAME phyloFlash - A script to rapidly estimate the phylogenetic composition of an illumina (meta)genomic dataset. - =head1 SYNOPSIS B -dbhome F -lib B -read1 F<> -read2 F<> @@ -46,7 +45,6 @@ =head1 OPTIONS Invokes checking of working environment and dependencies without data input. Use to test setup. - =item -dbhome F Directory containing phyloFlash reference databases. @@ -117,8 +115,7 @@ =head1 COPYRIGHT AND LICENSE Copyright (C) 2014- by Harald Gruber-Vodicka and Elmar A. Pruesse - with help from Brandon Seah mail: - + with help from Brandon Seah LICENCE @@ -160,8 +157,10 @@ =head1 COPYRIGHT AND LICENSE my $cwd = getcwd; # configuration variables / defaults -my $readsf = undef; # forward read file -my $readsr = undef; # reverse read file +my $readsf_full = undef; # path to forward read file +my $readsr_full = undef; # path to reverse read file +my $readsf = undef; # forward read filename, stripped of directory names +my $readsr = undef; # reverse read filename, stripped of directory names my $SEmode = 0; # single ended mode my $libraryNAME = undef; # output basename my $id = 70; # minimum %id for mapping @@ -254,8 +253,8 @@ sub process_required_tools { # parse arguments passed on commandline and do some # sanity checks sub parse_cmdline { - GetOptions('read1=s' => \$readsf, - 'read2=s' => \$readsr, + GetOptions('read1=s' => \$readsf_full, + 'read2=s' => \$readsr_full, 'lib=s' => \$libraryNAME, 'dbhome=s' => \$DBHOME, 'readlength=i' => \$readlength, @@ -293,25 +292,36 @@ sub parse_cmdline { # check correct read file(s) pod2usage("\nPlease specify input forward read file with -read1") - if !defined($readsf); - pod2usage("\nUnable to open forward read file '$readsf'. ". + if !defined($readsf_full); + pod2usage("\nUnable to open forward read file '$readsf_full'. ". "Make sure the file exists and is readable by you.") - if ! -e $readsf; + if ! -e $readsf_full; + # strip directory paths from forward read filename + if ($readsf_full =~ m/.*\/(.+)/) { + $readsf = $1; + } else { $readsf = $readsf_full; } + + if (defined($readsr)) { pod2usage("\nUnable to open reverse read file '$readsr'.". "Make sure the file exists and is readable by you.") if ! -e $readsr; pod2usage("\nForward and reverse input read file need to be different") if ($readsr eq $readsf); + if ($readsr_full =~ m/.*\/(.+)/) { # strip directory paths from reverse read filename + $readsr = $1; + } else { $readsr = $readsr_full; } + } else { $SEmode = 1; # no reverse reads, we operate in single ended mode $readsr = ""; + $readsr_full = ""; } - msg("Forward reads $readsf"); + msg("Forward reads $readsf_full"); if ($SEmode == 0) { - msg("Reverse reads $readsr"); + msg("Reverse reads $readsr_full"); } else { msg("Running in single ended mode"); } @@ -364,8 +374,8 @@ sub print_report { $version - high throughput phylogenetic screening using SSU rRNA gene(s) abundance(s) Library name:\t$libraryNAME --- -Forward read file\t$readsf -Reverse read file\t$readsr +Forward read file\t$readsf_full +Reverse read file\t$readsr_full Current working directory\t$cwd --- Minimum mapping identity:\t$id% @@ -443,8 +453,8 @@ sub write_csv { my @report = csv_escape(( "version",$version, "library, name",$libraryNAME, - "forward read file",$readsf, - "reverse read file",$readsr, + "forward read file",$readsf_full, + "reverse read file",$readsr_full, "cwd",$cwd, "minimum mapping identity",$id, "single ended mode",$SEmode, @@ -525,7 +535,7 @@ sub bbmap_fast_filter_run { . "path=$DBHOME " . "outm=$libraryNAME.$readsf.SSU.1.fq " . "build=1 " - . "in=$readsf " + . "in=$readsf_full " . "bhist=tmp.$libraryNAME.basecompositionhistogram " . "ihist=$libraryNAME.inserthistogram " . "scafstats=$libraryNAME.hitstats " @@ -1167,7 +1177,7 @@ sub write_report_html { Forward read file ENDHTML -print {$fh} " ".$readsf."\n"; +print {$fh} " ".$readsf_full."\n"; print {$fh} < @@ -1175,7 +1185,7 @@ sub write_report_html { Reverse read file ENDHTML -print {$fh} " ".$readsr."\n"; +print {$fh} " ".$readsr_full."\n"; print {$fh} <