blib/lib/Bio/Gonzales/Feat/IO/GFF3.pm

filter: Statementstmt 71.5% 141 / 197 Branchbran 59.0% 52 / 88 Conditioncond 25.0% 8 / 32 MC/DCmcdc 12.5% 2 / 16 Subroutinesub 85.1% 23 / 27 Podpod 50.0% 3 / 6 totaltotal 62.5% 229 / 366 CC 63 SCAR 35.5
CC
63
Cov
63%
_parse_header
94.1
next_feat_raw
90.0
_write_header
11.2
CRAP 34.9
« blib/lib/Bio/Gonzales/Project.pm ↑ Summary blib/lib/Bio/Gonzales/Seq/Util.pm »
1 package Bio::Gonzales::Feat::IO::GFF3;
2  
3 2 ▶use Mouse;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use 5.010;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use List::MoreUtils qw/zip/;
Subroutine BEGIN: called CC=1 SCAR=0.0
12 2 ▶use Bio::Gonzales::Feat;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 2 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 2 ▶use Scalar::Util qw/blessed/;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 2 ▶use Bio::Gonzales::Seq::Util qw/strand_convert/;
Subroutine BEGIN: called CC=1 SCAR=0.0
17  
18 2 extends 'Bio::Gonzales::Feat::IO::Base';
19  
20 2 our $VERSION = '0.062'; # VERSION
21  
22 2 our $FASTA_RE = qr/^\>/;
23 2 our $SEQ_REGION_RE = qr/^\#\#sequence-region\s+(\S+)\s+(\S+)\s+(\S+)\s*/;
24 2 our $ATTR_UNESCAPE_RE = qr/%([0-9A-Fa-f]{2})/;
25  
26 2 our @GFF_COLUMN_NAMES = qw/
27 seq_id
28 source
29 type
30 start
31 end
32 score
33 strand
34 phase
35 attributes
36 /;
37  
38 2 ▶has segments => ( is => 'rw', default => sub { [] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
39 2 has _wrote_sth_before => ( is => 'rw' );
40 2 ▶has pragmas => ( is => 'rw', default => sub { {} } );
Subroutine __ANON__: called CC=1 SCAR=0.0
41 2 has preprocess => ( is => 'rw' );
42 2 ▶has comments => ( is => 'rw', isa => 'ArrayRef', default => sub { [] } );
Subroutine __ANON__: called CC=1 SCAR=0.0
43 2 has no_header => ( is => 'rw' );
44 2 has escape_whitespace => ( is => 'rw' );
45 2 has quiet => ( is => 'rw' );
46  
47 sub BUILD {
48 2 ▶ my ($self) = @_;
Subroutine BUILD: called CC=2 SCAR=6.9
Pod documented
49  
50 2 ▶ $self->_parse_header if ( $self->mode eq '<' );
Branch: 1 branch
BranchTrueFalseTotal
if $self->mode eq "<" 1 1 2
51 }
52  
53 sub _parse_header {
54 1 ▶ my ($self) = @_;
Subroutine _parse_header: called CC=21 SCAR=45.4
55  
56 1 my $fhi = $self->_fhi;
57  
58 1 my $l;
59 1 ▶ while ( defined( $l = $fhi->() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($l = &$fhi())) 4 0 4
60 4 ▶ next if ( !$l || $l =~ /^\s*$/ );
Branch: 1 branch
BranchTrueFalseTotal
if not $l or $l =~ /^\s*$/ 0 4 4
Condition33%1/3
not $l or $l =~ /^\s*$/
l!l&&r!l&&!r
004
MC/DC0%0/2
not $l or $l =~ /^\s*$/
not $l $l =~ /^\s*$/
Truth table33%1/3
not(A) or B
A= not $lB= $l =~ /^\s*$/
ABresult
1X1
011
000
61  
62 4 ▶ if ( $l =~ /^##gff-version\s+(\d+)/ ) {
Branch: 10 branches
BranchTrueFalseTotal
if ($l =~ /^##gff-version\s+(\d+)/) { } 1 3 4
elsif ($l =~ /$Bio::Gonzales::Feat::IO::GFF3::SEQ_REGION_RE/) { } 1 2 3
elsif ($l =~ /^\#\#(feature-ontology)\s+(.*)$/) { } 0 2 2
elsif ($l =~ /^\#\#(attribute-ontology)\s+(.*)$/) { } 0 2 2
elsif ($l =~ /^\#\#(source-ontology)\s+(.*)$/) { } 0 2 2
elsif ($l =~ /^\#\#(species)\s+(.*)$/) { } 0 2 2
elsif ($l =~ /^\#\#(genome-build)\s+(.*)$/) { } 0 2 2
elsif ($l =~ /^(\#\#\#)/) { } 0 2 2
elsif ($l =~ /^(\#\#FASTA)/) { } 0 2 2
elsif ($l =~ /$Bio::Gonzales::Feat::IO::GFF3::FASTA_RE/) { } 0 2 2
63 1 ▶ confess "I need gff version 3" if ( $1 != 3 );
Branch: 1 branch
BranchTrueFalseTotal
if $1 != 3 0 1 1
64 # if no tag given, assume 3 by default
65 } elsif ( $l =~ /$SEQ_REGION_RE/ ) {
66 1 my ( $seqid, $start, $end ) = ( $1, $2, $3 );
67 1 push @{ $self->segments }, { id => $seqid, start => $start, end => $end };
68 } elsif ( $l =~ /^\#\#(feature-ontology)\s+(.*)$/ ) {
69 0 ▶ $self->pragmas->{$1} //= [];
Condition0%0/2
$self->pragmas->{$1} //= []
l!l
00
MC/DC0%0/1
$self->pragmas->{$1} //= []
$self->pragmas->{$1}
Truth table0%0/2
A
A= $self->pragmas->{$1}
Aresult
11
00
70 0 push @{ $self->pragmas->{$1} }, $2;
71 } elsif ( $l =~ /^\#\#(attribute-ontology)\s+(.*)$/ ) {
72 0 ▶ $self->pragmas->{$1} //= [];
Condition0%0/2
$self->pragmas->{$1} //= []
l!l
00
MC/DC0%0/1
$self->pragmas->{$1} //= []
$self->pragmas->{$1}
Truth table0%0/2
A
A= $self->pragmas->{$1}
Aresult
11
00
73 0 push @{ $self->pragmas->{$1} }, $2;
74 } elsif ( $l =~ /^\#\#(source-ontology)\s+(.*)$/ ) {
75 0 ▶ $self->pragmas->{$1} //= [];
Condition0%0/2
$self->pragmas->{$1} //= []
l!l
00
MC/DC0%0/1
$self->pragmas->{$1} //= []
$self->pragmas->{$1}
Truth table0%0/2
A
A= $self->pragmas->{$1}
Aresult
11
00
76 0 push @{ $self->pragmas->{$1} }, $2;
77 } elsif ( $l =~ /^\#\#(species)\s+(.*)$/ ) {
78 0 ▶ $self->pragmas->{$1} //= [];
Condition0%0/2
$self->pragmas->{$1} //= []
l!l
00
MC/DC0%0/1
$self->pragmas->{$1} //= []
$self->pragmas->{$1}
Truth table0%0/2
A
A= $self->pragmas->{$1}
Aresult
11
00
79 0 push @{ $self->pragmas->{$1} }, $2;
80 } elsif ( $l =~ /^\#\#(genome-build)\s+(.*)$/ ) {
81 0 ▶ $self->pragmas->{$1} //= [];
Condition0%0/2
$self->pragmas->{$1} //= []
l!l
00
MC/DC0%0/1
$self->pragmas->{$1} //= []
$self->pragmas->{$1}
Truth table0%0/2
A
A= $self->pragmas->{$1}
Aresult
11
00
82 0 push @{ $self->pragmas->{$1} }, $2;
83 } elsif ( $l =~ /^(\#\#\#)/ ) {
84 } elsif ( $l =~ /^(\#\#FASTA)/ ) {
85 } elsif ( $l =~ /$FASTA_RE/ ) {
86 0 $self->_parse_seq($l);
87 }
88  
89 #looks like the header is over!
90 4 ▶ last unless $l =~ /^\#/;
Branch: 1 branch
BranchTrueFalseTotal
unless $l =~ /^\#/ 1 3 4
91 }
92  
93 1 push @{ $self->_cached_records }, $l;
94  
95 1 return;
96 }
97  
98 sub _write_header {
99 1 ▶ my ($self) = @_;
Subroutine _write_header: called CC=7 SCAR=24.1
100  
101 1 ▶ $self->_wrote_sth_before(1) && return if ( $self->no_header );
Branch: 1 branch
BranchTrueFalseTotal
if $self->no_header 0 1 1
Condition20%1/5
$self->no_header && ($self->_wrote_sth_before(1) && (return))
!ll
100
$self->_wrote_sth_before(1) and return
!ll
00
MC/DC0%0/2
$self->no_header && ($self->_wrote_sth_before(1) && (return))
$self->no_header $self->_wrote_sth_before(1)
Truth table33%1/3
A && B
A= $self->no_headerB= $self->_wrote_sth_before(1)
ABresult
0X0
100
111
102 1 my $fh = $self->fh;
103 1 say $fh '##gff-version 3';
104  
105 1 ▶ while ( my ( $p, $entries ) = each %{ $self->pragmas } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = each %{$self->pragmas;}) 0 1 1
106 0 for my $e (@$entries) {
107 0 say $fh '##' . $p . " " . $e;
108 }
109 }
110  
111 1 for my $c ( @{ $self->comments } ) {
112 0 say $fh '#' . $c;
113 }
114  
115 1 for my $s ( @{ $self->segments } ) {
116 0 say $fh join ' ', '##sequence-region', @{$s}{qw/id start end/};
117 }
118  
119 1 $self->_wrote_sth_before(1);
120 }
121  
122 sub _parse_seq {
123 3 ▶ my ( $self, $faheader ) = @_;
Subroutine _parse_seq: called CC=4 SCAR=13.9
124  
125 3 my $fhi = $self->_fhi;
126  
127 # defined check not necessary
128 3 ▶ while ( my $l = $fhi->() ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $l = &$fhi()) 1265 1 1266
129 1265 ▶ if ( $l =~ /^\#/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ /^\#/) 0 1265 1265
130 0 last;
131 }
132 1265 ▶ if ( $l =~ /$FASTA_RE/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($l =~ /$Bio::Gonzales::Feat::IO::GFF3::FASTA_RE/) 2 1263 1265
133 2 push @{ $self->_cached_records }, $l;
134 2 last;
135 }
136 }
137 3 return;
138 }
139  
140 sub next_feat {
141 57 ▶ my ($self) = @_;
Subroutine next_feat: called CC=9 SCAR=22.0
Pod documented
142  
143 57 my $fhi = $self->_fhi;
144  
145 57 my $l;
146 57 ▶ while ( defined( $l = $fhi->() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($l = &$fhi())) 75 1 76
147 75 ▶ if ( $l =~ /$SEQ_REGION_RE/ ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($l =~ /$Bio::Gonzales::Feat::IO::GFF3::SEQ_REGION_RE/) { } 1 74 75
elsif ($l =~ /^\#\#\#/) { } 0 74 74
elsif ($l =~ /^\#/ or $l =~ /^\s*$/ or $l =~ m[^//]) { } 15 59 74
elsif ($l =~ /$Bio::Gonzales::Feat::IO::GFF3::FASTA_RE/) { } 3 56 59
148 1 my ( $seqid, $start, $end ) = ( $1, $2, $3 );
149 1 push @{ $self->segments }, { id => $seqid, start => $start, end => $end };
150 } elsif ( $l =~ /^\#\#\#/ ) {
151 0 next;
152 ▶ } elsif ( $l =~ /^\#/ || $l =~ /^\s*$/ || $l =~ m{^//} ) {
Condition83%5/6
$l =~ /^\#/ or $l =~ /^\s*$/ or $l =~ m[^//]
l!l&&r!l&&!r
15059
$l =~ /^\#/ or $l =~ /^\s*$/
l!l&&r!l&&!r
7859
MC/DC66%2/3
$l =~ /^\#/ or $l =~ /^\s*$/ or $l =~ m[^//]
$l =~ /^\#/ $l =~ /^\s*$/ $l =~ m[^//]
Truth table75%3/4
A or B or C
A= $l =~ /^\#/B= $l =~ /^\s*$/C= $l =~ m[^//]
ABCresult
1XX1
01X1
0011
0000
153 15 next;
154 } elsif ( $l =~ /$FASTA_RE/ ) {
155 3 $self->_parse_seq($l);
156 3 next;
157 } else {
158 56 last;
159 }
160 }
161 57 ▶ return unless $l;
Branch: 1 branch
BranchTrueFalseTotal
unless $l 1 56 57
162  
163 56 my $feat = $self->_parse_gff_line($l);
164  
165 56 return $feat;
166 }
167  
168 sub next_feat_raw {
169 0 ▶ my ($self) = @_;
Subroutine next_feat_raw: not called CC=9 SCAR=45.0
Pod undocumented
170  
171 0 my $fhi = $self->_fhi;
172  
173 0 my $l;
174 0 ▶ while ( defined( $l = $fhi->() ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined($l = &$fhi())) 0 0 0
175 0 ▶ if ( $l =~ /$SEQ_REGION_RE/ ) {
Branch: 4 branches
BranchTrueFalseTotal
if ($l =~ /$Bio::Gonzales::Feat::IO::GFF3::SEQ_REGION_RE/) { } 0 0 0
elsif ($l =~ /^\#\#\#/) { } 0 0 0
elsif ($l =~ /^\#/ or $l =~ /^\s*$/ or $l =~ m[^//]) { } 0 0 0
elsif ($l =~ /$Bio::Gonzales::Feat::IO::GFF3::FASTA_RE/) { } 0 0 0
176 0 my ( $seqid, $start, $end ) = ( $1, $2, $3 );
177 0 push @{ $self->segments }, { id => $seqid, start => $start, end => $end };
178 } elsif ( $l =~ /^\#\#\#/ ) {
179 0 next;
180 ▶ } elsif ( $l =~ /^\#/ || $l =~ /^\s*$/ || $l =~ m{^//} ) {
Condition0%0/6
$l =~ /^\#/ or $l =~ /^\s*$/ or $l =~ m[^//]
l!l&&r!l&&!r
000
$l =~ /^\#/ or $l =~ /^\s*$/
l!l&&r!l&&!r
000
MC/DC0%0/3
$l =~ /^\#/ or $l =~ /^\s*$/ or $l =~ m[^//]
$l =~ /^\#/ $l =~ /^\s*$/ $l =~ m[^//]
Truth table0%0/4
A or B or C
A= $l =~ /^\#/B= $l =~ /^\s*$/C= $l =~ m[^//]
ABCresult
1XX1
01X1
0011
0000
181 0 next;
182 } elsif ( $l =~ /$FASTA_RE/ ) {
183 0 $self->_parse_seq($l);
184 0 next;
185 } else {
186 0 last;
187 }
188 }
189 0 ▶ return unless $l;
Branch: 1 branch
BranchTrueFalseTotal
unless $l 0 0 0
190  
191 0 return $l;
192 }
193  
194 sub write_feat {
195 141 ▶ my ( $self, @feats ) = @_;
Subroutine write_feat: called CC=4 SCAR=14.1
Pod documented
196 141 my $fh = $self->fh;
197  
198 141 ▶ $self->_write_header
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_wrote_sth_before 0 141 141
199 unless ( $self->_wrote_sth_before );
200  
201 141 for my $f (@feats) {
202 141 ▶ confess "feature is no a Bio::Gonzales::Feat: " . Dumper($f)
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($f) eq "Bio::Gonzales::Feat" 0 141 141
203 unless ( blessed $f eq 'Bio::Gonzales::Feat' );
204 141 print $fh $f->to_gff3( $self->escape_whitespace );
205 }
206  
207 141 return $self;
208 }
209  
210 sub write_comment {
211 3 ▶ my ( $self, $text ) = @_;
Subroutine write_comment: called CC=2 SCAR=6.9
Pod undocumented
212  
213 3 my $fh = $self->fh;
214  
215 3 ▶ $self->_write_header
Branch: 1 branch
BranchTrueFalseTotal
unless $self->_wrote_sth_before 1 2 3
216 unless ( $self->_wrote_sth_before );
217  
218 3 print $fh '#' . $text . "\n";
219  
220 3 return $self;
221 }
222  
223 ▶sub _from_gff3_string {
Subroutine _from_gff3_string: not called CC=1 SCAR=0.0
224 }
225  
226 sub _split_attributes {
227 56 ▶ my ( $self, $attributes ) = @_;
Subroutine _split_attributes: called CC=5 SCAR=16.9
228  
229 56 my %attrs;
230 56 my @groups = split( /\s*;\s*/, $attributes );
231  
232 56 for my $group (@groups) {
233 111 my ( $tag, $value ) = split /=/, $group;
234  
235 111 $tag =~ s/$ATTR_UNESCAPE_RE/chr(hex($1))/eg;
236 111 ▶ if ( defined($value) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) { } 111 0 111
237 111 my @values = map { s/$ATTR_UNESCAPE_RE/chr(hex($1))/eg; $_ } split /,/, $value;
238 111 ▶ $attrs{$tag} //= [];
Condition50%1/2
$attrs{$tag} //= []
l!l
0111
MC/DC0%0/1
$attrs{$tag} //= []
$attrs{$tag}
Truth table50%1/2
A
A= $attrs{$tag}
Aresult
11
00
239 111 push @{ $attrs{$tag} }, @values;
240 } else {
241 0 ▶ carp "WARNING: Problems to extract attribute, found: $tag" unless ( $self->quiet );
Branch: 1 branch
BranchTrueFalseTotal
unless $self->quiet 0 0 0
242 }
243 }
244 56 return \%attrs;
245 }
246  
247 sub _parse_gff_line {
248 56 ▶ my ( $self, $l ) = @_;
Subroutine _parse_gff_line: called CC=7 SCAR=19.6
249  
250 56 my @d = split( /\t/, $l );
251  
252 56 ▶ confess "error in gff:\n$l\n"
Branch: 1 branch
BranchTrueFalseTotal
unless @d == 9 0 56 56
253 unless ( @d == 9 );
254  
255 56 ▶ if ( ref $self->preprocess eq 'CODE' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $self->preprocess eq "CODE") 0 56 56
256 0 @d = $self->preprocess->(@d);
257 }
258  
259 56 $d[8] = $self->_split_attributes( $d[8] );
260  
261 56 ▶ if ( $d[6] eq '-' ) { $d[6] = -1; }
Branch: 2 branches
BranchTrueFalseTotal
if ($d[6] eq '-') { } 8 48 56
elsif ($d[6] eq '+') { } 38 10 48
262 38 elsif ( $d[6] eq '+' ) { $d[6] = 1; }
263 10 else { $d[6] = 0; }
264  
265 56 my %feat;
266 56 ▶ for ( my $i = 0; $i < @GFF_COLUMN_NAMES; $i++ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @Bio::Gonzales::Feat::IO::GFF3::GFF_COLUMN_NAMES) 504 56 560
267 504 ▶ $feat{ $GFF_COLUMN_NAMES[$i] } = $d[$i] unless ( $d[$i] eq '.' );
Branch: 1 branch
BranchTrueFalseTotal
unless $d[$i] eq "." 406 98 504
268 }
269  
270 56 return Bio::Gonzales::Feat->new( \%feat );
271 }
272  
273 sub write_collected_feats {
274 0 ▶ my ( $self, $sub ) = @_;
Subroutine write_collected_feats: not called CC=2 SCAR=17.9
Pod undocumented
275 0 my $fh = $self->fh;
276  
277 0 $self->_connect_feats;
278 0 my $parents = $self->_find_parent_feats;
279 0 my $escape_whitespace = $self->escape_whitespace;
280  
281 my $gsub = sub {
282 0 ▶ my ( $f, $id ) = @_;
Subroutine __ANON__: not called CC=2 SCAR=17.9
283 0 ▶ $sub->( $f, $id ) if ($sub);
Branch: 1 branch
BranchTrueFalseTotal
if $sub 0 0 0
284 0 $f->sort_subfeats;
285 0 print $fh $f->to_gff3($escape_whitespace);
286 0 return;
287 0 };
288  
289 0 for my $p (@$parents) {
290 0 $gsub->($p);
291 0 $p->recurse_subfeats($gsub);
292 }
293 0 return;
294  
295 }
296  
297 2 1;
298  
299 __END__
300  
301 =head1 NAME
302  
303 Bio::Gonzales::Feat::IO::GFF3 - read and write gff files
304  
305 =head1 SYNOPSIS
306  
307 use Bio::Gonzales::Feat::IO::GFF3;
308  
309 my $output = Bio::Gonzales::Feat::IO::GFF3->new( file => 'a.gff', mode => '>', escape_whitespace => 1 );
310 my $gffin = Bio::Gonzales::Feat::IO::GFF3->new( file => 'a.gff' );
311  
312 # gzipped files can be read directly.
313 my $gffin = Bio::Gonzales::Feat::IO::GFF3->new( file => 'a.gff.gz' );
314  
315 my $gffin = Bio::Gonzales::Feat::IO::GFF3->new('a.gff');
316  
317 while ( my $feat = $gffin->next_feat ) {
318 # $feat is a Bio::Gonzales::Feat
319 next if ( $feat->type ne 'mRNA' );
320  
321 say STDERR $feat->id . " - " . $feat->parent_id;
322 }
323  
324 $gffin->close;
325  
326  
327 =head1 DESCRIPTION
328  
329 =head1 OPTIONS
330  
331 =over 4
332  
333 =item B<< mode => $mode >>
334  
335 Bio::Gonzales::Feat::IO::GFF3 supports 3 different modes,
336  
337 Bio::Gonzales::Feat::IO::GFF3->new(mode => '>', ...); #output
338 Bio::Gonzales::Feat::IO::GFF3->new(mode => '<', ...); #input, DEFAULT
339 Bio::Gonzales::Feat::IO::GFF3->new(mode => '>>', ...); #append
340  
341 all modes also work with gzipped files (ending on '.gz').
342  
343 =item B<< fh => $fh >>
344  
345 Bio::Gonzales::Feat::IO::GFF3 uses $fh to read or write data.
346  
347 open my $fh, '<', 'file.gff3' or confess "Can't open filehandle: $!";
348 my $gff = Bio::Gonzales::Feat::IO::GFF3->new(fh => $fh, ...);
349  
350 # ... do something ...
351  
352 $gff->close;
353 close $fh;
354  
355 =item B<< file => $file >>
356  
357 read from or write to the file C<$file>
358  
359 =item B<< escape_whitespace => 1 >>
360  
361 Usually, only whitespaces in the C<Target> attribute are escaped. If this
362 feature is turned on, whitespace in all attribute values will be escaped.
363  
364 =item B<< record_filter => sub { ... } >>
365  
366 Before reading in the GFF3 information, filter the raw line content according
367 to the supplied function. This functionality is handy for big gff3 files where
368 only a part of the output should be parsed.
369  
370 Example:
371  
372 my $sub = sub {
373 my $line = shift;
374  
375 return $line =~ /\tmRNA\t/;
376 };
377 my $gff = Bio::Gonzales::Feat::IO::GFF3->new( file => '...', mode => '<', record_filter => $sub );
378  
379 # ... only lines with the type 'mRNA' will be parsed ...
380  
381 $gff->close;
382  
383  
384 =back
385  
386 =head1 METHODS
387  
388 =over 4
389  
390 =item B<< $gffio->write_feat($feat) >>
391  
392 Write the feature to the output. Do not forget to call C<$gffio->close> at the
393 end of the processing, otherwise you probably end up writing only half of the
394 features.
395  
396 =item B<< my $feat = $gffio->next_feat() >>
397  
398 Retrieve the next feature, if in reading mode.
399  
400 =item B<< $gffio->segments >>
401  
402 =item B<< $gffio->pragmas >>
403  
404 =item B<< $gffio->preprocess(\&process) >>
405  
406 Change the gff input before the feature object gets instantiated. Arguments of the C<&process> sub are the nine columns of the gff file split into an array.
407  
408 Example sub:
409 sub process {
410 my @cols = @_;
411  
412 $cols[1] = "createdbyme";
413 return @cols;
414 }
415  
416 =item B<< $gffio->comments >>
417  
418 =back
419  
420 =head1 SEE ALSO
421  
422 =head1 AUTHOR
423  
424 jw bargsten, C<< <joachim.bargsten at wur.nl> >>
425  
426 =cut
« blib/lib/Bio/Gonzales/Project.pm ↑ Summary blib/lib/Bio/Gonzales/Seq/Util.pm »