JAL-1035 option to allow 'STOP' codon to translate as '*'
authorJim Procter <jprocter@compbio.dundee.ac.uk>
Mon, 17 Jun 2013 14:23:00 +0000 (15:23 +0100)
committerJim Procter <jprocter@compbio.dundee.ac.uk>
Mon, 17 Jun 2013 14:23:00 +0000 (15:23 +0100)
src/jalview/analysis/Dna.java

index 5285924..f610d08 100644 (file)
@@ -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++;
         }