From 1e5fe67a3cfd5b0dbae0847d3cff7dc93c31f174 Mon Sep 17 00:00:00 2001 From: jprocter Date: Wed, 24 Jun 2009 08:22:47 +0000 Subject: [PATCH] take the average of the three consecutive codon sites when translating annotation row scores from cDNA to protein. --- src/jalview/analysis/Dna.java | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/jalview/analysis/Dna.java b/src/jalview/analysis/Dna.java index ce13665..5ff6751 100644 --- a/src/jalview/analysis/Dna.java +++ b/src/jalview/analysis/Dna.java @@ -364,14 +364,44 @@ public class Dna { // Have a look at all the codon positions for annotation and put the first // one found into the translated annotation pos. + int contrib=0; + Annotation annot = null; for (int p = 0; p < 3; p++) { if (annotations[is[p]] != null) { - return new Annotation(annotations[is[p]]); + if (annot==null) { + annot = new Annotation(annotations[is[p]]); + contrib = 1; + } else { + // merge with last + Annotation cpy = new Annotation(annotations[is[p]]); + if (annot.colour==null) + { + annot.colour = cpy.colour; + } + if (annot.description==null || annot.description.length()==0) + { + annot.description = cpy.description; + } + if (annot.displayCharacter==null) + { + annot.displayCharacter = cpy.displayCharacter; + } + if (annot.secondaryStructure==0) + { + annot.secondaryStructure = cpy.secondaryStructure; + } + annot.value+=cpy.value; + contrib++; + } } } - return null; + if (contrib>1) + { + annot.value/=(float)contrib; + } + return annot; } /** -- 1.7.10.2