mirror of
https://github.com/galaxyproject/galaxy.git
synced 2026-10-25 00:12:08 +08:00
When comparing bam files in the test framework, convert them to sam for comparison.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import pkg_resources
|
||||
pkg_resources.require( "twill==0.9" )
|
||||
|
||||
import StringIO, os, sys, random, filecmp, time, unittest, urllib, logging, difflib, tarfile, zipfile, tempfile, re, shutil
|
||||
import StringIO, os, sys, random, filecmp, time, unittest, urllib, logging, difflib, tarfile, zipfile, tempfile, re, shutil, subprocess
|
||||
from itertools import *
|
||||
|
||||
import twill
|
||||
@@ -633,6 +633,9 @@ class TwillTestCase( unittest.TestCase ):
|
||||
try:
|
||||
if attributes is None:
|
||||
attributes = {}
|
||||
if attributes.get( 'ftype', None ) == 'bam':
|
||||
local_fh, temp_name = self._bam_to_sam( local_name, temp_name )
|
||||
local_name = local_fh.name
|
||||
compare = attributes.get( 'compare', 'diff' )
|
||||
extra_files = attributes.get( 'extra_files', None )
|
||||
if compare == 'diff':
|
||||
@@ -658,6 +661,17 @@ class TwillTestCase( unittest.TestCase ):
|
||||
finally:
|
||||
os.remove( temp_name )
|
||||
|
||||
def _bam_to_sam( self, local_name, temp_name ):
|
||||
temp_local = tempfile.NamedTemporaryFile( suffix='.sam', prefix='local_bam_converted_to_sam_' )
|
||||
fd, temp_temp = tempfile.mkstemp( suffix='.sam', prefix='history_bam_converted_to_sam_' )
|
||||
os.close( fd )
|
||||
p = subprocess.Popen( args="samtools view %s -o %s" % ( local_name, temp_local.name ), shell=True )
|
||||
assert not p.wait(), 'Converting local (test-data) bam to sam failed'
|
||||
p = subprocess.Popen( args="samtools view %s -o %s" % ( temp_name, temp_temp ), shell=True )
|
||||
assert not p.wait(), 'Converting history bam to sam failed'
|
||||
os.remove( temp_name )
|
||||
return temp_local, temp_temp
|
||||
|
||||
def verify_extra_files_content( self, extra_files, hda_id ):
|
||||
files_list = []
|
||||
for extra_type, extra_value, extra_name, extra_attributes in extra_files:
|
||||
|
||||
@@ -389,7 +389,7 @@ class UploadData( TwillTestCase ):
|
||||
self.upload_file( '1.bam' )
|
||||
hda = get_latest_hda()
|
||||
assert hda is not None, "Problem retrieving hda from database"
|
||||
self.verify_dataset_correctness( '1.bam', hid=str( hda.hid ) )
|
||||
self.verify_dataset_correctness( '1.bam', hid=str( hda.hid ), attributes={ 'ftype' : 'bam' } )
|
||||
self.check_history_for_string( '<span class="bam">bam</span>' )
|
||||
# Make sure the Bam index was created
|
||||
assert hda.metadata.bam_index is not None, "Bam index was not correctly created for 1.bam"
|
||||
|
||||
Reference in New Issue
Block a user