gffutils.interface.FeatureDB.interfeatures

FeatureDB.interfeatures(features, new_featuretype=None, merge_attributes=True, numeric_sort=False, dialect=None, attribute_func=None, update_attributes=None)[source]

Construct new features representing the space between features.

For example, if features is a list of exons, then this method will return the introns. If features is a list of genes, then this method will return the intergenic regions.

Providing N features will return N - 1 new features.

This method purposefully does not do any merging or sorting of coordinates. So nested or overlapping features may not behave as you might expect. You may want to use FeatureDB.merge() first, and when selecting features use the order_by kwarg, e.g., db.features_of_type('gene', order_by=('seqid', 'start')).

Parameters:
  • features (iterable of feature.Feature instances) – Sorted, merged iterable

  • new_featuretype (string or None) – The new features will all be of this type, or, if None (default) then the featuretypes will be constructed from the neighboring features, e.g., inter_exon_exon.

  • merge_attributes (bool) – If True, new features’ attributes will be a merge of the neighboring features’ attributes. This is useful if you have provided a list of exons; the introns will then retain the transcript and/or gene parents as a single item. Otherwise, if False, the attribute will be a comma-separated list of values, potentially listing the same gene ID twice.

  • numeric_sort (bool) – If True, then merged attributes that can be cast to float will be sorted by their numeric values (but will still be returned as string). This is useful, for example, when creating introns between exons and the exons have exon_number attributes as an integer. Using numeric_sort=True will ensure that the returned exons have merged exon_number attribute of [‘9’, ‘10’] (numerically sorted) rather than [‘10’, ‘9’] (alphabetically sorted).

  • attribute_func (callable or None) – If None, then nothing special is done to the attributes. If callable, then the callable accepts two attribute dictionaries and returns a single attribute dictionary. If merge_attributes is True, then attribute_func is called before merge_attributes. This could be useful for manually managing IDs for the new features.

  • update_attributes (dict) – After attributes have been modified and merged, this dictionary can be used to replace parts of the attributes dictionary.

Return type:

A generator that yields Feature objects