#pragma warning disable CA1810 // Initialize reference type static fields inline static AminoAcids() #pragma warning restore CA1810 // Initialize reference type static fields inline { // Create set of AtomContainers proteinogenics = new IAminoAcid[20]; #region Create proteinogenics { IChemFile list = CDK.Builder.NewChemFile(); using (var reader = new CMLReader(ResourceLoader.GetAsStream("NCDK.Templates.Data.list_aminoacids.cml"))) { try { list = (IChemFile)reader.Read(list); var containersList = ChemFileManipulator.GetAllAtomContainers(list); int counter = 0; foreach (var ac in containersList) { Debug.WriteLine($"Adding AA: {ac}"); // convert into an AminoAcid var aminoAcid = CDK.Builder.NewAminoAcid(); foreach (var next in ac.GetProperties().Keys) { Debug.WriteLine("Prop: " + next.ToString()); if (next is DictRef dictRef) { // Debug.WriteLine("DictRef type: " + dictRef.Type}"); if (string.Equals(dictRef.Type, "pdb:residueName", StringComparison.Ordinal)) { aminoAcid.SetProperty(ResidueNameKey, ac.GetProperty <string>(next).ToUpperInvariant()); aminoAcid.MonomerName = ac.GetProperty <string>(next); } else if (string.Equals(dictRef.Type, "pdb:oneLetterCode", StringComparison.Ordinal)) { aminoAcid.SetProperty(ResidueNameShortKey, ac.GetProperty <string>(next)); } else if (string.Equals(dictRef.Type, "pdb:id", StringComparison.Ordinal)) { aminoAcid.SetProperty(IdKey, ac.GetProperty <string>(next)); Debug.WriteLine($"Set AA ID to: {ac.GetProperty<string>(next)}"); } else { Trace.TraceError("Cannot deal with dictRef!"); } } } foreach (var atom in ac.Atoms) { string dictRef = atom.GetProperty <string>("org.openscience.cdk.dict"); switch (dictRef) { case "pdb:nTerminus": aminoAcid.AddNTerminus(atom); break; case "pdb:cTerminus": aminoAcid.AddCTerminus(atom); break; default: aminoAcid.Atoms.Add(atom); break; } } foreach (var bond in ac.Bonds) { aminoAcid.Bonds.Add(bond); } AminoAcidManipulator.RemoveAcidicOxygen(aminoAcid); aminoAcid.SetProperty(NoAtomsKey, "" + aminoAcid.Atoms.Count); aminoAcid.SetProperty(NoBoundsKey, "" + aminoAcid.Bonds.Count); if (counter < proteinogenics.Length) { proteinogenics[counter] = aminoAcid; } else { Trace.TraceError("Could not store AminoAcid! Array too short!"); } counter++; } } catch (Exception exception) { if (exception is CDKException | exception is IOException) { Trace.TraceError($"Failed reading file: {exception.Message}"); Debug.WriteLine(exception); } else { throw; } } } } #endregion int count = proteinogenics.Length; singleLetterCodeMap = new Dictionary <string, IAminoAcid>(count); threeLetterCodeMap = new Dictionary <string, IAminoAcid>(count); singleLetterToThreeLetter = new Dictionary <string, string>(count); threeLetterToSingleLetter = new Dictionary <string, string>(count); foreach (IAminoAcid aa in proteinogenics) { var single = aa.GetProperty <string>(ResidueNameShortKey); var three = aa.GetProperty <string>(ResidueNameKey); singleLetterCodeMap[single] = aa; threeLetterCodeMap[three] = aa; singleLetterToThreeLetter[single] = three; threeLetterToSingleLetter[three] = single; } }
/// <summary> Creates amino acid AminoAcid objects. /// /// </summary> /// <returns> aminoAcids, a HashMap containing the amino acids as AminoAcids. /// </returns> public static AminoAcid[] createAAs() { if (aminoAcids != null) { return(aminoAcids); } // Create set of AtomContainers aminoAcids = new AminoAcid[20]; IChemFile list = new ChemFile(); //UPGRADE_ISSUE: Method 'java.lang.ClassLoader.getResourceAsStream' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangClassLoader'" //UPGRADE_ISSUE: Method 'java.lang.Class.getClassLoader' was not converted. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1000_javalangClassgetClassLoader'" CMLReader reader = new CMLReader(Assembly.GetExecutingAssembly().GetManifestResourceStream("NuGenCDKSharp." + "list_aminoacids.cml"));//typeof(AminoAcids).getClassLoader().getResourceAsStream("data/templates/list_aminoacids.cml")); try { list = (IChemFile)reader.read(list); IAtomContainer[] containers = ChemFileManipulator.getAllAtomContainers(list); for (int i = 0; i < containers.Length; i++) { //logger.debug("Adding AA: ", containers[i]); // convert into an AminoAcid AminoAcid aminoAcid = new AminoAcid(); IAtom[] atoms = containers[i].Atoms; System.Collections.IEnumerator props = containers[i].Properties.Keys.GetEnumerator(); //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'" while (props.MoveNext()) { //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'" System.Object next = props.Current; //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Class.getName' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" //logger.debug("Prop class: " + next.GetType().FullName); //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" //logger.debug("Prop: " + next.ToString()); if (next is DictRef) { DictRef dictRef = (DictRef)next; // System.out.println("DictRef type: " + dictRef.getType()); if (dictRef.Type.Equals("pdb:residueName")) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Object.toString' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" aminoAcid.setProperty(RESIDUE_NAME, containers[i].getProperty(dictRef).ToString().ToUpper()); } else if (dictRef.Type.Equals("pdb:oneLetterCode")) { aminoAcid.setProperty(RESIDUE_NAME_SHORT, containers[i].getProperty(dictRef)); } else if (dictRef.Type.Equals("pdb:id")) { aminoAcid.setProperty(ID, containers[i].getProperty(dictRef)); //logger.debug("Set AA ID to: ", containers[i].getProperty(dictRef)); } else { //logger.error("Cannot deal with dictRef!"); } } } for (int atomCount = 0; atomCount < atoms.Length; atomCount++) { IAtom atom = atoms[atomCount]; System.String dictRef = (System.String)atom.getProperty("org.openscience.cdk.dict"); if (dictRef != null && dictRef.Equals("pdb:nTerminus")) { aminoAcid.addNTerminus(atom); } else if (dictRef != null && dictRef.Equals("pdb:cTerminus")) { aminoAcid.addCTerminus(atom); } else { aminoAcid.addAtom(atom); } } IBond[] bonds = containers[i].Bonds; for (int bondCount = 0; bondCount < bonds.Length; bondCount++) { aminoAcid.addBond(bonds[bondCount]); } AminoAcidManipulator.removeAcidicOxygen(aminoAcid); aminoAcid.setProperty(NO_ATOMS, "" + aminoAcid.AtomCount); aminoAcid.setProperty(NO_BONDS, "" + aminoAcid.getBondCount()); if (i < aminoAcids.Length) { aminoAcids[i] = aminoAcid; } else { //logger.error("Could not store AminoAcid! Array too short!"); } } } catch (System.Exception exception) { //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'" //logger.error("Failed reading file: ", exception.Message); //logger.debug(exception); } return(aminoAcids); }