This is a test version of Biostars. For the public version, visit https://www.biostars.org.
panning with python

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

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__'

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

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.

0 answers

No answers yet.

Log in to answer this question.