import galaxy.model from galaxy.model.orm import * from galaxy.model.mapping import context as sa_session from base.twilltestcase import TwillTestCase from base.test_db_util import * class UploadData( TwillTestCase ): def test_0000_setup_upload_tests( self ): """Configuring upload tests, setting admin_user""" self.logout() self.login( email='test@bx.psu.edu' ) global admin_user admin_user = get_user( email='test@bx.psu.edu' ) def test_0005_upload_file( self ): """Test uploading 1.bed, NOT setting the file format""" history = get_latest_history_for_user( admin_user ) self.upload_file( '1.bed' ) hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" self.verify_dataset_correctness( '1.bed', hid=str( hda.hid ) ) self.check_history_for_string( "1.Chrom2.Start3.End" ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0006_upload_file( self ): """Test uploading 1.bed.spaces, with space to tab selected, NOT setting the file format""" history = get_latest_history_for_user( admin_user ) self.upload_file( '1.bed.spaces', space_to_tab = True ) hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" self.verify_dataset_correctness( '1.bed', hid=str( hda.hid ) ) self.check_history_for_string( "1.Chrom2.Start3.End" ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0010_upload_file( self ): """Test uploading 4.bed.gz, manually setting the file format""" self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) self.upload_file( '4.bed.gz', dbkey='hg17', ftype='bed' ) hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" self.verify_dataset_correctness( '4.bed', hid=str( hda.hid ) ) self.check_history_for_string( "1.Chrom2.Start3.End" ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0012_upload_file( self ): """Test uploading 4.bed.bz2, manually setting the file format""" self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) self.upload_file( '4.bed.bz2', dbkey='hg17', ftype='bed' ) hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" self.verify_dataset_correctness( '4.bed', hid=str( hda.hid ) ) self.check_history_for_string( "1.Chrom2.Start3.End" ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0015_upload_file( self ): """Test uploading 1.scf, manually setting the file format""" self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) self.upload_file( '1.scf', ftype='scf' ) hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" self.verify_dataset_correctness( '1.scf', hid=str( hda.hid ) ) self.check_history_for_string( "Binary scf sequence file" ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0020_upload_file( self ): """Test uploading 1.scf, NOT setting the file format""" self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) self.upload_file( '1.scf' ) hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" self.check_history_for_string( "File Format' to 'Scf' when uploading scf files" ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0025_upload_file( self ): """Test uploading 4.bed.zip, manually setting the file format""" self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) self.upload_file( '4.bed.zip', ftype='bed' ) hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" self.verify_dataset_correctness( '4.bed', hid=str( hda.hid ) ) self.check_history_for_string( "1.Chrom2.Start3.End" ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0030_upload_file( self ): """Test uploading 4.bed.zip, NOT setting the file format""" self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) self.upload_file( '4.bed.zip' ) hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" self.verify_dataset_correctness( '4.bed', hid=str( hda.hid ) ) self.check_history_for_string( "1.Chrom2.Start3.End" ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0035_upload_file( self ): """Test uploading 1.sam NOT setting the file format""" self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) self.upload_file( '1.sam' ) hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" self.verify_dataset_correctness( '1.sam', hid=str( hda.hid ) ) self.check_history_for_string( "1.QNAME2.FLAG3.RNAME4.POS" ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0040_upload_file( self ): """Test uploading 1.sff, NOT setting the file format""" self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) self.upload_file( '1.sff' ) hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" self.verify_dataset_correctness( '1.sff', hid=str( hda.hid ) ) self.check_history_for_string( 'format: sff' ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0045_upload_file( self ): """Test uploading 454Score.pdf, NOT setting the file format""" self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) self.upload_file( '454Score.pdf' ) hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" self.check_history_for_string( "1: 454Score.pdf" ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0050_upload_file( self ): """Test uploading 454Score.png, NOT setting the file format""" self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) self.upload_file( '454Score.png' ) hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" self.check_history_for_string( "The uploaded file contains inappropriate content" ) def test_0055_upload_file( self ): """Test uploading lped composite datatype file, manually setting the file format""" # Logged in as admin_user self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) # lped data types include a ped_file and a map_file ( which is binary ) self.upload_file( None, ftype='lped', metadata = [ { 'name':'base_name', 'value':'rgenetics' } ], composite_data = [ { 'name':'ped_file', 'value':'tinywga.ped' }, { 'name':'map_file', 'value':'tinywga.map'} ] ) # Get the latest hid for testing hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" # We'll test against the resulting ped file and map file for correctness self.verify_composite_datatype_file_content( 'tinywga.ped', str( hda.id ), base_name = 'rgenetics.ped' ) self.verify_composite_datatype_file_content( 'tinywga.map', str( hda.id ), base_name = 'rgenetics.map' ) self.check_history_for_string( "rgenetics" ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0056_upload_file( self ): """Test uploading lped composite datatype file, manually setting the file format, and using space to tab on one file (tinywga.ped)""" # Logged in as admin_user self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) # lped data types include a ped_file and a map_file ( which is binary ) self.upload_file( None, ftype='lped', metadata = [ { 'name':'base_name', 'value':'rgenetics' } ], composite_data = [ { 'name':'ped_file', 'value':'tinywga.ped', 'space_to_tab':True }, { 'name':'map_file', 'value':'tinywga.map'} ] ) # Get the latest hid for testing hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" # We'll test against the resulting ped file and map file for correctness self.verify_composite_datatype_file_content( 'tinywga.ped.space_to_tab', str( hda.id ), base_name = 'rgenetics.ped' ) self.verify_composite_datatype_file_content( 'tinywga.map', str( hda.id ), base_name = 'rgenetics.map' ) self.check_history_for_string( "rgenetics" ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0060_upload_file( self ): """Test uploading pbed composite datatype file, manually setting the file format""" # Logged in as admin_user self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) # pbed data types include a bim_file, a bed_file and a fam_file self.upload_file( None, ftype='pbed', metadata = [ { 'name':'base_name', 'value':'rgenetics' } ], composite_data = [ { 'name':'bim_file', 'value':'tinywga.bim' }, { 'name':'bed_file', 'value':'tinywga.bed'}, { 'name':'fam_file', 'value':'tinywga.fam' } ] ) # Get the latest hid for testing hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" # We'll test against the resulting ped file and map file for correctness self.verify_composite_datatype_file_content( 'tinywga.bim', str( hda.id ), base_name = 'rgenetics.bim' ) self.verify_composite_datatype_file_content( 'tinywga.bed', str( hda.id ), base_name = 'rgenetics.bed' ) self.verify_composite_datatype_file_content( 'tinywga.fam', str( hda.id ), base_name = 'rgenetics.fam' ) self.check_history_for_string( "rgenetics" ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0065_upload_file( self ): """Test uploading asian_chars_1.txt, NOT setting the file format""" # Logged in as admin_user self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) self.upload_file( 'asian_chars_1.txt' ) hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" self.verify_dataset_correctness( 'asian_chars_1.txt', hid=str( hda.hid ) ) self.check_history_for_string( 'uploaded multi-byte char file' ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0070_upload_file( self ): """Test uploading 2gen.fastq, NOT setting the file format""" # Logged in as admin_user self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) self.upload_file( '2gen.fastq' ) hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" self.verify_dataset_correctness( '2gen.fastq', hid=str( hda.hid ) ) self.check_history_for_string( '2gen.fastq format: fastq, database: \? Info: uploaded fastq file' ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0075_upload_file( self ): """Test uploading 1.wig, NOT setting the file format""" # Logged in as admin_user self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) self.upload_file( '1.wig' ) hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" self.verify_dataset_correctness( '1.wig', hid=str( hda.hid ) ) self.check_history_for_string( '1.wig format: wig, database: \? Info: uploaded file' ) self.check_metadata_for_string( 'value="1.wig" value="\?"' ) self.check_metadata_for_string( 'Change data type selected value="wig" selected="yes"' ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0080_upload_file( self ): """Test uploading 1.tabular, NOT setting the file format""" # Logged in as admin_user self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) self.upload_file( '1.tabular' ) hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" self.verify_dataset_correctness( '1.tabular', hid=str( hda.hid ) ) self.check_history_for_string( '1.tabular format: tabular, database: \? Info: uploaded file' ) self.check_metadata_for_string( 'value="1.tabular" value="\?"' ) self.check_metadata_for_string( 'Change data type selected value="tabular" selected="yes"' ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0085_upload_file( self ): """Test uploading qualscores.qualsolid, NOT setting the file format""" # Logged in as admin_user self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) self.upload_file( 'qualscores.qualsolid' ) hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" self.verify_dataset_correctness( 'qualscores.qualsolid', hid=str( hda.hid ) ) self.check_history_for_string( '48 lines, format: qualsolid, database: \? Info: uploaded file' ) self.check_metadata_for_string( 'Change data type value="qualsolid" selected="yes">qualsolid' ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0090_upload_file( self ): """Test uploading qualscores.qual454, NOT setting the file format""" # Logged in as admin_user self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) self.upload_file( 'qualscores.qual454' ) hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" self.verify_dataset_correctness( 'qualscores.qual454', hid=str( hda.hid ) ) self.check_history_for_string( '49 lines, format: qual454, database: \?' ) self.check_metadata_for_string( 'Change data type value="qual454" selected="yes">qual454' ) self.delete_history( id=self.security.encode_id( history.id ) ) def test_0095_upload_file( self ): """Test uploading 3.maf, NOT setting the file format""" # Logged in as admin_user self.check_history_for_string( 'Your history is empty' ) history = get_latest_history_for_user( admin_user ) self.upload_file( '3.maf' ) hda = get_latest_hda() assert hda is not None, "Problem retrieving hda from database" self.verify_dataset_correctness( '3.maf', hid=str( hda.hid ) ) self.check_history_for_string( '3.maf format: maf, database: \? Info: uploaded file' ) self.check_metadata_for_string( 'value="3.maf" value="\?"' ) self.check_metadata_for_string( 'Convert to new format