def test_splice(): """ checks if the index is valid in the list. If other list is empty, nothing is added in the index. If the index is greater than the list size, Index out of Bounds assetion is thrown. :return: None """ dna_list = DNAList("SPLICETEST") other = DNAList(" Yayy ") dna_list.splice(5, other) print(dna_list) pass
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)
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()
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:") # Test splice at the front # Test case 11 temp1, temp2 = DNAList('ACGT'), DNAList('GTCA') temp1.splice(0, temp2) test('GTCAACGT', str(temp1)) # Test splice in the middle # Test case 12 temp1, temp2 = DNAList('ACGT'), DNAList('GTCA') temp1.splice(1, temp2) test('AGTCACGT', str(temp1)) # Test splice at the end # Test case 13 temp1, temp2 = DNAList('ACGT'), DNAList('GTCA') temp1.splice(4, temp2) test('ACGTGTCA', str(temp1)) # Test snip function
def splice_Tester(): test = DNAList('AACCGGTT') tester = DNAList('ACGT') test.splice(1, tester) print('Testing when index is not in range' + " " + test.__str__()) test = DNAList('AACCGGTT') tester = DNAList('ACGT') test.splice(7, tester) print('splice at last index' + " " + test.__str__()) test = DNAList('AACCGGTT') tester = DNAList('ACGT') test.splice(3, tester) print('splice at middle index' + " " + test.__str__()) test = DNAList('AACCGGTT') tester = DNAList('ACGT') test.splice(0, tester) print('splice at the first index' + " " + test.__str__()) test = DNAList('AACCGGTT') tester = DNAList('ACGT') test.splice(-1, tester) print('Negative index' + " " + test.__str__()) test = DNAList('AACCGGTT') tester = DNAList('') test.splice(1, tester) print('if the list is empty ' + " " + test.__str__())