So you may want to sometimes define a default value for your functions.
We just gave an example where we started at position zero in the very first base of
your sequence.
We want that to be our default.
But we to maybe allow the user to start at position one or two.
Because there are three possible reading frames,
as we call them, in a DNA sequence.
So let's make a slight change to our function.
And allow the user to specify what reading frame it will be in.
So, here we've got pretty much the same function.
Almost all the lines are the same.
But notice in our def command we wrote has_stop_codon (dna, frame).
So now, there's two variables, or arguments to the function.
One of which is the dna sequences as before.
And the other is the reading frame.
And the other change to our function here, is that when we
loop through our dna sequence, instead of going from 0 to the end of the sequence.
We go from frame to the end of the sequence.
Now if we passed in the value 0,
this would be exactly the same as what we did before.
But we don't want to pass in the value 1 or 2,
and then it will start at position 1 or 2.
So that'll work just like before.
So let's try this out.
Let's set our DNA sequence to be a short DNA sequence like the one I'm
showing here.
Notice there is a stop code on it, but at the second position.
There's a TGA.
So we call has stop codon dna starting in the frame zero.
It's going to say false.
Oh wait a minute.
There is a stop code on there.
Why did it return false?
That's because we started at position zero.
When we looked at the first triplet, which is atg.
And then we moved over by three bases.
And looked at the second triplet, which would be agc.
So we didn't find any stop codons in that reading frame.
If we instead start at position one.
And reading frame one.
So we'll call has stop codon with DNA, and give it the argument one.
Now we'll find that TGA that starts in the second position, which remember,
is at index one.