From: gmungoc Date: Tue, 16 May 2017 10:12:04 +0000 (+0100) Subject: JAL-2505 refactor to set type and group in SequenceFeature constructor X-Git-Tag: Release_2_10_3b1~273 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=51160e18fc93c618169ac9a4e5fda2a6a4486ec5;p=jalview.git JAL-2505 refactor to set type and group in SequenceFeature constructor --- diff --git a/src/jalview/io/gff/ExonerateHelper.java b/src/jalview/io/gff/ExonerateHelper.java index eb74eea..873fd27 100644 --- a/src/jalview/io/gff/ExonerateHelper.java +++ b/src/jalview/io/gff/ExonerateHelper.java @@ -352,12 +352,16 @@ public class ExonerateHelper extends Gff2Helper return false; } + /** + * An override to set feature group to "exonerate" instead of the default GFF + * source value (column 2) + */ @Override protected SequenceFeature buildSequenceFeature(String[] gff, Map> set) { - SequenceFeature sf = super.buildSequenceFeature(gff, set); - sf.setFeatureGroup("exonerate"); + SequenceFeature sf = super.buildSequenceFeature(gff, TYPE_COL, + "exonerate", set); return sf; } diff --git a/src/jalview/io/gff/Gff3Helper.java b/src/jalview/io/gff/Gff3Helper.java index 0273f9b..8af3933 100644 --- a/src/jalview/io/gff/Gff3Helper.java +++ b/src/jalview/io/gff/Gff3Helper.java @@ -361,9 +361,11 @@ public class Gff3Helper extends GffHelperBase */ @Override protected SequenceFeature buildSequenceFeature(String[] gff, + int typeColumn, String group, Map> attributes) { - SequenceFeature sf = super.buildSequenceFeature(gff, attributes); + SequenceFeature sf = super.buildSequenceFeature(gff, typeColumn, group, + attributes); String desc = getDescription(sf, attributes); if (desc != null) { diff --git a/src/jalview/io/gff/GffHelperBase.java b/src/jalview/io/gff/GffHelperBase.java index 48c33e5..41f141b 100644 --- a/src/jalview/io/gff/GffHelperBase.java +++ b/src/jalview/io/gff/GffHelperBase.java @@ -337,6 +337,19 @@ public abstract class GffHelperBase implements GffHelperI protected SequenceFeature buildSequenceFeature(String[] gff, Map> attributes) { + return buildSequenceFeature(gff, TYPE_COL, gff[SOURCE_COL], attributes); + } + + /** + * @param gff + * @param typeColumn + * @param group + * @param attributes + * @return + */ + protected SequenceFeature buildSequenceFeature(String[] gff, + int typeColumn, String group, Map> attributes) + { try { int start = Integer.parseInt(gff[START_COL]); @@ -355,8 +368,8 @@ public abstract class GffHelperBase implements GffHelperI // e.g. '.' - leave as zero } - SequenceFeature sf = new SequenceFeature(gff[TYPE_COL], - gff[SOURCE_COL], start, end, score, gff[SOURCE_COL]); + SequenceFeature sf = new SequenceFeature(gff[typeColumn], + gff[SOURCE_COL], start, end, score, group); sf.setStrand(gff[STRAND_COL]); diff --git a/src/jalview/io/gff/InterProScanHelper.java b/src/jalview/io/gff/InterProScanHelper.java index e1334e1..0aa3b74 100644 --- a/src/jalview/io/gff/InterProScanHelper.java +++ b/src/jalview/io/gff/InterProScanHelper.java @@ -73,13 +73,19 @@ public class InterProScanHelper extends Gff3Helper } /** - * - */ + * An override that + *
    + *
  • uses Source (column 2) as feature type instead of the default column 3
  • + *
  • sets "InterProScan" as the feature group
  • + *
  • extracts "signature_desc" attribute as the feature description
  • + *
+ */ @Override protected SequenceFeature buildSequenceFeature(String[] gff, Map> attributes) { - SequenceFeature sf = super.buildSequenceFeature(gff, attributes); + SequenceFeature sf = super.buildSequenceFeature(gff, SOURCE_COL, + INTER_PRO_SCAN, attributes); /* * signature_desc is a more informative source of description @@ -91,13 +97,6 @@ public class InterProScanHelper extends Gff3Helper sf.setDescription(description); } - /* - * Set sequence feature group as 'InterProScan', and type as the source - * database for this match (e.g. 'Pfam') - */ - sf.setType(gff[SOURCE_COL]); - sf.setFeatureGroup(INTER_PRO_SCAN); - return sf; }