commit/galaxy-central: natefoo: When comparing bam files in the test framework, convert them to sam for comparison.
1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/93783833e6b1/ changeset: r5116:93783833e6b1 user: natefoo date: 2011-02-23 20:53:54 summary: When comparing bam files in the test framework, convert them to sam for comparison. affected #: 2 files (949 bytes) --- a/test/base/twilltestcase.py Wed Feb 23 14:01:58 2011 -0500 +++ b/test/base/twilltestcase.py Wed Feb 23 14:53:54 2011 -0500 @@ -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 @@ 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 @@ 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: --- a/test/functional/test_get_data.py Wed Feb 23 14:01:58 2011 -0500 +++ b/test/functional/test_get_data.py Wed Feb 23 14:53:54 2011 -0500 @@ -389,7 +389,7 @@ 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" Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.
participants (1)
-
Bitbucket