File Coverage

blib/lib/App/RecordStream/Operation/fromgff3.pm
Criterion Covered Total %
statement 22 26 84.6
branch 2 2 100.0
condition n/a
subroutine 6 7 85.7
pod 0 3 0.0
total 30 38 78.9


line stmt bran cond sub pod time code
1 1     1   133198 use strict;
  1         2  
  1         25  
2 1     1   5 use warnings;
  1         2  
  1         31  
3              
4             package App::RecordStream::Operation::fromgff3;
5 1     1   5 use base qw(App::RecordStream::Operation);
  1         2  
  1         58  
6              
7 1     1   383 use Bio::GFF3::LowLevel qw< gff3_parse_feature >;
  1         2537  
  1         257  
8              
9             sub init {
10 1     1 0 481 my $this = shift;
11 1         2 my $args = shift;
12 1         2 my $options = {};
13 1         7 $this->parse_options($args, $options); # Ensures we pick up the automatic options
14             }
15              
16             sub accept_line {
17 20     20 0 1139 my $this = shift;
18 20         35 my $line = shift;
19              
20             # Skip headers, comments, and empty lines
21 20 100       227 return 1 if $line =~ /^#|^$/;
22              
23 11         30 my $feature = gff3_parse_feature($line);
24              
25 11         1257 $this->push_record( App::RecordStream::Record->new($feature) );
26 11         245 return 1;
27             }
28              
29             sub usage {
30 0     0 0   my $this = shift;
31 0           my $options = [];
32 0           my $args_string = $this->options_string($options);
33              
34 0           return <
35             Usage: recs fromgff3 []
36             __FORMAT_TEXT__
37             Each line of input (or lines of ) is parsed as a GFF3 (General
38             Feature Format version 3) formatted record to produce a recs output record.
39              
40             The output records will contain the following fields:
41             __FORMAT_TEXT__
42              
43             seq_id source type start end score strand phase attributes
44              
45             __FORMAT_TEXT__
46             Additional feature attributes are parsed into the "attributes" key, which is a
47             hash keyed by the attribute name. The values are arrays.
48             __FORMAT_TEXT__
49              
50             Refer to the GFF3 spec for field details:
51             https://github.com/The-Sequence-Ontology/Specifications/blob/master/gff3.md
52              
53             Arguments:
54             $args_string
55              
56             Examples:
57             Parse GFF3 and filter to just mRNA features:
58             recs fromgff3 hg38.gff | recs grep '{{type}} eq "mRNA"'
59              
60             USAGE
61             }
62              
63             1;