#!/usr/local/bin/perl # Time-stamp: <2005-05-04 11:03:30 kasper> use warnings; use strict; use Getopt::Long; use constant USAGE =>< file.table gff2table.pl file.gff file.table AUTHOR: Kasper Munch COPYRIGHT: This program is free software. You may copy and redistribute it under the same terms as Perl itself. END my $help = 0; GetOptions( "help" => \$help, ) or die USAGE; $help and die USAGE; @ARGV = ('-') unless @ARGV; my $input = shift @ARGV; open my $in, "$input" or die "$input: $!\n"; @ARGV = ('>&STDOUT') unless @ARGV; my $output = shift @ARGV; open my $out, "$output" or die "$output: $!\n"; while (<$in>) { $_ =~ /^((\S+\t){7}\S+)(.*)$/; print $out $1; my @att = split / ; /, $3; for (my $i = 0; $i < @att; $i++) { $att[$i] =~ s/^\s*\S+\s+/\t/; $att[$i] =~ s/\s+/\t/g if $i == 0; print $out "$att[$i]"; } print $out "\n"; } =head1 SYNOPSIS: gff2table.pl [OPTIONS] [infile] [outfile] =head1 DESCRIPTION: This script makes a tab seperated table out of a gff line with lots of messy stuff in the last column. =head1 OPTIONS: =over 4 =item --help Prints this help. =back =head1 EXAMPLES: cat file.gff | gff2table.pl > file.table gff2table.pl file.gff file.table =head1 AUTHOR: Kasper Munch =head1 COPYRIGHT: This program is free software. You may copy and redistribute it under the same terms as Perl itself. =cut