Example #1
0
def join_Tester():
    tester = DNAList("AACCGGTT")
    tester2 = DNAList("")
    tester.join(tester2)
    print('Join When List is Null' + " " + tester.__str__())
    tester = DNAList('AACCGGTT')
    tester2 = DNAList("AAA")
    tester.join(tester2)
    print('Joining at the end of the list' + " " + tester.__str__())
Example #2
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)
Example #3
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_join():
    """
    Another list is appended to the current list.
    It is added to the end of the list.
    If another list is empty, nothing is added.
    if the current list is empty, another list still can be added to it.

    :return:None
    """
    dna_list = DNAList("JOINTEST")
    dna_list.join(DNAList("I AM Joining"))
    print(dna_list)
    dna_list.join(DNAList(""))
    print(dna_list)
Example #5
0
# Test appending illegal item
# Test case 6
list1.append('')
test('GCCATTGA', str(list1))

# Test case 7
list1.append('1')
test('GCCATTGA', str(list1))

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

# Test join two non-empty list
# Test case 8
temp1, temp2 = DNAList('ACGT'), DNAList('GTCA')
temp1.join(temp2)
test('ACGTGTCA', str(temp1))

# Test join one empty list with a non-empty list
# Test case 9
temp1, temp2 = DNAList(''), DNAList('ACGT')
temp1.join(temp2)
test('ACGT', str(temp1))

# Test case 10
temp1, temp2 = DNAList('ACGT'), DNAList('')
temp1.join(temp2)
test('ACGT', str(temp1))

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