[Biopython-dev] Bug in Bio.Restriction.Analysis.print_as('map') + correction

Jogi derjogi at web.de
Sun Aug 7 13:44:03 UTC 2011


I'm new to the field of 'bug reporting', so please, if someone knows
where I should post this message please tell me or do it yourself :)

I've found a bug in the Bio.Restriction module when calling
Analysis.print_as('map').

The bugs (that I know of and that I corrected):
1. When there is a restriction site within the first 60 basepairs in the
sequence this one isn't added to a list and thus raises an KeyError: 0

2. Sometimes (I don't know exactly how to reproduce it any more) an
Enzyme is repeated in every line although there is no restriction site.

Solution:

Replace from line 310 in PrintFormat.py:
        x, counter, length = 0, 0, len(self.sequence)
        for x in xrange(60, length, 60):
            counter = x - 60
            l=[]
            for key in mapping:
                if key <= x:
                    l.append(key)
                else:
                    cutloc[counter] = l
                    mapping = mapping[mapping.index(key):]
                    break
            cutloc[x] = l
        cutloc[x] = mapping
        sequence = self.sequence.tostring()

With
        upper, lower, length = 0, 0, len(self.sequence)
        for upper in xrange(60, length+60, 60):
            lower = upper - 60
            l=[]
            for key in mapping:
                if key <= upper and key > lower:
                    l.append(key)
                else:
                    mapping = mapping[mapping.index(key):]
                    break
            cutloc[lower] = l
        sequence = self.sequence.tostring()


Hope this bug report/solution was/is helpful and at the right place :)
J.Kuhn








More information about the Biopython-dev mailing list