Subject: | Bio::DB::Sam problems |
Date: | Tue, 23 Jul 2013 12:22:48 +0200 |
To: | bug-Bio-SamTools [...] rt.cpan.org |
From: | Markus Bayerlein <bayerlein [...] genomatix.de> |
Hello.
I am using your nice Bio::DB::Sam Perl module to access BAM files to
view the data in our Genome Browser. Up to now, the BAM files were
uploaded and stored locally on our harddisk. But now I would like to
access BAM files remotely via HTTP.
I should mention that I do not have the latest version of Bio::DB::Sam
installed, but version 1.33
Unfortunately I encounter two problems:
1. When my script is run in taint-mode, it crashes with the error:
[SIGDIE] Insecure dependency in chdir while running with -T switch at
/usr/lib/perl5/Bio/DB/Sam.pm line 2233.
It seems that the return value of the 'getcwd' function you are calling
in line 2229 (in sub index_open_in_safewd) is tainted. This is not a
critical issue, as I could run the script without the -T switch.
2. The second problem arises from the usage of the File::Spec->tmpdir
method. This method returns the same value for each call from within the
same program, i.e. it caches the first value it returns, and keeps this
value for every other call. This means that changing the temporary
directory (by setting $ENV{TMPDIR}) is possible only once in a program.
(Even if $ENV{TMPDIR} was not modified, the return value of
File::Spec->tmpdir is sticky after the first call to it, meaning that
the method will always return '/tmp'.) However, setting $ENVP{TMPDIR}
should be possible once per script. But if Bio::DB::Sam is involved,
this seems no longer to be true. I tested this with the following Perl code:
-
use strict;
use File::Spec;
BEGIN { $ENV{TMPDIR} = '/home/bayerlein'; }
use Bio::DB::Sam;
print "tmpdir: ", File::Spec->tmpdir, "\n";
-> prints: tmpdir: /home/bayerlein
-
while this code:
-
use strict;
use File::Spec;
use Bio::DB::Sam;
$ENV{TMPDIR} = '/home/bayerlein';
print "tmpdir: ", File::Spec->tmpdir, "\n";
-> prints: tmpdir: /tmp
-
So the modification of $ENV{TMPDIR} is only effective if it is ensured
to take place BEFORE Bio::DB::Sam is loaded. Unfortunately, I cannot
ensure this in my application. This means that I cannot change the
directory where the BAM index file is saved (by 'index_open_in_safewd').
But in my application it is important to decide where to save the index
file (to avoid file name conflicts).
Do you have any advice how I could bypass this behaviour and force the
index to be saved in a specific directory? The only 'solution' I can
think of is to modify your code, but I would prefer not to do this
(besides any copyright/license infringement this might imply and of
course, because I don't know if my changes would work as expected).
Kind regards from Munich
Markus
--
Markus Bayerlein
Genomatix Software GmbH phone +49 (0)89 599 766 0
Bayerstrasse 85a FAX +49 (0)89 599 766 55
80335 Munich email bayerlein@genomatix.de
Germany WWW http://www.genomatix.de
Legal information: HRB 117956 Amtsgericht Muenchen; Tax-ID: DE 189568720
Geschaeftsfuehrer / Managing Director: Klaus May