[gt-users] New feature announcement
Brent Pedersen
bpederse at gmail.com
Tue Jan 27 01:56:51 CET 2009
On Mon, Jan 26, 2009 at 9:38 AM, Sascha Steinbiss
<steinbiss at zbh.uni-hamburg.de> wrote:
> Brent Pedersen wrote:
>> hi again,
>
> Hey Brent,
>
>> on a sorta related question:
>> should a FeatureStream yield FeatureNodes? currently, it's
>> GenomeNodes.
>
> Not really. All streams generically work on GenomeNodes. Of course,
> internally they are free to handle only the node types they are
> interested in. For example, RegionNodes which pass through a
> FeatureStream are left untouched by the stream itself (as its sole
> function is to collect feature subtrees in a FeatureIndex), but at the
> end of a stream chain they may be wanted. So pulling things through a
> stream should never change the type.
>
> However, I have not yet found a way to 'downcast' an object in a base
> class to a derived class in Python. I do not have much experience with
> Python idioms, after all. One could introduce a 'to_feature_node' method
i dont know either, but i _think_ that's what is happening in the __new__ call
in create_from_ptr()
> to the GenomeNode class, which checks on the C side whether an object
> can be safely cast to a FeatureNode or not and would return a new
> FeatureNode wrapper object if possible. This would require exposing the
> gt_feature_node_try_cast() C function, which is not in the API right now.
> Gordon, do you see a way around this or have a better idea?
>
> > i tried to implement with the patch below, and ti works
>> for soem cases, but segfaults for others. i think there may be a problem
>> with the FeatureNode.create_from_ptr() that i added when it needs
>> a newref(?).
>
> The newref parameter communicates to the C side whether a Python object
> holds a reference to the node and its children or not so the GenomeTools
> reference counting works correctly. Do you have example code (for
> debugging) in which your modified version fails? Having a newref too
> much set to True should only result in memory leaking, not segfaulting.
>
hmm. today i am unable to find how i did it. but it was definitely
only occurring with the
patch i sent in earlier email.
i'm still foggy at best on understanding the Stream or vistor stuff.
> Sascha
>
> P.S. I have your transparent background feature ready. It is in my
> 'brentp' branch -- Gordon, can you pull that into the master? I had to
> remove the @cachedproperty from FeatureNode.get_type() because
> gn.get_type() could not longer be called as a function this way. I
> changed that, if it's ok.
>
awesome! that's perfect.
i'll save this in hopes of understanding how things work better:
http://github.com/satta/genometools/commit/34493378f6dc3c2c842179c163d9d2e81351bf8f
thanks again!
-brentp
> --
> Sascha Steinbiss
> Center for Bioinformatics
> University of Hamburg
> Bundesstr. 43
> 20146 Hamburg
> Germany
>
> Email: steinbiss at zbh.uni-hamburg.de
> URL: http://www.zbh.uni-hamburg.de/steinbiss
> Phone: +49 (40) 42838 7322
> FAX: +49 (40) 42838 7312
>
> _______________________________________________
> gt-users mailing list
> gt-users at genometools.org
> http://genometools.org/mailman/listinfo/gt-users
>
More information about the gt-users
mailing list