for interval in my_bedtool: (chrom, start, end, _, _, strand) = interval
Suppose I want to compute the interval length, as follows:
length = end - start
This results in a
TypeError: unsupported operand type(s) for -: 'str' and 'str'.
It happens that the unpacked
start variables are strings.
Converting them to ints is probably suboptimal given that
Intervals can be created by providing ints for the coordinates:
from pybedtool import Interval interval = Interval("X", 0, 100, strand="+")
end attributes of an
Interval are ints.
I could do:
(chrom, start, end, strand) = ( interval.chrom, interval.start, interval.end, interval.strand)
But I think this looks a bit ugly.
Is there a better approach?