I've succeeded in enabling this with two changes are required to pysam
to enable this functionality; however when used with HTTP a warning
which simply is annoying with command line SAMTools appears to cause
an exception which requires catching; for FTP it appears to work.
First, in the section of code of Samfile.open concerned with reading
the test for file existence needs to be modified with two additional
tests (the first two); otherwise URLs are seen as bad file names
if strncmp(filename,”http:”,5)!=0 and
strncmp(filename,”ftp:”,4)!=0 and strncmp( filename, "-", 1) != 0 and
not os.path.exists( filename )
Second, samtools needs to be compiled with the _USE_KNETFILE macro;
the current SAMTools Makefile also invokes FILE_OFFSET_BITS so I set
that too, though that may not be essential
pysam = Extension(
"pysam/csamtools", # name of extension
[ "pysam/csamtools.pyx" ] +\
[ "pysam/%s" % x for x in (
"pysam_util.c", )] +\
glob.glob( os.path.join( "samtools", "*.c" ) ),
library_dirs=[],
include_dirs=[ "samtools", ],
libraries=[ "z", ],
language="c",
define_macros = [('FILE_OFFSET_BITS','64'),
('_USE_KNETFILE','')],
)
For HTTP, at least some operations raise
File "/usr/local/lib/python2.6/dist-packages/pysam/__init__.py",
line 54, in __call__
if stderr: raise SamtoolsError( "\n".join( stderr ) )
pysam.SamtoolsError: '[knet_seek] SEEK_END is not supported for HTTP.
Offset is unchanged.\n\n[samopen] inconsistent number of target
sequences.\n'
(Andrea & I are co-workers; I've placed this here for the benefit of
the project)
Keith R.