import exceptions

Syns ={
    '"|1-4-beta-D-Glucan|"' : "GLC",
    "1-4-beta-D-Glucan" : "GLC",
    '"|1-4-alpha-D-Glucan|"' : "GLC",
    "1-4-alpha-D-Glucan" : "GLC",
    "STARCH" : "GLC",
    "CELLULOSE" : "GLC",
    "XYLAN" : "XYLOSE",
    "L-glutamic acid" : "GLT",
    "glutamicacid":"GLT",
    "adenosine-phosphate" : "AMP",
    "glycine" : "GLY",
    "&alpha;-aminoglutaric acid" : "GLT",
    "glut" : "GLT",
    "L-methionine" : "MET",
    "tryptacin" : "TRP",
    "aspartate" : "L-ASPARTATE",
    "asparticacid" : "L-ASPARTATE",
    "guanosine-5'-monophosphate" : "GMP",
    "adenosine 5'-phosphate" : "AMP",
    "guanylic acid" : "GMP",
    "Arabinose":"ARABINOSE",
    "L-selenocysteine" : "L-SELENOCYSTEINE",
    "<I>N</I>-methyltryptophan" : "N-METHYLTRYPTOPHAN",
    "Cys" : "CYS",
    "&gamma;-hydroxyisoeugenol" : "CONIFERYL-ALCOHOL",
    "4-hydroxy-3-methoxycinnamyl alcohol" : "CONIFERYL-ALCOHOL",
    "<i>N</i>-carbamoyl-L-glutamate" : "N-CARBAMYL-L-GLUTAMATE",
    "deoxythymidylate" : "TMP",
    "aspartic acid &beta;-amide" : "ASN",
    "glumin" : "GLN",
    "carbamyl-aspartate" : "CARBAMYUL-L-ASPARTATE",
    "adenosine-monophosphate" : "AMP",
    "sinapyl-alcohol" : "SINAPYL-ALCOHOL",
    "guanosine-monophosphate" : "GMP",
    "(2S)-&alpha;-2-amino-4-methylvaleric acid" : "LEU",
    "<i>N</i>-carbamyl-L-glutamate" : "N-CARBAMYL-L-GLUTAMATE",
    "adenosine-5'-phosphate" : "AMP",
    "thymidylic acid" : "TMP",
    "lysine acid" : "LYS",
    "his" : "HIS",
    "L-Glutamate" : "GLT",
    "D" : "L-ASPARTATE",
    "L-valine" : "VAL",
    "H" : "HIS",
    "L" : "LEU",
    "glutaminic acid" : "GLT",
    "P" : "PRO",
    "Deoxythymidylic acid" : "TMP",
    "T" : "TMP",
    "valine" : "VAL",
    "L-leucine" : "LEU",
    "2-aminopentanedioic acid" : "GLT",
    "histidine" : "HIS",
    "carbamyul-aspartate" : "CARBAMYUL-L-ASPARTATE",
    "5'-adenylic acid" : "AMP",
    "Deoxythymidine 5'-phosphate" : "TMP",
    "thymidine-5'-phosphate" : "TMP",
    "guanosine-5'-phosphate" : "GMP",
    "adenylic acid" : "AMP",
    "cytidine-P" : "CMP",
    "glum" : "GLN",
    "thymidine-5'-monophosphate" : "TMP",
    "trp" : "TRP",
    "2-pyrrolidinecarboxylic acid" : "PRO",
    "&alpha;-amino-4-imidazoleproprionic acid" : "HIS",
    "alanine" : "L-ALPHA-ALANINE",
    "ser" : "SER",
    "phenylalanine" : "PHE",
    "(S)-&alpha;-amino-1H-imidazole-4-propanoic acid" : "HIS",
    "thymidine monophosphate" : "TMP",
    "L-tryptophan" : "TRP",
    "arg" : "ARG",
    "L-thr" : "THR",
    "carbamoyl-aspartate" : "CARBAMYUL-L-ASPARTATE",
    "proglumide" : "GLN",
    "<i>E</i>-coniferyl alcohol" : "CONIFERYL-ALCOHOL",
    "CMP" : "CMP",
    "L-ser" : "SER",
    "5'-Thymidylic acid" : "TMP",
    "uridylate" : "UMP",
    "L-aspartic acid" : "L-ASPARTATE",
    "Hexadecanoate (n-C16:0)" : "PALMITATE",
    "carbocysteine" : "CYS",
    "prol" : "PRO",
    "methionine" : "MET",
    "adenylate" : "AMP",
    "glutamine" : "GLN",
    "AMP" : "AMP",
    "L-threonine" : "THR",
    "1-amino-propane-1,3-dicarboxylic acid" : "GLT",
    "C" : "CMP",
    "asp" : "L-ASPARTATE",
    "L-ornithine" : "L-ORNITHINE",
    "G" : "GMP",
    "cytidine-5'-phosphate" : "CMP",
    "K" : "LYS",
    "2-amino-4-methylvaleric acid" : "LEU",
    "(-)-asparagine" : "ASN",
    "met" : "MET",
    "S" : "SER",
    "leu" : "LEU",
    "W" : "TRP",
    "5'-uridylic acid (8CI)(9CI)" : "UMP",
    "L-serine" : "SER",
    "&alpha;,&delta;-diaminovaleric acid" : "L-ORNITHINE",
    "L-lys" : "LYS",
    "ile" : "ILE",
    "gln" : "GLN",
    "coniferyl alcohol" : "CONIFERYL-ALCOHOL",
    "L-2,4-diamino-4-oxobutanoic acid" : "ASN",
    "gly" : "GLY",
    "uridine-monophosphate" : "UMP",
    "dTMP" : "TMP",
    "glt" : "GLT",
    "glu" : "GLT",
    "glyoxaline-5-alanine" : "HIS",
    "TMP" : "TMP",
    "2-aminoglutaramic acid" : "GLN",
    "L-methionine-(S)-S-oxide" : "CPD-8989",
    "iso-leucine" : "ILE",
    "isoleucine" : "ILE",
    "L-cysteine" : "CYS",
    "<i>N</i>-carbamoyl-L-aspartate" : "CARBAMYUL-L-ASPARTATE",
    "asparagine" : "ASN",
    "2-amino-5-guanidinovaleric acid" : "ARG",
    "hexadecanoate" : "PALMITATE",
    "cytidine-monophosphate" : "CMP",
    "5'-cytidylic acid" : "CMP",
    "glutacid" : "GLT",
    "(S)-2,4-diamino-4-oxobutanoic acid" : "ASN",
    "guanylate" : "GMP",
    "val" : "VAL",
    "thre" : "THR",
    "L-asparatamine" : "ASN",
    "agedoite" : "ASN",
    "2-amino-3-hydroxybutyric acid" : "THR",
    "UMP" : "UMP",
    "tyrosine" : "TYR",
    "&alpha;-aminosuccinamic acid" : "ASN",
    "(S)-asparagine" : "ASN",
    "L-&alpha;-alanine" : "L-ALPHA-ALANINE",
    "N-carbamoyl-L-aspartate" : "CARBAMYUL-L-ASPARTATE",
    "trofan" : "TRP",
    "F" : "PHE",
    "uridine-phosphate" : "UMP",
    "L-histidine" : "HIS",
    "arginine" : "ARG",
    "carbamyl-L-aspartate" : "CARBAMYUL-L-ASPARTATE",
    "L-glutamate" : "GLT",
    "L-phenylalanine" : "PHE",
    "R" : "ARG",
    "cytidylate" : "CMP",
    "V" : "VAL",
    "tryptophan" : "TRP",
    "2, 5-diaminovaleric acid" : "L-ORNITHINE",
    "GMP" : "GMP",
    "5'-UMP" : "UMP",
    "cytidine-phosphate" : "CMP",
    "5'-AMP" : "AMP",
    "glutamic acid 5-amide" : "GLN",
    "Ornithine" : "L-ORNITHINE",
    "cysteine" : "CYS",
    "altheine" : "ASN",
    "L-isoleucine" : "ILE",
    "cytidine-5'-monophosphate" : "CMP",
    "L-arginine" : "ARG",
    "asparagine acid" : "ASN",
    "aminoacetic acid" : "GLY",
    "guanosine-phosphate" : "GMP",
    "2-amino-3-indolylpropanic acid" : "TRP",
    "lys" : "LYS",
    "coniferol" : "CONIFERYL-ALCOHOL",
    "pro" : "PRO",
    "uridine-5'-monophosphate" : "UMP",
    "palmitate" : "PALMITATE",
    "guanosine monophosphate" : "GMP",
    "L-lysine" : "LYS",
    "L-proline" : "PRO",
    "seleno-cysteine" : "L-SELENOCYSTEINE",
    "4-(3-hydroxy-1-propenyl)-2-methoxyphenol" : "CONIFERYL-ALCOHOL",
    "glutamate" : "GLT",
    "lysine" : "LYS",
    "L-aspartate" : "L-ASPARTATE",
    "L-methionine-(R)-S-oxide" : "CPD-8990",
    "2, 5-diaminopentanoic acid" : "L-ORNITHINE",
    "L-tyrosine" : "TYR",
    "uridine-5'-phosphate" : "UMP",
    "leucine" : "LEU",
    "coumaryl-alcohol" : "COUMARYL-ALCOHOL",
    "L-asparagine" : "ASN",
    "5'-adenosine monophosphate" : "AMP",
    "L-glu" : "GLT",
    "proline" : "PRO",
    "serine" : "SER",
    "E" : "GLT",
    "cytidylic acid" : "CMP",
    "I" : "ILE",
    "M" : "MET",
    "L-&beta;-asparagine" : "ASN",
    "phe" : "PHE",
    "3-(4-hydroxy-3-methoxyphenyl)-2-propen-1-ol" : "CONIFERYL-ALCOHOL",
    "Q" : "GLN",
    "endophenyl" : "PHE",
    "U" : "UMP",
    "2,6-diaminohexanoic acid" : "LYS",
    "Y" : "TYR",
    "threonine" : "THR",
    "tyr" : "TYR",
    "thymidine-phosphate" : "TMP",
    "2, 5-diaminopentanoate" : "L-ORNITHINE",
    "adenosine 5'-monophosphate" : "AMP",
    "carbamyul-L-aspartate" : "CARBAMYUL-L-ASPARTATE",
    "L-glutamine" : "GLN",
    "thr" : "THR",
    "butanoic acid, 2,4-diamino-4-oxo-, (S)-" : "ASN",
    "(2S)-&alpha;-leucine" : "LEU",
    "Thymidylate" : "TMP",
    "palmitic acid" : "PALMITATE",
    "2-aminosuccinamic acid, L-" : "ASN",
    "2,4-diamino-4-oxobutanoic acid, (S)-" : "ASN",
    "L-alanine" : "L-ALPHA-ALANINE",
    "aspartic acid" : "L-ASPARTATE",
    "Cysteine" : "CYS",
    "Aspartate" : "ASP",
    "Asparagine" : "ASN",
    "Glutamate" : "GLU",
    "Glutamine" : "GLN",
    "Serine" : "SER",
    "Glycine" : "GLY",
    "Threonine" : "THR",
    "Histidine" : "HIS",
    "Alanine" : "ALA",
    "Tyrosine" : "TYR",
    "Arginine" : "ARG",
    "Valine" : "VAL",
    "Tryptophan" : "TRP",
    "Methionine" : "MET",
    "Phenylalannine" : "PHE",
    "Isoleucine" : "ILE",
    "Leucine" : "LEU",
    "Lysine" : "LYS",
    "ALA": "L-ALPHA-ALANINE",
    "ASP":  "L-ASPARTATE",
    "GLU": "GLT",
    "Glucose": "GLC",
    "|1-4-alpha-D-Glucan|":"GLC",
    "1-4-alpha-D-Glucan":"GLC",
    "x_Starch":"GLC",
    "NH4":"AMMONIUM",
    "NO3":"NITRATE",
    "SO4": "SULFATE",
    "SULPHATE": "SULFATE",
    "homoserine":"HOMO-SER",
    "ornithine":"L-ORNITHINE",
    "b-alanine":"B-ALANINE",
    "g-aminobutyricacid":"4-AMINO-BUTYRATE"
    
}

MolWts = {
    "DAMP" : 331.224 ,
    "DCMP" : 307.199 ,
    "DGMP" : 347.224 ,
    "TMP" : 322.211,
    "ILE" : 131.174,
    "UMP" : 324.183,
    "GLN" : 146.146,
    "L-ORNITHINE" : 132.162,
    "GLT" : 147.13,
    "CMP" : 323.199,
    "CYS" : 121.154,
    "HIS" : 154.148,
    "SER" : 105.093,
    "LYS" : 146.189,
    "PRO" : 115.132,
    "AMP" : 347.224,
    "N-CARBAMYL-L-GLUTAMATE" : 190.155,
    "ASN" : 132.119,
    "L-ASPARTATE" : 133.104,
    "VAL" : 117.147,
    "THR" : 119.12,
    "N-METHYLTRYPTOPHAN" : 218.255,
    "TRP" : 204.228,
    "GMP" : 363.223,
    "L-SELENOCYSTEINE" : 168.054,
    "CONIFERYL-ALCOHOL" : 180.203,
    "CARBAMYUL-L-ASPARTATE" : 176.129,
    "PALMITATE" : 256.428,
    "PHE" : 165.191,
    "MET" : 149.207,
    "COUMARYL-ALCOHOL" : 150.177,
    "SINAPYL-ALCOHOL" : 210.229,
    "LEU" : 131.174,
    "ARG" : 174.202,
    "L-ALPHA-ALANINE" : 89.094,
    "TYR" : 181.191,
    "GLY" :75.067,
    "GLC":180.157,
    "AMMONIUM":18.038,
    "NITRATE":62.005,
    "SULFATE":96.058,
    "HOMO-SER":119.12,
    "B-ALANINE":89.094,
    "ARABINOSE":150.131,
    "4-AMINO-BUTYRATE":103.121,
    "ARABINOSE" : 150.131,
    "LINOLEIC_ACID" : 280.45,
    "FUM":116.073,
    "SUCROSE":342.299,
    'ALPHA-GLUCOSE':180.157,
    "CIT":192.125,
    "MAL": 134.088,
    "4-AMINO-BUTYRATE":103.121,
    "SUC": 118.089,
    "XYLOSE" : 150.053
}

def Syn2Metacyc(met):
    if MolWts.has_key(met):
        return met
    return Syn2Metacyc(Syns[met])


def MolWt(Compound):

    if MolWts.has_key(Compound):
        return MolWts[Compound]
    if Syns.has_key(Compound):
        return MolWt(Syns[Compound])
    print Compound, "not found"

   
    
