def test_extact_feature_sequences_ui(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.extract_feature_sequences = [["CDS"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert hf.string2hash(out) == "842d9c911a33c0fd0484383eabefb0fe" test_in_args.extract_feature_sequences = [["TMD"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert hf.string2hash(out) == "cc7a1c6a22f721ec0668fc8ea6b23429" test_in_args.extract_feature_sequences = [["TMD1", "splice_a"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert hf.string2hash(out) == "497d536b1be9a90ef0ef75281d0c867f" test_in_args.extract_feature_sequences = [["TMD2:TMD3"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert hf.string2hash(out) == "07773f4fb1dc430c0c3ce6cd5a799439" test_in_args.extract_feature_sequences = [["foo"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert hf.string2hash(out) == "ac15492b38ca2ac4baa63e63a9b747f7"
def test_extact_feature_sequences_ui(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.extract_feature_sequences = [["CDS"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert hf.string2hash(out) == "2d8b6524010177f6507dde387146378c" test_in_args.extract_feature_sequences = [["TMD"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert hf.string2hash(out) == "3c20784722e00567cee04f3e7adca99c" test_in_args.extract_feature_sequences = [["TMD1", "splice_a"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert hf.string2hash(out) == "6a556349095dac86339b0e0057467fdd" test_in_args.extract_feature_sequences = [["TMD2:TMD3"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert hf.string2hash(out) == "1076bce8903f736787ce16fd95899af8" test_in_args.extract_feature_sequences = [["foo"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert hf.string2hash(out) == "0ef69def122bd6923bc9ca02e2a19233"
def test_rename_ids_ui(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.rename_ids = [["[a-z](.)", "?\\1", 2]] tester = alb_resources.get_one("m p s") Alb.command_line_ui(test_in_args, tester, True) out, err = capsys.readouterr() assert hf.string2hash(out) == "888f2e3feb9e67f9bc008183082c822a" test_in_args.rename_ids = [["[a-z](.)"]] with pytest.raises(AttributeError) as err: Alb.command_line_ui(test_in_args, tester, pass_through=True) assert "rename_ids requires two or three argments:" in str(err) test_in_args.rename_ids = [["[a-z](.)", "?\\1", 2, "foo"]] with pytest.raises(AttributeError) as err: Alb.command_line_ui(test_in_args, tester, pass_through=True) assert "rename_ids requires two or three argments:" in str(err) test_in_args.rename_ids = [["[a-z](.)", "?\\1", "foo"]] with pytest.raises(ValueError) as err: Alb.command_line_ui(test_in_args, tester, pass_through=True) assert "Max replacements argument must be an integer" in str(err) test_in_args.rename_ids = [["[a-z](.)", "?\\1\\2", 2]] with pytest.raises(AttributeError) as err: Alb.command_line_ui(test_in_args, tester, pass_through=True) assert "There are more replacement" in str(err)
def test_delete_invariant_sites_ui(capsys, hf, alb_odd_resources): test_in_args = deepcopy(in_args) test_in_args.delete_invariant_sites = [[]] tester = Alb.AlignBuddy(alb_odd_resources['dna']['single']['ambiguous']) Alb.command_line_ui(test_in_args, tester, skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "27233a416437eabc72aa5d57cb695036"
def test_consensus_ui(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.consensus = ['SiMpL'] Alb.command_line_ui(test_in_args, alb_resources.get_one("m d s"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "9b69e5fb65ca1512de5a17472d105500" Alb.command_line_ui(test_in_args, alb_resources.get_one("m p s"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "d1a8f7e629a020f5130373d7af65f9d9" test_in_args.consensus = ['WeiG'] Alb.command_line_ui(test_in_args, alb_resources.get_one("m d s"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "2364532e0ec2465ea27f04acc5d0e61b" Alb.command_line_ui(test_in_args, alb_resources.get_one("m p s"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "bf50c95916e9d62c95a460bbc517c053" test_in_args.consensus = ['foo'] Alb.command_line_ui(test_in_args, alb_resources.get_one("m d s"), skip_exit=True) out, err = capsys.readouterr() assert "No valid consensus mode" in err
def test_screw_formats_ui2(_format, next_hash, capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.screw_formats = _format tester = alb_resources.get_one("m p py") Alb.command_line_ui(test_in_args, tester, True) out, err = capsys.readouterr() assert hf.string2hash(out) == next_hash
def test_extact_feature_sequences_ui(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.extract_feature_sequences = [["CDS"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert hf.string2hash(out) == "2a42c56df314609d042bdbfa742871a3" test_in_args.extract_feature_sequences = [["TMD"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert hf.string2hash(out) == "eb878a1b14b73dd6148291f630ba98d8" test_in_args.extract_feature_sequences = [["TMD1", "splice_a"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert hf.string2hash(out) == "f086752f8915872dc2260486142f643b" test_in_args.extract_feature_sequences = [["TMD2:TMD3"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert hf.string2hash(out) == "78d674f258e634ef0737db1cc6067be6" test_in_args.extract_feature_sequences = [["foo"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert hf.string2hash(out) == "0ef69def122bd6923bc9ca02e2a19233"
def test_test(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.delete_records = ["α1"] test_in_args.test = True Alb.command_line_ui(test_in_args, alb_resources.get_one("o d f"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "d41d8cd98f00b204e9800998ecf8427e"
def test_uppercase_ui(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.uppercase = True Alb.command_line_ui(test_in_args, alb_resources.get_one("m p s"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "6f3f234d796520c521cb85c66a3e239a"
def test_map_features2alignment_ui(capsys, alb_resources, sb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.mapfeat2align = [sb_resources.get_one("d g", "paths")] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d n"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "c1359470ad0916902c4e96facd088378"
def test_lowercase_ui(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.lowercase = True Alb.command_line_ui(test_in_args, alb_resources.get_one("m p s"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "00661f7afb419c6bb8c9ac654af7c976"
def test_faux_align_ui(capsys, alb_resources): test_in_args = deepcopy(in_args) test_in_args.faux_align = [None] test_in_args.alignments = [alb_resources.get_one("o p g", "paths")] Alb.command_line_ui(test_in_args, Alb.AlignBuddy, skip_exit=True) out, err = capsys.readouterr() alignbuddy = Alb.AlignBuddy(out) assert len(alignbuddy.alignments[0][0]) == 625
def test_position_frequency_matrix_ui(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.pos_freq_mat = True Alb.command_line_ui(test_in_args, alb_resources.get_one("m p s"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "a229988a3fdae4f089b91f5047ad816d", print( out)
def test_consensus_ui(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.consensus = True Alb.command_line_ui(test_in_args, alb_resources.get_one("m d s"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "7b0aa3cca159b276158cf98209be7dab" Alb.command_line_ui(test_in_args, alb_resources.get_one("m p s"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "89130797253646e61b78ab7d91ad3fd9"
def test_enforce_triplets_ui(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.enforce_triplets = True Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "34c7d45c3f279df93ba82840f4320a5a" Alb.command_line_ui(test_in_args, alb_resources.get_one("m p c"), skip_exit=True) out, err = capsys.readouterr() assert "Nucleic acid sequence required, not protein." in err
def test_generate_alignment_ui(capsys, monkeypatch, sb_resources, alb_resources, hf): monkeypatch.setattr(Alb, "generate_msa", lambda *_: alb_resources.get_one("o d g")) test_in_args = deepcopy(in_args) test_in_args.generate_alignment = [[]] test_in_args.alignments = [sb_resources.get_one("d g", "paths")] test_in_args.out_format = "gb" Alb.command_line_ui(test_in_args, Alb.AlignBuddy, skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "2a42c56df314609d042bdbfa742871a3"
def test_translate_ui(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.translate = True Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "a949edce98525924dbbc3ced03c18214" with pytest.raises(TypeError) as err: Alb.command_line_ui(test_in_args, alb_resources.get_one("o p n"), pass_through=True) assert "Nucleic acid sequence required, not protein." in str(err)
def test_reverse_transcribe_ui(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.reverse_transcribe = True Alb.command_line_ui(test_in_args, alb_resources.get_one("o r n"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "f8c2b216fa65fef9c74c1d0c4abc2ada" with pytest.raises(TypeError) as err: Alb.command_line_ui(test_in_args, alb_resources.get_one("m d s"), pass_through=True) assert "RNA sequence required, not IUPACAmbiguousDNA()." in str(err)
def test_enforce_triplets_ui(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.enforce_triplets = True Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "6ff2a8a7c58bb6ac0d98fe373981e220" Alb.command_line_ui(test_in_args, alb_resources.get_one("m p c"), skip_exit=True) out, err = capsys.readouterr() assert "Nucleic acid sequence required, not protein." in err
def test_transcribe_ui(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.transcribe = True Alb.command_line_ui(test_in_args, alb_resources.get_one("o d n"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "e531dc31f24192f90aa1f4b6195185b0" with pytest.raises(TypeError) as err: Alb.command_line_ui(test_in_args, alb_resources.get_one("o r n"), pass_through=True) assert "DNA sequence required, not IUPACAmbiguousRNA()." in str(err)
def test_extract_regions_ui(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.extract_regions = [["100:200", "250", ":10/50"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert hf.string2hash(out) == "891bdc3af63c6ddc96a507939e2d771a" test_in_args.extract_regions = [["100:200", "250", ":10/foo"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert "Unable to decode the positions string" in err
def test_extract_regions_ui(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.extract_regions = [["100:200", "250", ":10/50"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert hf.string2hash(out) == "7e202f9f6caaf83c558631a3577af20a" test_in_args.extract_regions = [["100:200", "250", ":10/foo"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert "Unable to decode the positions string" in err
def test_order_ids_ui(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.order_ids = [False] Alb.command_line_ui(test_in_args, alb_resources.get_one("m p s"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "f36f73e973aa7a2dcd2fc86f239d5a23" test_in_args.order_ids = ['rev'] Alb.command_line_ui(test_in_args, alb_resources.get_one("m p s"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "d4dcdc5059fd82c6b9cc44a66770b801"
def test_list_ids(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.list_ids = [False] Alb.command_line_ui(test_in_args, alb_resources.get_one("m p s"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "f087f9c1413ba66c28fb0fccf7c974e6" test_in_args.list_ids = [3] Alb.command_line_ui(test_in_args, alb_resources.get_one("m p s"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "4d85249a1f187d38d411a78ced65a98c"
def test_extract_regions_ui(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.extract_regions = [["100:200", "250", ":10/50"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert hf.string2hash(out) == "569f1946a6af1b92a754c5a13279795b" test_in_args.extract_regions = [["100:200", "250", ":10/foo"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d g"), True) out, err = capsys.readouterr() assert "Unable to decode the positions string" in err
def test_clean_seqs_ui(capsys, alb_resources, alb_odd_resources, hf): test_in_args = deepcopy(in_args) test_in_args.clean_seq = [[None]] Alb.command_line_ui(test_in_args, alb_resources.get_one("m p pr"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "73b5d11dd25dd100648870228ab10d3d" test_in_args.clean_seq = [['strict', 'X']] Alb.command_line_ui(test_in_args, Alb.AlignBuddy(alb_odd_resources['dna']['single']['ambiguous']), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "6755ea1408eddd0e5f267349c287d989"
def test_split_alignment_ui(_format, _code, alb_resources): TEMP_DIR.subdir(_format) test_in_args = deepcopy(in_args) test_in_args.split_to_files = [["%s/%s" % (TEMP_DIR.path, _format), "Foo_"]] tester = alb_resources.get_one(_code) for num in range(7): tester.alignments += tester.alignments Alb.command_line_ui(test_in_args, tester, True) assert os.path.isfile("%s/%s/Foo_001.%s" % (TEMP_DIR.path, _format, br.format_to_extension[_format])) assert os.path.isfile("%s/%s/Foo_061.%s" % (TEMP_DIR.path, _format, br.format_to_extension[_format])) assert os.path.isfile("%s/%s/Foo_121.%s" % (TEMP_DIR.path, _format, br.format_to_extension[_format])) TEMP_DIR.del_subdir(_format)
def test_pull_records_ui(capsys, alb_resources, hf): test_in_args = deepcopy(in_args) test_in_args.pull_records = [["α[1-5]$", "β[A-M]"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("m d s"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "2de557d6fd3dc6cd1bf43a1995392a4c" assert err == "" test_in_args.pull_records = [["α[1-5]$", "ML218922a", "full"]] Alb.command_line_ui(test_in_args, alb_resources.get_one("o d s"), skip_exit=True) out, err = capsys.readouterr() assert hf.string2hash(out) == "fb82ffec15ece60a74d9ac8db92d2999"
def test_alignment_lengths_ui(capsys, alb_resources): test_in_args = deepcopy(in_args) test_in_args.alignment_lengths = True Alb.command_line_ui(test_in_args, alb_resources.get_one("m p c"), skip_exit=True) out, err = capsys.readouterr() assert out == "481\n683\n" assert err == "# Alignment 1\n# Alignment 2\n" Alb.command_line_ui(test_in_args, alb_resources.get_one("o p py"), skip_exit=True) out, err = capsys.readouterr() assert out == "681\n" assert err == ""
def test_bootstrap_ui(capsys, alb_resources): test_in_args = deepcopy(in_args) test_in_args.bootstrap = [False] Alb.command_line_ui(test_in_args, alb_resources.get_one("m p s"), skip_exit=True) out, err = capsys.readouterr() tester = Alb.AlignBuddy(out) assert tester.lengths() == [481, 683] test_in_args.bootstrap = [3] Alb.command_line_ui(test_in_args, alb_resources.get_one("m p s"), skip_exit=True) out, err = capsys.readouterr() tester = Alb.AlignBuddy(out) assert tester.lengths() == [481, 481, 481, 683, 683, 683]