samfile1.fetch( until_eof = True )):
self.assertEqual( a.compare( b), 0 )
-class TestRemoteFileFTP(unittest.TestCase):
- '''test remote access.
-
- '''
-
- # Need to find an ftp server without password on standard
- # port.
-
- url = "ftp://ftp.sanger.ac.uk/pub/rd/humanSequences/CV.bam"
- region = "1:1-1000"
-
- def testFTPView( self ):
- return
- result = pysam.view( self.url, self.region )
- self.assertEqual( len(result), 36 )
-
- def testFTPFetch( self ):
- return
- samfile = pysam.Samfile(self.url, "rb")
- result = list(samfile.fetch( region = self.region ))
- self.assertEqual( len(result), 36 )
-
-class TestRemoteFileHTTP( unittest.TestCase):
-
- url = "http://genserv.anat.ox.ac.uk/downloads/pysam/test/ex1.bam"
- region = "chr1:1-1000"
- local = "ex1.bam"
-
- def testView( self ):
- samfile_local = pysam.Samfile(self.local, "rb")
- ref = list(samfile_local.fetch( region = self.region ))
-
- result = pysam.view( self.url, self.region )
- self.assertEqual( len(result), len(ref) )
-
- def testFetch( self ):
- samfile = pysam.Samfile(self.url, "rb")
- result = list(samfile.fetch( region = self.region ))
- samfile_local = pysam.Samfile(self.local, "rb")
- ref = list(samfile_local.fetch( region = self.region ))
-
- self.assertEqual( len(ref), len(result) )
- for x, y in zip(result, ref):
- self.assertEqual( x.compare( y ), 0 )
-
- def testFetchAll( self ):
- samfile = pysam.Samfile(self.url, "rb")
- result = list(samfile.fetch())
- samfile_local = pysam.Samfile(self.local, "rb")
- ref = list(samfile_local.fetch() )
-
- self.assertEqual( len(ref), len(result) )
- for x, y in zip(result, ref):
- self.assertEqual( x.compare( y ), 0 )
-
class TestLargeOptValues( unittest.TestCase ):
ints = ( 65536, 214748, 2147484, 2147483647 )
reference_filename = os.path.join(BAM_DATADIR, 'ex1.fa')
-class TestRemoteFileFTP(unittest.TestCase):
-
- '''test remote access.
-
- '''
-
- # Need to find an ftp server without password on standard
- # port.
-
- url = "ftp://ftp.sanger.ac.uk/pub/rd/humanSequences/CV.bam"
- region = "1:1-1000"
-
- def testFTPView(self):
- return
- if not checkURL(self.url):
- return
-
- result = pysam.samtools.view(self.url, self.region)
- self.assertEqual(len(result), 36)
-
- def testFTPFetch(self):
- return
- if not checkURL(self.url):
- return
-
- samfile = pysam.AlignmentFile(self.url, "rb")
- result = list(samfile.fetch(region=self.region))
- self.assertEqual(len(result), 36)
-
-
-class TestRemoteFileHTTP(unittest.TestCase):
-
- url = "http://genserv.anat.ox.ac.uk/downloads/pysam/test/ex1.bam"
- region = "chr1:1-1000"
- local = os.path.join(BAM_DATADIR, "ex1.bam")
-
- def testView(self):
- if not checkURL(self.url):
- return
-
- samfile_local = pysam.AlignmentFile(self.local, "rb")
- ref = list(samfile_local.fetch(region=self.region))
-
- result = pysam.samtools.view(self.url, self.region)
- self.assertEqual(len(result.splitlines()), len(ref))
-
- def testFetch(self):
- if not checkURL(self.url):
- return
-
- with pysam.AlignmentFile(self.url, "rb") as samfile:
- result = list(samfile.fetch(region=self.region))
-
- with pysam.AlignmentFile(self.local, "rb") as samfile_local:
- ref = list(samfile_local.fetch(region=self.region))
-
- self.assertEqual(len(ref), len(result))
- for x, y in zip(result, ref):
- self.assertEqual(x.compare(y), 0)
-
- def testFetchAll(self):
- if not checkURL(self.url):
- return
-
- with pysam.AlignmentFile(self.url, "rb") as samfile:
- result = list(samfile.fetch())
-
- with pysam.AlignmentFile(self.local, "rb") as samfile_local:
- ref = list(samfile_local.fetch())
-
- self.assertEqual(len(ref), len(result))
- for x, y in zip(result, ref):
- self.assertEqual(x.compare(y), 0)
-
-
class TestLargeOptValues(unittest.TestCase):
ints = (65536, 214748, 2147484, 2147483647)
globals()[n] = type(n, (TestVCFFromVariantFile,), dict(filename=vcf_file,))
-class TestRemoteFileHTTP(unittest.TestCase):
-
- url = "http://genserv.anat.ox.ac.uk/downloads/pysam/test/example.gtf.gz"
- region = "chr1:1-1000"
- local = os.path.join(TABIX_DATADIR, "example.gtf.gz")
-
- def setUp(self):
- if not pysam.config.HAVE_LIBCURL or not checkURL(self.url):
- self.remote_file = None
- else:
- self.remote_file = pysam.TabixFile(self.url, "r")
-
- self.local_file = pysam.TabixFile(self.local, "r")
-
- def tearDown(self):
- if self.remote_file is None:
- return
-
- self.remote_file.close()
- self.local_file.close()
-
- def testFetchAll(self):
- if self.remote_file is None:
- return
-
- remote_result = list(self.remote_file.fetch())
- local_result = list(self.local_file.fetch())
-
- self.assertEqual(len(remote_result), len(local_result))
- for x, y in zip(remote_result, local_result):
- self.assertEqual(x, y)
-
- def testHeader(self):
- if self.remote_file is None:
- return
-
- self.assertEqual(list(self.local_file.header), [])
-
-
-class TestRemoteFileHTTPWithHeader(TestRemoteFileHTTP):
-
- url = "http://genserv.anat.ox.ac.uk/downloads/pysam/test/example_comments.gtf.gz"
- region = "chr1:1-1000"
- local = os.path.join(TABIX_DATADIR, "example_comments.gtf.gz")
-
- def setUp(self):
- if not pysam.config.HAVE_LIBCURL or not checkURL(self.url):
- self.remote_file = None
- else:
- self.remote_file = pysam.TabixFile(self.url, "r")
- self.local_file = pysam.TabixFile(self.local, "r")
-
- def testHeader(self):
- if self.remote_file is None:
- return
-
- self.assertEqual(list(self.local_file.header), ["# comment at start"])
- self.assertEqual(list(self.local_file.header), self.remote_file.header)
-
-
class TestIndexArgument(unittest.TestCase):
filename_src = os.path.join(TABIX_DATADIR, "example.vcf.gz")