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