4 # Copyright (C) 2007-2008 Martin A. Hansen.
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; either version 2
9 # of the License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 # http://www.gnu.org/copyleft/gpl.html
23 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> DESCRIPTION <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
26 # Routines for manipulation 'Generic Feature Format' - GFF.
29 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
36 use vars qw( @ISA @EXPORT_OK );
40 @ISA = qw( Exporter );
43 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
48 # Martin A. Hansen, February 2008.
50 # Reads a single entry from a filehandle to a GFF file.
52 my ( $fh, # file handle
57 my ( $line, @fields, %entry, $q_beg, $q_end, @atts, $att, $key, $val );
59 while ( $line = <$fh> )
63 @fields = split "\t", $line;
67 $q_beg = $fields[ 3 ] - 1;
68 $q_end = $fields[ 4 ] - 1;
70 ( $q_beg, $q_end ) = ( $q_end, $q_beg ) if $q_beg > $q_end;
74 SOURCE => $fields[ 1 ],
78 SCORE => $fields[ 5 ],
79 STRAND => $fields[ 6 ],
80 PHASE => $fields[ 7 ],
84 @atts = split ";", $fields[ 8 ];
86 foreach $att ( @atts )
88 ( $key, $val ) = split "=", $att;
90 $entry{ "ATT_" . uc $key } = $val;
93 return wantarray ? %entry : \%entry;
101 # Martin A. Hansen, February 2008.
103 # Reads GFF file and returns a list of entries.
105 my ( $path, # full path to GFF file.
110 my ( $fh, $entry, @entries );
112 $fh = Maasha::Common::read_open( $path );
114 while ( $entry = get_entry( $fh ) ) {
115 push @entries, $entry;
120 return wantarray ? @entries : \@entries;
138 # >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<