Skip to content Skip to sidebar Skip to footer

Going To A Certain Position In A String

I want to get to a certain point on a string that is opposite (from the negative side) to that of what I am given. AAAAAAAAAACCCCCCCCCCTTTTTTTTTTGGGGGGGGGG TTTTTTTT

Solution 1:

Try adding parentheses around the last term:

s = ''.join(bc[base.upper()] for base in (chr_string[-starts-1:-ends-1]\
                                         ^
            for starts, ends in zipped)) +'\n'
                                      ^

Your defining two different generators here. This is equivalent to:

strands = (chr_string[-starts-1:-ends-1] for starts, ends in zipped)
complementary_strands = (bc[base.upper()] for base in stage_1)
joined_exons = ''.join(stage_2) + '\n'

Solution 2:

It looks like you are trying to do too much in your generator expression.

The two fors are the wrong way around. You mean:

s = ''.join(bc[base.upper()] for starts,ends in zipped forbasein chr_string[-starts-1:-ends-1])+'\n'

Then starts and ends are defined for the second for.

Given the questions you've asked today, I recommend reading a good book, such as Dive Into Python 3 so that you can solve these issues yourself.

Solution 3:

You're defining exonstarts and then referring to starts, which is not defined.

Post a Comment for "Going To A Certain Position In A String"