[gt-users] custom-track memory leak
Troels Marstrand
troels.marstrand at gmail.com
Mon Nov 16 18:15:38 CET 2009
I am trying to replicate the custom track example from the python
tutorial pages, however, I get to following error message:
/Library/Frameworks/Python.framework/Versions/2.6/lib/python2.6/site-
packages/gt/annotationsketch/layout.py:51: RuntimeWarning: memory leak
in callback function.
had_err = gtlib.gt_layout_sketch(self.layout, canvas, err)
Here is a copy of the python script I am using:
#!/usr/bin/python
#import genometools
from gt.core import *
from gt.extended import *
from gt.annotationsketch import *
from gt.annotationsketch.custom_track import CustomTrack
from gt.core.gtrange import Range
class CustomTrackInsertions(CustomTrack):
def __init__(self, sidelength, data):
super(CustomTrackInsertions, self).__init__()
self.sidelength = sidelength
self.data = data
def get_height(self):
return 20
def get_title(self):
return "Insertion site"
def render(self, graphics, ypos, rng, style, error):
height = (self.sidelength*math.sqrt(3))/2
margins = graphics.get_xmargins()
red = Color(1, 0, 0, 0.7)
for pos, desc in self.data.iteritems():
drawpos = margins + (float(pos)-rng.start)/(rng.end-rng.start
+1) \
* (graphics.get_image_width()-2*margins)
graphics.draw_line(drawpos-self.sidelength/2, ypos +
height, \
drawpos,
ypos, \
red, 1)
graphics.draw_line(drawpos,
ypos, \
drawpos+self.sidelength/2, ypos +
height, \
red, 1)
graphics.draw_line(drawpos-self.sidelength/2, ypos +
height, \
drawpos+self.sidelength/2, ypos +
height, \
red, 1)
graphics.draw_text_centered(drawpos, ypos + height + 13,
str(desc))
return 0
style = Style()
style.load_file('default.style')
feature_index = FeatureIndexMemory()
feature_index.add_gff3file('tmp.gff3')
seqid = feature_index.get_first_seqid()
range = feature_index.get_range_for_seqid(seqid)
diagram = Diagram.from_index(feature_index, seqid, range, style)
ctt = CustomTrackInsertions(15, {67100417:"foo", 67113051:"bar",
67143471:"baz"})
diagram.add_custom_track(ctt)
layout = Layout(diagram, 600, style)
height = layout.get_height()
canvas = CanvasCairoFile(style, 600, height)
layout.sketch(canvas)
Thanks in advance for any help
Cheers
Troels
More information about the gt-users
mailing list