Exemple #1
0
        public override void TestClone()
        {
            IBioPolymer polymer = (IBioPolymer)NewChemObject();
            object      clone   = polymer.Clone();

            Assert.IsTrue(clone is IBioPolymer);
        }
Exemple #2
0
        public override void TestGetMonomerCount()
        {
            IBioPolymer oBioPolymer = (IBioPolymer)NewChemObject();

            Assert.AreEqual(0, oBioPolymer.GetMonomerMap().Count());

            IStrand oStrand1 = oBioPolymer.Builder.NewStrand();

            oStrand1.StrandName = "A";
            IStrand oStrand2 = oBioPolymer.Builder.NewStrand();

            oStrand2.StrandName = "B";
            IMonomer oMono1 = oBioPolymer.Builder.NewMonomer();

            oMono1.MonomerName = "TRP279";
            IMonomer oMono2 = oBioPolymer.Builder.NewMonomer();

            oMono2.MonomerName = "HOH";
            IAtom oAtom1 = oBioPolymer.Builder.NewAtom("C");
            IAtom oAtom2 = oBioPolymer.Builder.NewAtom("C");
            IAtom oAtom3 = oBioPolymer.Builder.NewAtom("C");

            oBioPolymer.Atoms.Add(oAtom1);
            oBioPolymer.AddAtom(oAtom2, oMono1, oStrand1);
            oBioPolymer.AddAtom(oAtom3, oMono2, oStrand2);
            Assert.IsNotNull(oBioPolymer.Atoms[0]);
            Assert.IsNotNull(oBioPolymer.Atoms[1]);
            Assert.IsNotNull(oBioPolymer.Atoms[2]);
            Assert.AreEqual(oAtom1, oBioPolymer.Atoms[0]);
            Assert.AreEqual(oAtom2, oBioPolymer.Atoms[1]);
            Assert.AreEqual(oAtom3, oBioPolymer.Atoms[2]);

            Assert.AreEqual(2, oBioPolymer.GetMonomerMap().Count());
        }
Exemple #3
0
        public virtual void TestGetStrands()
        {
            IBioPolymer oBioPolymer = (IBioPolymer)NewChemObject();
            IStrand     oStrand1    = oBioPolymer.Builder.NewStrand();
            IStrand     oStrand2    = oBioPolymer.Builder.NewStrand();

            oStrand1.StrandName = "A";
            oStrand2.StrandName = "B";
            IMonomer oMono1 = oBioPolymer.Builder.NewMonomer();

            oMono1.MonomerName = "TRP279";
            IMonomer oMono2 = oBioPolymer.Builder.NewMonomer();

            oMono2.MonomerName = "GLY123";
            IAtom oAtom1 = oBioPolymer.Builder.NewAtom("C");
            IAtom oAtom2 = oBioPolymer.Builder.NewAtom("C");

            oBioPolymer.AddAtom(oAtom1, oMono1, oStrand1);
            oBioPolymer.AddAtom(oAtom2, oMono2, oStrand2);
            IDictionary <string, IStrand> strands = new Dictionary <string, IStrand>
            {
                { "A", oStrand1 },
                { "B", oStrand2 }
            };

            Assert.IsTrue(Compares.AreDeepEqual(strands, oBioPolymer.GetStrandMap()));
        }
Exemple #4
0
        public void TestNewBioPolymer()
        {
            IChemObjectBuilder builder = RootObject.Builder;
            IBioPolymer        polymer = builder.NewBioPolymer();

            Assert.IsNotNull(polymer);
        }
Exemple #5
0
        public virtual void TestGetMonomer_String_String()
        {
            IBioPolymer oBioPolymer = (IBioPolymer)NewChemObject();

            IStrand oStrand1 = oBioPolymer.Builder.NewStrand();

            oStrand1.StrandName = "A";
            IStrand oStrand2 = oBioPolymer.Builder.NewStrand();

            oStrand2.StrandName = "B";
            IMonomer oMono1 = oBioPolymer.Builder.NewMonomer();

            oMono1.MonomerName = "TRP279";
            IMonomer oMono2 = oBioPolymer.Builder.NewMonomer();

            oMono2.MonomerName = "HOH";
            IAtom oAtom1 = oBioPolymer.Builder.NewAtom("C");
            IAtom oAtom2 = oBioPolymer.Builder.NewAtom("C");
            IAtom oAtom3 = oBioPolymer.Builder.NewAtom("C");

            oBioPolymer.AddAtom(oAtom1, oMono1, oStrand1);
            oBioPolymer.AddAtom(oAtom2, oMono1, oStrand1);
            oBioPolymer.AddAtom(oAtom3, oMono2, oStrand2);

            Assert.AreEqual(oMono1, oBioPolymer.GetMonomer("TRP279", "A"));
            Assert.AreEqual(oMono2, oBioPolymer.GetMonomer("HOH", "B"));
        }
Exemple #6
0
        public override void TestToString()
        {
            IBioPolymer bp          = (IBioPolymer)NewChemObject();
            string      description = bp.ToString();

            for (int i = 0; i < description.Length; i++)
            {
                Assert.IsTrue('\n' != description[i]);
                Assert.IsTrue('\r' != description[i]);
            }
        }
Exemple #7
0
        public void TestCreateProtein()
        {
            IBioPolymer protein = ProteinBuilderTool.CreateProtein("GAGA", CDK.Builder);

            Assert.IsNotNull(protein);
            Assert.AreEqual(4, protein.GetMonomerMap().Count());
            Assert.AreEqual(1, protein.GetStrandMap().Count());
            Assert.AreEqual(18 + 1, protein.Atoms.Count);
            // 1=terminal oxygen
            Assert.AreEqual(14 + 3 + 1, protein.Bonds.Count);
            // 3 = extra back bone bonds, 1=bond to terminal oxygen
        }
        public void TestSFBug1085912_1()
        {
            string filename_pdb = "NCDK.Data.PDB.1CKV.pdb";
            var    ins1         = ResourceLoader.GetAsStream(this.GetType(), filename_pdb);

            ISimpleChemObjectReader reader = new PDBReader(ins1);
            IChemFile chemFile1            = (IChemFile)reader.Read(builder.NewChemFile());

            reader.Close();
            IChemSequence  seq1           = chemFile1[0];
            IChemModel     model1         = seq1[0];
            IAtomContainer container      = model1.MoleculeSet[0];
            IBioPolymer    polymer1       = (IBioPolymer)container;
            int            countchemFile1 = chemFile1.Count;
            int            countmodel1    = model1.MoleculeSet.Count;
            int            countpolymer1  = polymer1.Atoms.Count;

            StringWriter writer    = new StringWriter();
            CMLWriter    cmlWriter = new CMLWriter(writer);

            cmlWriter.RegisterCustomizer(new PDBAtomCustomizer());
            cmlWriter.Write(polymer1);
            cmlWriter.Close();
            string cmlContent1 = writer.ToString();

            CMLReader reader2  = new CMLReader(new MemoryStream(Encoding.UTF8.GetBytes(cmlContent1)));
            var       chemFil2 = reader2.Read(builder.NewChemFile());

            reader2.Close();
            IChemSequence seq2     = chemFil2[0];
            IChemModel    model2   = seq2[0];
            var           polymer2 = (IPDBPolymer)model2.MoleculeSet[0];

            int countchemFile2 = chemFil2.Count;
            int countmodel2    = model2.MoleculeSet.Count;
            int countpolymer2  = polymer2.Atoms.Count;

            Assert.AreEqual(countchemFile1, countchemFile2);
            Assert.AreEqual(countmodel1, countmodel2);
            Assert.AreEqual(countpolymer1, countpolymer2);

            writer    = new StringWriter();
            cmlWriter = new CMLWriter(writer);
            cmlWriter.RegisterCustomizer(new PDBAtomCustomizer());
            cmlWriter.Write(polymer2);
            cmlWriter.Close();
            string cmlContent2 = writer.ToString();

            string conte1 = cmlContent1.Substring(0, 1000);
            string conte2 = cmlContent2.Substring(0, 1000);

            Assert.AreEqual(conte1, conte2);
        }
 private static IBioPolymer AddAminoAcid(IBioPolymer protein, IAminoAcid aaToAdd, IStrand strand)
 {
     foreach (var atom in aaToAdd.Atoms)
     {
         protein.AddAtom(atom, aaToAdd, strand);
     }
     foreach (var bond in aaToAdd.Bonds)
     {
         protein.Bonds.Add(bond);
     }
     return(protein);
 }
Exemple #10
0
        public override void TestAddAtom_IAtom()
        {
            IBioPolymer oBioPolymer = (IBioPolymer)NewChemObject();

            IAtom oAtom1 = oBioPolymer.Builder.NewAtom("C");
            IAtom oAtom2 = oBioPolymer.Builder.NewAtom("C");

            oBioPolymer.Atoms.Add(oAtom1);
            oBioPolymer.Atoms.Add(oAtom2);

            Assert.AreEqual(2, oBioPolymer.Atoms.Count);
        }
 /// <summary>
 /// Builds a protein by connecting a new amino acid at the C-terminus of the
 /// given strand. The acidic oxygen of the added amino acid is removed so that
 /// additional amino acids can be added savely. But this also means that you
 /// might want to add an oxygen at the end of the protein building!
 /// </summary>
 /// <param name="protein">protein to which the strand belongs</param>
 /// <param name="aaToAdd">amino acid to add to the strand of the protein</param>
 /// <param name="strand">strand to which the protein is added</param>
 /// <param name="aaToAddTo"></param>
 public static IBioPolymer AddAminoAcidAtCTerminus(IBioPolymer protein, IAminoAcid aaToAdd, IStrand strand, IAminoAcid aaToAddTo)
 {
     // then add the amino acid
     AddAminoAcid(protein, aaToAdd, strand);
     // Now think about the protein back bone connection
     if (protein.GetMonomerMap().Any() && (aaToAddTo != null))
     {
         // make the connection between that aminoAcid's N-terminus and the
         // protein's C-terminus
         protein.Bonds.Add(aaToAdd.Builder.NewBond(aaToAddTo.CTerminus,
                                                   aaToAdd.NTerminus, BondOrder.Single));
     } // else : no current C-terminus, so nothing special to do
     return(protein);
 }
Exemple #12
0
        public virtual void TestGetStrand_String()
        {
            IBioPolymer oBioPolymer = (IBioPolymer)NewChemObject();
            IStrand     oStrand1    = oBioPolymer.Builder.NewStrand();

            oStrand1.StrandName = "A";
            IMonomer oMono1 = oBioPolymer.Builder.NewMonomer();

            oMono1.MonomerName = "TRP279";
            IAtom oAtom1 = oBioPolymer.Builder.NewAtom("C");

            oBioPolymer.AddAtom(oAtom1, oMono1, oStrand1);

            Assert.AreEqual(oStrand1, oBioPolymer.GetStrand("A"));
        }
Exemple #13
0
        public virtual void TestAddAtom_IAtom_IMonomer_IStrand()
        {
            IBioPolymer oBioPolymer = (IBioPolymer)NewChemObject();
            IStrand     oStrand1    = oBioPolymer.Builder.NewStrand();

            oStrand1.StrandName = "A";
            IMonomer oMono1 = oBioPolymer.Builder.NewMonomer();

            oMono1.MonomerName = "TRP279";
            IAtom oAtom1 = oBioPolymer.Builder.NewAtom("C");
            IAtom oAtom2 = oBioPolymer.Builder.NewAtom("C");

            oBioPolymer.AddAtom(oAtom1, oMono1, oStrand1);
            oBioPolymer.AddAtom(oAtom2, oMono1, oStrand1);
            oBioPolymer.AddAtom(oAtom1, null, oStrand1);

            Assert.AreEqual(2, oBioPolymer.GetMonomer("TRP279", "A").Atoms.Count);
            Assert.AreEqual(0, oBioPolymer.GetMonomer("", "A").Atoms.Count);
        }
Exemple #14
0
        public virtual void TestRemoveStrand_String()
        {
            IBioPolymer oBioPolymer = (IBioPolymer)NewChemObject();
            IStrand     oStrand1    = oBioPolymer.Builder.NewStrand();

            oStrand1.StrandName = "A";
            IMonomer oMono1 = oBioPolymer.Builder.NewMonomer();

            oMono1.MonomerName = "TRP279";
            IAtom oAtom1 = oBioPolymer.Builder.NewAtom("C");

            oBioPolymer.AddAtom(oAtom1, oMono1, oStrand1);

            Assert.IsTrue(oBioPolymer.GetStrandNames().Contains(oStrand1.StrandName));
            Assert.AreEqual(1, oBioPolymer.Atoms.Count);
            oBioPolymer.RemoveStrand("A");
            Assert.IsFalse(oBioPolymer.GetStrandNames().Contains(oStrand1.StrandName));
            Assert.AreEqual(0, oBioPolymer.Atoms.Count);
        }
        private static List <IMonomer> GetMonomers(IBioPolymer iBioPolymer)
        {
            var monomList = new List <IMonomer>();

            var strands    = iBioPolymer.GetStrandMap();
            var strandKeys = strands.Keys;

            foreach (var key in strandKeys)
            {
                var aStrand = strands[key];
                var tmp     = aStrand.GetMonomerMap();
                var keys    = tmp.Keys;
                foreach (var o1 in keys)
                {
                    monomList.Add(tmp[o1]);
                }
            }

            return(monomList);
        }
        /// <summary>
        /// Calculates the 147 TAE descriptors for amino acids.
        /// </summary>
        /// <returns>The 147 TAE descriptors</returns>
        public Result Calculate(IBioPolymer container)
        {
            container = (IBioPolymer)container.Clone(); // don't mod original

            var peptide = container;

            // I assume that we get single letter names
            var desc = new double[ndesc];

            for (int i = 0; i < ndesc; i++)
            {
                desc[i] = 0.0;
            }

            var monomers = GetMonomers(peptide);

            foreach (var monomer in monomers)
            {
                string o = monomer.MonomerName;

                if (o.Length == 0)
                {
                    continue;
                }

                var olc = o.Substring(0, 1).ToUpperInvariant();
                var tlc = AminoAcids.ConvertOneLetterCodeToThreeLetterCode(olc).ToLowerInvariant();

                Debug.WriteLine($"Converted {olc} to {tlc}");

                // get the params for this AA
                var parameters = taeParams[tlc];

                for (int i = 0; i < ndesc; i++)
                {
                    desc[i] += parameters[i];
                }
            }

            return(new Result(desc));
        }
Exemple #17
0
        private bool createBondsWithRebondTool(IBioPolymer pol)
        {
            RebondTool tool = new RebondTool(2.0, 0.5, 0.5);

            try
            {
                //			 configure atoms
                AtomTypeFactory factory = AtomTypeFactory.getInstance("jmol_atomtypes.txt", pol.Builder);
                IAtom[]         atoms   = pol.Atoms;
                for (int i = 0; i < atoms.Length; i++)
                {
                    try
                    {
                        IAtomType[] types = factory.getAtomTypes(atoms[i].Symbol);
                        if (types.Length > 0)
                        {
                            // just pick the first one
                            AtomTypeManipulator.configure(atoms[i], types[0]);
                        }
                        else
                        {
                            System.Console.Out.WriteLine("Could not configure atom with symbol: " + atoms[i].Symbol);
                        }
                    }
                    catch (System.Exception e)
                    {
                        //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'"
                        System.Console.Out.WriteLine("Could not configure atom (but don't care): " + e.Message);
                        //logger.debug(e);
                    }
                }
                tool.rebond(pol);
            }
            catch (System.Exception e)
            {
                //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("Could not rebond the polymer: " + e.Message);
                //logger.debug(e);
            }
            return(true);
        }
Exemple #18
0
        /// <summary> Create bonds when reading a protein PDB file. NB ONLY works for protein
        /// PDB files! If you want to read small molecules I recommend using molecule
        /// file format where the connectivity is explicitly stated. [This method can
        /// however reasonably easily be extended to cover e.g. nucleic acids or your
        /// favourite small molecule]. Returns 'false' if bonds could not be created
        /// due to incomplete pdb-records or other reasons.
        ///
        /// </summary>
        /// <param name="pol">The Biopolymer to work on
        /// </param>
        public virtual bool createBonds(IBioPolymer pol)
        {
            //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'"
            System.Collections.Hashtable AAs = AminoAcids.HashMapByThreeLetterCode;
            int[][] AABondInfo = AminoAcids.aaBondInfo();
            System.Collections.Hashtable   strands    = pol.Strands;
            System.Collections.IEnumerator strandKeys = strands.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 (strandKeys.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'"
                IStrand strand                = (IStrand)strands[strandKeys.Current];
                int     atoms                 = 0;
                int     atomsInLastResidue    = 0;
                int     atomsInPresentResidue = 0;

                while (atoms < strand.AtomCount - 1)
                {
                    PDBAtom anAtom = (PDBAtom)strand.getAtomAt(atoms);

                    // Check that we have bond info about residue/ligand, if not - exit.
                    if (!AAs.ContainsKey(anAtom.ResName))
                    {
                        return(false);
                    }
                    //UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'"
                    IMonomer monomer = (IMonomer)AAs[anAtom.ResName];

                    atomsInPresentResidue = System.Int32.Parse((string)monomer.getProperty(AminoAcids.NO_ATOMS));

                    /* Check if there's something wrong with the residue record (e.g. it doesn't contain the
                     * correct number of atom records). */
                    int counter = 1;
                    while (atoms + counter < strand.AtomCount && anAtom.ResName.Equals(strand.getAtomAt(atoms + counter).getProperty(AminoAcids.RESIDUE_NAME)))
                    {
                        counter++;
                    }
                    // Check if something is wrong. Remember to deal with possible OXT atom...
                    if (counter % atomsInPresentResidue != 0 && (atoms + counter == strand.AtomCount && counter % atomsInPresentResidue != 1))
                    {
                        return(false);
                    }

                    // If nothing's wrong, add bonds
                    int bondID = System.Int32.Parse((string)monomer.getProperty(AminoAcids.ID));
                    for (int l = 0; l < System.Int32.Parse((string)monomer.getProperty(AminoAcids.NO_BONDS)); l++)
                    {
                        IBond bond = pol.Builder.newBond(strand.getAtomAt(AABondInfo[bondID + l][1] + atoms), strand.getAtomAt(AABondInfo[bondID + l][2] + atoms), (double)(AABondInfo[bondID + l][3]));
                        pol.addBond(bond);
                    }

                    // If not first residue, connect residues
                    if (atomsInLastResidue != 0)
                    {
                        IBond bond = pol.Builder.newBond(strand.getAtomAt(atoms - atomsInLastResidue + 2), strand.getAtomAt(atoms), 1);
                        pol.addBond(bond);
                    }

                    atoms = atoms + atomsInPresentResidue;
                    atomsInLastResidue = atomsInPresentResidue;

                    // Check if next atom is an OXT. The reason to why this is seemingly overly complex is because
                    // not all PDB-files have ending OXT. If that were the case you could just check if
                    // atoms == mol.getAtomCount()...
                    if (strand.AtomCount < atoms && ((PDBAtom)strand.getAtomAt(atoms)).Oxt)
                    {
                        //				if(strand.getAtomCount() < atoms && ((String)strand.getAtomAt(atoms).getProperty("oxt")).equals("1"))	{
                        IBond bond = pol.Builder.newBond(strand.getAtomAt(atoms - atomsInLastResidue + 2), strand.getAtomAt(atoms), 1);
                        pol.addBond(bond);
                    }
                }
            }
            return(true);
        }
Exemple #19
0
 private bool createBondsWithRebondTool(IBioPolymer pol)
 {
     RebondTool tool = new RebondTool(2.0, 0.5, 0.5);
     try
     {
         //			 configure atoms
         AtomTypeFactory factory = AtomTypeFactory.getInstance("jmol_atomtypes.txt", pol.Builder);
         IAtom[] atoms = pol.Atoms;
         for (int i = 0; i < atoms.Length; i++)
         {
             try
             {
                 IAtomType[] types = factory.getAtomTypes(atoms[i].Symbol);
                 if (types.Length > 0)
                 {
                     // just pick the first one
                     AtomTypeManipulator.configure(atoms[i], types[0]);
                 }
                 else
                 {
                     System.Console.Out.WriteLine("Could not configure atom with symbol: " + atoms[i].Symbol);
                 }
             }
             catch (System.Exception e)
             {
                 //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'"
                 System.Console.Out.WriteLine("Could not configure atom (but don't care): " + e.Message);
                 //logger.debug(e);
             }
         }
         tool.rebond(pol);
     }
     catch (System.Exception e)
     {
         //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("Could not rebond the polymer: " + e.Message);
         //logger.debug(e);
     }
     return true;
 }
Exemple #20
0
        /// <summary> Create bonds when reading a protein PDB file. NB ONLY works for protein
        /// PDB files! If you want to read small molecules I recommend using molecule
        /// file format where the connectivity is explicitly stated. [This method can
        /// however reasonably easily be extended to cover e.g. nucleic acids or your
        /// favourite small molecule]. Returns 'false' if bonds could not be created
        /// due to incomplete pdb-records or other reasons. 
        /// 
        /// </summary>
        /// <param name="pol">The Biopolymer to work on
        /// </param>
        public virtual bool createBonds(IBioPolymer pol)
        {
            //UPGRADE_TODO: Class 'java.util.HashMap' was converted to 'System.Collections.Hashtable' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMap'"
            System.Collections.Hashtable AAs = AminoAcids.HashMapByThreeLetterCode;
            int[][] AABondInfo = AminoAcids.aaBondInfo();
            System.Collections.Hashtable strands = pol.Strands;
            System.Collections.IEnumerator strandKeys = strands.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 (strandKeys.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'"
                IStrand strand = (IStrand)strands[strandKeys.Current];
                int atoms = 0;
                int atomsInLastResidue = 0;
                int atomsInPresentResidue = 0;

                while (atoms < strand.AtomCount - 1)
                {
                    PDBAtom anAtom = (PDBAtom)strand.getAtomAt(atoms);

                    // Check that we have bond info about residue/ligand, if not - exit.
                    if (!AAs.ContainsKey(anAtom.ResName))
                    {
                        return false;
                    }
                    //UPGRADE_TODO: Method 'java.util.HashMap.get' was converted to 'System.Collections.Hashtable.Item' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilHashMapget_javalangObject'"
                    IMonomer monomer = (IMonomer)AAs[anAtom.ResName];

                    atomsInPresentResidue = System.Int32.Parse((string)monomer.getProperty(AminoAcids.NO_ATOMS));

                    /* Check if there's something wrong with the residue record (e.g. it doesn't contain the
                    * correct number of atom records). */
                    int counter = 1;
                    while (atoms + counter < strand.AtomCount && anAtom.ResName.Equals(strand.getAtomAt(atoms + counter).getProperty(AminoAcids.RESIDUE_NAME)))
                    {
                        counter++;
                    }
                    // Check if something is wrong. Remember to deal with possible OXT atom...
                    if (counter % atomsInPresentResidue != 0 && (atoms + counter == strand.AtomCount && counter % atomsInPresentResidue != 1))
                    {
                        return false;
                    }

                    // If nothing's wrong, add bonds
                    int bondID = System.Int32.Parse((string)monomer.getProperty(AminoAcids.ID));
                    for (int l = 0; l < System.Int32.Parse((string)monomer.getProperty(AminoAcids.NO_BONDS)); l++)
                    {
                        IBond bond = pol.Builder.newBond(strand.getAtomAt(AABondInfo[bondID + l][1] + atoms), strand.getAtomAt(AABondInfo[bondID + l][2] + atoms), (double)(AABondInfo[bondID + l][3]));
                        pol.addBond(bond);
                    }

                    // If not first residue, connect residues
                    if (atomsInLastResidue != 0)
                    {
                        IBond bond = pol.Builder.newBond(strand.getAtomAt(atoms - atomsInLastResidue + 2), strand.getAtomAt(atoms), 1);
                        pol.addBond(bond);
                    }

                    atoms = atoms + atomsInPresentResidue;
                    atomsInLastResidue = atomsInPresentResidue;

                    // Check if next atom is an OXT. The reason to why this is seemingly overly complex is because
                    // not all PDB-files have ending OXT. If that were the case you could just check if
                    // atoms == mol.getAtomCount()...
                    if (strand.AtomCount < atoms && ((PDBAtom)strand.getAtomAt(atoms)).Oxt)
                    {
                        //				if(strand.getAtomCount() < atoms && ((String)strand.getAtomAt(atoms).getProperty("oxt")).equals("1"))	{
                        IBond bond = pol.Builder.newBond(strand.getAtomAt(atoms - atomsInLastResidue + 2), strand.getAtomAt(atoms), 1);
                        pol.addBond(bond);
                    }
                }
            }
            return true;
        }
 IDescriptorResult IBioPolymerDescriptor.Calculate(IBioPolymer mol) => Calculate(mol);
Exemple #22
0
 public ProteinPocketFinder(IBioPolymer protein, double[][][] grid)
 {
     this.Protein       = protein;
     this.Grid          = grid;
     gridGenerator.Grid = grid;
 }