Question: panning with python
0
gravatar for oshin707
3.0 years ago by
oshin70710
oshin70710 wrote:

So for my assignment, I have to show panning of a graph. But it doesnt work. Can anyone help???? Please

I used this code:

def pann_input():

        x=0
        y=0

        FASTAa=open("P04637.fas", "r")  
        header=FASTAa.readline()

        a=""    
        for ll in FASTAa:  
            #print ll
            a+=ll.rstrip()
        al=list(FASTAa)

        FASTAb=open("Q0VCX4.fas", "r") # r means read
        header=FASTAb.readline()
        b=""
        for ll in FASTAb:  
            #print ll
            b+=ll.rstrip()
        bl=list(FASTAb)

try:
        p1=str(a[x:(x+75)])
        p2=str(b[y:(y+25)])

        print " ", ' '.join(p1), " "
        for i in p2:
                print "\n" "%s" %i,
                for x in p1:
                        if i==x in p2:
                                print '*',
                        else: 
                                print ' ' , 
except IOError:
        print "Error: Give a different name:"

def limits():    
        while True:
                try:
        # Dotplot shifting
                        option = raw_input('\nEnter [r]ight, [l]eft, [u]p, [d]own or [m]enu: ')
                        if option == 'r':
                                if limits['x_right'] < limits['x_max']:
                                        limits['x_right'] += 10
                                        limits['x_left'] += 10
                        if option == 'l':
                                if limits['x_left'] > 0:
                                        limits['x_left'] -= 10
                                        limits['x_right'] -= 10
                        if option == 'u':
                                if limits['y_up'] > 0:
                                        limits['y_down'] -= 10
                                        limits['y_up'] -= 10
                        if option == 'd':
                                if limits['y_down'] < limits['y_max']:
                                        limits['y_down'] += 10
                                        limits['y_up'] += 10
                        if option == 'm':
                                print "Do you want to go to the Menu?"
                except ValueError:
                        print "Error"

pann_input()
limits()
python panning • 841 views
ADD COMMENTlink modified 3.0 years ago by RamRS24k • written 3.0 years ago by oshin70710

What about the answer you got here? Panning through a graph using python

ADD REPLYlink written 3.0 years ago by WouterDeCoster42k

it just says to try the matplotlib way for panning. but we cant use it in this question.

so I used a different code for panning the graph. this code shows me this error: I dont understand the error

Traceback (most recent call last):

File "pann.py", line 71, in <module>

limits()

File "pann.py", line 49, in limits

if limits['x_right'] < limits['x_max']:

TypeError: 'function' object has no attribute '__getitem__'

ADD REPLYlink modified 3.0 years ago • written 3.0 years ago by oshin70710
1

I'd recommend asking stackoverflow. Strictly speaking, this isn't really bioinformatics.

ADD REPLYlink written 3.0 years ago by RamRS24k
1

Why can't you use matplotlib? In addition, you are supposed to fix assignments on your own. How will you learn if we provide the answer? By the way, your code only runs once.

And you are reusing a function and a variable with the same name. That's what your error is about.

ADD REPLYlink modified 3.0 years ago • written 3.0 years ago by WouterDeCoster42k
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.3.0
Traffic: 1296 users visited in the last hour