[gt-users] New feature announcement

Sascha Steinbiss steinbiss at zbh.uni-hamburg.de
Mon Jan 26 18:38:27 CET 2009


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

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.

-- 
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



More information about the gt-users mailing list