From: jprocter Date: Thu, 8 Jun 2006 13:56:37 +0000 (+0000) Subject: simplest conversion of gff to jalview annotation format files. X-Git-Tag: Release_2_1~376 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=08ae2201710b9a5ef0732129efc4a4afd6c7d09a;p=jalview.git simplest conversion of gff to jalview annotation format files. --- diff --git a/utils/gff2annot.pl b/utils/gff2annot.pl new file mode 100755 index 0000000..f144df1 --- /dev/null +++ b/utils/gff2annot.pl @@ -0,0 +1,35 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +my %annotLines; + +my @fields; +while (<>) { + my @fields = split /\s+/, $_; + if (scalar @fields) { + (defined $annotLines{$fields[1]}) or $annotLines{$fields[1]}=[]; + my $line = [$fields[2],$fields[0], "ID_NOT_SPECIFIED", $fields[3], $fields[4], $fields[2]]; + my $attribs = {}; + if (scalar @fields>5) { + $attribs->{"gff:score"}=$fields[5]; + (scalar @fields>6) and $attribs->{"gff:strand"}=$fields[6]; + (scalar @fields>7) and $attribs->{"gff:frame"}=$fields[7]; + if (scalar @fields>8) { + for (my $i=7; ($i+1)<(scalar @fields); $i+=2) { + $attribs->{"gff:".$fields[$i]} = $fields[$i+1]; + } + } + } + push @{$annotLines{$fields[1]}}, [$line, $attribs]; + } +} + +foreach my $labels (keys %annotLines) { + print "startgroup\t".$labels."\n"; + foreach my $annot (@{$annotLines{$labels}}) { + print "".(join "\t",@{$annot->[0]})."\n"; + } + print "endgroup\t".$labels."\n"; +}