1 #*******************************************************************************
2 # Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
3 # Copyright (C) 2011 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
5 # This file is part of Jalview.
7 # Jalview is free software: you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License
9 # as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
11 # Jalview is distributed in the hope that it will be useful, but
12 # WITHOUT ANY WARRANTY; without even the implied warranty
13 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 # PURPOSE. See the GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
17 #*******************************************************************************
19 # Jalview - A Sequence Alignment Editor and Viewer (Version 2.7)
20 # Copyright (C) 2011 J Procter, AM Waterhouse, G Barton, M Clamp, S Searle
22 # This file is part of Jalview.
24 # Jalview is free software: you can redistribute it and/or
25 # modify it under the terms of the GNU General Public License
26 # as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
28 # Jalview is distributed in the hope that it will be useful, but
29 # WITHOUT ANY WARRANTY; without even the implied warranty
30 # of MERCHANTABILITY or FITNESS FOR A PARTICULAR
31 # PURPOSE. See the GNU General Public License for more details.
33 # You should have received a copy of the GNU General Public License along with Jalview. If not, see <http://www.gnu.org/licenses/>.
44 my @fields = split /\s+/, $_;
46 (defined $annotLines{$fields[1]}) or $annotLines{$fields[1]}=[];
47 # this is the tab-separated set of fields forming a jalview annotation line
48 # we only use sequence IDs, not numbers
49 my $line = [$fields[2],$fields[0],"-1", $fields[3], $fields[4], $fields[2]];
50 $featureids{$fields[2]}="FF0000"; # red is the colour.
52 if (scalar @fields>5) {
53 $attribs->{"gff:score"}=$fields[5];
54 (scalar @fields>6) and $attribs->{"gff:strand"}=$fields[6];
55 (scalar @fields>7) and $attribs->{"gff:frame"}=$fields[7];
56 if (scalar @fields>8) {
57 for (my $i=7; ($i+1)<(scalar @fields); $i+=2) {
58 $attribs->{"gff:".$fields[$i]} = $fields[$i+1];
62 push @{$annotLines{$fields[1]}}, [$line, $attribs];
65 foreach my $labels (keys %featureids) {
66 print "$labels\t".$featureids{$labels}."\n";
68 foreach my $labels (keys %annotLines) {
69 print "STARTGROUP\t".$labels."\n";
70 foreach my $annot (@{$annotLines{$labels}}) {
71 # bare minimum is written - no attributes/links yet.
72 print "".(join "\t",@{$annot->[0]})."\n";
74 print "ENDGROUP\t".$labels."\n";
86 gff2annot.pl [one or more files containing gff annotation]
88 Generates a nominally usable Jalview Annotation file on B<STDOUT> from arbitrary GFF annotation lines.
92 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.
94 For a series of GFF annotation lines looking like :
96 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>]]
98 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.
102 Passing some GFF annotation through STDIN:
105 Seq1 blastx significant_hsp 1 5 0.9 + 1 link http://mylink/
107 Seq1 blasty significant_hsp 15 25 0.9 + 1 link http://mylink/
108 Seq1 blastz significant_hsp 32 43 0.9 + 1 link http://mylink/
109 Seq2 blastx significant_hsp 1 5 0.9 + 1 link http://mylink/
110 Seq2 blasty significant_hsp 1 5 0.9 + 1 link http://mylink/
111 Seq2 blastz significant_hsp 1 5 0.9
112 Seq3 blastx significant_hsp 50 70
117 significant_hsp FF0000
119 significant_hsp Seq1 -1 15 25 significant_hsp
120 significant_hsp Seq2 -1 1 5 significant_hsp
123 significant_hsp Seq1 -1 1 5 significant_hsp
124 significant_hsp Seq2 -1 1 5 significant_hsp
125 significant_hsp Seq3 -1 50 70 significant_hsp
128 significant_hsp Seq1 -1 32 43 significant_hsp
129 significant_hsp Seq2 -1 1 5 significant_hsp