def validate_run(sequencing_run): """Do the validation on a run, its samples, and files. This function is kinda yucky because the validators should be raising exceptions instead of returning validation objects... Arguments: sequencing_run -- the run to validate """ sample_sheet = sequencing_run.sample_sheet validation = validate_sample_sheet(sequencing_run.sample_sheet) if not validation.is_valid(): send_message(sequencing_run.offline_validation_topic, run=sequencing_run, errors=validation.get_errors()) raise SampleSheetError( 'Sample sheet {} is invalid. Reason:\n {}'.format( sample_sheet, validation.get_errors()), validation.error_list()) validation = validate_sample_list(sequencing_run.sample_list) if not validation.is_valid(): raise SampleError( 'Sample sheet {} is invalid. Reason:\n {}'.format( sample_sheet, validation.get_errors()), validation.error_list())
def test_validateSampleList_invalid_empty(self): sample_list = [] self.assertEqual(len(sample_list), 0) v_res = validate_sample_list(sample_list) self.assertFalse(v_res.is_valid()) self.assertEqual(v_res.error_count(), 1) self.assertTrue( "The given list of samples is empty" in v_res.get_errors())
def test_validate_sample_list_valid(self): sample1 = Sample({ "sequencerSampleId": "01-1111", "sampleName": "01-1111", "Sample_Plate": "1", "Sample_Well": "01", "I7_Index_ID": "N01", "index": "AAAAAAAA", "I5_Index_ID": "S01", "index2": "TTTTTTTT", "sampleProject": "6", "description": "Super bug" }) sample2 = Sample({ "sequencerSampleId": "02-2222", "sampleName": "02-2222", "Sample_Plate": "2", "Sample_Well": "02", "I7_Index_ID": "N02", "index": "GGGGGGGG", "I5_Index_ID": "S02", "index2": "CCCCCCCC", "sampleProject": "6", "description": "Scary bug" }) sample3 = Sample({ "sequencerSampleId": "03-3333", "sampleName": "03-3333", "Sample_Plate": "3", "Sample_Well": "03", "I7_Index_ID": "N03", "index": "CCCCCCCC", "I5_Index_ID": "S03", "index2": "GGGGGGGG", "sampleProject": "6", "description": "Deadly bug" }) sample_list = [sample1, sample2, sample3] v_res = validate_sample_list(sample_list) self.assertTrue(v_res.is_valid()) self.assertEqual(v_res.error_count(), 0) self.assertTrue("No error messages" in v_res.get_errors())
def test_validateSampleList_invalid_missing_req_values(self): sample1 = Sample({ "sequencerSampleId": "01-1111", "sampleName": "01-1111", "Sample_Plate": "1", "Sample_Well": "01", "I7_Index_ID": "N01", "index": "AAAAAAAA", "I5_Index_ID": "S01", "index2": "TTTTTTTT", "sampleProject": "", "description": "Super bug" }) sample2 = Sample({ "sequencerSampleId": "02-2222", "sampleName": "", "Sample_Plate": "2", "Sample_Well": "02", "I7_Index_ID": "N02", "index": "GGGGGGGG", "I5_Index_ID": "S02", "index2": "CCCCCCCC", "sampleProject": "6", "description": "Scary bug" }) sample_list = [sample1, sample2] v_res = validate_sample_list(sample_list) self.assertFalse(v_res.is_valid()) self.assertEqual(v_res.error_count(), 2) expected_err_msg1 = ("{sid} missing Project ID").format( sid=sample1.get_id()) self.assertIn(expected_err_msg1, v_res.get_errors()) expected_err_msg2 = ("{sid} missing Sample Name").format( sid=sample2.get_id()) self.assertIn(expected_err_msg2, v_res.get_errors())
def test_validate_sample_list_valid_empty_description(self): sample = Sample({ "Sample_Well": "03", "index": "CCCCCCCC", "Sample_Plate": "3", "I7_Index_ID": "N03", "sampleName": "03-3333", "sampleProject": "6", "sequencerSampleId": "03-3333", "I5_Index_ID": "S03", "index2": "GGGGGGGG", "description": "" }) sample_list = [sample] v_res = validate_sample_list(sample_list) self.assertTrue(v_res.is_valid()) self.assertEqual(v_res.error_count(), 0) self.assertTrue("No error messages" in v_res.get_errors())