From 83ff5551a4f4b4fb92a7cdb5f519ad6453c56cc4 Mon Sep 17 00:00:00 2001 From: Jim Procter Date: Mon, 17 Jun 2013 15:23:00 +0100 Subject: [PATCH] JAL-1035 option to allow 'STOP' codon to translate as '*' --- src/jalview/analysis/Dna.java | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/src/jalview/analysis/Dna.java b/src/jalview/analysis/Dna.java index 5285924..f610d08 100644 --- a/src/jalview/analysis/Dna.java +++ b/src/jalview/analysis/Dna.java @@ -125,7 +125,7 @@ public class Dna { SequenceI newseq = translateCodingRegion(selection[s], seqstring[s], viscontigs, codons, gapCharacter, - (product != null) ? product[s] : null); // possibly anonymous + (product != null) ? product[s] : null, false); // possibly anonymous // product if (newseq != null) { @@ -420,13 +420,36 @@ public class Dna * @param codons * Definition of global ORF alignment reference frame * @param gapCharacter - * @param newSeq * @return sequence ready to be added to alignment. + * @deprecated Use {@link #translateCodingRegion(SequenceI,String,int[],AlignedCodonFrame,char,DBRefEntry,boolean)} instead */ public static SequenceI translateCodingRegion(SequenceI selection, String seqstring, int[] viscontigs, AlignedCodonFrame codons, char gapCharacter, DBRefEntry product) { + return translateCodingRegion(selection, seqstring, viscontigs, codons, + gapCharacter, product, false); + } + + /** + * Translate a na sequence + * + * @param selection + * sequence displayed under viscontigs visible columns + * @param seqstring + * ORF read in some global alignment reference frame + * @param viscontigs + * mapping from global reference frame to visible seqstring ORF read + * @param codons + * Definition of global ORF alignment reference frame + * @param gapCharacter + * @param starForStop when true stop codons will translate as '*', otherwise as 'X' + * @return sequence ready to be added to alignment. + */ + public static SequenceI translateCodingRegion(SequenceI selection, + String seqstring, int[] viscontigs, AlignedCodonFrame codons, + char gapCharacter, DBRefEntry product, final boolean starForStop) + { java.util.List skip = new ArrayList(); int skipint[] = null; ShiftList vismapping = new ShiftList(); // map from viscontigs to seqstring @@ -560,7 +583,7 @@ public class Dna } if (aa.equals("STOP")) { - aa = "X"; + aa = starForStop ? "*" : "X"; } resSize++; } -- 1.7.10.2