python - How do I get the keys associated with the minimum value in a dict? -
So, I'm working on a bioinformatics course set up the problem right now, and got stuck on an algorithm.
My problem is that I do not seem to understand a way to do the last job ( SkewMin
), because it is only to return those terms where Slant is
at least.
And yes, I know that indexing starts at 0, but I'll add 1 minimumValues
to adjust every value, then go with it :)
# Examples: # Index: 1 2 3 4 5 6 7 8 9 10 11 12 13 # Genome = & gt; A T T C GGGCGGCC # SCU (Genome) = & gt; 0 0 0 -1 -1 0 -1 -2 -1 -1 -1 -2 MinSkew (genome) = & gt; 9 13
Here is the real code (I have removed the code for scu
, as I have completely described above, and I have to work The code is not allowed online, which is why I am not mentioning the course name):
# MinSkew uses Squaw, where at the minimum to scout the posts #EX: Slant ("ACGTGCC") returns index 0 1 2 3 4 5 6 7 #and with MinSkew 0 -1 0 0 1 0 -1 # ("ACGTGC") Index of scoring nucletides 1 in the genome # results: (2,7) DEF MinSkew (genome): dictOfSkew = dict () skewValues = skew (genome) minimumSkew = 0 minimumValues = list () I in range (0, lane (Genome) +1): dictOfSkew [i] = skewValues [i] if minimum squ & gt; SkewValues [i]: minimumSkew = skewValues [i] minimumValues.append (i) return minimumValues
Your main error is that when you get a new minute, you never clean the minimum value
, so the values of the last minute are still around BartoszKP The answer is OK, but to do this in one pass:
If minimum SKU> SkewValues [i]: minimumSkew = skewValues [i] minimumValues = [i] elif minimumSkew == skewValues [i]: minimumValues.append (i)
Comments
Post a Comment