X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fio%2FIdentifyFile.java;h=4c83ac155e8948a8e8d36a2d03e160bf9fe270da;hb=ab22918ab8fc67d30dad1fb1ae0f37e51f49df95;hp=beb1385ab5ffb2b456cd066f470674b7669b0ed4;hpb=ab43013b7e357b84b4abade0dba949668dfb2a0e;p=jalview.git diff --git a/src/jalview/io/IdentifyFile.java b/src/jalview/io/IdentifyFile.java index beb1385..4c83ac1 100755 --- a/src/jalview/io/IdentifyFile.java +++ b/src/jalview/io/IdentifyFile.java @@ -1,6 +1,6 @@ /* - * Jalview - A Sequence Alignment Editor and Viewer (Version 2.8.2b1) - * Copyright (C) 2014 The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$) + * Copyright (C) $$Year-Rel$$ The Jalview Authors * * This file is part of Jalview. * @@ -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. * @@ -96,7 +98,7 @@ public class IdentifyFile } while ((data = source.nextLine()) != null) { - length += data.length(); + length += data.trim().length(); if (!lineswereskipped) { for (int i = 0; !isBinary && i < data.length(); i++) @@ -130,20 +132,34 @@ 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; + } + // if (data.matches("<(\"[^\"]*\"|'[^']*'|[^'\">])*>")) + if (data.matches("<(?i)html(\"[^\"]*\"|'[^']*'|[^'\">])*>")) + { + reply = HtmlFile.FILE_DESC; break; } - if ((data.indexOf("<") > -1)) + if (data.matches("<(?i)rnaml (\"[^\"]*\"|'[^']*'|[^'\">])*>")) { reply = "RNAML"; - break; } + if (data.indexOf("{\"") > -1) + { + reply = JSONFile.FILE_DESC; + break; + } if ((data.length() < 1) || (data.indexOf("#") == 0)) { lineswereskipped = true; @@ -275,6 +291,7 @@ public class IdentifyFile break; } + /* * // TODO comment out SimpleBLAST identification for Jalview 2.4.1 else * if (!lineswereskipped && data.indexOf("BLAST")<4) { reply = @@ -320,6 +337,7 @@ public class IdentifyFile public static void main(String[] args) { + for (int i = 0; args != null && i < args.length; i++) { IdentifyFile ider = new IdentifyFile();