1 package jalview.io.gff;
5 * A factory to serve instances of GFF helper classes
7 public class GffHelperFactory
11 * Returns a class to process the GFF line based on inspecting its column
12 * data. This may return a general-purpose GFF2 or GFF3 helper, or a
13 * specialisation for a flavour of GFF generated by a particular tool.
18 public static GffHelperI getHelper(String[] gff)
20 if (gff == null || gff.length < 6)
25 GffHelperI result = null;
26 if (ExonerateHelper.recognises(gff))
28 result = new ExonerateHelper();
30 else if (InterProScanHelper.recognises(gff))
32 result = new InterProScanHelper();
34 else if (looksLikeGff3(gff))
36 result = new Gff3Helper();
40 result = new Gff2Helper();
47 * Heuristic rule: if column 9 seems to have Name=Value entries, assume this
48 * is GFF3. GFF3 uses '=' as name-value separator, GFF2 uses space ' '.
53 protected static boolean looksLikeGff3(String[] gff)
57 String attributes = gff[8].trim();
58 int pos1 = attributes.indexOf(';');
59 int pos2 = attributes.indexOf('=');
60 if (pos2 != -1 && (pos1 == -1 || pos2 < pos1))
62 // there is an '=' before the first ';' (if any)
63 // not foolproof as theoretically GFF2 could be like "Name Value=123;"