As discussed before, the top section is a function called ‘countSubStringMatchRecursive’. This function is simply defined in the top section. It is called (or it’s told to run its code) in the line highlighted in yellow.
In all actuality there are two parts to this piece of code below. The top half is the definition of the function, with lists detailed after. I’ve changed the font of the non-interactive pieces to blue. The font in black is the code that is actually telling the terminal to do something. It will reference the information in blue and use it when necessary, but it’s not technically part of the active piece.
| def countSubStringMatchRecursive(target, key, x): x = find(target, key, x) if x == -1: return 0 else: return countSubStringMatchRecursive(target, key, x+1) +1 target = ["atgacatgcacaagtatgcat", "atgaatgcatggatgtaaatgcag"] key = ["a", "atg", "atgc", "atgca"] for t in target: for k in key: print "There were " + str(countSubStringMatchRecursive(t, k, 0)) + " occurances of your key " + k + " in " + t |
| There were 8 occurances of your key a in atgacatgcacaagtatgcat There were 3 occurances of your key atg in atgacatgcacaagtatgcat There were 2 occurances of your key atgc in atgacatgcacaagtatgcat There were 2 occurances of your key atgca in atgacatgcacaagtatgcat There were 9 occurances of your key a in atgaatgcatggatgtaaatgcag There were 5 occurances of your key atg in atgaatgcatggatgtaaatgcag There were 2 occurances of your key atgc in atgaatgcatggatgtaaatgcag There were 2 occurances of your key atgca in atgaatgcatggatgtaaatgcag |