0

I'm trying to do some basic python with DNA sequences but now I'm running into a little problem.

This is my initial code:

def positie(enzyme):
    pos = sequentie.find(enzyme.lower())
    print (pos)

def searchopdracht(enzyme):
    if enzyme.lower() in sequentie:
        print(enzyme, " does cut, at location:")
        positie(enzyme)
        print(" ")
    else:
        print(enzyme, "does not cut")
        print(" ")

for enzyme in [DdeI, BspMII, EcoRI, HindIII, TaqI]:
    searchopdracht(enzyme)

Which outputs the following:

CTGAG does cut, at location: 1022
TCCGGA does not cut  
GAATTC  does cut, at location: 1449
AAGCTT  does cut, at location: 77
TCGA  does cut, at location: 171

All fine and working, but I want the names of the enzymes to be displayed instead of the sequences, for example, not "CTGAG does cut, at location: 1022" but "DdeI does cut, at location: 1022"

This is what I tried (but gives no output whatsoever), but feel free to give other suggestions:

def positie( enzyme ):
    pos = sequentie.find(enzyme.lower())
    print (pos)

def searchopdracht(enzyme, enzyme_name):
    if enzyme.lower() in sequentie:
        print(enzyme_name," does cut, at location:")
        positie(enzyme)
        print(" ")
    else:
        print(enzyme_name, "does not cut")
        print(" ")

list1 = [DdeI, BspMII, EcoRI, HindIII, TaqI]
list2 = ["DdeI", "BspMII", "EcoRI", "HindIII", "TaqI"]

for (enzyme, enzyme_name) in (list1, list2):
    searchopdracht(enzyme)
James Antill
  • 2,825
  • 18
  • 16
RnRoger
  • 682
  • 1
  • 9
  • 33

1 Answers1

0

You need to pass the enzyme_name as an argument to searchopdracht(), and use zip to create tuple pairs of your input:

for enzyme, enzyme_name in zip(list1, list2):
    searchopdracht(enzyme, enzyme_name) # added argument
ChrisFreeman
  • 5,831
  • 4
  • 20
  • 32