JAL-1807 still testing
[jalviewjs.git] / bin / jalview / io / IdentifyFile.js
index cf35241..4d88cdd 100644 (file)
-Clazz.declarePackage ("jalview.io");
-Clazz.load (null, "jalview.io.IdentifyFile", ["jalview.io.FileParse"], function () {
-c$ = Clazz.declareType (jalview.io, "IdentifyFile");
-Clazz.defineMethod (c$, "Identify", 
-function (file, protocol) {
-var emessage = "UNIDENTIFIED FILE PARSING ERROR";
-var parser = null;
-try {
-parser =  new jalview.io.FileParse (file, protocol);
-if (parser.isValid ()) {
-return this.Identify (parser);
-}} catch (e) {
-if (Clazz.exceptionOf (e, Exception)) {
-System.err.println ("Error whilst identifying");
-e.printStackTrace (System.err);
-emessage = e.getMessage ();
-} else {
-throw e;
-}
-}
-if (parser != null) {
-return parser.errormessage;
-}return emessage;
-}, "~S,~S");
-Clazz.defineMethod (c$, "Identify", 
-function (source) {
-return this.Identify (source, true);
-}, "jalview.io.FileParse");
-Clazz.defineMethod (c$, "Identify", 
-function (source, closeSource) {
-var reply = "PFAM";
-var data;
-var length = 0;
-var lineswereskipped = false;
-var isBinary = false;
-try {
-if (!closeSource) {
-source.mark ();
-}while ((data = source.nextLine ()) != null) {
-length += data.trim ().length;
-if (!lineswereskipped) {
-for (var i = 0; !isBinary && i < data.length; i++) {
-var c = data.charAt (i);
-isBinary = (c.charCodeAt (0) < 32 && c != '\t' && c != '\n' && c != '\r' && c.charCodeAt (0) != 5 && c.charCodeAt (0) != 27);
-}
-}if (isBinary) {
-if (source.inFile != null) {
-var fileStr = source.inFile.getName ();
-if (fileStr.lastIndexOf (".jar") > -1 || fileStr.lastIndexOf (".zip") > -1) {
-reply = "Jalview";
-}}if (!lineswereskipped && data.startsWith ("PK")) {
-reply = "Jalview";
-break;
-}}data = data.toUpperCase ();
-if (data.startsWith ("##GFF-VERSION")) {
-reply = "GFF v2 or v3";
-break;
-}if (data.indexOf ("# STOCKHOLM") > -1) {
-reply = "STH";
-break;
-}if (data.matches ("<HTML(\"[^\"]*\"|'[^']*'|[^'\">])*>")) {
-reply = "HTML";
-break;
-}if (data.matches ("<RNAML (\"[^\"]*\"|'[^']*'|[^'\">])*>")) {
-reply = "RNAML";
-break;
-}if (data.indexOf ("{\"") > -1) {
-reply = "JSON";
-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) {
-var checkPIR = false;
-var starterm = false;
-if ((data.indexOf (">P1;") > -1) || (data.indexOf (">DL;") > -1)) {
-checkPIR = true;
-reply = "PIR";
-}data = source.nextLine ();
-if (data.indexOf (">") > -1) {
-reply = "BLC";
-} else {
-var data1 = source.nextLine ();
-var data2 = source.nextLine ();
-var c1;
-if (checkPIR) {
-starterm = (data1 != null && data1.indexOf ("*") > -1) || (data2 != null && data2.indexOf ("*") > -1);
-}if (data2 != null && (c1 = data.indexOf ("*")) > -1) {
-if (c1 == 0 && c1 == data2.indexOf ("*")) {
-reply = "BLC";
-} else {
-reply = "FASTA";
-}} else {
-reply = "FASTA";
-if (!checkPIR) {
-break;
-}}}if (checkPIR) {
-var dta = null;
-if (!starterm) {
-do {
-try {
-dta = source.nextLine ();
-} catch (ex) {
-if (Clazz.exceptionOf (ex, java.io.IOException)) {
-} else {
-throw ex;
-}
-}
-;if (dta != null && dta.indexOf ("*") > -1) {
-starterm = true;
-}} while (dta != null && !starterm);
-}if (starterm) {
-reply = "PIR";
-break;
-} else {
-reply = "FASTA";
-}}break;
-} else if (data.indexOf ("HEADER") == 0 || data.indexOf ("ATOM") == 0) {
-reply = "PDB";
-break;
-} else if (data.matches ("\\s*\\d+\\s+\\d+\\s*")) {
-reply = "PHYLIP";
-break;
-} else if (!lineswereskipped && data.charAt (0) != '*' && data.charAt (0) != ' ' && data.indexOf (":") < data.indexOf (",")) {
-reply = "JnetFile";
-break;
-}lineswereskipped = true;
-}
-if (closeSource) {
-source.close ();
-} else {
-source.reset ();
-}} catch (ex) {
-if (Clazz.exceptionOf (ex, Exception)) {
-System.err.println ("File Identification failed!\n" + ex);
-return source.errormessage;
-} else {
-throw ex;
-}
-}
-if (length == 0) {
-System.err.println ("File Identification failed! - Empty file was read.");
-return "EMPTY DATA FILE";
-}return reply;
-}, "jalview.io.FileParse,~B");
-Clazz.defineStatics (c$,
-"GFF3File", "GFF v2 or v3");
-});
+Clazz.declarePackage ("jalview.io");\r
+Clazz.load (null, "jalview.io.IdentifyFile", ["jalview.io.FileParse"], function () {\r
+c$ = Clazz.declareType (jalview.io, "IdentifyFile");\r
+Clazz.defineMethod (c$, "Identify", \r
+function (file, protocol) {\r
+var emessage = "UNIDENTIFIED FILE PARSING ERROR";\r
+var parser = null;\r
+try {\r
+parser =  new jalview.io.FileParse (file, protocol);\r
+if (parser.isValid ()) {\r
+return this.Identify (parser);\r
+}} catch (e) {\r
+if (Clazz.exceptionOf (e, Exception)) {\r
+System.err.println ("Error whilst identifying");\r
+e.printStackTrace (System.err);\r
+emessage = e.getMessage ();\r
+} else {\r
+throw e;\r
+}\r
+}\r
+if (parser != null) {\r
+return parser.errormessage;\r
+}return emessage;\r
+}, "~S,~S");\r
+Clazz.defineMethod (c$, "Identify", \r
+function (source) {\r
+return this.Identify (source, true);\r
+}, "jalview.io.FileParse");\r
+Clazz.defineMethod (c$, "Identify", \r
+function (source, closeSource) {\r
+var reply = "PFAM";\r
+var data;\r
+var length = 0;\r
+var lineswereskipped = false;\r
+var isBinary = false;\r
+try {\r
+if (!closeSource) {\r
+source.mark ();\r
+}while ((data = source.nextLine ()) != null) {\r
+length += data.trim ().length;\r
+if (!lineswereskipped) {\r
+for (var i = 0; !isBinary && i < data.length; i++) {\r
+var c = data.charAt (i);\r
+isBinary = (c.charCodeAt (0) < 32 && c != '\t' && c != '\n' && c != '\r' && c.charCodeAt (0) != 5 && c.charCodeAt (0) != 27);\r
+}\r
+}if (isBinary) {\r
+if (source.inFile != null) {\r
+var fileStr = source.inFile.getName ();\r
+if (fileStr.lastIndexOf (".jar") > -1 || fileStr.lastIndexOf (".zip") > -1) {\r
+reply = "Jalview";\r
+}}if (!lineswereskipped && data.startsWith ("PK")) {\r
+reply = "Jalview";\r
+break;\r
+}}data = data.toUpperCase ();\r
+if (data.startsWith ("##GFF-VERSION")) {\r
+reply = "GFF v2 or v3";\r
+break;\r
+}if (data.indexOf ("# STOCKHOLM") > -1) {\r
+reply = "STH";\r
+break;\r
+}if (data.matches ("<HTML(\"[^\"]*\"|'[^']*'|[^'\">])*>")) {\r
+reply = "HTML";\r
+break;\r
+}if (data.matches ("<RNAML (\"[^\"]*\"|'[^']*'|[^'\">])*>")) {\r
+reply = "RNAML";\r
+break;\r
+}if (data.indexOf ("{\"") > -1) {\r
+reply = "JSON";\r
+break;\r
+}if ((data.length < 1) || (data.indexOf ("#") == 0)) {\r
+lineswereskipped = true;\r
+continue;\r
+}if (data.indexOf ("PILEUP") > -1) {\r
+reply = "PileUp";\r
+break;\r
+}if ((data.indexOf ("//") == 0) || ((data.indexOf ("!!") > -1) && (data.indexOf ("!!") < data.indexOf ("_MULTIPLE_ALIGNMENT ")))) {\r
+reply = "MSF";\r
+break;\r
+} else if (data.indexOf ("CLUSTAL") > -1) {\r
+reply = "CLUSTAL";\r
+break;\r
+} else if (data.indexOf (">") > -1) {\r
+var checkPIR = false;\r
+var starterm = false;\r
+if ((data.indexOf (">P1;") > -1) || (data.indexOf (">DL;") > -1)) {\r
+checkPIR = true;\r
+reply = "PIR";\r
+}data = source.nextLine ();\r
+if (data.indexOf (">") > -1) {\r
+reply = "BLC";\r
+} else {\r
+var data1 = source.nextLine ();\r
+var data2 = source.nextLine ();\r
+var c1;\r
+if (checkPIR) {\r
+starterm = (data1 != null && data1.indexOf ("*") > -1) || (data2 != null && data2.indexOf ("*") > -1);\r
+}if (data2 != null && (c1 = data.indexOf ("*")) > -1) {\r
+if (c1 == 0 && c1 == data2.indexOf ("*")) {\r
+reply = "BLC";\r
+} else {\r
+reply = "FASTA";\r
+}} else {\r
+reply = "FASTA";\r
+if (!checkPIR) {\r
+break;\r
+}}}if (checkPIR) {\r
+var dta = null;\r
+if (!starterm) {\r
+do {\r
+try {\r
+dta = source.nextLine ();\r
+} catch (ex) {\r
+if (Clazz.exceptionOf (ex, java.io.IOException)) {\r
+} else {\r
+throw ex;\r
+}\r
+}\r
+;if (dta != null && dta.indexOf ("*") > -1) {\r
+starterm = true;\r
+}} while (dta != null && !starterm);\r
+}if (starterm) {\r
+reply = "PIR";\r
+break;\r
+} else {\r
+reply = "FASTA";\r
+}}break;\r
+} else if (data.indexOf ("HEADER") == 0 || data.indexOf ("ATOM") == 0) {\r
+reply = "PDB";\r
+break;\r
+} else if (data.matches ("\\s*\\d+\\s+\\d+\\s*")) {\r
+reply = "PHYLIP";\r
+break;\r
+} else if (!lineswereskipped && data.charAt (0) != '*' && data.charAt (0) != ' ' && data.indexOf (":") < data.indexOf (",")) {\r
+reply = "JnetFile";\r
+break;\r
+}lineswereskipped = true;\r
+}\r
+if (closeSource) {\r
+source.close ();\r
+} else {\r
+source.reset ();\r
+}} catch (ex) {\r
+if (Clazz.exceptionOf (ex, Exception)) {\r
+System.err.println ("File Identification failed!\n" + ex);\r
+return source.errormessage;\r
+} else {\r
+throw ex;\r
+}\r
+}\r
+if (length == 0) {\r
+System.err.println ("File Identification failed! - Empty file was read.");\r
+return "EMPTY DATA FILE";\r
+}return reply;\r
+}, "jalview.io.FileParse,~B");\r
+Clazz.defineStatics (c$,\r
+"GFF3File", "GFF v2 or v3");\r
+});\r