From 92cccf420dbe7501fae76b9941fd701151bdf5ab Mon Sep 17 00:00:00 2001 From: gmungoc Date: Thu, 21 Jan 2016 15:58:15 +0000 Subject: [PATCH] JAL-653 refactor / tidy --- src/jalview/io/gff/Gff3Helper.java | 61 ++++++++++++++++++++++++++---------- 1 file changed, 44 insertions(+), 17 deletions(-) diff --git a/src/jalview/io/gff/Gff3Helper.java b/src/jalview/io/gff/Gff3Helper.java index 4c67caa..55a0f9a 100644 --- a/src/jalview/io/gff/Gff3Helper.java +++ b/src/jalview/io/gff/Gff3Helper.java @@ -61,19 +61,6 @@ public class Gff3Helper extends GffHelperBase AlignmentI align, List newseqs, boolean relaxedIdMatching) throws IOException { - /* - * (For now) we don't process mappings from reverse complement ; to do - * this would require (a) creating a virtual sequence placeholder for - * the reverse complement (b) resolving the sequence by its id from some - * source (GFF ##FASTA or other) (c) creating the reverse complement - * sequence (d) updating the mapping to be to the reverse complement - */ - if ("-".equals(gff[STRAND_COL])) - { - System.err - .println("Skipping mapping from reverse complement as not yet supported"); - return null; - } SequenceFeature sf = null; if (gff.length == 9) @@ -135,10 +122,18 @@ public class Gff3Helper extends GffHelperBase throws IOException { String strand = gffColumns[STRAND_COL]; - if ("-1".equals(strand)) + + /* + * (For now) we don't process mappings from reverse complement ; to do + * this would require (a) creating a virtual sequence placeholder for + * the reverse complement (b) resolving the sequence by its id from some + * source (GFF ##FASTA or other) (c) creating the reverse complement + * sequence (d) updating the mapping to be to the reverse complement + */ + if ("-".equals(strand)) { System.err - .println("Currently ignoring mappings from reverse complement"); + .println("Skipping mapping from reverse complement as not yet supported"); return null; } @@ -351,11 +346,43 @@ public class Gff3Helper extends GffHelperBase Map> attributes) { SequenceFeature sf = super.buildSequenceFeature(gff, attributes); + String desc = getDescription(sf, attributes); + if (desc != null) + { + sf.setDescription(desc); + } + return sf; + } + + /** + * Apply heuristic rules to try to get the most useful feature description + * + * @param sf + * @param attributes + * @return + */ + protected String getDescription(SequenceFeature sf, + Map> attributes) + { + String desc = null; String target = (String) sf.getValue(TARGET); if (target != null) { - sf.setDescription(target.split(" ")[0]); + desc = target.split(" ")[0]; } - return sf; + + if (SequenceOntology.getInstance().isSequenceVariant(sf.getType())) + { + /* + * Ensembl returns alleles and consequence_type (amongst other details) + */ + String alleles = StringUtils.listToDelimitedString( + attributes.get("alleles"), ","); + String consequence = StringUtils.listToDelimitedString( + attributes.get("consequence_type"), ","); + desc = String.format("alleles %s; consequence %s", alleles, + consequence); + } + return desc; } } -- 1.7.10.2