From: jprocter Date: Mon, 19 Mar 2007 15:41:54 +0000 (+0000) Subject: translate aligned cDNA to aligned peptide X-Git-Tag: Release_2_3~321 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=4484ac6bdcc92f0e0e430f64d3587f026fafb476;p=jalview.git translate aligned cDNA to aligned peptide --- 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)