예제 #1
0
def test_insertion_inside_insertion():

    testCase = ({
        1267: ["A", "ACGTGCTAAC", [(0, 1267)] + [(70, x) for x in range(0, 9)]],
        1276: ["A", "AGCACTTTCTGT", [(0, 1276)] + [(54, x) for x in range(0, 11)]]
    },
    {54: 1276, 70: 1267},
    [mutation(mType=mType.INS, genomePos=5, insertionPos=70, source="", target="GCGGGCGC", index=1)])

    apply_general_test(testCase)
예제 #2
0
def test_deletion_overlapping_starting_from_indel():

    testCase = ({
        1267: ["A", "ACGTGCTAAC", [(0, 1267)] + [(70, x) for x in range(0, 9)]],
        1276: ["A", "AGCACTTTCTGT", [(0, 1276)] + [(54, x) for x in range(0, 11)]]
    },
    {54: 1276, 70: 1267},
    [mutation(mType=mType.DEL, genomePos=5, insertionPos=70, source="TAACAAAAAAAAAGC", target="")])

    apply_general_test(testCase)
예제 #3
0
def test_substitution_on_genome():
    
    testCase = ({
        1267: ["A", "ACGTGCTAAC", [(0, 1267)] + [(70, x) for x in range(0, 9)]],
        1276: ["A", "AGCACTTTCTGT", [(0, 1276)] + [(54, x) for x in range(0, 11)]]
    },
    {54: 1276, 70: 1267},
    [mutation(mType=mType.SUB, genomePos=1, insertionPos=0, source="A", target="G")])

    apply_general_test(testCase)
예제 #4
0
def test_multiple_deletions_together_slightly_different():

    testCase = ({
        1406: ['A', '-CTG', [(0, 1406), (23, 0), (23, 1), (23, 2)]], 
        1401: ['AAAA', '----', [(0, 1401), (0, 1402), (0, 1403), (0, 1404)]],
        1408: ['AAA', '---', [(0, 1408), (0, 1409), (0, 1410)]]
    },
    {23: 1406},
    [mutation(mType=mType.DEL, genomePos=1399, insertionPos=0, source="AAACTGAAAAAAAA", target="")])

    apply_general_test(testCase)
예제 #5
0
def test_printing_functions():

    genome_tree = setup_genome_tree()

    class MockFile:
        """
        A class which has 1 method called write, 
        so that I can use it as a mock file object in this test.
        """
        def __init__(self):
            self.written_data = ""

        def write(self, string):
            self.written_data += string

    def parameterised_test(mutDict, insertionDict, mutations, expected_output):
        f = MockFile()
        node = TreeNode(name="test_node")
        node.mutations = mutations

        original_mD = mutDict.copy()
        original_iD = insertionDict.copy()
        genome_tree.writeGenomeShortIndels(node=node,
                                           file=f,
                                           mutDict=mutDict,
                                           insertionDict=insertionDict)
        # the whole point of this function is that the genome tree updates and then de-updates
        # any mutations. So we need the mutDict and insertionDict to remain the same before and after printing.
        assert mutDict == original_mD
        assert insertionDict == original_iD
        assert f.written_data == expected_output  #

    parameterised_test(mutDict={},
                       insertionDict={},
                       mutations=[
                           phastSim.mutation(mType=phastSim.mType.DEL,
                                             genomePos=4,
                                             insertionPos=0,
                                             source="GAAT",
                                             target="")
                       ],
                       expected_output=">test_node\nGAAT5----\n")