def test__validate_settings_keys_error(self): expected_settings = { ns_test._get_library_name_key(): "CV4", ns_test._get_library_fp_key(): "/some/path/to/CV4.txt", ns_test._get_library_settings_keys()[0]: "19", ns_test._get_library_settings_keys()[1]: "21" } input_settings = { ns_test._get_library_name_key(): "CV4", ns_test._get_library_fp_key(): "/some/path/to/CV4.txt" } with self.assertRaises(ValueError): ns_test._validate_settings_keys("CV4", input_settings)
def test__validate_library_id_error_too_many(self): input_dicts_list = [{ ns_test._get_library_name_key(): "CV4", ns_test._get_library_fp_key(): "/some/path/to/CV4.txt", ns_test._get_library_settings_keys()[0]: "19", ns_test._get_library_settings_keys()[1]: "21" }, { ns_test._get_library_name_key(): "CV4", ns_test._get_library_fp_key(): "/old/path/to/CV4.txt", ns_test._get_library_settings_keys()[0]: "19", ns_test._get_library_settings_keys()[1]: "21" }] with self.assertRaises(ValueError): ns_test._validate_library_id("CV4", input_dicts_list)
def test__validate_library_id_valid(self): input_dicts_list = [{ ns_test._get_library_name_key(): "CV4", ns_test._get_library_fp_key(): "/some/path/to/CV4.txt", ns_test._get_library_settings_keys()[0]: "19", ns_test._get_library_settings_keys()[1]: "21" }] ns_test._validate_library_id("CV4", input_dicts_list)
def test__validate_settings_keys_valid(self): input_settings = { ns_test._get_library_name_key(): "CV4", ns_test._get_library_fp_key(): "/some/path/to/CV4.txt", ns_test._get_library_settings_keys()[0]: "19", ns_test._get_library_settings_keys()[1]: "21" } ns_test._validate_settings_keys("CV4", input_settings)
def test__id_and_validate_library_missing_values(self): input_dicts_list = [{ ns_test._get_library_name_key(): "CV4", ns_test._get_library_fp_key(): "/some/path/to/CV4.txt", ns_test._get_library_settings_keys()[0]: "", ns_test._get_library_settings_keys()[1]: "21" }] with self.assertRaises(ValueError): ns_test._id_and_validate_library("CV4", input_dicts_list)
def test__id_and_validate_library_too_many_libs(self): expected_output = { ns_test._get_library_name_key(): "CV4", ns_test._get_library_fp_key(): "/some/path/to/CV4.txt", ns_test._get_library_settings_keys()[0]: "19", ns_test._get_library_settings_keys()[1]: "21" } input_dicts_list = [ expected_output, { ns_test._get_library_name_key(): "CV4", ns_test._get_library_fp_key(): "/old/path/to/CV4.txt", ns_test._get_library_settings_keys()[0]: "19", ns_test._get_library_settings_keys()[1]: "21" } ] with self.assertRaises(ValueError): ns_test._id_and_validate_library("CV4", input_dicts_list)
def test__id_and_validate_library_valid(self): expected_output = { ns_test._get_library_name_key(): "CV4", ns_test._get_library_fp_key(): "/some/path/to/CV4.txt", ns_test._get_library_settings_keys()[0]: "19", ns_test._get_library_settings_keys()[1]: "21" } input_dicts_list = [expected_output] real_output = ns_test._id_and_validate_library("CV4", input_dicts_list) self.assertEqual(expected_output, real_output)
def test__validate_settings_keys_valid_w_warning(self): input_settings = { ns_test._get_library_name_key(): "CV4", ns_test._get_library_fp_key(): "/some/path/to/CV4.txt", ns_test._get_library_settings_keys()[0]: "19", ns_test._get_library_settings_keys()[1]: "21", "key2": "goldish" } with warnings.catch_warnings(record=True) as warnings_list: # Cause all warnings to always be triggered. warnings.simplefilter("always") ns_test._validate_settings_keys("CV4", input_settings) assert len(warnings_list) == 1 assert "ignored" in str(warnings_list[-1].message)
def test__mine_library_file_partial_contents_missing_key(self): file_contents_str = """# library_name = CV4 # min_trimmed_grna_len = 19 construct_id target_a_id probe_a_id probe_a_seq target_b_id probe_b_id probe_b_seq FinalSequence Gene_A_chr Gene_A_pos Gene_B_chr Gene_B_pos BRCA1_chr17_41276018__NonTargetingControlGuideForHuman0412 BRCA1 BRCA1_chr17_41276018 TCTTGTGCTGACTTACCAGA NonTargetingControlGuideForHuman0412 NonTargetingControlGuideForHuman0412 GCACGCTGTACAGACGACAA tatatatcttgtggaaaggacgaaacACCGTCTTGTGCTGACTTACCAGAGTTTcAGAGCTAtgctgGAAActgcaTAGCAAGTTgAAATAAGGCTAGTCCGTTATCAACTTGAAAAAGTGGCACCGAGTCGGTGCTTTTTTGTACTGAGtCGCCCaGTCTCAGATAGATCCGACGCCGCCATCTCTAGGCCCGCGCCGGCCCCCTCGCACAGACTTGTGGGAGAAGCTCGGCTACTCCCCTGCCCCGGTTAATTTGCATATAATATTTCCTAGTAACTATAGAGGCTTAATGTGCGATAAAAGAGGCACGCTGTACAGACGACAAGTTTTAGAGCTAGAAATAGCAAGTTAAAATAAGG chr17 41276018 NA NA NonTargetingControlGuideForHuman0352__SETD2_chr3_47142972 NonTargetingControlGuideForHuman0352 NonTargetingControlGuideForHuman0352 GCCATTCTAGTCCCGGCATA SETD2 SETD2_chr3_47142972 AACGTTAACTCTGAGCCTGA tatatatcttgtggaaaggacgaaacACCGGCCATTCTAGTCCCGGCATAGTTTcAGAGCTAtgctgGAAActgcaTAGCAAGTTgAAATAAGGCTAGTCCGTTATCAACTTGAAAAAGTGGCACCGAGTCGGTGCTTTTTTGTACTGAGtCGCCCaGTCTCAGATAGATCCGACGCCGCCATCTCTAGGCCCGCGCCGGCCCCCTCGCACAGACTTGTGGGAGAAGCTCGGCTACTCCCCTGCCCCGGTTAATTTGCATATAATATTTCCTAGTAACTATAGAGGCTTAATGTGCGATAAAAGAGAACGTTAACTCTGAGCCTGAGTTTTAGAGCTAGAAATAGCAAGTTAAAATAAGG NA NA chr3 47142972 """ expected_output = { ns_test._get_library_name_key(): "CV4", ns_test._get_library_fp_key(): "/some/path/to/CV4.txt", ns_test._get_library_settings_keys()[1]: "19" } file_contents_obj = io.StringIO(file_contents_str) real_output = ns_test._mine_library_file("CV4", "/some/path/to/CV4.txt", file_contents_obj) # one of required keys is missing from file, so output dict will be one entry short self.assertEqual(expected_output, real_output)