Ejemplo n.º 1
0
        public override void TestToString()
        {
            IAminoAcid m         = (IAminoAcid)NewChemObject();
            IAtom      nTerminus = m.Builder.NewAtom("N");

            m.AddNTerminus(nTerminus);
            string description = m.ToString();

            for (int i = 0; i < description.Length; i++)
            {
                Assert.IsTrue('\n' != description[i]);
                Assert.IsTrue('\r' != description[i]);
            }

            m = (IAminoAcid)NewChemObject();
            IAtom cTerminus = m.Builder.NewAtom("C");

            m.AddCTerminus(cTerminus);
            description = m.ToString();
            for (int i = 0; i < description.Length; i++)
            {
                Assert.IsTrue('\n' != description[i]);
                Assert.IsTrue('\r' != description[i]);
            }
        }
Ejemplo n.º 2
0
        public void TestNewAminoAcid()
        {
            IChemObjectBuilder builder = RootObject.Builder;
            IAminoAcid         aa      = builder.NewAminoAcid();

            Assert.IsNotNull(aa);
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Removes the singly bonded oxygen from the acid group of the AminoAcid.
        /// </summary>
        /// <param name="acid">AminoAcid from which to remove the oxygen</param>
        /// <exception cref="CDKException">when the C-terminus is not defined for the given AminoAcid</exception>
        public static void RemoveAcidicOxygen(IAminoAcid acid)
        {
            if (acid.CTerminus == null)
            {
                throw new CDKException("Cannot remove oxygen: C-terminus is not defined!");
            }

            var atomsToRemove = new List <IAtom>();

            // ok, look for the oxygen which is singly bonded
            foreach (var bond in acid.GetConnectedBonds(acid.CTerminus))
            {
                if (bond.Order == BondOrder.Single)
                {
                    for (int j = 0; j < bond.Atoms.Count; j++)
                    {
                        if (bond.Atoms[j].AtomicNumber.Equals(AtomicNumbers.O))
                        {
                            // yes, we found a singly bonded oxygen!
                            atomsToRemove.Add(bond.Atoms[j]);
                        }
                    }
                }
            }
            foreach (var atom in atomsToRemove)
            {
                acid.RemoveAtom(atom);
            }
        }
Ejemplo n.º 4
0
        /// <summary> Removes the singly bonded oxygen from the acid group of the AminoAcid.
        ///
        /// </summary>
        /// <param name="acid">AminoAcid from which to remove the oxygen
        /// </param>
        /// <throws>  CDKException when the C-terminus is not defined for the given AminoAcid  </throws>
        public static void removeAcidicOxygen(IAminoAcid acid)
        {
            if (acid.getCTerminus() == null)
            {
                throw new CDKException("Cannot remove oxygen: C-terminus is not defined!");
            }

            IBond[] bonds = acid.getConnectedBonds(acid.getCTerminus());
            // ok, look for the oxygen which is singly bonded
            for (int i = 0; i < bonds.Length; i++)
            {
                if (bonds[i].Order == CDKConstants.BONDORDER_SINGLE)
                {
                    IAtom[] atoms = bonds[i].getAtoms();
                    for (int j = 0; j < atoms.Length; j++)
                    {
                        if (atoms[j].Symbol.Equals("O"))
                        {
                            // yes, we found a singly bonded oxygen!
                            acid.removeAtomAndConnectedElectronContainers(atoms[j]);
                        }
                    }
                }
            }
        }
        /// <summary> Adds the singly bonded oxygen from the acid group of the AminoAcid.
        /// 
        /// </summary>
        /// <param name="acid">        AminoAcid to which to add the oxygen
        /// </param>
        /// <throws>  CDKException when the C-terminus is not defined for the given AminoAcid  </throws>
        public static void addAcidicOxygen(IAminoAcid acid)
        {
            if (acid.getCTerminus() == null)
                throw new CDKException("Cannot add oxygen: C-terminus is not defined!");

            acid.addBond(acid.Builder.newBond(acid.getCTerminus(), acid.Builder.newAtom("O"), CDKConstants.BONDORDER_SINGLE));
        }
Ejemplo n.º 6
0
        public virtual void TestAddNTerminus_IAtom()
        {
            IAminoAcid m         = (IAminoAcid)NewChemObject();
            IAtom      nTerminus = m.Builder.NewAtom("N");

            m.AddNTerminus(nTerminus);
            Assert.AreEqual(nTerminus, m.NTerminus);
        }
Ejemplo n.º 7
0
        /// <summary> Adds the singly bonded oxygen from the acid group of the AminoAcid.
        ///
        /// </summary>
        /// <param name="acid">        AminoAcid to which to add the oxygen
        /// </param>
        /// <throws>  CDKException when the C-terminus is not defined for the given AminoAcid  </throws>
        public static void addAcidicOxygen(IAminoAcid acid)
        {
            if (acid.getCTerminus() == null)
            {
                throw new CDKException("Cannot add oxygen: C-terminus is not defined!");
            }

            acid.addBond(acid.Builder.newBond(acid.getCTerminus(), acid.Builder.newAtom("O"), CDKConstants.BONDORDER_SINGLE));
        }
Ejemplo n.º 8
0
        public void TestRemoveAcidicOxygen_IAminoAcid()
        {
            IAminoAcid glycine = builder.NewAminoAcid();

            glycine.Add(CDK.SmilesParser.ParseSmiles("C(C(=O)O)N"));
            Assert.AreEqual(5, glycine.Atoms.Count);
            glycine.AddCTerminus(glycine.Atoms[1]);
            AminoAcidManipulator.RemoveAcidicOxygen(glycine);
            Assert.AreEqual(4, glycine.Atoms.Count);
        }
Ejemplo n.º 9
0
        public void TestAddAcidicOxygen_IAminoAcid()
        {
            // FIXME: I think this is the proper test, but it currently fails
            IAminoAcid glycine = builder.NewAminoAcid();

            glycine.Add(CDK.SmilesParser.ParseSmiles("C(C=O)N"));
            Assert.AreEqual(4, glycine.Atoms.Count);
            glycine.AddCTerminus(glycine.Atoms[1]);
            AminoAcidManipulator.AddAcidicOxygen(glycine);
            Assert.AreEqual(5, glycine.Atoms.Count);
        }
Ejemplo n.º 10
0
 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);
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Adds the singly bonded oxygen from the acid group of the AminoAcid.
        /// </summary>
        /// <param name="acid">AminoAcid to which to add the oxygen</param>
        /// <exception cref="CDKException">when the C-terminus is not defined for the given AminoAcid</exception>
        public static void AddAcidicOxygen(IAminoAcid acid)
        {
            if (acid.CTerminus == null)
            {
                throw new CDKException("Cannot add oxygen: C-terminus is not defined!");
            }

            IAtom acidicOxygen = acid.Builder.NewAtom("O");

            acid.Atoms.Add(acidicOxygen);
            acid.Bonds.Add(acid.Builder.NewBond(acid.CTerminus, acidicOxygen, BondOrder.Single));
        }
Ejemplo n.º 12
0
 /// <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);
 }
Ejemplo n.º 13
0
        /// <summary>
        /// Creates a BioPolymer from a sequence of amino acid as identified by a
        /// the sequence of their one letter codes. It uses the given <see cref="IChemObjectBuilder"/>
        /// to create a data model.
        /// </summary>
        /// <example>
        /// For example:
        /// <code>
        /// IBioPolymer protein = ProteinBuilderTool.CreateProtein("GAGA", Silent.ChemObjectBuilder.Instance);
        /// </code>
        /// </example>
        /// <seealso cref="CreateProtein(string)"/>
        public static IBioPolymer CreateProtein(string sequence, IChemObjectBuilder builder)
        {
            var        templates  = AminoAcids.MapBySingleCharCode;
            var        protein    = builder.NewBioPolymer();
            var        strand     = builder.NewStrand();
            IAminoAcid previousAA = null;

            for (int i = 0; i < sequence.Length; i++)
            {
                string aminoAcidCode = "" + sequence[i];
                Debug.WriteLine($"Adding AA: {aminoAcidCode}");
                if (string.Equals(aminoAcidCode, " ", StringComparison.Ordinal))
                {
                    // fine, just skip spaces
                }
                else
                {
                    IAminoAcid aminoAcid = templates[aminoAcidCode];
                    if (aminoAcid == null)
                    {
                        throw new CDKException("Cannot build sequence! Unknown amino acid: " + aminoAcidCode);
                    }
                    aminoAcid             = (IAminoAcid)aminoAcid.Clone();
                    aminoAcid.MonomerName = aminoAcidCode + i;
                    Debug.WriteLine($"protein: {protein}");
                    Debug.WriteLine($"strand: {strand}");
                    AddAminoAcidAtCTerminus(protein, aminoAcid, strand, previousAA);
                    previousAA = aminoAcid;
                }
            }
            // add the last oxygen of the protein
            var oxygen = builder.NewAtom("O");

            // ... to amino acid
            previousAA.Atoms.Add(oxygen);
            var bond = builder.NewBond(oxygen, previousAA.CTerminus, BondOrder.Single);

            previousAA.Bonds.Add(bond);
            // ... and to protein
            protein.AddAtom(oxygen, previousAA, strand);
            protein.Bonds.Add(bond);
            return(protein);
        }
Ejemplo n.º 14
0
        public static Protein ToProtein(ISequence <INucleobase> nucleobaseChain)
        {
            Debug.Assert(nucleobaseChain.Count % 3 == 0);

            var protein = new Protein();

            IEnumerator <INucleobase> enumerator = nucleobaseChain.GetEnumerator();

            while (enumerator.MoveNext())
            {
                INucleobase nb1 = enumerator.Current;
                enumerator.MoveNext();
                INucleobase nb2 = enumerator.Current;
                enumerator.MoveNext();
                INucleobase nb3 = enumerator.Current;

                IAminoAcid aa = ToAminoAcid(nb1, nb2, nb3);
                protein.Add(aa);
            }


            return(protein);
        }
Ejemplo n.º 15
0
        public RepeatedAcid(IAminoAcid aminoAcid, string times)
        {
            this.aminoAcid = aminoAcid;

            if (times.StartsWith("(") && times.EndsWith(")"))
            {
                string withoutBrackets = times.Substring(1, times.Length - 2);
                if (withoutBrackets.Contains(",")) //"(1,2)
                {
                    var numbers = withoutBrackets.Split(',');
                    from = int.Parse(numbers[0]);
                    to   = int.Parse(numbers[1]);
                }
                else // "(1)"
                {
                    to = from = int.Parse(withoutBrackets);
                }
            }
            else //""
            {
                from = to = 1;
            }
        }
Ejemplo n.º 16
0
        /// <summary> Removes the singly bonded oxygen from the acid group of the AminoAcid.
        /// 
        /// </summary>
        /// <param name="acid">AminoAcid from which to remove the oxygen
        /// </param>
        /// <throws>  CDKException when the C-terminus is not defined for the given AminoAcid  </throws>
        public static void removeAcidicOxygen(IAminoAcid acid)
        {
            if (acid.getCTerminus() == null)
                throw new CDKException("Cannot remove oxygen: C-terminus is not defined!");

            IBond[] bonds = acid.getConnectedBonds(acid.getCTerminus());
            // ok, look for the oxygen which is singly bonded
            for (int i = 0; i < bonds.Length; i++)
            {
                if (bonds[i].Order == CDKConstants.BONDORDER_SINGLE)
                {
                    IAtom[] atoms = bonds[i].getAtoms();
                    for (int j = 0; j < atoms.Length; j++)
                    {
                        if (atoms[j].Symbol.Equals("O"))
                        {
                            // yes, we found a singly bonded oxygen!
                            acid.removeAtomAndConnectedElectronContainers(atoms[j]);
                        }
                    }
                }
            }
        }
Ejemplo n.º 17
0
        public override void TestClone()
        {
            IAminoAcid aa    = (IAminoAcid)NewChemObject();
            object     clone = aa.Clone();

            Assert.IsTrue(clone is IAminoAcid);
            Assert.AreNotSame(aa, clone);

            aa = (IAminoAcid)NewChemObject();
            IAtom nTerminus = aa.Builder.NewAtom("N");

            aa.AddNTerminus(nTerminus);
            clone = aa.Clone();
            Assert.IsTrue(clone is IAminoAcid);
            Assert.AreNotSame(aa, clone);

            aa = (IAminoAcid)NewChemObject();
            IAtom cTerminus = aa.Builder.NewAtom("C");

            aa.AddCTerminus(cTerminus);
            clone = aa.Clone();
            Assert.IsTrue(clone is IAminoAcid);
            Assert.AreNotSame(aa, clone);
        }
Ejemplo n.º 18
0
        public virtual void TestGetNTerminus()
        {
            IAminoAcid m = (IAminoAcid)NewChemObject();

            Assert.IsNull(m.NTerminus);
        }
Ejemplo n.º 19
0
 public void AddVariableModification(IMass modificaiton, IAminoAcid aminoAcid)
 {
 }
Ejemplo n.º 20
0
 public void AddVariableModification(IMass modificaiton, IAminoAcid aminoAcid)
 {
 }