*/
package jalview.analysis;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-import java.util.Map;
-
import jalview.api.AlignViewportI;
import jalview.datamodel.AlignedCodon;
import jalview.datamodel.AlignedCodonFrame;
import jalview.util.MapList;
import jalview.util.ShiftList;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Map;
+
public class Dna
{
- private static final String STOP_X = "X";
+ private static final String STOP_ASTERIX = "*";
private static final Comparator<AlignedCodon> comparator = new CodonComparator();
}
if (aa.equals("STOP"))
{
- aa = STOP_X;
+ aa = STOP_ASTERIX;
}
resSize++;
}
{
assertTrue(AlignmentUtils.translatesAs("tttcccaaaggg".toCharArray(), 0,
"FPKG".toCharArray()));
- // with start codon
+ // with start codon (not in protein)
assertTrue(AlignmentUtils.translatesAs("atgtttcccaaaggg".toCharArray(),
3, "FPKG".toCharArray()));
- // with stop codon1
+ // with stop codon1 (not in protein)
assertTrue(AlignmentUtils.translatesAs("tttcccaaagggtaa".toCharArray(),
0, "FPKG".toCharArray()));
- // with stop codon2
+ // with stop codon1 (in protein as *)
+ assertTrue(AlignmentUtils.translatesAs("tttcccaaagggtaa".toCharArray(),
+ 0, "FPKG*".toCharArray()));
+ // with stop codon2 (not in protein)
assertTrue(AlignmentUtils.translatesAs("tttcccaaagggtag".toCharArray(),
0, "FPKG".toCharArray()));
- // with stop codon3
+ // with stop codon3 (not in protein)
assertTrue(AlignmentUtils.translatesAs("tttcccaaagggtga".toCharArray(),
0, "FPKG".toCharArray()));
// with start and stop codon1
assertTrue(AlignmentUtils.translatesAs(
- "atgtttcccaaaggtaa".toCharArray(), 3, "FPKG".toCharArray()));
+ "atgtttcccaaagggtaa".toCharArray(), 3, "FPKG".toCharArray()));
+ // with start and stop codon1 (in protein as *)
+ assertTrue(AlignmentUtils.translatesAs(
+ "atgtttcccaaagggtaa".toCharArray(), 3, "FPKG*".toCharArray()));
// with start and stop codon2
assertTrue(AlignmentUtils.translatesAs(
- "atgtttcccaaaggtag".toCharArray(), 3, "FPKG".toCharArray()));
+ "atgtttcccaaagggtag".toCharArray(), 3, "FPKG".toCharArray()));
// with start and stop codon3
assertTrue(AlignmentUtils.translatesAs(
- "atgtttcccaaaggtga".toCharArray(), 3, "FPKG".toCharArray()));
+ "atgtttcccaaagggtga".toCharArray(), 3, "FPKG".toCharArray()));
+
+ // with embedded stop codon
+ assertTrue(AlignmentUtils.translatesAs(
+ "atgtttTAGcccaaaTAAgggtga".toCharArray(), 3,
+ "F*PK*G".toCharArray()));
// wrong protein
assertFalse(AlignmentUtils.translatesAs("tttcccaaaggg".toCharArray(),