GMOD / GBrowse

the Generic Genome Browser
http://gmod.org/wiki/GBrowse
Other
49 stars 37 forks source link

Custom tracks with .gff suffix are always treated as GFF2 #39

Open nathanweeks opened 10 years ago

nathanweeks commented 10 years ago

A custom track uploaded from a file will be loaded with Bio::DB::SeqFeature::Store::GFF2Loader if it has a .gff suffix, even if the file contains "##gff-version 3" as the first line.

Since it is not uncommon for a GFF3 files to have a ".gff" suffix, the loader should detect this.

The following patch accomplishes this for uncompressed .gff files; ideally, this could be accomplished somehow for compressed files as well:

diff --git a/lib/Bio/Graphics/Browser2/UserTracks.pm b/lib/Bio/Graphics/Browser2/UserTracks.pm
index b63915e..7883335 100644
--- a/lib/Bio/Graphics/Browser2/UserTracks.pm
+++ b/lib/Bio/Graphics/Browser2/UserTracks.pm
@@ -754,6 +754,8 @@ sub _guess_upload_type {
               :$filename =~ /\.(?:tar|tgz|tbz|tbz2|zip)(?:\.(gz|bz2))?$/i ? 'archive'
               :undef;

+    # .gff file may be GFF3 if first line contains the gff-version pragma
+    return ('gff3',\@lines,$eol) if $filename =~ /\.gff$/i && $lines[0] =~ /^\#\#gff-version\s+3/;
     return ($ftype,\@lines,$eol) if $ftype;

     # otherwise scan the thing until we find a pattern we know about