+
+ /**
+ * Returns true if the data appears to be Jnet concise annotation format
+ *
+ * @param data
+ * @return
+ */
+ protected boolean looksLikeJnetData(String data)
+ {
+ char firstChar = data.charAt(0);
+ int colonPos = data.indexOf(":");
+ int commaPos = data.indexOf(",");
+ boolean isJnet = firstChar != '*' && firstChar != ' ' && colonPos > -1
+ && commaPos > -1 && colonPos < commaPos;
+ // && data.indexOf(",")<data.indexOf(",", data.indexOf(","))) / ??
+ return isJnet;
+ }
+
+ /**
+ * Returns true if the data has at least 6 tab-delimited fields _and_ fields 4
+ * and 5 are integer (start/end)
+ *
+ * @param data
+ * @return
+ */
+ protected boolean looksLikeFeatureData(String data)
+ {
+ if (data == null)
+ {
+ return false;
+ }
+ String[] columns = data.split("\t");
+ if (columns.length < 6)
+ {
+ return false;
+ }
+ for (int col = 3; col < 5; col++)
+ {
+ try
+ {
+ Integer.parseInt(columns[col]);
+ } catch (NumberFormatException e)
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ /**
+ *
+ * @param args
+ * @j2sIgnore
+ */
+ public static void main(String[] args)
+ {
+ for (int i = 0; args != null && i < args.length; i++)
+ {
+ IdentifyFile ider = new IdentifyFile();
+ FileFormatI type = null;
+ try
+ {
+ type = ider.identify(args[i], DataSourceType.FILE);
+ } catch (FileFormatException e)
+ {
+ Console.error(
+ String.format("Error '%s' identifying file type for %s",
+ args[i], e.getMessage()));
+ }
+ Console.debug("Type of " + args[i] + " is " + type);
+ }
+ if (args == null || args.length == 0)
+ {
+ Console.error("Usage: <Filename> [<Filename> ...]");
+ }
+ }
+