| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 4 | ▶ | next if ( !$l || $l =~ /^\s*$/ ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
not $l or $l =~ /^\s*$/
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*$/
| |||||||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 4 | ▶ | if ( $l =~ /^##gff-version\s+(\d+)/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 10 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 1 | ▶ | confess "I need gff version 3" if ( $1 != 3 ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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} //= []
MC/DC0%0/1
$self->pragmas->{$1} //= []
$self->pragmas->{$1}
Truth table0%0/2
A
A= $self->pragmas->{$1}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 0 | push @{ $self->pragmas->{$1} }, $2; | |||||||||||||||||||||||||||||||||||||||||||||
| 71 | } elsif ( $l =~ /^\#\#(attribute-ontology)\s+(.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | ▶ | $self->pragmas->{$1} //= []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->pragmas->{$1} //= []
MC/DC0%0/1
$self->pragmas->{$1} //= []
$self->pragmas->{$1}
Truth table0%0/2
A
A= $self->pragmas->{$1}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | push @{ $self->pragmas->{$1} }, $2; | |||||||||||||||||||||||||||||||||||||||||||||
| 74 | } elsif ( $l =~ /^\#\#(source-ontology)\s+(.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 0 | ▶ | $self->pragmas->{$1} //= []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->pragmas->{$1} //= []
MC/DC0%0/1
$self->pragmas->{$1} //= []
$self->pragmas->{$1}
Truth table0%0/2
A
A= $self->pragmas->{$1}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 76 | 0 | push @{ $self->pragmas->{$1} }, $2; | |||||||||||||||||||||||||||||||||||||||||||||
| 77 | } elsif ( $l =~ /^\#\#(species)\s+(.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 0 | ▶ | $self->pragmas->{$1} //= []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->pragmas->{$1} //= []
MC/DC0%0/1
$self->pragmas->{$1} //= []
$self->pragmas->{$1}
Truth table0%0/2
A
A= $self->pragmas->{$1}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | push @{ $self->pragmas->{$1} }, $2; | |||||||||||||||||||||||||||||||||||||||||||||
| 80 | } elsif ( $l =~ /^\#\#(genome-build)\s+(.*)$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | ▶ | $self->pragmas->{$1} //= []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$self->pragmas->{$1} //= []
MC/DC0%0/1
$self->pragmas->{$1} //= []
$self->pragmas->{$1}
Truth table0%0/2
A
A= $self->pragmas->{$1}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
Condition20%1/5
$self->no_header && ($self->_wrote_sth_before(1) && (return))
$self->_wrote_sth_before(1) and return
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)
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 129 | 1265 | ▶ | if ( $l =~ /^\#/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 1265 | ▶ | if ( $l =~ /$FASTA_RE/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 75 | ▶ | if ( $l =~ /$SEQ_REGION_RE/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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 =~ /^\#/ or $l =~ /^\s*$/
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[^//]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | ▶ | if ( $l =~ /$SEQ_REGION_RE/ ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 4 branches
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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 =~ /^\#/ or $l =~ /^\s*$/
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[^//]
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 237 | 111 | my @values = map { s/$ATTR_UNESCAPE_RE/chr(hex($1))/eg; $_ } split /,/, $value; | |||||||||||||||||||||||||||||||||||||||||||||
| 238 | 111 | ▶ | $attrs{$tag} //= []; | ||||||||||||||||||||||||||||||||||||||||||||
|
Condition50%1/2
$attrs{$tag} //= []
MC/DC0%0/1
$attrs{$tag} //= []
$attrs{$tag}
Truth table50%1/2
A
A= $attrs{$tag}
| |||||||||||||||||||||||||||||||||||||||||||||||
| 239 | 111 | push @{ $attrs{$tag} }, @values; | |||||||||||||||||||||||||||||||||||||||||||||
| 240 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | carp "WARNING: Problems to extract attribute, found: $tag" unless ( $self->quiet ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 253 | unless ( @d == 9 ); | ||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 56 | ▶ | if ( ref $self->preprocess eq 'CODE' ) { | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 504 | ▶ | $feat{ $GFF_COLUMN_NAMES[$i] } = $d[$i] unless ( $d[$i] eq '.' ); | ||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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
| |||||||||||||||||||||||||||||||||||||||||||||||
| 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 | ||||||||||||||||||||||||||||||||||||||||||||||