def test_update_file_processed_format_re_check(update_ffmeta_event_data_re_check): report_key = 'lalala/re_report' s3 = boto3.client('s3') s3.put_object(Body='clipped-mates with RE motif: 76.54 %'.encode('utf-8'), Bucket='elasticbeanstalk-fourfront-webdev-wfoutput', Key=report_key) updater = FourfrontUpdater(**update_ffmeta_event_data_re_check) input_uuid = updater.ff_meta.input_files[0]['value'] updater.update_file_processed_format_re_check() precent_re = updater.parse_re_check(updater.read('motif_percent')) assert precent_re == 76.54 assert input_uuid in updater.patch_items assert 'percent_clipped_sites_with_re_motif' in updater.patch_items[input_uuid] assert updater.patch_items[input_uuid]['percent_clipped_sites_with_re_motif'] == 76.54 s3.delete_object(Bucket='elasticbeanstalk-fourfront-webdev-wfoutput', Key=report_key)
def test_fastq_first_line(update_ffmeta_event_data_fastq_first_line): report_key = 'lalala/first_line' s3 = boto3.client('s3') s3.put_object(Body='@HWI-ST1318:469:HV2C3BCXY:1:1101:2874:1977 1:N:0:ATGTCA'.encode('utf-8'), Bucket='elasticbeanstalk-fourfront-webdev-wfoutput', Key=report_key) updater = FourfrontUpdater(**update_ffmeta_event_data_fastq_first_line) updater.update_fastq_first_line() first_line = updater.parse_fastq_first_line_report(updater.read('first_line')) assert first_line == "@HWI-ST1318:469:HV2C3BCXY:1:1101:2874:1977 1:N:0:ATGTCA" assert '4c3be0d1-cd00-4a14-85ed-43269591fe41' in updater.patch_items assert 'file_first_line' in updater.patch_items['4c3be0d1-cd00-4a14-85ed-43269591fe41'] assert updater.patch_items['4c3be0d1-cd00-4a14-85ed-43269591fe41']['file_first_line'] == \ "@HWI-ST1318:469:HV2C3BCXY:1:1101:2874:1977 1:N:0:ATGTCA" s3.delete_object(Bucket='elasticbeanstalk-fourfront-webdev-wfoutput', Key=report_key)
def test_rna_strandedness(update_ffmeta_event_data_rna_strandedness): report_key = 'lalala/match_count' s3 = boto3.client('s3') s3.put_object(Body='1234\n5'.encode('utf-8'), Bucket='elasticbeanstalk-fourfront-webdev-wfoutput', Key=report_key) updater = FourfrontUpdater(**update_ffmeta_event_data_rna_strandedness) updater.update_rna_strandedness() sense, antisense = updater.parse_rna_strandedness_report(updater.read('match_count')) assert sense == 1234 assert antisense == 5 assert '4c3be0d1-cd00-4a14-85ed-43269591fe41' in updater.patch_items assert 'beta_actin_sense_count' in updater.patch_items['4c3be0d1-cd00-4a14-85ed-43269591fe41'] assert 'beta_actin_antisense_count' in updater.patch_items['4c3be0d1-cd00-4a14-85ed-43269591fe41'] assert updater.patch_items['4c3be0d1-cd00-4a14-85ed-43269591fe41']['beta_actin_sense_count'] == 1234 assert updater.patch_items['4c3be0d1-cd00-4a14-85ed-43269591fe41']['beta_actin_antisense_count'] == 5 s3.delete_object(Bucket='elasticbeanstalk-fourfront-webdev-wfoutput', Key=report_key)
def test_md5(update_ffmeta_event_data_newmd5): report_key = 'lalala/md5_report' s3 = boto3.client('s3') s3.put_object(Body='1234\n5678'.encode('utf-8'), Bucket='elasticbeanstalk-fourfront-webdev-wfoutput', Key=report_key) updater = FourfrontUpdater(**update_ffmeta_event_data_newmd5) assert updater.app_name == 'md5' with pytest.raises(Exception) as exec_info: updater.update_md5() assert 'md5sum not matching the original one' in str(exec_info.value) real_md5_content = 'bc75002f8a473bc6854d562789525a90\n6bb2dfa5b435ed03105cb59c32442d23' s3.put_object(Body=real_md5_content.encode('utf-8'), Bucket='elasticbeanstalk-fourfront-webdev-wfoutput', Key=report_key) updater.update_md5() md5, content_md5 = updater.parse_md5_report(updater.read('report')) assert md5 == 'bc75002f8a473bc6854d562789525a90' assert content_md5 == '6bb2dfa5b435ed03105cb59c32442d23' assert 'f4864029-a8ad-4bb8-93e7-5108f462ccaa' in updater.patch_items assert 'md5sum' not in updater.patch_items['f4864029-a8ad-4bb8-93e7-5108f462ccaa'] # already in assert 'file_size' in updater.patch_items['f4864029-a8ad-4bb8-93e7-5108f462ccaa'] s3.delete_object(Bucket='elasticbeanstalk-fourfront-webdev-wfoutput', Key=report_key)