Пример #1
0
 private void writeChemFile(IChemFile file)
 {
     IAtomContainer[] molecules = ChemFileManipulator.getAllAtomContainers(file);
     for (int i = 0; i < molecules.Length; i++)
     {
         try
         {
             bool[] isVisible = new bool[molecules[i].AtomCount];
             for (int k = 0; k < isVisible.Length; k++)
             {
                 isVisible[k] = true;
             }
             writeMolecule(file.Builder.newMolecule(molecules[i]), isVisible);
         }
         catch (System.Exception exc)
         {
         }
     }
 }
Пример #2
0
        /// <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);
        }