From 4484ac6bdcc92f0e0e430f64d3587f026fafb476 Mon Sep 17 00:00:00 2001 From: jprocter Date: Mon, 19 Mar 2007 15:41:54 +0000 Subject: [PATCH] translate aligned cDNA to aligned peptide --- src/jalview/analysis/Dna.java | 227 ++++++++ src/jalview/gui/AlignFrame.java | 1165 +++++++++++++++++++-------------------- 2 files changed, 804 insertions(+), 588 deletions(-) create mode 100644 src/jalview/analysis/Dna.java diff --git a/src/jalview/analysis/Dna.java b/src/jalview/analysis/Dna.java new file mode 100644 index 0000000..836c39e --- /dev/null +++ b/src/jalview/analysis/Dna.java @@ -0,0 +1,227 @@ +package jalview.analysis; + +import java.util.Hashtable; +import java.util.Vector; + +import jalview.datamodel.Alignment; +import jalview.datamodel.AlignmentAnnotation; +import jalview.datamodel.AlignmentI; +import jalview.datamodel.Annotation; +import jalview.datamodel.ColumnSelection; +import jalview.datamodel.Sequence; +import jalview.datamodel.SequenceFeature; +import jalview.datamodel.SequenceI; +import jalview.schemes.ResidueProperties; +import jalview.util.MapList; + +public class Dna { + /** + * + * @param cdp1 + * @param cdp2 + * @return -1 if cdp1 aligns before cdp2, 0 if in the same column or cdp2 is null, +1 if after cdp2 + */ + private static int compare_codonpos(int[] cdp1, int[] cdp2) { + if (cdp2==null || (cdp1[0]==cdp2[0] && cdp1[1] == cdp2[1] && cdp1[2] == cdp2[2])) + return 0; + if (cdp1[0]=aslen) + aslen=aspos+1; + break; // check the next position for alignment + case 0: + // codon aligns at aspos position. + findpos = false; + } + } + // codon aligns with all other sequence residues found at aspos + protein.append(aa); + if (codons[aspos]==null) + { + // mark this column as aligning to this aligned reading frame + codons[aspos] = new int[] { cdp[0], cdp[1], cdp[2] }; + } + aspos++; + if (aspos>=aslen) + aslen=aspos+1; + } + } + if (resSize>0) + { + newSeq[s] = new Sequence(selection[s].getName(), + protein.toString()); + if (rf!=0) + { + jalview.bin.Cache.log.debug("trimming contigs for incomplete terminal codon."); + // trim contigs + vc=scontigs.length-1; + nend-=rf; + // incomplete ORF could be broken over one or two visible contig intervals. + while (vc>0 && scontigs[vc]>nend) + { + if (scontigs[vc-1]>nend) + { + vc-=2; + } else { + // correct last interval in list. + scontigs[vc]=nend; + } + } + if ((vc+2)