X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fio%2FIdentifyFile.java;h=dae8f82c53e85a616edf484f5de098ce0d84df06;hb=6897b5d861a256c94b23167254c3f4e2ab6acb3a;hp=4fb2516873b74e99d53dfa747ac56565da6591aa;hpb=2273eba5668e5340354da60fed329c6c716cc439;p=jalview.git diff --git a/src/jalview/io/IdentifyFile.java b/src/jalview/io/IdentifyFile.java index 4fb2516..dae8f82 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.2) - * 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,26 +132,50 @@ public class IdentifyFile } data = data.toUpperCase(); - if ((data.indexOf("# STOCKHOLM") > -1)) + if (data.startsWith("##GFF-VERSION")) { - reply = "STH"; - + reply = GFF3File; break; } - // if (data.matches("<(\"[^\"]*\"|'[^']*'|[^'\">])*>")) - if (data.matches("<(?i)html(\"[^\"]*\"|'[^']*'|[^'\">])*>")) + if (data.indexOf("# STOCKHOLM") > -1) { - reply = "HTML"; + reply = "STH"; break; } - if (data.matches("<(?i)rnaml (\"[^\"]*\"|'[^']*'|[^'\">])*>")) + if ((data.indexOf("<") > -1)) // possible Markup Language data i.e HTML, + // RNAML, XML { - reply = "RNAML"; + boolean identified = false; + do + { + if (data.matches("<(?i)html(\"[^\"]*\"|'[^']*'|[^'\">])*>")) + { + reply = HtmlFile.FILE_DESC; + identified = true; + break; + } - break; + if (data.matches("<(?i)rnaml (\"[^\"]*\"|'[^']*'|[^'\">])*>")) + { + reply = "RNAML"; + identified = true; + break; + } + } while ((data = source.nextLine()) != null); + + if (identified) + { + break; + } } + + if (data.indexOf("{\"") > -1) + { + reply = JSONFile.FILE_DESC; + break; + } if ((data.length() < 1) || (data.indexOf("#") == 0)) { lineswereskipped = true;