gffutils.interface.FeatureDB.add_relation

FeatureDB.add_relation(parent, child, level, parent_func=None, child_func=None)[source]

Manually add relations to the database.

Parameters:
  • parent (str or Feature instance) – Parent feature to add.

  • child (str or Feature instance) – Child feature to add

  • level (int) – Level of the relation. For example, if parent is a gene and child is an mRNA, then you might want level to be 1. But if child is an exon, then level would be 2.

  • parent_func (callable) –

    These optional functions control how attributes are updated in the database. They both have the signature func(parent, child) and must return a [possibly modified] Feature instance. For example, we could add the child’s database id as the “child” attribute in the parent:

    def parent_func(parent, child):
        parent.attributes['child'] = child.id
    

    and add the parent’s “gene_id” as the child’s “Parent” attribute:

    def child_func(parent, child):
        child.attributes['Parent'] = parent['gene_id']
    

  • child_func (callable) –

    These optional functions control how attributes are updated in the database. They both have the signature func(parent, child) and must return a [possibly modified] Feature instance. For example, we could add the child’s database id as the “child” attribute in the parent:

    def parent_func(parent, child):
        parent.attributes['child'] = child.id
    

    and add the parent’s “gene_id” as the child’s “Parent” attribute:

    def child_func(parent, child):
        child.attributes['Parent'] = parent['gene_id']
    

Return type:

FeatureDB object with new relations added.