bioperl / bioperl-live-redmine

Legacy tickets migrated from the OBF Redmine issue tracker: http://redmine.open-bio.org
0 stars 0 forks source link

Bio::Tools::Run::StandAloneBlast does not quote shell metacharacters in filenames, but Bio::SearchIO::blast does #50

Open cjfields opened 8 years ago

cjfields commented 8 years ago

Author Name: Roy Chaudhuri (Roy Chaudhuri) Original Redmine Issue: 2707, https://redmine.open-bio.org/issues/2707 Original Date: 2008-12-10 Original Assignee: Bioperl Guts


I’m having a problem using Bio::Tools::Run::StandAloneBlast with a filename that contains shell metacharacters. It looks like Bio::Tools::Run::StandAloneBlast does not quote metacharacters but Bio::SearchIO::blast does. This means that if I have an awkward filename like: $filename=‘needs(quoting)’; then B:T:R:SAB throws an exception “blastall call crashed”, since blastall crashes when it can’t write an output file with that name. However, if I quote the name: $filename=qq(‘needs(quoting)’); then B:T:R:SAB is perfectly happy, but when I try to read the results file Bio::SearchIO::blast throws an exception (via Bio::Root::IO) since it can’t find a file called ‘needs(quoting)’ (including the quotes).

I’ve attached an example script that demonstrates the problem. I’d guess that B:T:R:SAB should be using Bio::Root::IO to ensure consistent behaviour.

cjfields commented 8 years ago

Original Redmine Comment Author Name: Roy Chaudhuri Original Date: 2008-12-10T10:43:36Z


Created an attachment (id=1154) Example script demonstrating the problem

cjfields commented 8 years ago

Original Redmine Comment Author Name: Chris Fields Original Date: 2008-12-11T00:05:24Z


(In reply to comment #0)

I’m having a problem using Bio::Tools::Run::StandAloneBlast with a filename that contains shell metacharacters. It looks like Bio::Tools::Run::StandAloneBlast does not quote metacharacters but Bio::SearchIO::blast does. This means that if I have an awkward filename like: $filename=‘needs(quoting)’; then B:T:R:SAB throws an exception “blastall call crashed”, since blastall crashes when it can’t write an output file with that name. However, if I quote the name: $filename=qq(‘needs(quoting)’); then B:T:R:SAB is perfectly happy, but when I try to read the results file Bio::SearchIO::blast throws an exception (via Bio::Root::IO) since it can’t find a file called ‘needs(quoting)’ (including the quotes).

Roy, I committed a fix which quotemeta’s file names temporarily in StandAloneBlast while building the parameter strings. Seems to handle both your cases as well as other odd ones like ‘needs“quoting”’.

Thanks!

cjfields commented 8 years ago

Original Redmine Comment Author Name: Chris Fields Original Date: 2009-01-15T00:15:20Z


Reopening but adding as a TODO for 1.6.x. This doesn’t work adequately for Win32 (per Scott Markel):

‘There is a problem with the output filename for bl2seq on Windows. In response to bug 2707, quotemeta was used when building the parameter string at line 507 in Bio::Tools::Run::StandAloneNCBIBlast (1.5.9_2). This causes a problem with the path to the output file on Windows. For example, “C:\DOCUME~1\outfile” becomes “C\:\DOCUME\~1\outfile”. bl2seq can’t open the output file and fails.’

A workaround is in place for 1.6.0 which simply doesn’t quotemeta if the OS is Windows. I’m wondering, though, if a better solution may be to actually punt the issue back to the user and describe the possible workarounds instead, maybe as a FAQ. Accurately quoting shell/meta characters for files is notoriously system-dependent and can be based on use (shell, file names, etc). I’m not completely convinced it’s the job of BioPerl core to worry about that, particularly seeing there are Perl operators for that (quotemeta and /Q /E).