Beispiel #1
0
        public void AddFastaFile(string fastaFilePath)
        {
            String databasePath = textPath.Text;

            Settings.Default.FastaDirectory = Path.GetDirectoryName(fastaFilePath);
            int duplicateSequenceCount = 0;

            using (var longWaitDlg = new LongWaitDlg {
                ProgressValue = 0
            })
            {
                try
                {
                    longWaitDlg.PerformWork(this, 0, progressMonitor =>
                    {
                        ProteomeDb proteomeDb = File.Exists(databasePath)
                            ? ProteomeDb.OpenProteomeDb(databasePath)
                            : ProteomeDb.CreateProteomeDb(databasePath);
                        using (proteomeDb)
                        {
                            using (var reader = File.OpenText(fastaFilePath))
                            {
                                IProgressStatus status = new ProgressStatus(longWaitDlg.Message);
                                proteomeDb.AddFastaFile(reader, progressMonitor, ref status, false, out duplicateSequenceCount);
                            }
                        }
                    });
                }
                catch (Exception x)
                {
                    var message = TextUtil.LineSeparate(string.Format(Resources.BuildBackgroundProteomeDlg_AddFastaFile_An_error_occurred_attempting_to_add_the_FASTA_file__0__,
                                                                      fastaFilePath), x.Message);
                    MessageDlg.ShowWithException(this, message, x);
                    return;
                }
            }

            string path = Path.GetFileName(fastaFilePath);

            if (path != null)
            {
                listboxFasta.Items.Add(path);
            }
            RefreshStatus();

            if (duplicateSequenceCount > 0)
            {
                MessageDlg.Show(this, string.Format(Resources.BuildBackgroundProteomeDlg_AddFastaFile_The_added_file_included__0__repeated_protein_sequences__Their_names_were_added_as_aliases_to_ensure_the_protein_list_contains_only_one_copy_of_each_sequence_, duplicateSequenceCount));
            }
        }
Beispiel #2
0
        public void AddFastaFile(string fastaFilePath)
        {
            String databasePath = textPath.Text;

            Settings.Default.FastaDirectory = Path.GetDirectoryName(fastaFilePath);
            using (var longWaitDlg = new LongWaitDlg {
                ProgressValue = 0
            })
            {
                var progressMonitor = new ProgressMonitor(longWaitDlg);
                try
                {
                    longWaitDlg.PerformWork(this, 0, () =>
                    {
                        ProteomeDb proteomeDb = File.Exists(databasePath)
                            ? ProteomeDb.OpenProteomeDb(databasePath)
                            : ProteomeDb.CreateProteomeDb(databasePath);
                        using (proteomeDb)
                        {
                            using (var reader = File.OpenText(fastaFilePath))
                            {
                                proteomeDb.AddFastaFile(reader, progressMonitor.UpdateProgress);
                            }
                        }
                    });
                }
                catch (Exception x)
                {
                    var message = TextUtil.LineSeparate(string.Format(Resources.BuildBackgroundProteomeDlg_AddFastaFile_An_error_occurred_attempting_to_add_the_FASTA_file__0__,
                                                                      fastaFilePath), x.Message);
                    MessageDlg.ShowWithException(this, message, x);
                    return;
                }
            }

            string path = Path.GetFileName(fastaFilePath);

            if (path != null)
            {
                listboxFasta.Items.Add(path);
            }
            RefreshStatus();
        }
Beispiel #3
0
        public void TestProteomeDb()
        {
            using (var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE))
            {
                string fastaPath  = testFilesDir.GetTestPath("high_ipi.Human.20060111.fasta");
                string protDbPath = testFilesDir.GetTestPath("test.protdb");

                using (ProteomeDb proteomeDb = ProteomeDb.CreateProteomeDb(protDbPath))
                {
                    IProgressStatus status = new ProgressStatus(string.Empty);
                    using (var reader = new StreamReader(fastaPath))
                    {
                        proteomeDb.AddFastaFile(reader, new SilentProgressMonitor(), ref status, true); // Delay indexing
                    }
                    // perform digestion
                    Digestion digestion         = proteomeDb.GetDigestion();
                    var       digestedProteins0 = digestion.GetProteinsWithSequence("EDGWVK");
                    Assert.IsTrue(digestedProteins0.Count >= 1);
                }
            }
        }
        public void TestProteomeDb()
        {
            using (var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE))
            {
                string fastaPath  = testFilesDir.GetTestPath("high_ipi.Human.20060111.fasta");
                string protDbPath = testFilesDir.GetTestPath("test.protdb");

                using (ProteomeDb proteomeDb = ProteomeDb.CreateProteomeDb(protDbPath))
                {
                    Enzyme trypsin = EnzymeList.GetDefault();
                    using (var reader = new StreamReader(fastaPath))
                    {
                        proteomeDb.AddFastaFile(reader, (msg, progress) => true);
                    }
                    // perform digestion
                    proteomeDb.Digest(new ProteaseImpl(trypsin), (msg, progress) => true);
                    Digestion digestion         = proteomeDb.GetDigestion(trypsin.Name);
                    var       digestedProteins0 = digestion.GetProteinsWithSequencePrefix("EDGWVK", 100);
                    Assert.IsTrue(digestedProteins0.Count >= 1);
                }
            }
        }
Beispiel #5
0
        public void TestProteomeDb()
        {
            using (var testFilesDir = new TestFilesDir(TestContext, ZIP_FILE))
            {
                string fastaPath  = testFilesDir.GetTestPath("high_ipi.Human.20060111.fasta");
                string protDbPath = testFilesDir.GetTestPath("test.protdb");

                using (ProteomeDb proteomeDb = ProteomeDb.CreateProteomeDb(protDbPath))
                {
                    Enzyme          trypsin = EnzymeList.GetDefault();
                    IProgressStatus status  = new ProgressStatus(string.Empty);
                    using (var reader = new StreamReader(fastaPath))
                    {
                        proteomeDb.AddFastaFile(reader, new SilentProgressMonitor(), ref status, true); // Delay indexing
                    }
                    // perform digestion
                    proteomeDb.Digest(new ProteaseImpl(trypsin), ProteomeDb.PROTDB_MAX_MISSED_CLEAVAGES, new SilentProgressMonitor(), ref status);
                    Digestion digestion         = proteomeDb.GetDigestion(trypsin.Name);
                    var       digestedProteins0 = digestion.GetProteinsWithSequencePrefix("EDGWVK", 100);
                    Assert.IsTrue(digestedProteins0.Count >= 1);
                }
            }
        }
Beispiel #6
0
        public void DoTestOlderProteomeDb(TestContext testContext, bool doActualWebAccess)
        {
            using (var testFilesDir = new TestFilesDir(testContext, ZIP_FILE))
            {
                string fastaPath  = testFilesDir.GetTestPath("tiny.fasta");
                string protDbPath = testFilesDir.GetTestPath("celegans_mini.protdb"); // a version 0 protdb file
                string blibPath   = testFilesDir.GetTestPath("random.blib");          // a bibliospec file

                // What happens when you try to open a random file as a protdb file?
                AssertEx.ThrowsException <DbException>(() => ProteomeDb.OpenProteomeDb(fastaPath));

                // What happens when you try to open a non-protdb database file as a protdb file?
                AssertEx.ThrowsException <FileLoadException>(() => ProteomeDb.OpenProteomeDb(blibPath));

                using (ProteomeDb proteomeDb = ProteomeDb.OpenProteomeDb(protDbPath))
                {
                    Assert.IsTrue(proteomeDb.GetSchemaVersionMajor() == 0); // the initial db from our zipfile should be ancient
                    Assert.IsTrue(proteomeDb.GetSchemaVersionMinor() == 0); // the initial db from our zipfile should be ancient
                    Assert.AreEqual(9, proteomeDb.GetProteinCount());

                    var protein = proteomeDb.GetProteinByName("Y18D10A.20");
                    Assert.IsNotNull(protein);
                    Assert.IsTrue(String.IsNullOrEmpty(protein.Accession)); // old db won't have this populated

                    WebEnabledFastaImporter searcher = new WebEnabledFastaImporter(doActualWebAccess ? null :new WebEnabledFastaImporter.FakeWebSearchProvider());
                    bool            searchComplete;
                    IProgressStatus status = new ProgressStatus(string.Empty);
                    Assert.IsTrue(proteomeDb.LookupProteinMetadata(new SilentProgressMonitor(), ref status, searcher, false, out searchComplete)); // add any missing protein metadata
                    Assert.IsTrue(searchComplete);

                    protein = proteomeDb.GetProteinByName("Y18D10A.20");
                    Assert.IsNotNull(protein);
                    if (doActualWebAccess) // We can actually go to the web for metadata
                    {
                        Assert.AreEqual("Q9XW16", protein.Accession);
                    }

                    using (var reader = new StreamReader(fastaPath))
                    {
                        proteomeDb.AddFastaFile(reader, new SilentProgressMonitor(), ref status, false);
                    }
                    // the act of writing should update to the current version
                    Assert.AreEqual(ProteomeDb.SCHEMA_VERSION_MAJOR_CURRENT, proteomeDb.GetSchemaVersionMajor());
                    Assert.AreEqual(ProteomeDb.SCHEMA_VERSION_MINOR_CURRENT, proteomeDb.GetSchemaVersionMinor());
                    Assert.AreEqual(19, proteomeDb.GetProteinCount());

                    // check for propery processed protein metadata
                    Assert.IsTrue(proteomeDb.LookupProteinMetadata(new SilentProgressMonitor(), ref status, searcher, false, out searchComplete));
                    Assert.IsTrue(searchComplete);
                    protein = proteomeDb.GetProteinByName("IPI00000044");
                    Assert.IsNotNull(protein);
                    Assert.AreEqual("P01127", protein.Accession); // We get this offline with our ipi->uniprot mapper
                    if (doActualWebAccess)
                    {
                        Assert.AreEqual("PDGFB_HUMAN", protein.PreferredName); // But this we get only with web access
                    }

/*
 *                  // TODO(bspratt): fix  "GetDigestion has no notion of a Db that has been added to, doesn't digest the new proteins and returns immediately (issue #304)"
 *                  Enzyme trypsin = EnzymeList.GetDefault();
 *                  proteomeDb.Digest(trypsin,  new SilentProgressMonitor());
 *                  Digestion digestion = proteomeDb.GetDigestion(trypsin.Name);
 *                  var digestedProteins0 = digestion.GetProteinsWithSequencePrefix("EDGWVK", 100);
 *                  Assert.IsTrue(digestedProteins0.Count >= 1);
 * */
                }
            }
        }