Question: panning with python

0

oshin707 •

**10**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()
```

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

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

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

20kWhy 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.

37k