Exemplo n.º 1
0
def test1():
    """
    This is a simple test case which checks all the functions
    :return:
    """
    print("TEST CASE 1")
    dna = DNAList()

    # items with values will be appended in the gene list
    dna.append("A")
    dna.append("B")
    dna.append("C")

    print("After append method ", dna)

    other = DNAList()
    other.append("D")
    other.append("E")
    other.append("F")
    other.append("G")

    # list with values will be appended in the gene list
    dna.join(other)
    print("After join method with the list provided", dna)

    # if gene list is not empty then it will copy the current items in the list in a new list
    newList = dna.copy()
    print("After copy method", newList)

    newother = DNAList()
    newother.append("H")
    newother.append("I")
    newother.append("J")
    newother.append("K")

    # list with elements after the index will be added in the list
    dna.splice(4, newother)
    print("After splice method at index 4 ", dna)

    # index of elements specified will be removed from the list
    dna.snip(4, 5)
    print("After snip method with index 4 and 5 ", dna)

    newotherlist = DNAList()
    newotherlist.append("W")
    newotherlist.append("Q")
    newotherlist.append("R")

    # the string given will be replaced with the list given
    dna.replace("BCD", newotherlist)
    print("After replace method with string BCD", dna)
    print()
def test_replace():
    """
    If the other list is empty, nothing is replaced.
    If repstr String is not found, nothing is replaced.
    If The String is found, it is replaced.
    :return: None
    """
    dna_list = DNAList("HIIAMAAMIT")
    other = DNAList("ADITI")
    dna_list.replace("Jaisinghani", other)
    print(dna_list)
    dna_list.replace("AMIT", other)
    print(dna_list)
    pass
Exemplo n.º 3
0
def test2():
    """
    The second test function
    """
    print("TEST CASE 2")

    dna = DNAList()
    # checks for test case of copy cannot copy when gene list is empty
    dna.copy()

    # checks the append function if empty string is appended it wont append the empty String
    dna.append("")

    # if the item is None it also won't be appended in the gene list
    dna.append(None)

    # items with values will be appended in the gene list
    dna.append("A")
    dna.append("B")
    dna.append("C")
    print("After append method ", dna)

    normList = DNAList()
    # empty list wont be appended in the gene list
    dna.join(normList)

    newother = DNAList()
    newother.append("H")
    newother.append("I")
    newother.append("J")
    newother.append("K")

    # will append the elements in the front if index is 0
    dna.splice(0, newother)
    print("After splice method at index 0 ", dna)
    # will not append the gene list if the list passed in the function is empty
    dna.splice(0, normList)

    newotherlist = DNAList()
    newotherlist.append("W")
    newotherlist.append("Q")
    newotherlist.append("R")

    # will not replace if the given object is of list is empty
    dna.replace("BCD", normList)
    #cannot replace if string to be replaced is None or empty
    dna.replace("", newotherlist)
    dna.replace(None, newotherlist)

    # replaces the starting value of the gene list with other list
    # replace any substring with any other list of elements provided
    dna.replace("H", newotherlist)
Exemplo n.º 4
0
def replace_Tester():
    test = DNAList('AACCGGTT')
    r = DNAList('TTGGCC')
    test.replace('AA', r)
    print('Normal case' + " " + test.__str__())
    test = DNAList('')
    r = DNAList('TTGGCC')
    test.replace('AA', r)
    print('List 1 is empty' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    r = DNAList('')
    test.replace('AA', r)
    print('List 2 is empty' + " " + test.__str__())
Exemplo n.º 5
0
test('GTGA', str(temp1))

# Test snip end part
# Note: if the end index is out of bound, all items from the
# begining index until the end of the DNAList will be deleted.
# Test case 16
temp1 = DNAList('ACGTGA')
temp1.snip(2, 10)
test('AC', str(temp1))

# Test replace function
print("Testing replace function:")

# Test case 17
temp1, repstr, temp2 = DNAList(''), 'ACG', DNAList('GTC')
test(False, temp1.replace(repstr, temp2))

# Test case 18
temp1, repstr, temp2 = DNAList('TCACGAA'), 'ACG', DNAList('GTC')
temp1.replace(repstr, temp2)
test('TCGTCAA', str(temp1))

# Test case 19
temp1, repstr, temp2 = DNAList('ATCGGAC'), 'ACG', DNAList('GTC')
test(False, temp1.replace(repstr, temp2))

# Test case 20
temp1, repstr, temp2 = DNAList('TCAACG'), 'ACG', DNAList('GTC')
temp1.replace(repstr, temp2)
test('TCAGTC', str(temp1))