File Coverage

blib/lib/App/RecordStream/Operation/togff3.pm
Criterion Covered Total %
statement 23 27 85.1
branch 2 2 100.0
condition n/a
subroutine 6 7 85.7
pod 0 3 0.0
total 31 39 79.4


line stmt bran cond sub pod time code
1 1     1   281 use strict;
  1         2  
  1         26  
2 1     1   5 use warnings;
  1         2  
  1         33  
3              
4             package App::RecordStream::Operation::togff3;
5 1     1   5 use base qw(App::RecordStream::Operation);
  1         2  
  1         60  
6              
7 1     1   6 use Bio::GFF3::LowLevel qw< gff3_format_feature >;
  1         3  
  1         167  
8              
9             sub init {
10 1     1 0 19382 my $self = shift;
11 1         3 my $args = shift;
12 1         2 my $options = {};
13 1         7 $self->parse_options($args, $options); # Ensures we pick up the automatic options
14             }
15              
16             sub accept_record {
17 11     11 0 1368 my $self = shift;
18 11         18 my $record = shift;
19              
20 11         23 my $feature = gff3_format_feature($record);
21              
22             $self->push_line("##gff-version 3")
23 11 100       5561 unless $self->{HEADER_EMITTED}++;
24              
25 11         43 chomp $feature;
26 11         29 $self->push_line($feature);
27              
28 11         128 return 1;
29             }
30              
31             sub usage {
32 0     0 0   my $self = shift;
33 0           my $options = [];
34 0           my $args_string = $self->options_string($options);
35              
36 0           return <
37             Usage: recs togff3 []
38             __FORMAT_TEXT__
39             Each input record is formatted as a GFF3 (General Feature Format version 3)
40             line and output to stdout.
41              
42             The input records should contain the following fields:
43             __FORMAT_TEXT__
44              
45             seq_id source type start end score strand phase attributes
46              
47             __FORMAT_TEXT__
48             These are the same fields obtained when using the corresponding "fromgff3"
49             command.
50             __FORMAT_TEXT__
51              
52             Refer to the GFF3 spec for field details:
53             https://github.com/The-Sequence-Ontology/Specifications/blob/master/gff3.md
54              
55             Arguments:
56             $args_string
57              
58             Examples:
59             Parse GFF3 and filter to just mRNA features, writing back out GFF3:
60             recs fromgff3 hg38.gff | recs grep '{{type}} eq "mRNA"' | recs togff3
61              
62             USAGE
63             }
64              
65             1;