/*
- * 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.
*
*/
package jalview.io;
+import jalview.jsdev.Constants;
+import jalview.jsdev.GenericFileAdapter;
+
import java.io.IOException;
/**
*/
public class IdentifyFile
{
+ public static final String GFF3File = "GFF v2 or v3";
+
/**
* Identify a datasource's file content.
*
}
while ((data = source.nextLine()) != null)
{
- length += data.length();
+ length += data.trim().length();
if (!lineswereskipped)
{
for (int i = 0; !isBinary && i < data.length(); i++)
}
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(\"[^\"]*\"|'[^']*'|[^'\">])*>"))
+ if (data.matches("<HTML(\"[^\"]*\"|'[^']*'|[^'\">])*>")) // BH was (?i)rnaml, but JavaScript regex does not support (?i); data is already upper case
{
- reply = "HTML";
+ reply = Constants.Html_FILE_DESC;
break;
}
- if (data.matches("<(?i)rnaml (\"[^\"]*\"|'[^']*'|[^'\">])*>"))
+ if (data.matches("<RNAML (\"[^\"]*\"|'[^']*'|[^'\">])*>")) // BH was (?i)rnaml, but JavaScript regex does not support (?i); data is already upper case
{
reply = "RNAML";
-
break;
}
+ if (data.indexOf("{\"") > -1)
+ {
+ reply = Constants.JSON_FILE_DESC;
+ break;
+ }
if ((data.length() < 1) || (data.indexOf("#") == 0))
{
lineswereskipped = true;
}
else if (data.matches("\\s*\\d+\\s+\\d+\\s*"))
{
- reply = PhylipFile.FILE_DESC;
+ reply = Constants.Phylip_FILE_DESC;
break;
}
return reply;
}
+ /**
+ * @j2sIgnore
+ *
+ * @param args
+ */
public static void main(String[] args)
{