X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fjalview%2Fio%2FIdentifyFile.java;h=a241e0e7fe6a92fda5c508defc7047fd102cd359;hb=17e77c3f2949a0729322b4a8d907f3f34b6a9914;hp=4c83ac155e8948a8e8d36a2d03e160bf9fe270da;hpb=fddf3084802b37e5cee17829e32692a4aac3e60d;p=jalview.git diff --git a/src/jalview/io/IdentifyFile.java b/src/jalview/io/IdentifyFile.java index 4c83ac1..a241e0e 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-Rel$$) - * Copyright (C) $$Year-Rel$$ The Jalview Authors + * Jalview - A Sequence Alignment Editor and Viewer (Version 2.9) + * Copyright (C) 2015 The Jalview Authors * * This file is part of Jalview. * @@ -142,53 +142,8 @@ public class IdentifyFile reply = "STH"; break; } - // if (data.matches("<(\"[^\"]*\"|'[^']*'|[^'\">])*>")) - if (data.matches("<(?i)html(\"[^\"]*\"|'[^']*'|[^'\">])*>")) - { - reply = HtmlFile.FILE_DESC; - break; - } - - 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; - continue; - } - - if (data.indexOf("PILEUP") > -1) - { - reply = "PileUp"; - - break; - } - - if ((data.indexOf("//") == 0) - || ((data.indexOf("!!") > -1) && (data.indexOf("!!") < data - .indexOf("_MULTIPLE_ALIGNMENT ")))) - { - reply = "MSF"; - - break; - } - else if (data.indexOf("CLUSTAL") > -1) - { - reply = "CLUSTAL"; - - break; - } - - else if (data.indexOf(">") > -1) + // if (data.indexOf(">") > -1) + if (data.startsWith(">")) { // FASTA, PIR file or BLC file boolean checkPIR = false, starterm = false; @@ -280,6 +235,66 @@ public class IdentifyFile // read as a FASTA (probably) break; } + if ((data.indexOf("<") > -1)) // possible Markup Language data i.e HTML, + // RNAML, XML + { + boolean identified = false; + do + { + if (data.matches("<(?i)html(\"[^\"]*\"|'[^']*'|[^'\">])*>")) + { + reply = HtmlFile.FILE_DESC; + identified = true; + 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; + continue; + } + + if (data.indexOf("PILEUP") > -1) + { + reply = "PileUp"; + + break; + } + + if ((data.indexOf("//") == 0) + || ((data.indexOf("!!") > -1) && (data.indexOf("!!") < data + .indexOf("_MULTIPLE_ALIGNMENT ")))) + { + reply = "MSF"; + + break; + } + else if (data.indexOf("CLUSTAL") > -1) + { + reply = "CLUSTAL"; + + break; + } + else if (data.indexOf("HEADER") == 0 || data.indexOf("ATOM") == 0) { reply = "PDB"; @@ -291,19 +306,18 @@ public class IdentifyFile break; } - /* * // TODO comment out SimpleBLAST identification for Jalview 2.4.1 else * if (!lineswereskipped && data.indexOf("BLAST")<4) { reply = * "SimpleBLAST"; break; - * + * * } // end comments for Jalview 2.4.1 */ else if (!lineswereskipped && data.charAt(0) != '*' && data.charAt(0) != ' ' && data.indexOf(":") < data.indexOf(",")) // && - // data.indexOf(",")