From dab5cea53c80d566d12455951077db33e2490631 Mon Sep 17 00:00:00 2001 From: gmungoc Date: Fri, 12 Dec 2014 15:29:11 +0000 Subject: [PATCH] JAL-845 don't translate hidden annotation (plus formatting) --- src/jalview/analysis/Dna.java | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/src/jalview/analysis/Dna.java b/src/jalview/analysis/Dna.java index 2e56e67..675a44a 100644 --- a/src/jalview/analysis/Dna.java +++ b/src/jalview/analysis/Dna.java @@ -20,10 +20,6 @@ */ package jalview.analysis; -import java.util.ArrayList; -import java.util.Hashtable; -import java.util.Vector; - import jalview.datamodel.AlignedCodonFrame; import jalview.datamodel.Alignment; import jalview.datamodel.AlignmentAnnotation; @@ -39,6 +35,10 @@ import jalview.schemes.ResidueProperties; import jalview.util.MapList; import jalview.util.ShiftList; +import java.util.ArrayList; +import java.util.Hashtable; +import java.util.Vector; + public class Dna { /** @@ -52,9 +52,13 @@ public class Dna { if (cdp2 == null || (cdp1[0] == cdp2[0] && cdp1[1] == cdp2[1] && cdp1[2] == cdp2[2])) + { return 0; + } if (cdp1[0] < cdp2[0] || cdp1[1] < cdp2[1] || cdp1[2] < cdp2[2]) + { return -1; // one base in cdp1 precedes the corresponding base in the + } // other codon return 1; // one base in cdp1 appears after the corresponding base in the // other codon. @@ -146,7 +150,9 @@ public class Dna } } if (codons.aaWidth == 0) + { return null; + } SequenceI[] newseqs = new SequenceI[pepseqs.size()]; pepseqs.copyInto(newseqs); AlignmentI al = new Alignment(newseqs); @@ -264,7 +270,9 @@ public class Dna // generate seqstring for this sequence based on mapping if (sqstr.length() > alwidth) + { alwidth = sqstr.length(); + } cdnasqs.addElement(sqstr.toString()); cdnasqi.addElement(dna); cdnaprod.addElement(intersect); @@ -312,6 +320,13 @@ public class Dna continue; } + // skip hidden sequence annotations + final SequenceI seqRef = annotations[i].sequenceRef; + if (seqRef != null && !annotations[i].visible) + { + continue; + } + aSize = codons.getaaWidth(); // aa alignment width. jalview.datamodel.Annotation[] anots = (annotations[i].annotations == null) ? null : new jalview.datamodel.Annotation[aSize]; @@ -320,7 +335,7 @@ public class Dna for (a = 0; a < aSize; a++) { // process through codon map. - if (codons.codons[a] != null + if (a < codons.codons.length && codons.codons[a] != null && codons.codons[a][0] == (codons.codons[a][2] - 2)) { anots[a] = getCodonAnnotation(codons.codons[a], @@ -343,10 +358,10 @@ public class Dna { aa.setScore(annotations[i].getScore()); } - if (annotations[i].sequenceRef != null) + if (seqRef != null) { SequenceI aaSeq = codons - .getAaForDnaSeq(annotations[i].sequenceRef); + .getAaForDnaSeq(seqRef); if (aaSeq != null) { // aa.compactAnnotationArray(); // throw away alignment annotation @@ -407,7 +422,7 @@ public class Dna } if (contrib > 1) { - annot.value /= (float) contrib; + annot.value /= contrib; } return annot; } @@ -429,6 +444,7 @@ public class Dna * {@link #translateCodingRegion(SequenceI,String,int[],AlignedCodonFrame,char,DBRefEntry,boolean)} * instead */ + @Deprecated public static SequenceI translateCodingRegion(SequenceI selection, String seqstring, int[] viscontigs, AlignedCodonFrame codons, char gapCharacter, DBRefEntry product) @@ -694,7 +710,9 @@ public class Dna scontigs = t; } if (vc <= 0) + { scontigs = null; + } } if (scontigs != null) { @@ -705,7 +723,9 @@ public class Dna scontigs[vc] = selection.findPosition(scontigs[vc]); // not from 1! scontigs[vc + 1] = selection.findPosition(scontigs[vc + 1]); // exclusive if (scontigs[vc + 1] == selection.getEnd()) + { break; + } } // trim trailing empty intervals. if ((vc + 2) < scontigs.length) -- 1.7.10.2