def test_snip():
    """
    checks if the start and end index lies within the range of list.
    If the index is greater than the list size, Index out of Bounds assetion is thrown.
    :return: None
    """
    dna_list = DNAList("SNIPTEST")
    dna_list.snip(0, 4)
    print(dna_list)
    pass
Esempio n. 2
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()
Esempio n. 3
0
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
print("Testing snip function:")

# Test snip middle part
# Test case 14
temp1 = DNAList('ACGTGA')
temp1.snip(1, 2)
test('AGTGA', str(temp1))

# Test snip front part
# Test case 15
temp1 = DNAList('ACGTGA')
temp1.snip(0, 2)
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))
Esempio n. 4
0
def snip_Tester():
    test = DNAList('AACCGGTT')
    test.snip(1, 4)
    print('Indices in range' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    test.snip(1, 8)
    print('Index is not in range' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    test.snip(0, 7)
    print('Snip using boundary indices' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    test.snip(1, 1)
    print('Illegal passing of arguments' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    test.snip(1, -4)
    print('Negative value of arguments' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    test.snip(4, 1)
    print('i1 is greater than i2 ' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    test.snip(3, 3)
    print('i1 equal to i2 ' + " " + test.__str__())
    test = DNAList('AACCGGTT')
    test.snip(0, 0)
    print('i1 and i2 equals to 0' + " " + test.__str__())