2 #*******************************************************************************
3 # Jalview - A Sequence Alignment Editor and Viewer (Version 2.8)
4 # Copyright (C) 2012 J Procter, AM Waterhouse, LM Lui, J Engelhardt, G Barton, M Clamp, S Searle
6 # This file is part of Jalview.
8 # Jalview is free software: you can redistribute it and/or
9 # modify it under the terms of the GNU General Public License
10 # as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
12 # Jalview is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty
14 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 # PURPOSE. See the GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
18 #*******************************************************************************
28 my @fields = split /\s+/, $_;
30 (defined $annotLines{$fields[1]}) or $annotLines{$fields[1]}=[];
31 # this is the tab-separated set of fields forming a jalview annotation line
32 # we only use sequence IDs, not numbers
33 my $line = [$fields[2],$fields[0],"-1", $fields[3], $fields[4], $fields[2]];
34 $featureids{$fields[2]}="FF0000"; # red is the colour.
36 if (scalar @fields>5) {
37 $attribs->{"gff:score"}=$fields[5];
38 (scalar @fields>6) and $attribs->{"gff:strand"}=$fields[6];
39 (scalar @fields>7) and $attribs->{"gff:frame"}=$fields[7];
40 if (scalar @fields>8) {
41 for (my $i=7; ($i+1)<(scalar @fields); $i+=2) {
42 $attribs->{"gff:".$fields[$i]} = $fields[$i+1];
46 push @{$annotLines{$fields[1]}}, [$line, $attribs];
49 foreach my $labels (keys %featureids) {
50 print "$labels\t".$featureids{$labels}."\n";
52 foreach my $labels (keys %annotLines) {
53 print "STARTGROUP\t".$labels."\n";
54 foreach my $annot (@{$annotLines{$labels}}) {
55 # bare minimum is written - no attributes/links yet.
56 print "".(join "\t",@{$annot->[0]})."\n";
58 print "ENDGROUP\t".$labels."\n";
70 gff2annot.pl [one or more files containing gff annotation]
72 Generates a nominally usable Jalview Annotation file on B<STDOUT> from arbitrary GFF annotation lines.
76 This script will generate a jalview features file on standard out, from a set of GFF annotation lines input from STDIN and/or any provided filenames.
78 For a series of GFF annotation lines looking like :
80 E<lt>seqIdE<gt> E<lt>sourceE<gt> E<lt>nameE<gt> E<lt>startE<gt> E<lt>endE<gt> [E<lt>scoreE<gt> E<lt>strandE<gt> E<lt>frameE<gt> [E<lt>AttributeE<gt> E<lt>Attribute-Value<gt>]]
82 The script will generate a seuqence features file on B<STDOUT> where annotation with a particular B<source> string will be grouped together under that name.
86 Passing some GFF annotation through STDIN:
89 Seq1 blastx significant_hsp 1 5 0.9 + 1 link http://mylink/
91 Seq1 blasty significant_hsp 15 25 0.9 + 1 link http://mylink/
92 Seq1 blastz significant_hsp 32 43 0.9 + 1 link http://mylink/
93 Seq2 blastx significant_hsp 1 5 0.9 + 1 link http://mylink/
94 Seq2 blasty significant_hsp 1 5 0.9 + 1 link http://mylink/
95 Seq2 blastz significant_hsp 1 5 0.9
96 Seq3 blastx significant_hsp 50 70
101 significant_hsp FF0000
103 significant_hsp Seq1 -1 15 25 significant_hsp
104 significant_hsp Seq2 -1 1 5 significant_hsp
107 significant_hsp Seq1 -1 1 5 significant_hsp
108 significant_hsp Seq2 -1 1 5 significant_hsp
109 significant_hsp Seq3 -1 50 70 significant_hsp
112 significant_hsp Seq1 -1 32 43 significant_hsp
113 significant_hsp Seq2 -1 1 5 significant_hsp