[gt-users] method to either delete a child from a FeatureNode, or to update its type
Gordon Gremme
gremme at gmail.com
Thu Apr 30 13:12:55 CEST 2009
Hi Mauricio,
> Is there a way to update the type of an already existing child feature? What about to remove it and recreate a correct one?
there wasn't any, but I just added a set_type method to the C lib and
the python bindings ;-)
I didn't need one before...
> I am trying to correct the type for the wrongly labeled UTRs in the GFF files I am working with (I sent two sample GFF files yesterday in the thread "A series of questions regarding GenomeTools C and its Python interface") and since I don't see a way to modify (or have access to) a FeatureNode's type with something like FeatureNode.setType() I was instead trying to remove the child node (with fn.__del__) and recreating a new one in its place.
>
> Of the two choices, it might be cleaner just o update the type. The sample GFF contains some gene models for which the UTRs labels are reversed (5' should be 3' or viceversa).
>
> Please see my python function below where I was trying to take a pointer to the current child_feature, checking it and returning the same one if nothing needed updating or destroying it and recreating a new one. See line annotated with "****"
Your code didn't work, because the feature iterator gives you new
references during the traversal. I.e., fn.__del__() just deletes the
new reference but leaves the traversed feature intact. You would have
to modify the traversed feature (i.e., remove a child), but that isn't
available in the Python bindings yet. In the C library I have a method
which removes a leaf (i.e., a feature without any children), because
in this case it is clear what to do.
But in your case, just using set_type is the better solution anyway.
Gordon
More information about the gt-users
mailing list