panning with python
0
0
Entering edit mode
7.5 years ago
oshin707 ▴ 10

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 • 1.7k views
ADD COMMENT
0
Entering edit mode

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

ADD REPLY
0
Entering edit mode

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 REPLY
1
Entering edit mode

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

ADD REPLY
1
Entering edit mode

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 REPLY

Login before adding your answer.

Traffic: 2017 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6