JAL-653 GFF recognition for identifyFile and format adapters
authorJim Procter <jprocter@issues.jalview.org>
Sun, 7 Jun 2015 18:03:45 +0000 (19:03 +0100)
committerJim Procter <jprocter@issues.jalview.org>
Sun, 7 Jun 2015 18:03:45 +0000 (19:03 +0100)
src/jalview/io/AppletFormatAdapter.java
src/jalview/io/IdentifyFile.java

index 5601f27..ba620ca 100755 (executable)
@@ -82,7 +82,7 @@ public class AppletFormatAdapter
    */
   public static final String[] READABLE_FORMATS = new String[]
   { "BLC", "CLUSTAL", "FASTA", "MSF", "PileUp", "PIR", "PFAM", "STH",
-      "PDB", "JnetFile", "RNAML", PhylipFile.FILE_DESC, JSONFile.FILE_DESC,
+      "PDB", "JnetFile", "RNAML", PhylipFile.FILE_DESC, JSONFile.FILE_DESC, IdentifyFile.GFF3File,
       "HTML" };
 
   /**
@@ -92,6 +92,7 @@ public class AppletFormatAdapter
   public static final String[] READABLE_EXTENSIONS = new String[]
   { "fa, fasta, mfa, fastq", "aln", "pfam", "msf", "pir", "blc", "amsa",
       "sto,stk", "xml,rnaml", PhylipFile.FILE_EXT, JSONFile.FILE_EXT,
+      ".gff2,gff3",
       "jar,jvp", HtmlFile.FILE_EXT };
 
   /**
@@ -100,7 +101,7 @@ public class AppletFormatAdapter
    */
   public static final String[] READABLE_FNAMES = new String[]
   { "Fasta", "Clustal", "PFAM", "MSF", "PIR", "BLC", "AMSA", "Stockholm",
-      "RNAML", PhylipFile.FILE_DESC, JSONFile.FILE_DESC, "Jalview",
+      "RNAML", PhylipFile.FILE_DESC, JSONFile.FILE_DESC, IdentifyFile.GFF3File, "Jalview",
       HtmlFile.FILE_DESC };
 
   /**
@@ -309,6 +310,10 @@ public class AppletFormatAdapter
       {
         alignFile = new RnamlFile(inFile, type);
       }
+      else if (format.equals(IdentifyFile.GFF3File))
+      {
+        alignFile = new Gff3File(inFile, type);
+      }
 
       al = new Alignment(alignFile.getSeqsAsArray());
 
@@ -432,6 +437,10 @@ public class AppletFormatAdapter
       {
         alignFile = new PhylipFile(source);
       }
+      else if (format.equals(IdentifyFile.GFF3File))
+      {
+        alignFile = new Gff3File(inFile, type);
+      }
       else if (format.equals(JSONFile.FILE_DESC))
       {
         alignFile = new JSONFile(source);
index f1089ec..27f08ae 100755 (executable)
@@ -30,6 +30,8 @@ import java.io.IOException;
  */
 public class IdentifyFile
 {
+  public static final String GFF3File = "GFF v2 or v3";
+
   /**
    * Identify a datasource's file content.
    *
@@ -130,7 +132,12 @@ public class IdentifyFile
         }
         data = data.toUpperCase();
 
-        if ((data.indexOf("# STOCKHOLM") > -1))
+        if (data.startsWith("##GFF-VERSION"))
+        {
+          reply = GFF3File;
+          break;
+        }
+        if (data.indexOf("# STOCKHOLM") > -1)
         {
           reply = "STH";
           break;