Last active
May 27, 2018 22:58
-
-
Save DarkCoder28/5d1294524cd30cee3af10918bfea8cc3 to your computer and use it in GitHub Desktop.
All RNA combinations. to be used with my Amino.java gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.aidensheeran.DNATranslator; | |
import java.util.HashMap; | |
import java.util.Map; | |
public enum RNA { | |
UUU("UUU",Amino.PHE),UUC("UUC",Amino.PHE),UUA("UUA",Amino.LEU),UUG("UUG",Amino.LEU),CUU("CUU",Amino.LEU),CUC("CUC",Amino.LEU), | |
CUA("CUA",Amino.LEU),CUG("CUG",Amino.LEU),AUU("AUU",Amino.ILE),AUC("AUC",Amino.ILE),AUA("AUA",Amino.ILE),AUG("AUG",Amino.MET), | |
GUU("GUU",Amino.VAL),GUC("GUC",Amino.VAL),GUA("GUA",Amino.VAL),GUG("GUG",Amino.VAL),UCU("UCU",Amino.SER),UCC("UCC",Amino.SER), | |
UCA("UCA",Amino.SER),UCG("UCG",Amino.SER),CCU("CCU",Amino.PRO),CCC("CCC",Amino.PRO),CCA("CCA",Amino.PRO),CCG("CCG",Amino.PRO), | |
ACU("ACU",Amino.THR),ACC("ACC",Amino.THR),ACA("ACA",Amino.THR),ACG("ACG",Amino.THR),GCU("GCU",Amino.ALA),GCC("GCC",Amino.ALA), | |
GCA("GCA",Amino.ALA),GCG("GCG",Amino.ALA),UAU("UAU",Amino.TYR),UAC("UAC",Amino.TYR),UAA("UAA",Amino.STP),UAG("UAG",Amino.STP), | |
CAU("CAU",Amino.HIS),CAC("CAC",Amino.HIS),CAA("CAA",Amino.GLN),CAG("CAG",Amino.GLN),AAU("AAU",Amino.ASN),AAC("AAC",Amino.ASN), | |
AAA("AAA",Amino.LYS),AAG("AAG",Amino.LYS),GAU("GAU",Amino.ASP),GAC("GAC",Amino.ASP),GAA("GAA",Amino.GLU),GAG("GAG",Amino.GLU), | |
UGU("UGU",Amino.CYS),UGC("UGC",Amino.CYS),UGA("UGA",Amino.STP),UGG("UGG",Amino.TRP),CGU("CGU",Amino.ARG),CGC("CGC",Amino.ARG), | |
CGA("CGA",Amino.ARG),CGG("CGG",Amino.ARG),AGU("AGU",Amino.SER),AGC("AGC",Amino.SER),AGA("AGA",Amino.ARG),AGG("AGG",Amino.ARG), | |
GGU("GGU",Amino.GLY),GGC("GGC",Amino.GLY),GGA("GGA",Amino.GLY),GGG("GGG",Amino.GLY), | |
UNKNOWN("Unknown",Amino.UNKNOWN); | |
/** | |
* The RNA's amino acid & name. | |
*/ | |
private String name; | |
private Amino amino; | |
/** | |
* The set of RNAs addressed by abbreviations. | |
*/ | |
//private static final Map<String, RNA> RNAS_BY_NAME = new HashMap<String, RNA>(); | |
private static final Map<Amino, RNA> RNAS_BY_AMINO = new HashMap<Amino, RNA>(); | |
/* static initializer */ | |
static { | |
for (RNA RNA : values()) { | |
RNAS_BY_AMINO.put(RNA.getAmino(), RNA); | |
} | |
} | |
/** | |
* Constructs a new RNA. | |
* | |
* @param the Amino Acid's name. | |
*/ | |
RNA(String name, Amino amino) { | |
this.name = name; | |
this.amino = amino; | |
} | |
/** | |
* Returns the RNA's abbreviation. | |
* | |
* @return the RNA's abbreviation. | |
*/ | |
public Amino getAmino() { | |
return amino; | |
} | |
public String getName() { | |
return name; | |
} | |
/** | |
* Gets the enum constant with the specified abbreviation. | |
* | |
* @param abbr the RNA's aminos. | |
* @return the enum constant with the specified amino. | |
* @throws SunlightException if the abbreviation is invalid. | |
*/ | |
public static RNA valueOfAmino(final Amino amino) { | |
final RNA RNA = RNAS_BY_AMINO.get(amino); | |
if (RNA != null) { | |
return RNA; | |
} else { | |
return UNKNOWN; | |
} | |
} | |
public static RNA valueOfName(final String name) { | |
final String enumName = name.toUpperCase().replaceAll(" ", "_"); | |
try { | |
return valueOf(enumName); | |
} catch (final IllegalArgumentException e) { | |
return RNA.UNKNOWN; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment