From 6d221394895c3b26fc68c64094b1e6c8cff96320 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Sun, 7 Jun 2015 19:03:45 +0100 Subject: [PATCH] JAL-653 GFF recognition for identifyFile and format adapters --- src/jalview/io/AppletFormatAdapter.java | 13 +++++++++++-- src/jalview/io/IdentifyFile.java | 9 ++++++++- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/jalview/io/AppletFormatAdapter.java b/src/jalview/io/AppletFormatAdapter.java index 5601f27..ba620ca 100755 --- a/src/jalview/io/AppletFormatAdapter.java +++ b/src/jalview/io/AppletFormatAdapter.java @@ -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); diff --git a/src/jalview/io/IdentifyFile.java b/src/jalview/io/IdentifyFile.java index f1089ec..27f08ae 100755 --- a/src/jalview/io/IdentifyFile.java +++ b/src/jalview/io/IdentifyFile.java @@ -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; -- 1.7.10.2