Bio::ViennaNGS::FeatureIO - Versatile I/O interface for Bio::ViennaNGS feature annotation classes


  use Bio::ViennaNGS::FeatureIO;

  # initialize a FeatureIO object from a Bed6 file
  my $data_bed = Bio::ViennaNGS::FeatureIO->new(
                                               file => "file.bed6",
                                               filetype => 'Bed6',
                                               instanceOf => 'Feature',
                                               base => 0,

  # initialize a FeatureIO object from a Bed12 file
  my $data_bed = Bio::ViennaNGS::FeatureIO->new(
                                               file => "file.bed12",
                                               filetype => 'Bed12',
                                               instanceOf => 'Bed',
                                               base => 0,

  # initialize a FeatureIO object from a bedGraph file
  my $obj = Bio::ViennaNGS::FeatureIO->new(file       => "",
                                           filetype   => "BedGraph",
                                           instanceOf => "BedGraph",
                                           base => 0,


This module provides an object-oriented interface for easy input/output operations on common feature annotation file formats. It is - by design - a very generic module that stores all annotation data within the $self->data ArrayRef. $self->filetype specifies the file type to be processed. Currently parsing of Bed6, Bed12 and bedGraph files is supported. $self->instanceOf determines the object type of elements held in the $self->data ArrayRef(s).

In case of parsing Bed6 data, $self->instanceOf can either be Feature, FeatureChain or FeatureChainBlock. While the first causes $self->data to hold an ArrayRef to individual Bio::ViennaNGS::Feature objects, the second triggers creation of individual Bio::ViennaNGS::FeatureChain objects (each containing exactly one feature interval, corresponding to individual Bed6 entries). A FeatureChainBlock value to the $self->instanceOf causes $self->data to hold an ArrayRef to a combined Bio::ViennaNGS::FeatureChain containing an entire block of features. In the context of Bed annotation this corresponds to a single Bed12 line (e.g. gene/transcript) that contains all individual Bed6 features (e.g. exons). Evidently, this only makes sense if all Bed6 features originate from the same chromosome and strand.

In case of parsing Bed12 data, currently only Bed is supported for $self->instanceOf, causing $self->data to hold an ArrayRef to Bio::ViennaNGS::Bed (aka Bed12) features. This will be adjusted to Bio::ViennaNGS::FeatureChain in the future.

In case of pasring bedGraph data, $self->instanceOf is ignored and $self->data holds an ArrayRef to individual Bio::ViennaNGS::BedGraph objects.

Bio::ViennaNGS::FeatureIO implements the Bio::ViennaNGS::FeatureBase role, i.e. it is aware of 0-based (default) or 1-based features (aka BED intervals).



These methods are used for object construction and should not be called directly.




Michael T. Wolfinger <>


Copyright (C) 2014-2018 Michael T. Wolfinger <>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.10.0 or, at your option, any later version of Perl 5 you may have available.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.