Beispiel #1
0
        public static Protease FindOrCreateProtease(
            string name,
            bool endoProtease,
            string cleaveRes,
            string notCleaveRes)
        {
            string newName = name;
            int    count   = 1;

            while (Registered(newName))
            {
                Protease p = GetProteaseByName(newName);
                if (p.IsEndoProtease == endoProtease && p.CleaveageResidues.Equals(cleaveRes) &&
                    p.NotCleaveResidues.Equals(notCleaveRes))
                {
                    return(p);
                }

                newName = name + "_" + count;
                count++;
            }

            var result = new Protease(newName, endoProtease, cleaveRes, notCleaveRes);

            RegisterProtease(result);
            return(result);
        }
        public void TestGetNumProteaseTermini()
        {
            Protease trypsin = new Protease("Trypsin", true, "KR", "P");

            Assert.AreEqual(0, trypsin.GetNumProteaseTermini('M', "ABCDE", 'N', '-', 3));
            Assert.AreEqual(1, trypsin.GetNumProteaseTermini('M', "ABCDE", 'N', '-', 2));
            Assert.AreEqual(2, trypsin.GetNumProteaseTermini('M', "ABCDR", 'N', '-', 2));
        }
Beispiel #3
0
        /**
         * Creates and registers a new Protease. In future the Protease can be recovered
         * using the getProteaseByName() method.
         * @param name the name of the Protease
         * @param endoProtease is it an endo protease?
         * @param cleaveRes the cleavege residues
         * @param notCleaveRes the exceptions to the cleavage residues
         * @return a reference to the new Protease
         * @throws IllegalSymbolException if the cleaveRes or notCleaveRes are not
         * from the PROTEIN alphabet
         * @throws BioException if a Protease with the same name already exists.
         */

        public static Protease CreateProtease(
            string name,
            bool endoProtease,
            string cleaveRes,
            string notCleaveRes)
        {
            var p = new Protease(name, endoProtease, cleaveRes, notCleaveRes);

            RegisterProtease(p);
            return(p);
        }
        public void TestIsCleavageSite()
        {
            Protease trypsin = new Protease("Trypsin", true, "KR", "P");

            Assert.AreEqual(true, trypsin.IsCleavageSite('K', 'A', '-'));
            Assert.AreEqual(true, trypsin.IsCleavageSite('R', 'A', '-'));
            Assert.AreEqual(true, trypsin.IsCleavageSite('K', '-', '-'));
            Assert.AreEqual(true, trypsin.IsCleavageSite('R', '-', '-'));
            Assert.AreEqual(false, trypsin.IsCleavageSite('K', 'P', '-'));
            Assert.AreEqual(false, trypsin.IsCleavageSite('R', 'P', '-'));
            Assert.AreEqual(false, trypsin.IsCleavageSite('N', 'A', '-'));
        }
Beispiel #5
0
        /**
         * Registers a protease and ensures its flyweight status
         * @param prot the Protease to register
         */
        public static void RegisterProtease(Protease protease)
        {
            var name = GetShortName(protease.Name);

            if (Registered(protease.Name))
            {
                throw new ArgumentException(
                          "A Protease has already been registered with the name "
                          + protease.Name, "protease");
            }
            name2Protease[name] = protease;
        }
        public void TestGetMissCleavageSiteCount()
        {
            Protease trypsin = new Protease("Trypsin", true, "KR", "P");

            Assert.AreEqual(0, trypsin.GetMissCleavageSiteCount("EGEABDR"));
            Assert.AreEqual(0, trypsin.GetMissCleavageSiteCount("EGEKPABDR"));
            Assert.AreEqual(0, trypsin.GetMissCleavageSiteCount("EGERPABDR"));
            Assert.AreEqual(1, trypsin.GetMissCleavageSiteCount("EGEKABDR"));
            Assert.AreEqual(1, trypsin.GetMissCleavageSiteCount("EGERABDR"));
            Assert.AreEqual(2, trypsin.GetMissCleavageSiteCount("EGEKARBDR"));

            Protease noenzyme = new Protease("Noenzyme", true, "", "");

            Assert.AreEqual(0, noenzyme.GetMissCleavageSiteCount("EGEABDR"));
        }
Beispiel #7
0
        public void TestLoadFromFile()
        {
            ProteaseManager.LoadFromFile(@TestContext.CurrentContext.TestDirectory + "/../../../data//proteases.xml");
            Assert.IsTrue(ProteaseManager.Registered("Trypsin"));
            Assert.IsTrue(ProteaseManager.Registered("Chymotrypsin"));
            Assert.IsTrue(ProteaseManager.Registered("LysC/P+AspC"));

            Assert.IsFalse(ProteaseManager.Registered("ProteaseNotExist"));

            Protease trypsin = ProteaseManager.GetProteaseByName("Trypsin");

            Assert.AreEqual("Trypsin", trypsin.Name);
            Assert.AreEqual(true, trypsin.IsEndoProtease);
            Assert.AreEqual("KR", trypsin.CleaveageResidues);
            Assert.AreEqual("P", trypsin.NotCleaveResidues);
        }
        private void Read(string filename)
        {
            this.dtaProteaseMap = new Dictionary <string, Protease>();

            using (var filein = new StreamReader(new FileStream(filename, FileMode.Open, FileAccess.Read)))
            {
                var    enzymeMap = new Dictionary <string, Protease>();
                string sline;
                while ((sline = filein.ReadLine()) != null && sline.Length > 0)
                {
                    Protease enzyme = ProteaseManager.ValueOf(sline);
                    string[] lines  = Regex.Split(sline, "\t");
                    enzymeMap[lines[0]] = enzyme;
                }

                while ((sline = filein.ReadLine()) != null)
                {
                    if (sline.StartsWith("DEFAULT_ENZYME"))
                    {
                        string[] lines = Regex.Split(sline, "\t");
                        this.defaultProtease = enzymeMap[lines[1]];
                        break;
                    }
                }

                while ((sline = filein.ReadLine()) != null)
                {
                    if (sline.Length == 0)
                    {
                        continue;
                    }

                    string[] lines = Regex.Split(sline, "\t");
                    if (lines.Length < 2)
                    {
                        break;
                    }

                    this.dtaProteaseMap[lines[0]] = enzymeMap[lines[1]];
                }
            }
        }