The possible ways a nucleotide sequence can be translated to a protein. (Forward and reverse and 3 different phases).
| 42 | * |
| 43 | */ |
| 44 | public abstract class TranslatedFrame implements Frame, PseudoEnum { |
| 45 | |
| 46 | /** The number of nucleotides per codon */ |
| 47 | public static final int NUCLEOTIDES_PER_CODON = 3; |
| 48 | |
| 49 | /** |
| 50 | * Normal forward direction - phase 1. |
| 51 | */ |
| 52 | public static final TranslatedFrame FORWARD1 = new TranslatedFrame(0, "FORWARD1", "+1", 0) { |
| 53 | @Override |
| 54 | public byte code(final byte[] codes, final int length, final int index) { |
| 55 | return code(codes, length, index, 0, length); |
| 56 | } |
| 57 | |
| 58 | @Override |
| 59 | public byte code(byte[] codes, int length, int index, int firstValid, int lastValid) { |
| 60 | final int x = firstValid + index + 2; |
| 61 | if (x >= length) { |
| 62 | throw new ArrayIndexOutOfBoundsException(index); |
| 63 | } |
| 64 | return codonToAmino(codes[firstValid + index], codes[firstValid + index + 1], codes[x]); |
| 65 | } |
| 66 | |
| 67 | @Override |
| 68 | public int calculateFirstValid(int offset, int length, int fullLength) { |
| 69 | return f(offset); |
| 70 | } |
| 71 | |
| 72 | @Override |
| 73 | public int calculateLastValid(int offset, int length, int fullLength) { |
| 74 | return length; |
| 75 | } |
| 76 | |
| 77 | @Override |
| 78 | public boolean isForward() { |
| 79 | return true; |
| 80 | } |
| 81 | |
| 82 | @Override |
| 83 | public Frame getReverse() { |
| 84 | return REVERSE1; |
| 85 | } |
| 86 | }; |
| 87 | |
| 88 | /** |
| 89 | * Normal forward direction - phase 2. |
| 90 | */ |
| 91 | public static final TranslatedFrame FORWARD2 = new TranslatedFrame(1, "FORWARD2", "+2", 1) { |
| 92 | @Override |
| 93 | public byte code(final byte[] codes, final int length, final int index) { |
| 94 | return code(codes, length, index, 0, length); |
| 95 | } |
| 96 | |
| 97 | @Override |
| 98 | public byte code(byte[] codes, int length, int index, int firstValid, int lastValid) { |
| 99 | final int x = firstValid + index + 3; |
| 100 | if (x >= length) { |
| 101 | throw new ArrayIndexOutOfBoundsException(index); |
nothing calls this directly
no test coverage detected