private void TrainFace_Click(object sender, RoutedEventArgs e)
        {
            LoadFaces();
            //Save all the current saved faces to file for quality check
            for (int i = 0; i < _savedFaces.Count(); i++)
            {
                var success = MyFileManager.SaveImage(_savedFaces[i], i.ToString());
            }
            //Get data ready for training and train.
            List <Face> faces = _dataClient.CallFaces("ALL_USERS");

            byte[][] faceImages = new byte[faces.Count()][];
            int[]    faceLabels = new int[faces.Count()];

            for (int i = 0; i < faces.Count(); i++)
            {
                faceImages[i] = (byte[])faces[i].Image.Clone();
                faceLabels[i] = faces[i].UserId;
            }
            //Echo results to UI
            if (_trainer.Train(faceImages, faceLabels))
            {
                ResultsString = "Training Successfull";
            }
            else
            {
                ResultsString = "Training Failed";
            }
            NotifyPropertyChanged("ResultsString");
        }
Пример #2
0
        public async Task Decrypt()
        {
            var keyQueueTask = Task.Run(() => KeepKeyQueueData());

            while (
                keyQueueTask.Status != TaskStatus.RanToCompletion ||
                PendingKeysCount != 0)
            {
                for (int i = 0; i < tasks.Length; i++)
                {
                    if (PendingKeysCount <= 0)
                    {
                        await Task.Delay(1);

                        break;
                    }
                    if (tasks[i] == null || tasks[i].Status == TaskStatus.RanToCompletion)
                    {
                        tasks[i] = Task.Run(() => ProccessNextKeyTask(i));
                    }
                }
            }

            keyQueueTask.Wait();
            MyFileManager.WriteBuilderToFile();
            MyFileManagerSuccesses.WriteBuilderToFile();
            MyFileManagerBad.WriteBuilderToFile();
        }
Пример #3
0
        public static void OxoniumIonAnalysis()
        {
            Assert.That(Glycan.AllOxoniumIons[4] == 13805550);
            Assert.That(Glycan.AllOxoniumIons[5] == 14406607);
            Assert.That(Glycan.AllOxoniumIons[9] == 20408720);
            Assert.That(Glycan.AllOxoniumIons[10] == 27409268);
            Assert.That(Glycan.AllOxoniumIons[12] == 29210324);
            Assert.That(Glycan.AllOxoniumIons[14] == 36614002);

            //Get Scan
            CommonParameters commonParameters = new CommonParameters(dissociationType: DissociationType.EThcD, trimMsMsPeaks: false);
            string           spectraFile      = Path.Combine(TestContext.CurrentContext.TestDirectory, @"GlycoTestData\2019_09_16_StcEmix_35trig_EThcD25_rep1_4565.mgf");
            var file = new MyFileManager(true).LoadFile(spectraFile, commonParameters);
            var scan = MetaMorpheusTask.GetMs2Scans(file, spectraFile, commonParameters).First();

            var productSearchMode     = new SinglePpmAroundZeroSearchMode(20);
            var oxoniumIonIntensities = GlycoPeptides.ScanOxoniumIonFilter(scan, productSearchMode, DissociationType.EThcD);

            //Get glycanBox
            var glycanBox = OGlycanBoxes[19];

            var satifyOxonium = GlycoPeptides.OxoniumIonsAnalysis(oxoniumIonIntensities, glycanBox);

            Assert.That(satifyOxonium);
        }
Пример #4
0
        public MetaDraw()
        {
            UsefulProteomicsDatabases.Loaders.LoadElements();

            InitializeComponent();

            itemsControlSampleViewModel = new ItemsControlSampleViewModel();
            DataContext = itemsControlSampleViewModel;
            mainViewModel = new PsmAnnotationViewModel();
            plotView.DataContext = mainViewModel;
            allPsms = new ObservableCollection<PsmFromTsv>();
            filteredListOfPsms = new ObservableCollection<PsmFromTsv>();
            propertyView = new DataTable();
            propertyView.Columns.Add("Name", typeof(string));
            propertyView.Columns.Add("Value", typeof(string));
            peptideSpectralMatchesView = CollectionViewSource.GetDefaultView(filteredListOfPsms);
            dataGridScanNums.DataContext = peptideSpectralMatchesView;
            dataGridProperties.DataContext = propertyView.DefaultView;
            Title = "MetaDraw: version " + GlobalVariables.MetaMorpheusVersion;
            spectraFileManager = new MyFileManager(true);
            SetUpDictionaries();
            modificationAnnotationColor = Brushes.Yellow;
            metaDrawGraphicalSettings = new MetaDrawGraphicalSettings();
            metaDrawFilterSettings = new MetaDrawFilterSettings();
            base.Closing += this.OnClosing;

            ParentChildScanView.Visibility = Visibility.Collapsed;
            ParentScanView.Visibility = Visibility.Collapsed;

            plotTypes = new ObservableCollection<string>();
            SetUpPlots();
            //plotsListBox.ItemsSource = plotTypes;
        }
Пример #5
0
        public static void ReplaceBadStdevTwo()
        {
            //here we are adding a really hydrophobic psm at the same time as a regular peptide so that there is a big difference in their computed hydrophobicities. The stdev of these hydrophobicities is out of whach the the collective and so it needs to get replaced by the global average

            var              variableModifications = new List <Modification>();
            var              fixedModifications    = new List <Modification>();
            var              origDataFile          = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\TaGe_SA_HeLa_04_subset_longestSeq.mzML");
            MyFileManager    myFileManager         = new MyFileManager(true);
            CommonParameters CommonParameters      = new CommonParameters(digestionParams: new DigestionParams());
            var              myMsDataFile          = myFileManager.LoadFile(origDataFile, CommonParameters);
            var              searchModes           = new SinglePpmAroundZeroSearchMode(5);
            List <Protein>   proteinList           = ProteinDbLoader.LoadProteinFasta(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\hela_snip_for_unitTest.fasta"), true, DecoyType.Reverse, false, ProteinDbLoader.UniprotAccessionRegex, ProteinDbLoader.UniprotFullNameRegex, ProteinDbLoader.UniprotFullNameRegex, ProteinDbLoader.UniprotGeneNameRegex,
                                                                                      ProteinDbLoader.UniprotOrganismRegex, out var dbErrors, -1);
            var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, @"TestData\TaGe_SA_HeLa_04_subset_longestSeq.mzML", CommonParameters).OrderBy(b => b.PrecursorMass).ToArray();

            //adding a new scan that creates a psm at an isolated retention time. This will ultimately cause PEP to replace its retention time standard deviation "Z-score" with the global average.
            Ms2ScanWithSpecificMass topMs2Scan = listOfSortedms2Scans[395];
            int        newOneBasedScanNumber   = 1000;
            MzRange    range             = new MzRange(topMs2Scan.TheScan.MassSpectrum.XArray.Min(), topMs2Scan.TheScan.MassSpectrum.XArray.Max());
            MzSpectrum mzs               = new MzSpectrum(topMs2Scan.TheScan.MassSpectrum.XArray, topMs2Scan.TheScan.MassSpectrum.YArray, true);
            double     newRetentionTime  = topMs2Scan.TheScan.RetentionTime - 25;
            MsDataScan msd               = new MsDataScan(mzs, newOneBasedScanNumber, 2, topMs2Scan.TheScan.IsCentroid, Polarity.Positive, newRetentionTime, range, "", MZAnalyzerType.Orbitrap, topMs2Scan.TheScan.TotalIonCurrent, topMs2Scan.TheScan.InjectionTime, topMs2Scan.TheScan.NoiseData, "", topMs2Scan.TheScan.SelectedIonMZ, topMs2Scan.TheScan.SelectedIonChargeStateGuess, topMs2Scan.TheScan.SelectedIonIntensity, topMs2Scan.TheScan.IsolationMz, topMs2Scan.TheScan.IsolationWidth, DissociationType.HCD, topMs2Scan.TheScan.OneBasedPrecursorScanNumber, topMs2Scan.TheScan.SelectedIonMonoisotopicGuessMz);
            Ms2ScanWithSpecificMass mwsm = new Ms2ScanWithSpecificMass(msd, topMs2Scan.PrecursorMonoisotopicPeakMz, topMs2Scan.PrecursorCharge, topMs2Scan.FullFilePath, new CommonParameters(), topMs2Scan.ExperimentalFragments);

            Ms2ScanWithSpecificMass[] extendedArray = new Ms2ScanWithSpecificMass[listOfSortedms2Scans.Length + 1];
            for (int i = 0; i < listOfSortedms2Scans.Length; i++)
            {
                extendedArray[i] = listOfSortedms2Scans[i];
            }
            extendedArray[listOfSortedms2Scans.Length] = mwsm;

            extendedArray = extendedArray.OrderBy(b => b.PrecursorMass).ToArray();

            PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[extendedArray.Length];
            new ClassicSearchEngine(allPsmsArray, extendedArray, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, CommonParameters, new List <string>()).Run();

            List <PeptideSpectralMatch> nonNullPsms = allPsmsArray.Where(p => p != null).ToList();

            nonNullPsms = nonNullPsms.OrderByDescending(p => p.Score).ToList();
            List <PeptideSpectralMatch> psmBloated = new List <PeptideSpectralMatch>();

            psmBloated.AddRange(nonNullPsms);
            int arrayMax = nonNullPsms.Count;

            psmBloated.AddRange(nonNullPsms.GetRange(2, arrayMax - 2));
            psmBloated.AddRange(nonNullPsms.GetRange(2, arrayMax - 2));


            PeptideSpectralMatch pp = psmBloated.Where(p => p.ScanRetentionTime < (newRetentionTime + 1)).First();

            PeptideWithSetModifications newPwsmTwo = new PeptideWithSetModifications(new Protein("WAGVLPWFPWAAVVWGFWF", "ACCESSION", "ORGANISM"), new DigestionParams(), 1, 2, CleavageSpecificity.Full, "", 0, new Dictionary <int, Modification>(), 0);
            PeptideSpectralMatch        newPsmTwo  = new PeptideSpectralMatch(newPwsmTwo, pp.BestMatchingPeptides.First().Notch, pp.Score, pp.ScanIndex, mwsm, new DigestionParams(), pp.MatchedFragmentIons);

            psmBloated.Add(newPsmTwo);

            FdrAnalysisResults fdrResultsClassicDelta = (FdrAnalysisResults)(new FdrAnalysisEngine(psmBloated.Where(p => p != null).ToList(), 1, CommonParameters, new List <string>()).Run());
        }
Пример #6
0
        public static void GlyTest_GlyGetTheoreticalFragments()
        {
            Protein         pep             = new Protein("TKPREEQYNSTYR", "accession");
            DigestionParams digestionParams = new DigestionParams(minPeptideLength: 7);
            var             aPeptideWithSetModifications = pep.Digest(digestionParams, new List <Modification>(), new List <Modification>());

            string[] motifs = new string[] { "Nxs", "Nxt" };
            var      sites  = GlycoSpectralMatch.GetPossibleModSites(aPeptideWithSetModifications.Last(), motifs);
            Glycan   glycan = Glycan.Struct2Glycan("(N(F)(N(H(H(N))(H(N)))))", 0);


            //using (StreamWriter output = new StreamWriter(Path.Combine(TestContext.CurrentContext.TestDirectory, "GlycanFragmentions.txt")))
            //{
            //    foreach (var product in fragmentIons)
            //    {
            //        foreach (var ion in product.Item2)
            //        {
            //            output.WriteLine(ion.Annotation + "\t" + ion.NeutralLoss.ToString() + "\t" + ion.NeutralMass.ToString());
            //        }
            //    }
            //}

            CommonParameters commonParameters = new CommonParameters(deconvolutionMassTolerance: new PpmTolerance(20), trimMsMsPeaks: false);
            string           filePath         = Path.Combine(TestContext.CurrentContext.TestDirectory, @"GlycoTestData/Glyco_3383.mgf"); //"25170.mgf"
            MyFileManager    myFileManager    = new MyFileManager(true);
            var msDataFile           = myFileManager.LoadFile(filePath, commonParameters);
            var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(msDataFile, filePath, commonParameters).ToArray();

            var            glycanMod    = Glycan.NGlycanToModification(glycan);
            var            glycopep     = GlycoPeptides.GenerateGlycopeptide(sites[0], aPeptideWithSetModifications.Last(), glycan);
            List <Product> fragmentIons = new List <Product>();

            glycopep.Fragment(DissociationType.HCD, FragmentationTerminus.Both, fragmentIons);

            var glycanYIons        = GlycoPeptides.GetGlycanYIons(listOfSortedms2Scans[0].PrecursorMass, glycan);
            var matchedGlycanYIons = MetaMorpheusEngine.MatchFragmentIons(listOfSortedms2Scans[0], glycanYIons, commonParameters);

            Assert.AreEqual(matchedGlycanYIons.Count, 14);

            //TO DO: The neutroloss is not annotated well.
            var matchedFragmentIons = MetaMorpheusEngine.MatchFragmentIons(listOfSortedms2Scans[0], fragmentIons, commonParameters);

            var coreIons = GlycoPeptides.ScanGetTrimannosylCore(matchedFragmentIons, glycan);

            Assert.AreEqual(coreIons.Count, 6);
            var filter = GlycoPeptides.ScanTrimannosylCoreFilter(matchedFragmentIons, glycan);

            Assert.AreEqual(filter, true);
            var NGlycans    = GlycanDatabase.LoadGlycan(GlobalVariables.NGlycanLocations[0], true, false);
            var bestGlycans = GlycoPeptides.MatchBestGlycan(listOfSortedms2Scans[0], NGlycans.ToArray(), commonParameters).Where(p => p != null && p.Item2 >= 2).OrderByDescending(p => p.Item2).Take(100).OrderBy(p => p.Item3).ToArray();;
        }
Пример #7
0
        public static void RemoveAmbiguousPeptides()
        {
            var              variableModifications = new List <Modification>();
            var              fixedModifications    = new List <Modification>();
            var              origDataFile          = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\TaGe_SA_HeLa_04_subset_longestSeq.mzML");
            MyFileManager    myFileManager         = new MyFileManager(true);
            CommonParameters CommonParameters      = new CommonParameters(digestionParams: new DigestionParams());
            var              myMsDataFile          = myFileManager.LoadFile(origDataFile, CommonParameters);
            var              searchModes           = new SinglePpmAroundZeroSearchMode(5);
            List <Protein>   proteinList           = ProteinDbLoader.LoadProteinFasta(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\hela_snip_for_unitTest.fasta"), true, DecoyType.Reverse, false, ProteinDbLoader.UniprotAccessionRegex, ProteinDbLoader.UniprotFullNameRegex, ProteinDbLoader.UniprotFullNameRegex, ProteinDbLoader.UniprotGeneNameRegex,
                                                                                      ProteinDbLoader.UniprotOrganismRegex, out var dbErrors, -1);
            var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, @"TestData\TaGe_SA_HeLa_04_subset_longestSeq.mzML", CommonParameters).OrderBy(b => b.PrecursorMass).ToArray();

            PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length];
            new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, CommonParameters, new List <string>()).Run();

            var nonNullPsms = allPsmsArray.Where(p => p != null).ToList();

            nonNullPsms.OrderByDescending(p => p.Score);
            var maxScore = nonNullPsms.Select(n => n.Score).Max();
            PeptideSpectralMatch maxScorePsm = nonNullPsms.Where(n => n.Score == maxScore).First();

            Protein newProteinToRemove = new Protein("RREMVE", "BUBBA", isDecoy: false);
            PeptideWithSetModifications pwsmToRemove = new PeptideWithSetModifications(newProteinToRemove, new DigestionParams(), 1, 6, CleavageSpecificity.Full, "peptideDescription", 2, new Dictionary <int, Modification>(), 1, "RREMVE");

            maxScorePsm.AddOrReplace(pwsmToRemove, maxScore, 1, true, maxScorePsm.MatchedFragmentIons, maxScore);
            maxScorePsm.ResolveAllAmbiguities();

            List <PeptideSpectralMatch> psmBloated = new List <PeptideSpectralMatch>();

            psmBloated.AddRange(nonNullPsms);
            psmBloated.AddRange(nonNullPsms.GetRange(0, nonNullPsms.Count - 2));
            foreach (PeptideSpectralMatch psm in nonNullPsms.GetRange(0, nonNullPsms.Count - 2))
            {
                Protein newDecoyProtein = new Protein(psm.BestMatchingPeptides.First().Peptide.BaseSequence + "K", "DECOY_" + psm.BestMatchingPeptides.First().Peptide.Protein.Accession, isDecoy: true);
                PeptideWithSetModifications pwsmDecoy = new PeptideWithSetModifications(newDecoyProtein, new DigestionParams(), 1, psm.BestMatchingPeptides.First().Peptide.BaseSequence.Length + 1, CleavageSpecificity.Full, "peptideDescription", 2, new Dictionary <int, Modification>(), 1, psm.BestMatchingPeptides.First().Peptide.BaseSequence + "K");
                PeptideSpectralMatch        decoyPsm  = new PeptideSpectralMatch(pwsmDecoy, 1, psm.Score, psm.ScanIndex, listOfSortedms2Scans[psm.ScanIndex], new DigestionParams(), psm.MatchedFragmentIons);
                decoyPsm.ResolveAllAmbiguities();
                psmBloated.Add(decoyPsm);
            }

            PeptideSpectralMatch oldBloatedMaxScorePsm = psmBloated.Where(n => n.Score == maxScore).First();
            int countOfBestPeptidesBloatedMax          = oldBloatedMaxScorePsm.BestMatchingPeptides.Count();

            FdrAnalysisResults fdrResultsClassicDelta = (FdrAnalysisResults)(new FdrAnalysisEngine(psmBloated.Where(p => p != null).ToList(), 1, CommonParameters, new List <string>()).Run());

            PeptideSpectralMatch newMaxScorePsm = psmBloated.Where(n => n.Score == maxScore).First();

            Assert.AreEqual(countOfBestPeptidesBloatedMax - 1, newMaxScorePsm.BestMatchingPeptides.Count());
        }
Пример #8
0
        private void button1_Click(object sender, EventArgs e)
        {
            SqlConnection connection = MyDB.getConnection();
            SqlCommand    sqlCommand;
            SqlDataReader dataReader;
            string        output_definition = "";

            try
            {
                connection.Open();

                sqlCommand = new SqlCommand("DECLARE @PKRepetida varchar(40), @longitud int = 0, @i int = 0, @Nombre_columna varchar (40), @anomalias int, @j int = 0, @Id_objeto int, @EstaVacio int SET @longitud = (select count(*) from ( select COlUMN_NAME, COUNT(COLUMN_NAME) as duplicados from ( select TABLE_NAME,COLUMN_NAME, CONSTRAINT_NAME, ORDINAL_POSITION from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where TABLE_NAME NOT IN (select distinct TABLE_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where ORDINAL_POSITION > 1 ) )T1 where CONSTRAINT_NAME LIKE 'PK%' or CONSTRAINT_NAME LIKE 'UPKCL%' group by COLUMN_NAME)T2) WHILE @i < @longitud BEGIN SET @i = @i + 1 IF ((select duplicados from ( select COUNT(COLUMN_NAME) as duplicados,ROW_NUMBER() OVER (ORDER BY (select 1)) AS a from ( select TABLE_NAME,COLUMN_NAME, CONSTRAINT_NAME, ORDINAL_POSITION from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where TABLE_NAME NOT IN (select distinct TABLE_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where ORDINAL_POSITION > 1 ) )T1 where CONSTRAINT_NAME LIKE 'PK%' or CONSTRAINT_NAME LIKE 'UPKCL%' group by COLUMN_NAME)T2 where a = @i)>1) Begin SET @Nombre_columna =(select COLUMN_NAME from ( select COUNT(COLUMN_NAME) as duplicados, COLUMN_NAME,ROW_NUMBER() OVER (ORDER BY (select 1)) AS a from ( select TABLE_NAME,COLUMN_NAME, CONSTRAINT_NAME, ORDINAL_POSITION from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where TABLE_NAME NOT IN (select distinct TABLE_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where ORDINAL_POSITION > 1 ) )T1 where CONSTRAINT_NAME LIKE 'PK%' or CONSTRAINT_NAME LIKE 'UPKCL%' group by COLUMN_NAME)T2 where a = @i) print @Nombre_columna SET @anomalias = (select count(*) from ( select ROW_NUMBER() OVER (ORDER BY (select 1)) AS a, object_id from ( select TABLE_NAME, CONSTRAINT_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where COLUMN_NAME = @Nombre_columna)T1 join sys.objects so on (T1.TABLE_NAME = so.name) where CONSTRAINT_NAME LIKE 'PK%' or CONSTRAINT_NAME LIKE 'UPKCL%')T2) WHILE @j < @anomalias BEGIN SET @j = @j + 1 SET @Id_objeto = (select object_id from ( select ROW_NUMBER() OVER (ORDER BY (select 1)) AS a, object_id from ( select TABLE_NAME, CONSTRAINT_NAME from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where COLUMN_NAME = @Nombre_columna) T1 join sys.objects so on (T1.TABLE_NAME = so.name) where CONSTRAINT_NAME LIKE 'PK%' or CONSTRAINT_NAME LIKE 'UPKCL%')T2 where a = @j) SET @EstaVacio = (select count(*) from sys.triggers st join sys.sql_modules ssm on (st.object_id = ssm.object_id ) where st.parent_id = @Id_objeto ) IF (@EstaVacio > 0) Begin select so.name as tabla,st.object_id, st.name , ssm.definition from sys.triggers st join sys.sql_modules ssm on (st.object_id = ssm.object_id ) join sys.objects so on (so.object_id = st.parent_id) where st.parent_id = @Id_objeto END END END END", connection);


                dataReader = sqlCommand.ExecuteReader();



                while (dataReader.Read())
                {
                    // Console.WriteLine("LEYENDO " + dataReader.FieldCount);
                    int index = 0;

                    string tabla      = dataReader.GetValue(index++).ToString();
                    long   object_id  = Int64.Parse(dataReader.GetValue(index++).ToString());
                    string name       = dataReader.GetValue(index++).ToString();
                    string definition = dataReader.GetValue(index++).ToString();


                    output_definition += "Tabla: " + tabla + ", Object_id: " + object_id + ", nombre: " + name + "\nDefinition: " + definition + "\n\n";
                }

                this.richTextBox2.Text = output_definition;
                MyFileManager.writeTXT(output_definition, "D://LOG_AUDITORIA_ANOMALIAS_DEFINICION.txt");



                sqlCommand.Dispose();
                dataReader.Close();
            }
            catch (Exception error)
            {
                Console.WriteLine("Error: " + error.Message);
            }
            finally
            {
                connection.Close();
            }
        }
Пример #9
0
        public MetaDraw()
        {
            InitializeComponent();

            mainViewModel          = new PsmAnnotationViewModel();
            plotView.DataContext   = mainViewModel;
            peptideSpectralMatches = new ObservableCollection <MetaDrawPsm>();
            propertyView           = new DataTable();
            propertyView.Columns.Add("Name", typeof(string));
            propertyView.Columns.Add("Value", typeof(string));
            peptideSpectralMatchesView     = CollectionViewSource.GetDefaultView(peptideSpectralMatches);
            dataGridScanNums.DataContext   = peptideSpectralMatchesView;
            dataGridProperties.DataContext = propertyView.DefaultView;
            Title = "MetaDraw: version " + GlobalVariables.MetaMorpheusVersion;
            spectraFileManager = new MyFileManager(true);
        }
Пример #10
0
    // Use this for initialization
    void Start()
    {
        createSingleton();                                 // Create a static reference to this object

        activateRig();                                     // Adjust any settings at runtime

        targetData = generateRandomTargets(10);            // Generates randomized target data

        fileManager = new MyFileManager(targetData, true); // Create a file manager using this target data

        createTarget();

        // Debug info
        Debug.Log(Application.dataPath);
        Debug.Log("Start Finished");
    }
Пример #11
0
        public MetaDraw()
        {
            UsefulProteomicsDatabases.Loaders.LoadElements();

            InitializeComponent();

            itemsControlSampleViewModel = new ItemsControlSampleViewModel();
            DataContext          = itemsControlSampleViewModel;
            mainViewModel        = new PsmAnnotationViewModel();
            plotView.DataContext = mainViewModel;
            allPsms            = new ObservableCollection <PsmFromTsv>();
            filteredListOfPsms = new ObservableCollection <PsmFromTsv>();
            proteinTree        = new ObservableCollection <ProteinForTreeView>();
            filteredTree       = new ObservableCollection <ProteinForTreeView>();
            propertyView       = new DataTable();
            propertyView.Columns.Add("Name", typeof(string));
            propertyView.Columns.Add("Value", typeof(string));
            psmsWithMatch = new List <PsmFromTsv>();
            proteinTreeView.DataContext    = proteinTree;
            dataGridProperties.DataContext = propertyView.DefaultView;
            Title = "MetaDraw: version " + GlobalVariables.MetaMorpheusVersion;
            spectraFileManager = new MyFileManager(true);
            SetUpDictionaries();
            variantCrossColor               = Colors.Green;
            modificationAnnotationColor     = Brushes.Orange;
            metaDrawGraphicalSettings       = new MetaDrawGraphicalSettings();
            metaDrawFilterSettings          = new MetaDrawFilterSettings();
            SearchModifications.Timer.Tick += new EventHandler(searchBox_TextChangedHandler);
            base.Closing += this.OnClosing;

            ParentChildScanView.Visibility = Visibility.Collapsed;
            ParentScanView.Visibility      = Visibility.Collapsed;
            mapViewer.Visibility           = Visibility.Collapsed;
            legend.Visibility = Visibility.Collapsed;

            plotTypes = new ObservableCollection <string>();
            proteases = new string[1] {
                "trypsin"
            };

            SetUpPlots();
            //plotsListBox.ItemsSource = plotTypes;
            ChangeMapScrollViewSize();
        }
Пример #12
0
        private void Page_Loaded(object sender, RoutedEventArgs e)
        {
			var Members = new List<Member>(MemberDao.getData());
			myMembers = new BindingList<ListViewMember>();
			foreach(var item in Members)
            {
				myMembers.Add(new ListViewMember { Info = MemberDao.ConvertString(item), Source = item.ImgSource });
            }

			MembersListView.ItemsSource = myMembers;

			var Folder = AppDomain.CurrentDomain.BaseDirectory;
			var path = $"{Folder}Resources/Data/AppInfo.txt";

			MyFileManager.CheckFilePath(path);
			var Data = File.ReadAllText(path);

			AppInfo.Text = Data;
        }
Пример #13
0
        public static void TestCompressionDecompression()
        {
            string        testInputFolder = Path.Combine(TestContext.CurrentContext.TestDirectory, @"CompressionTest");
            DirectoryInfo testDirectory   = new DirectoryInfo(testInputFolder);

            MyFileManager.CompressDirectory(testDirectory);

            foreach (FileInfo file in testDirectory.GetFiles())
            {
                Assert.AreEqual(".gz", file.Extension);
            }

            MyFileManager.DecompressDirectory(testDirectory);

            foreach (FileInfo file in testDirectory.GetFiles())
            {
                Assert.AreNotEqual(".gz", file.Extension);
            }
        }
Пример #14
0
        public static void AnotherSpectralLibrarySearchTestDecoy()
        {
            var              testDir          = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\SpectralLibrarySearch");
            string           myFile           = Path.Combine(testDir, @"slicedMouse.raw");
            MyFileManager    myFileManager    = new MyFileManager(true);
            CommonParameters commonParameters = new CommonParameters(maxThreadsToUsePerFile: 1, scoreCutoff: 1);
            MsDataFile       myMsDataFile     = myFileManager.LoadFile(myFile, commonParameters);

            var variableModifications = new List <Modification>();
            var fixedModifications    = new List <Modification>();
            var proteinList           = new List <Protein> {
                new Protein("QTATIAHVTTMLGEVIGFNDHIVK", "P16858")
            };

            string targetSpectralLibrary = Path.Combine(testDir, @"P16858_target.msp");
            string decoySpectralLibrary  = Path.Combine(testDir, @"P16858_decoy.msp");

            List <string> specLibs = new List <string> {
                targetSpectralLibrary, decoySpectralLibrary
            };

            SpectralLibrary sl = new SpectralLibrary(specLibs);

            var searchModes = new SinglePpmAroundZeroSearchMode(5);

            var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray();

            PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length];
            bool writeSpectralLibrary           = false;

            new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null,
                                    proteinList, searchModes, commonParameters, null, sl, new List <string>(), writeSpectralLibrary).Run();

            // Single search mode
            Assert.AreEqual(7, allPsmsArray.Length);
            Assert.IsTrue(allPsmsArray[5].Score > 38);
            Assert.AreEqual("VIHDNFGIVEGLMTTVHAITATQK", allPsmsArray[5].BaseSequence);
            Assert.IsTrue(allPsmsArray[5].IsDecoy);

            SpectralLibrarySearchFunction.CalculateSpectralAngles(sl, allPsmsArray, listOfSortedms2Scans, commonParameters);
            Assert.That(allPsmsArray[5].SpectralAngle, Is.EqualTo(0.69).Within(0.01));
        }
Пример #15
0
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            string Folder = AppDomain.CurrentDomain.BaseDirectory;

            //Check file path
            string newFolder = $"{Folder}Resources\\Data";

            MyFileManager.CheckDictionary(newFolder);

            newFolder = $"{Folder}Resources\\Images";
            MyFileManager.CheckDictionary(newFolder);

            newFolder = $"{Folder}Resources\\Icons";
            MyFileManager.CheckDictionary(newFolder);

            _list_menu           = MenuDao.GetAll();
            menuList.ItemsSource = _list_menu;

            _content            = new HomePage();
            menuPage.Content    = _content;
            menuPage.Visibility = Visibility.Visible;
        }
Пример #16
0
        private void buttonDetectAnomalies_Click(object sender, EventArgs e)
        {
            List <Anomaly> anomalies_dbcc      = AnomalyDetector.detectAnomaliesWithData();
            List <Anomaly> anomalies_structure = AnomalyDetector.detectAnomaliesWithNoData();


            string output_log = "";

            output_log += "**********ANOMALY in DATA***********\n";

            foreach (var item in anomalies_dbcc)
            {
                // string extra_summary = Trigger.getExtraSummary(item.object_id);

                output_log += "\n***Anomalía del objeto " + item.object_id + ": \n" + item.summary; // + "\n" + extra_summary + "\n";
            }

            output_log += "\n\n**********ANOMALY STRUCTURE*************\n";
            foreach (var item in anomalies_structure)
            {
                output_log += "\n***Anomalía structure in " + item.object_id + ": \n" + item.summary;
            }

            MyFileManager.writeTXT(output_log, "D://LOG_AUDITORIA_FULL_ANOMALIAS.txt");

            if (anomalies_dbcc.Count + anomalies_structure.Count > 0)
            {
                output_log += "\n\nLOG GENERADO CON ANOMALÍAS en D://AUDITORIA_LOG_.txt";
            }
            else
            {
                output_log += "\n\nNO SE DETECTARON ANOMALÍAS";
            }

            this.richTextBox1.Text = output_log;
        }
Пример #17
0
 private void toolStripMenuItemFileCreateFolder_Click(object sender, EventArgs e)
 {
     newNameForm             = new NewName();
     newNameForm.LabelText   = "Введите имя создаваемой папки";
     newNameForm.TextBoxText = "Новая папка";
     if (DialogResult.OK == newNameForm.ShowDialog() &&
         newNameForm.TextBoxText != "")
     {
         string newPath = Path.Combine(fullPathSelected, newNameForm.TextBoxText);
         try
         {
             MyFileManager.CreateDirectory(newPath);
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.Message,
                             "Создание папки " + newPath,
                             MessageBoxButtons.OK,
                             MessageBoxIcon.Error);
         }
         LoadList();
         UpdateTreeNode(fullPathSelected);
     }
 }
Пример #18
0
        public static void TestComputePEPValue()
        {
            var              variableModifications = new List <Modification>();
            var              fixedModifications    = new List <Modification>();
            var              origDataFile          = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\TaGe_SA_HeLa_04_subset_longestSeq.mzML");
            MyFileManager    myFileManager         = new MyFileManager(true);
            CommonParameters CommonParameters      = new CommonParameters(digestionParams: new DigestionParams());
            var              myMsDataFile          = myFileManager.LoadFile(origDataFile, CommonParameters);
            var              searchModes           = new SinglePpmAroundZeroSearchMode(5);
            List <Protein>   proteinList           = ProteinDbLoader.LoadProteinFasta(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\hela_snip_for_unitTest.fasta"), true, DecoyType.Reverse, false, ProteinDbLoader.UniprotAccessionRegex, ProteinDbLoader.UniprotFullNameRegex, ProteinDbLoader.UniprotFullNameRegex, ProteinDbLoader.UniprotGeneNameRegex,
                                                                                      ProteinDbLoader.UniprotOrganismRegex, out var dbErrors, -1);
            var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, CommonParameters).OrderBy(b => b.PrecursorMass).ToArray();

            PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length];
            new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, proteinList, searchModes, CommonParameters, new List <string>()).Run();
            FdrAnalysisResults fdrResultsClassicDelta = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArray.Where(p => p != null).ToList(), 1, CommonParameters, new List <string>()).Run());

            var nonNullPsms             = allPsmsArray.Where(p => p != null).ToList();
            var nonNullPsmsOriginalCopy = allPsmsArray.Where(p => p != null).ToList();
            var accessionCounts         = PEP_Analysis.GetAccessionCounts(nonNullPsms);

            var maxScore    = nonNullPsms.Select(n => n.Score).Max();
            var maxScorePsm = nonNullPsms.Where(n => n.Score == maxScore).First();

            Dictionary <string, int> sequenceToPsmCount = new Dictionary <string, int>();

            List <string> sequences = new List <string>();

            foreach (PeptideSpectralMatch psm in nonNullPsms)
            {
                var ss = psm.BestMatchingPeptides.Select(b => b.Peptide.FullSequence).ToList();
                sequences.Add(String.Join("|", ss));
            }

            var s = sequences.GroupBy(i => i);

            foreach (var grp in s)
            {
                sequenceToPsmCount.Add(grp.Key, grp.Count());
            }

            var maxPsmData = PEP_Analysis.CreateOnePsmDataFromPsm(maxScorePsm, accessionCounts, sequenceToPsmCount);

            Assert.That(maxScorePsm.PeptidesToMatchingFragments.Count, Is.EqualTo(maxPsmData.Ambiguity));
            Assert.That(maxScorePsm.DeltaScore, Is.EqualTo(maxPsmData.DeltaScore).Within(0.05));
            Assert.That((float)(maxScorePsm.Score - (int)maxScorePsm.Score), Is.EqualTo(maxPsmData.Intensity).Within(0.05));

            Assert.That(maxScorePsm.BestMatchingPeptides.Select(p => p.Peptide).First().MissedCleavages, Is.EqualTo(maxPsmData.MissedCleavagesCount));
            Assert.That(maxScorePsm.BestMatchingPeptides.Select(p => p.Peptide).First().AllModsOneIsNterminus.Values.Count(), Is.EqualTo(maxPsmData.ModsCount));
            Assert.That(maxScorePsm.Notch ?? 0, Is.EqualTo(maxPsmData.Notch));
            Assert.That(maxScorePsm.PsmCount, Is.EqualTo(maxPsmData.PsmCount));
            Assert.That(maxScorePsm.ScanPrecursorCharge, Is.EqualTo(maxPsmData.ScanPrecursorCharge));

            PEP_Analysis.ComputePEPValuesForAllPSMsGeneric(nonNullPsms);

            int trueCount = 0;

            foreach (var item in allPsmsArray.Where(p => p != null))
            {
                var b = item.FdrInfo.PEP;
                if (b >= 0.5)
                {
                    trueCount++;
                }
            }

            Assert.GreaterOrEqual(32, trueCount);
        }
Пример #19
0
        public static void OGlycoTest_Localization2()
        {
            //There may have a bug that MM cannot identify Peptide modified with (HexNAc), This is to test and find the bug.
            //Get glycanBox
            var glycanBox = OGlycanBoxes[0];

            //Get unmodified peptide, products, allPossible modPos and all boxes.
            Protein        protein  = new Protein("AATVGSLAGQPLQER", "P16150");
            var            peptide  = protein.Digest(new DigestionParams(), new List <Modification>(), new List <Modification>()).First();
            List <Product> products = new List <Product>();

            peptide.Fragment(DissociationType.ETD, FragmentationTerminus.Both, products);

            int[] modPos = GlycoSpectralMatch.GetPossibleModSites(peptide, new string[] { "S", "T" }).OrderBy(p => p).ToArray();
            var   boxes  = GlycanBox.BuildChildOGlycanBoxes(glycanBox.NumberOfMods, glycanBox.ModIds).ToArray();

            //Load scan.
            CommonParameters commonParameters = new CommonParameters(dissociationType: DissociationType.ETD, trimMsMsPeaks: false);
            string           spectraFile      = Path.Combine(TestContext.CurrentContext.TestDirectory, @"GlycoTestData\181217_Fusion_(LC2)_NewObj_Serum_deSA_Jacalin_HRM_4h_ETD_HCD_DDA_mz(400_1200)_21707.mgf");
            var file  = new MyFileManager(true).LoadFile(spectraFile, commonParameters);
            var scans = MetaMorpheusTask.GetMs2Scans(file, spectraFile, commonParameters).ToArray();

            //Known peptideWithMod match.
            var peptideWithMod = GlycoPeptides.OGlyGetTheoreticalPeptide(new int[1] {
                4
            }, peptide, glycanBox);

            Assert.That(peptideWithMod.FullSequence == "AAT[O-Glycosylation:N1 on X]VGSLAGQPLQER");
            //List<Product> knownProducts = peptideWithMod.Fragment(DissociationType.EThcD, FragmentationTerminus.Both).ToList();
            List <Product> knownProducts            = GlycoPeptides.OGlyGetTheoreticalFragments(DissociationType.ETD, peptide, peptideWithMod);
            var            matchedKnownFragmentIons = MetaMorpheusEngine.MatchFragmentIons(scans.First(), knownProducts, commonParameters);

            //Get hashset int
            int        obsPreviousFragmentCeilingMz = 0;
            List <int> binsToSearch = new List <int>();

            foreach (var envelope in scans.First().ExperimentalFragments)
            {
                // assume charge state 1 to calculate mass tolerance
                double experimentalFragmentMass = envelope.MonoisotopicMass;

                // get theoretical fragment bins within mass tolerance
                int obsFragmentFloorMass   = (int)Math.Floor((commonParameters.ProductMassTolerance.GetMinimumValue(experimentalFragmentMass)) * 1000);
                int obsFragmentCeilingMass = (int)Math.Ceiling((commonParameters.ProductMassTolerance.GetMaximumValue(experimentalFragmentMass)) * 1000);

                // prevents double-counting peaks close in m/z and lower-bound out of range exceptions
                if (obsFragmentFloorMass < obsPreviousFragmentCeilingMz)
                {
                    obsFragmentFloorMass = obsPreviousFragmentCeilingMz;
                }
                obsPreviousFragmentCeilingMz = obsFragmentCeilingMass + 1;

                // search mass bins within a tolerance
                for (int fragmentBin = obsFragmentFloorMass; fragmentBin <= obsFragmentCeilingMass; fragmentBin++)
                {
                    binsToSearch.Add(fragmentBin);
                }
            }
            HashSet <int> allPeaks = new HashSet <int>(binsToSearch);


            //Graph Localization
            LocalizationGraph localizationGraph = new LocalizationGraph(modPos, glycanBox, boxes, -1);

            LocalizationGraph.LocalizeOGlycan(localizationGraph, scans.First(), commonParameters.ProductMassTolerance, products);

            var allPaths = LocalizationGraph.GetAllHighestScorePaths(localizationGraph.array, localizationGraph.ChildModBoxes);

            var knowPath = new int[2] {
                1, 1
            };

            Assert.That(Enumerable.SequenceEqual(knowPath, allPaths[0]));

            var local = LocalizationGraph.GetLocalizedPath(localizationGraph, allPaths.First());

            Assert.That(Enumerable.SequenceEqual(local.Mods.Select(p => p.Item1), new List <int> {
                4
            }));
            Assert.That(Enumerable.SequenceEqual(local.Mods.Select(p => p.Item2), new List <int> {
                0
            }));
        }
Пример #20
0
        public static void OGlycoTest_Localization()
        {
            //Get glycanBox
            var glycanBox = OGlycanBoxes[19];

            //Get unmodified peptide, products, allPossible modPos and all boxes.
            Protein        protein  = new Protein("TTGSLEPSSGASGPQVSSVK", "P16150");
            var            peptide  = protein.Digest(new DigestionParams(), new List <Modification>(), new List <Modification>()).First();
            List <Product> products = new List <Product>();

            peptide.Fragment(DissociationType.ETD, FragmentationTerminus.Both, products);

            int[] modPos = GlycoSpectralMatch.GetPossibleModSites(peptide, new string[] { "S", "T" }).OrderBy(v => v).ToArray();
            var   boxes  = GlycanBox.BuildChildOGlycanBoxes(3, glycanBox.ModIds).ToArray();

            Assert.That(boxes.Count() == 6);

            //Get Unlocal Fragment
            var unlocalCost = GlycoPeptides.GetUnlocalFragment(products, modPos, glycanBox);

            Assert.That(unlocalCost.Count == 4); //Basicly, the unlocal are c/z ions that don't localize glycosylation.

            //Get scan
            CommonParameters commonParameters = new CommonParameters(dissociationType: DissociationType.EThcD, trimMsMsPeaks: false);
            string           spectraFile      = Path.Combine(TestContext.CurrentContext.TestDirectory, @"GlycoTestData\2019_09_16_StcEmix_35trig_EThcD25_rep1_4565.mgf");
            var file  = new MyFileManager(true).LoadFile(spectraFile, commonParameters);
            var scans = MetaMorpheusTask.GetMs2Scans(file, spectraFile, commonParameters).ToArray();

            //Known peptideWithMod match.
            var peptideWithMod = GlycoPeptides.OGlyGetTheoreticalPeptide(new int[3] {
                10, 2, 3
            }, peptide, glycanBox);

            Assert.That(peptideWithMod.FullSequence == "T[O-Glycosylation:H1N1 on X]T[O-Glycosylation:H1N1 on X]GSLEPSS[O-Glycosylation:N1 on X]GASGPQVSSVK");
            List <Product> knownProducts            = GlycoPeptides.OGlyGetTheoreticalFragments(DissociationType.EThcD, peptide, peptideWithMod);
            var            matchedKnownFragmentIons = MetaMorpheusEngine.MatchFragmentIons(scans.First(), knownProducts, commonParameters);

            //Graph Localization
            LocalizationGraph localizationGraph = new LocalizationGraph(modPos, glycanBox, boxes, -1);

            LocalizationGraph.LocalizeOGlycan(localizationGraph, scans.First(), commonParameters.ProductMassTolerance, products);
            var allPaths = LocalizationGraph.GetAllHighestScorePaths(localizationGraph.array, localizationGraph.ChildModBoxes);
            var knowPath = new int[8] {
                2, 4, 4, 4, 5, 5, 5, 5
            };

            Assert.That(Enumerable.SequenceEqual(knowPath, allPaths[0]));

            //Get localized Route
            var local = LocalizationGraph.GetLocalizedPath(localizationGraph, allPaths.First());

            Assert.That(Enumerable.SequenceEqual(local.Mods.Select(v => v.Item1), new List <int> {
                2, 3, 10
            }));
            Assert.That(Enumerable.SequenceEqual(local.Mods.Select(v => v.Item2), new List <int> {
                1, 1, 0
            }));


            //Get all paths, calculate PScore and calculate position probability.
            var p = scans.First().TheScan.MassSpectrum.Size *commonParameters.ProductMassTolerance.GetRange(1000).Width / scans.First().TheScan.MassSpectrum.Range.Width;
            var n = knownProducts.Where(v => v.ProductType == ProductType.c || v.ProductType == ProductType.zDot).Count();
            var allPathWithWeights = LocalizationGraph.GetAllPaths_CalP(localizationGraph, p, n);

            Assert.That(allPathWithWeights.Count == 168);

            //Calculate Site Specific Localization Probability
            var y = LocalizationGraph.CalSiteSpecificLocalizationProbability(allPathWithWeights, localizationGraph.ModPos);

            Assert.That(y.Count == 8);
            Assert.That(y.First().Value[1].Item2 > 0.99);
        }
Пример #21
0
        private void button_get_integrity_metadata_Click(object sender, EventArgs e)
        {
            SqlConnection connection = MyDB.getConnection();

            try
            {
                SqlCommand sqlCommand = new SqlCommand("SELECT LlaveForanea =o.name, Esquema =SCHEMA_NAME(t1.schema_id), Tabla =t1.name, Columna =c1.name, Esquema_Ref =SCHEMA_NAME(t2.schema_id), Tabla_Ref =t2.name, Columna_Ref =c2.name FROM sys.foreign_keys o INNER JOIN sys.foreign_key_columns fk ON o.object_id = fk.constraint_object_id INNER JOIN sys.tables t1 ON t1.object_id = fk.parent_object_id INNER JOIN sys.columns c1 ON c1.column_id = parent_column_id AND c1.object_id = t1.object_id INNER JOIN sys.tables t2 ON t2.object_id = fk.referenced_object_id INNER JOIN sys.columns c2 ON c2.column_id = referenced_column_id AND c2.object_id = t2.object_id", connection);

                connection.Open();

                // create data adapter
                SqlDataAdapter dataAdapter = new SqlDataAdapter(sqlCommand);

                DataTable dtRecord = new DataTable();
                dataAdapter.Fill(dtRecord);
                dataGridView1.DataSource = dtRecord;


                sqlCommand = new SqlCommand("SELECT LlaveForanea =o.name, Esquema =SCHEMA_NAME(t1.schema_id), Tabla =t1.name, Columna =c1.name, Esquema_Ref =SCHEMA_NAME(t2.schema_id), Tabla_Ref =t2.name, Columna_Ref =c2.name FROM sys.foreign_keys o INNER JOIN sys.foreign_key_columns fk ON o.object_id = fk.constraint_object_id INNER JOIN sys.tables t1 ON t1.object_id = fk.parent_object_id INNER JOIN sys.columns c1 ON c1.column_id = parent_column_id AND c1.object_id = t1.object_id INNER JOIN sys.tables t2 ON t2.object_id = fk.referenced_object_id INNER JOIN sys.columns c2 ON c2.column_id = referenced_column_id AND c2.object_id = t2.object_id", connection);

                SqlDataReader dataReader = sqlCommand.ExecuteReader();
                string        output_log = "LlaveForanea,Esquema,Tabla,Columna,Esquema_Ref,Tabla_Ref,Columna_Ref\n";
                while (dataReader.Read())
                {
                    // Console.WriteLine("LEYENDO " + dataReader.FieldCount);
                    int index = 0;

                    string LlaveForanea = dataReader.GetValue(index++).ToString();
                    string Esquema      = dataReader.GetValue(index++).ToString();
                    string Tabla        = dataReader.GetValue(index++).ToString();
                    string Columna      = dataReader.GetValue(index++).ToString();
                    string Esquema_Ref  = dataReader.GetValue(index++).ToString();
                    string Tabla_Ref    = dataReader.GetValue(index++).ToString();
                    string Columna_Ref  = dataReader.GetValue(index++).ToString();

                    output_log += LlaveForanea + "," + Esquema + "," + Tabla + "," + Columna + "," + Esquema_Ref + "," + Tabla_Ref + "," + Columna_Ref + "\n";
                }


                MyFileManager.writeTXT(output_log, "D://LOG_AUDITORIA_RELACIONES_INTEGRIDAD_REFERENCIAL.txt");

                sqlCommand.Dispose();
                dataReader.Close();
            }
            catch (Exception error)
            {
                Console.WriteLine("Error: " + error.Message);
            }
            finally
            {
                connection.Close();
            }



            /*
             *
             * string[][] sqls = new string[][] {
             *  //--->Esquemas
             *  //--Sys.schemas
             *  new string[]{"sys-schemas", "[name],[schema_id],[principal_id]", "SELECT [name],[schema_id],[principal_id] FROM [pubs].[sys].[schemas]"},
             *  //--->Información general de tablas:
             *  //--INFORMATION_SCHEMA.TABLES
             *  new string[]{ "INFORMATION_SCHEMA-TABLES", "[TABLE_CATALOG],[TABLE_SCHEMA],[TABLE_NAME]", "SELECT [TABLE_CATALOG],[TABLE_SCHEMA],[TABLE_NAME],[TABLE_TYPE] FROM[pubs].[INFORMATION_SCHEMA].[TABLES]"},
             *  //--->Información de claves primarias y foráneas
             *  //--INFORMATION_SCHEMA.REFERENTIAL_CONSTRAINTS
             *  new string[]{ "INFORMATION_SCHEMA-REFERENTIAL_CONSTRAINTS", "[CONSTRAINT_CATALOG],[CONSTRAINT_SCHEMA],[CONSTRAINT_NAME],[UNIQUE_CONSTRAINT_CATALOG],[UNIQUE_CONSTRAINT_SCHEMA],[UNIQUE_CONSTRAINT_NAME],[MATCH_OPTION],[UPDATE_RULE],[DELETE_RULE]", "SELECT [CONSTRAINT_CATALOG],[CONSTRAINT_SCHEMA],[CONSTRAINT_NAME],[UNIQUE_CONSTRAINT_CATALOG],[UNIQUE_CONSTRAINT_SCHEMA],[UNIQUE_CONSTRAINT_NAME],[MATCH_OPTION],[UPDATE_RULE],[DELETE_RULE] FROM [pubs].[INFORMATION_SCHEMA].[REFERENTIAL_CONSTRAINTS]"},
             *  //--INFORMATION_SCHEMA.TABLE_CONSTRAINTS
             *  new string[]{ "INFORMATION_SCHEMA-TABLE_CONSTRAINTS", "[CONSTRAINT_CATALOG],[CONSTRAINT_SCHEMA],[CONSTRAINT_NAME],[TABLE_CATALOG],[TABLE_SCHEMA],[TABLE_NAME],[CONSTRAINT_TYPE],[IS_DEFERRABLE],[INITIALLY_DEFERRED]", "SELECT [CONSTRAINT_CATALOG],[CONSTRAINT_SCHEMA],[CONSTRAINT_NAME],[TABLE_CATALOG],[TABLE_SCHEMA],[TABLE_NAME],[CONSTRAINT_TYPE],[IS_DEFERRABLE],[INITIALLY_DEFERRED] FROM [pubs].[INFORMATION_SCHEMA].[TABLE_CONSTRAINTS]"},
             *  //--Sys.key_constraints
             *  new string[]{ "sys-key_constraints", "[name], [object_id], [principal_id],[schema_id],[parent_object_id],[type],[type_desc],[create_date],[modify_date],[is_ms_shipped],[is_published],[is_schema_published],[unique_index_id],[is_system_named],[is_enforced]", "SELECT [name], [object_id], [principal_id],[schema_id],[parent_object_id],[type],[type_desc],[create_date],[modify_date],[is_ms_shipped],[is_published],[is_schema_published],[unique_index_id],[is_system_named],[is_enforced] FROM [pubs].[sys].[key_constraints]"},
             *  //--Sys.foreign_key_columns
             *  new string[]{ "sys-foreign_key_columns", "[constraint_object_id],[constraint_column_id],[parent_object_id],[parent_column_id],[referenced_object_id],[referenced_column_id]", "SELECT [constraint_object_id],[constraint_column_id],[parent_object_id],[parent_column_id],[referenced_object_id],[referenced_column_id] FROM [pubs].[sys].[foreign_key_columns]"},
             *  //--Sys.foreign_key
             *  new string[]{ "sys-foreign_key", "[name],[object_id],[principal_id],[schema_id],[parent_object_id],[type],[type_desc],[create_date],[modify_date],[is_ms_shipped],[is_published],[is_schema_published],[referenced_object_id],[key_index_id],[is_disabled],[is_not_for_replication],[is_not_trusted],[delete_referential_action],[delete_referential_action_desc],[update_referential_action],[update_referential_action_desc],[is_system_named]", "SELECT [name],[object_id],[principal_id],[schema_id],[parent_object_id],[type],[type_desc],[create_date],[modify_date],[is_ms_shipped],[is_published],[is_schema_published],[referenced_object_id],[key_index_id],[is_disabled],[is_not_for_replication],[is_not_trusted],[delete_referential_action],[delete_referential_action_desc],[update_referential_action],[update_referential_action_desc],[is_system_named] FROM [pubs].[sys].[foreign_keys]"},
             *  //--->Información general detallada de las tablas
             *  //--Sys.tables
             *  new string[]{ "sys-tables", "[name] ,[object_id] ,[principal_id] ,[schema_id] ,[parent_object_id] ,[type] ,[type_desc] ,[create_date] ,[modify_date] ,[is_ms_shipped] ,[is_published] ,[is_schema_published] ,[lob_data_space_id] ,[filestream_data_space_id] ,[max_column_id_used] ,[lock_on_bulk_load] ,[uses_ansi_nulls] ,[is_replicated] ,[has_replication_filter] ,[is_merge_published] ,[is_sync_tran_subscribed] ,[has_unchecked_assembly_data] ,[text_in_row_limit] ,[large_value_types_out_of_row] ,[is_tracked_by_cdc] ,[lock_escalation] ,[lock_escalation_desc] ,[is_filetable] ,[is_memory_optimized] ,[durability] ,[durability_desc] ,[temporal_type] ,[temporal_type_desc] ,[history_table_id] ,[is_remote_data_archive_enabled] ,[is_external] ,[history_retention_period] ,[history_retention_period_unit] ,[history_retention_period_unit_desc] ,[is_node] ,[is_edge]", "SELECT [name] ,[object_id] ,[principal_id] ,[schema_id] ,[parent_object_id] ,[type] ,[type_desc] ,[create_date] ,[modify_date] ,[is_ms_shipped] ,[is_published] ,[is_schema_published] ,[lob_data_space_id] ,[filestream_data_space_id] ,[max_column_id_used] ,[lock_on_bulk_load] ,[uses_ansi_nulls] ,[is_replicated] ,[has_replication_filter] ,[is_merge_published] ,[is_sync_tran_subscribed] ,[has_unchecked_assembly_data] ,[text_in_row_limit] ,[large_value_types_out_of_row] ,[is_tracked_by_cdc] ,[lock_escalation] ,[lock_escalation_desc] ,[is_filetable] ,[is_memory_optimized] ,[durability] ,[durability_desc] ,[temporal_type] ,[temporal_type_desc] ,[history_table_id] ,[is_remote_data_archive_enabled] ,[is_external] ,[history_retention_period] ,[history_retention_period_unit] ,[history_retention_period_unit_desc] ,[is_node] ,[is_edge] FROM [pubs].[sys].[tables]"},
             *  //--Sys.columns
             *  new string[]{ "sys-columns", "[object_id] ,[name] ,[column_id] ,[system_type_id] ,[user_type_id] ,[max_length] ,[precision] ,[scale] ,[collation_name] ,[is_nullable] ,[is_ansi_padded] ,[is_rowguidcol] ,[is_identity] ,[is_computed] ,[is_filestream] ,[is_replicated] ,[is_non_sql_subscribed] ,[is_merge_published] ,[is_dts_replicated] ,[is_xml_document] ,[xml_collection_id] ,[default_object_id] ,[rule_object_id] ,[is_sparse] ,[is_column_set] ,[generated_always_type] ,[generated_always_type_desc] ,[encryption_type] ,[encryption_type_desc] ,[encryption_algorithm_name] ,[column_encryption_key_id] ,[column_encryption_key_database_name] ,[is_hidden] ,[is_masked] ,[graph_type] ,[graph_type_desc]", "SELECT [object_id] ,[name] ,[column_id] ,[system_type_id] ,[user_type_id] ,[max_length] ,[precision] ,[scale] ,[collation_name] ,[is_nullable] ,[is_ansi_padded] ,[is_rowguidcol] ,[is_identity] ,[is_computed] ,[is_filestream] ,[is_replicated] ,[is_non_sql_subscribed] ,[is_merge_published] ,[is_dts_replicated] ,[is_xml_document] ,[xml_collection_id] ,[default_object_id] ,[rule_object_id] ,[is_sparse] ,[is_column_set] ,[generated_always_type] ,[generated_always_type_desc] ,[encryption_type] ,[encryption_type_desc] ,[encryption_algorithm_name] ,[column_encryption_key_id] ,[column_encryption_key_database_name] ,[is_hidden] ,[is_masked] ,[graph_type] ,[graph_type_desc] FROM [pubs].[sys].[columns]"},
             *  //--Sys.systypes
             *  new string[]{ "sys-systypes", "[name] ,[xtype] ,[status] ,[xusertype] ,[length] ,[xprec] ,[xscale] ,[tdefault] ,[domain] ,[uid] ,[reserved] ,[collationid] ,[usertype] ,[variable] ,[allownulls] ,[type] ,[printfmt] ,[prec] ,[scale] ,[collation]", "SELECT [name] ,[xtype] ,[status] ,[xusertype] ,[length] ,[xprec] ,[xscale] ,[tdefault] ,[domain] ,[uid] ,[reserved] ,[collationid] ,[usertype] ,[variable] ,[allownulls] ,[type] ,[printfmt] ,[prec] ,[scale] ,[collation] FROM [pubs].[sys].[systypes]"},
             *  //--Sys.default_constraints
             *  new string[]{ "sys-default_constraints", "[name] ,[object_id] ,[principal_id] ,[schema_id] ,[parent_object_id] ,[type] ,[type_desc] ,[create_date] ,[modify_date] ,[is_ms_shipped] ,[is_published] ,[is_schema_published] ,[parent_column_id] ,[definition] ,[is_system_named]", "SELECT [name] ,[object_id] ,[principal_id] ,[schema_id] ,[parent_object_id] ,[type] ,[type_desc] ,[create_date] ,[modify_date] ,[is_ms_shipped] ,[is_published] ,[is_schema_published] ,[parent_column_id] ,[definition] ,[is_system_named] FROM [pubs].[sys].[default_constraints]"},
             *  //--->Restricciones / Checks
             *  //--INFORMATION_SCHEMA.CHECK_CONSTRAINTS
             *  new string[]{ "INFORMATION_SCHEMA-CHECK_CONSTRAINTS", "[CONSTRAINT_CATALOG] ,[CONSTRAINT_SCHEMA] ,[CONSTRAINT_NAME] ,[CHECK_CLAUSE]", "SELECT [CONSTRAINT_CATALOG] ,[CONSTRAINT_SCHEMA] ,[CONSTRAINT_NAME] ,[CHECK_CLAUSE] FROM [pubs].[INFORMATION_SCHEMA].[CHECK_CONSTRAINTS]"},
             *  //--Sys.check_constraints
             *  new string[]{ "sys-check_constraints", "[name] ,[object_id] ,[principal_id] ,[schema_id] ,[parent_object_id] ,[type] ,[type_desc] ,[create_date] ,[modify_date] ,[is_ms_shipped] ,[is_published] ,[is_schema_published] ,[is_disabled] ,[is_not_for_replication] ,[is_not_trusted] ,[parent_column_id] ,[definition] ,[uses_database_collation] ,[is_system_named]", "SELECT [name] ,[object_id] ,[principal_id] ,[schema_id] ,[parent_object_id] ,[type] ,[type_desc] ,[create_date] ,[modify_date] ,[is_ms_shipped] ,[is_published] ,[is_schema_published] ,[is_disabled] ,[is_not_for_replication] ,[is_not_trusted] ,[parent_column_id] ,[definition] ,[uses_database_collation] ,[is_system_named] FROM [pubs].[sys].[check_constraints]"},
             *  //--Sys.triggers
             *  // new string[]{"sys-triggers", "[name] ,[object_id] ,[parent_class] ,[parent_class_desc] ,[parent_id] ,[type] ,[type_desc] ,[create_date] ,[modify_date] ,[is_ms_shipped] ,[is_disabled] ,[is_not_for_replication] ,[is_instead_of_trigger]", "SELECT [name] ,[object_id] ,[parent_class] ,[parent_class_desc] ,[parent_id] ,[type] ,[type_desc] ,[create_date] ,[modify_date] ,[is_ms_shipped] ,[is_disabled] ,[is_not_for_replication] ,[is_instead_of_trigger] FROM [pubs].[sys].[triggers]"},
             *
             *  };
             *
             *
             * for (int i = 0; i < sqls.Length; i++)
             * {
             *  string filename = sqls[i][0], header = sqls[i][1], sql = sqls[i][2];
             *  MyDB.selectAllAndWrite(sql, "D://" + filename + ".txt", header);
             * }
             *
             * MessageBox.Show("TXT generados con los metadatos en D://");
             */
        }
Пример #22
0
        public static void TestComputePEPValue()
        {
            var              variableModifications = new List <Modification>();
            var              fixedModifications    = new List <Modification>();
            var              origDataFile          = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\TaGe_SA_HeLa_04_subset_longestSeq.mzML");
            MyFileManager    myFileManager         = new MyFileManager(true);
            CommonParameters CommonParameters      = new CommonParameters(digestionParams: new DigestionParams());
            var              myMsDataFile          = myFileManager.LoadFile(origDataFile, CommonParameters);
            var              searchModes           = new SinglePpmAroundZeroSearchMode(5);
            List <Protein>   proteinList           = ProteinDbLoader.LoadProteinFasta(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\hela_snip_for_unitTest.fasta"), true, DecoyType.Reverse, false, ProteinDbLoader.UniprotAccessionRegex, ProteinDbLoader.UniprotFullNameRegex, ProteinDbLoader.UniprotFullNameRegex, ProteinDbLoader.UniprotGeneNameRegex,
                                                                                      ProteinDbLoader.UniprotOrganismRegex, out var dbErrors, -1);
            var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, @"TestData\TaGe_SA_HeLa_04_subset_longestSeq.mzML", CommonParameters).OrderBy(b => b.PrecursorMass).ToArray();

            PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length];
            new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchModes, CommonParameters, new List <string>()).Run();
            FdrAnalysisResults fdrResultsClassicDelta = (FdrAnalysisResults)(new FdrAnalysisEngine(allPsmsArray.Where(p => p != null).ToList(), 1, CommonParameters, new List <string>()).Run());

            var nonNullPsms             = allPsmsArray.Where(p => p != null).ToList();
            var nonNullPsmsOriginalCopy = allPsmsArray.Where(p => p != null).ToList();

            var maxScore = nonNullPsms.Select(n => n.Score).Max();
            PeptideSpectralMatch maxScorePsm = nonNullPsms.Where(n => n.Score == maxScore).First();

            Dictionary <string, int> sequenceToPsmCount = new Dictionary <string, int>();

            List <string> sequences = new List <string>();

            foreach (PeptideSpectralMatch psm in nonNullPsms)
            {
                var ss = psm.BestMatchingPeptides.Select(b => b.Peptide.FullSequence).ToList();
                sequences.Add(String.Join("|", ss));
            }

            var s = sequences.GroupBy(i => i);

            foreach (var grp in s)
            {
                sequenceToPsmCount.Add(grp.Key, grp.Count());
            }

            Dictionary <string, Dictionary <int, Tuple <double, double> > > fileSpecificRetTimeHI_behavior = new Dictionary <string, Dictionary <int, Tuple <double, double> > >();
            Dictionary <string, Dictionary <int, Tuple <double, double> > > fileSpecificRetTemHI_behaviorModifiedPeptides = new Dictionary <string, Dictionary <int, Tuple <double, double> > >();

            //average hydrophobicity, standard deviation hydrophobicity
            Tuple <double, double> at = new Tuple <double, double>(33.0, 1.0);

            Dictionary <int, Tuple <double, double> > HI_Time_avg_dev = new Dictionary <int, Tuple <double, double> >
            {
                { 154, at }
            };

            fileSpecificRetTimeHI_behavior.Add(@"TestData\TaGe_SA_HeLa_04_subset_longestSeq.mzML", HI_Time_avg_dev);

            string[] trainingVariables = new[] { "HydrophobicityZScore", "Intensity", "ScanPrecursorCharge", "DeltaScore", "Notch", "PsmCount", "ModsCount", "MissedCleavagesCount", "Ambiguity", "LongestFragmentIonSeries", "IsVariantPeptide" };

            int chargeStateMode = 4;

            var(notch, pwsm) = maxScorePsm.BestMatchingPeptides.First();
            var maxPsmData = PEP_Analysis.CreateOnePsmDataEntry(maxScorePsm, sequenceToPsmCount, fileSpecificRetTimeHI_behavior, fileSpecificRetTemHI_behaviorModifiedPeptides, chargeStateMode, pwsm, trainingVariables, notch, !pwsm.Protein.IsDecoy);

            Assert.That(maxScorePsm.PeptidesToMatchingFragments.Count - 1, Is.EqualTo(maxPsmData.Ambiguity));
            Assert.That(maxScorePsm.DeltaScore, Is.EqualTo(maxPsmData.DeltaScore).Within(0.05));
            Assert.That((float)(maxScorePsm.Score - (int)maxScorePsm.Score), Is.EqualTo(maxPsmData.Intensity).Within(0.05));
            Assert.That(maxPsmData.HydrophobicityZScore, Is.EqualTo(5.170955).Within(0.05));
            Assert.That(maxScorePsm.BestMatchingPeptides.Select(p => p.Peptide).First().MissedCleavages, Is.EqualTo(maxPsmData.MissedCleavagesCount));
            Assert.That(maxScorePsm.BestMatchingPeptides.Select(p => p.Peptide).First().AllModsOneIsNterminus.Values.Count(), Is.EqualTo(maxPsmData.ModsCount));
            Assert.That(maxScorePsm.Notch ?? 0, Is.EqualTo(maxPsmData.Notch));
            Assert.That(maxScorePsm.PsmCount, Is.EqualTo(maxPsmData.PsmCount));
            Assert.That(-Math.Abs(chargeStateMode - maxScorePsm.ScanPrecursorCharge), Is.EqualTo(maxPsmData.PrecursorChargeDiffToMode));
            Assert.AreEqual((float)0, maxPsmData.IsVariantPeptide);

            PEP_Analysis.ComputePEPValuesForAllPSMsGeneric(nonNullPsms);

            int trueCount = 0;

            foreach (var item in allPsmsArray.Where(p => p != null))
            {
                var b = item.FdrInfo.PEP;
                if (b >= 0.5)
                {
                    trueCount++;
                }
            }

            List <PeptideSpectralMatch> moreNonNullPSMs = new List <PeptideSpectralMatch>();

            for (int i = 0; i < 3; i++)
            {
                foreach (PeptideSpectralMatch psm in nonNullPsms)
                {
                    moreNonNullPSMs.Add(psm);
                }
            }

            string expectedMetrics = "************************************************************\r\n*       Metrics for Determination of PEP Using Binary Classification      \r\n" +
                                     "*-----------------------------------------------------------\r\n*       Accuracy:  1\r\n*       Area Under Curve:  1\r\n*       Area under Precision recall Curve:  1\r\n*       F1Score:  1\r\n" +
                                     "*       LogLoss:  2.60551851621861E-10\r\n*       LogLossReduction:  0.999999999599165\r\n*       PositivePrecision:  1\r\n*       PositiveRecall:  1\r\n*       NegativePrecision:  1\r\n" +
                                     "*       NegativeRecall:  1\r\n*       Count of Ambiguous Peptides Removed:  0\r\n************************************************************\r\n";

            string metrics = PEP_Analysis.ComputePEPValuesForAllPSMsGeneric(moreNonNullPSMs);

            Assert.AreEqual(expectedMetrics, metrics);
            Assert.GreaterOrEqual(32, trueCount);

            //Test Variant Peptide as Input is identified as such as part of PEP calculation input much of the next several lines simply necessry to create a psm.

            var anMzSpectrum             = new MzSpectrum(new double[] { 1, 1 }, new double[] { 2, 2 }, true);
            Ms2ScanWithSpecificMass scan = new Ms2ScanWithSpecificMass(new MsDataScan(anMzSpectrum, 1, 1, true, Polarity.Negative, 2, null, "", MZAnalyzerType.Orbitrap, 2, null, null, null), 1, 1, "path", new CommonParameters());
            Protein variantProtein       = new Protein("MPEPPPTIDE", "protein3", sequenceVariations: new List <SequenceVariation> {
                new SequenceVariation(4, 6, "PPP", "P", @"1\t50000000\t.\tA\tG\t.\tPASS\tANN=G||||||||||||||||\tGT:AD:DP\t1/1:30,30:30", null)
            });
            PeptideWithSetModifications varPep     = variantProtein.GetVariantProteins().SelectMany(p => p.Digest(CommonParameters.DigestionParams, null, null)).FirstOrDefault();
            PeptideSpectralMatch        variantPSM = new PeptideSpectralMatch(varPep, 0, maxScorePsm.Score, maxScorePsm.ScanIndex, scan, new DigestionParams(), null);

            sequenceToPsmCount = new Dictionary <string, int>();
            sequences          = new List <string>();
            nonNullPsms.Add(variantPSM);
            foreach (PeptideSpectralMatch psm in nonNullPsms)
            {
                var ss = psm.BestMatchingPeptides.Select(b => b.Peptide.FullSequence).ToList();
                sequences.Add(String.Join("|", ss));
            }

            s = sequences.GroupBy(i => i);

            foreach (var grp in s)
            {
                sequenceToPsmCount.Add(grp.Key, grp.Count());
            }
            var(vnotch, vpwsm) = variantPSM.BestMatchingPeptides.First();
            PsmData variantPsmData = PEP_Analysis.CreateOnePsmDataEntry(variantPSM, sequenceToPsmCount, fileSpecificRetTimeHI_behavior, fileSpecificRetTemHI_behaviorModifiedPeptides, chargeStateMode, vpwsm, trainingVariables, vnotch, !maxScorePsm.IsDecoy);

            Assert.AreEqual((float)1, variantPsmData.IsVariantPeptide);
        }
Пример #23
0
        private void ProcessAscii(DecryptedObject decryptedObject)
        {
            bool foundSomething = false;

            string sDecryptOrig = decryptedObject.GetDecodedString(Encoding.UTF8);

            var sDecyptPrintable = new StringBuilder(sDecryptOrig).RemoveAsciiControllChars().RemoveNewLines().RemoveChar(';').GetString();

            if (new StringBuilder(sDecryptOrig).CountChar("[½|¿]") > 100)
            {
                string ln = $";{decryptedObject.GetBytesKeyHex()};;;;;;;;;;;;;{sDecyptPrintable}";
                MyFileManagerBad.ConcatNewLine(ln);
                return;
            }
            string sProcessed = new StringBuilder(sDecryptOrig).RemoveNoneAlphanumericChars().GetString();


            int cDChars  = new StringBuilder(sDecryptOrig).CountChars(); //Numero de Caracteres en String Decriptada
            int cPChars  = new StringBuilder(sProcessed).CountChars();   //Numero de Caracteres en String Procesada
            int cCharDif = cDChars - cPChars;                            // Diferencia Numercia de Caracteres entre original y procesada



            if (Regex.Match(sDecryptOrig, regex, RegexOptions.IgnoreCase).Success)
            {
                foundSomething = true;
            }


            //var sDecyptPrintable = new StringBuilder(sDecryptOrig).RemoveNewLines()
            //    .RemoveChar(';').RemoveChar('\n').RemoveChar('?').RemoveAsciiControllChars().GetString();

            int cDIsAlpha = new StringBuilder(sDecryptOrig).CountAlphanumericChars();   //Numero de Caracteres Alphanumericos
            int cDNoAlpha = new StringBuilder(sDecryptOrig).CountNoAlphanumericChars(); //Numero de Caracteres No Alphanumericos

            int cDIsHex = new StringBuilder(sDecryptOrig).CountHexadecimalChars();      //Numero de Caracteres Hexadecimales
            int cDNoHex = new StringBuilder(sDecryptOrig).CountNoHexadecimalChars();    //Numero de Caracteres No Hexadecimales


            //int cPIsAlpha = new StringBuilder(sProcessed).CountAlphanumericChars(); //Numero de Caracteres Alphanumericos
            int cPNoAlpha = new StringBuilder(sProcessed).CountNoAlphanumericChars(); //Numero de Caracteres No Alphanumericos

            //int cPIsHex = new StringBuilder(sProcessed).CountHexadecimalChars(); //Numero de Caracteres Hexadecimales
            int cPNoHex = new StringBuilder(sProcessed).CountNoHexadecimalChars(); //Numero de Caracteres No Hexadecimales


            string line = $"{foundSomething}";

            line += $";{decryptedObject.GetBytesKeyHex()}"; //Llave utilizada
            line += $";{cDChars};{cPChars}";                //Numero de Caracteres en la String
            line += $";{cCharDif}";                         // Diferencia Numercia de Caracteres entre original y procesada

            //cPIsAlpha
            line += $";{cDIsAlpha};";            //Numero de Caracteres Alphanumericos original y procesada

            line += $";{cDNoAlpha};{cPNoAlpha}"; //Numero de Caracteres No Alphanumericos original y procesada

            //cPIsHex
            line += $";{cDIsHex};";          //Numero de Caracteres Hexadecimales original y procesada

            line += $";{cDNoHex};{cPNoHex}"; //Numero de Caracteres No Hexadecimales original y procesada

            line += $";{sProcessed}";        // String Procesada
            line += $";{sDecyptPrintable}";  // String original sin saltos de linea ni ';'

            if (foundSomething == true)
            {
                MyFileManagerSuccesses.ConcatNewLine(line);
            }

            MyFileManager.ConcatNewLine(line);
        }
Пример #24
0
        public static void TestComputePEPValueTopDown()
        {
            //just making sure that topdown data goes through the pep calculator without crashing.
            CommonParameters CommonParameters = new CommonParameters(
                digestionParams: new DigestionParams(protease: "top-down"),
                scoreCutoff: 1,
                assumeOrphanPeaksAreZ1Fragments: false);

            var            variableModifications = new List <Modification>();
            var            fixedModifications    = new List <Modification>();
            List <Protein> proteinList           = ProteinDbLoader.LoadProteinFasta(Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\HeLaFakeTopDown.fasta"), true, DecoyType.Reverse, false, ProteinDbLoader.UniprotAccessionRegex, ProteinDbLoader.UniprotFullNameRegex, ProteinDbLoader.UniprotFullNameRegex, ProteinDbLoader.UniprotGeneNameRegex,
                                                                                    ProteinDbLoader.UniprotOrganismRegex, out var dbErrors, -1);

            var           origDataFile  = Path.Combine(TestContext.CurrentContext.TestDirectory, @"TestData\TaGe_SA_HeLa_04_subset_longestSeq.mzML");
            MyFileManager myFileManager = new MyFileManager(true);
            var           myMsDataFile  = myFileManager.LoadFile(origDataFile, CommonParameters);

            var searchMode = new SinglePpmAroundZeroSearchMode(5);

            Tolerance DeconvolutionMassTolerance = new PpmTolerance(5);

            var listOfSortedms2Scans = MetaMorpheusTask.GetMs2Scans(myMsDataFile, null, new CommonParameters()).OrderBy(b => b.PrecursorMass).ToArray();

            PeptideSpectralMatch[] allPsmsArray = new PeptideSpectralMatch[listOfSortedms2Scans.Length];
            new ClassicSearchEngine(allPsmsArray, listOfSortedms2Scans, variableModifications, fixedModifications, null, null, null, proteinList, searchMode, CommonParameters, new List <string>()).Run();
            var nonNullPsms = allPsmsArray.Where(p => p != null).ToList();
            List <PeptideSpectralMatch> moreNonNullPSMs = new List <PeptideSpectralMatch>();

            int reps = 3;

            for (int i = 0; i < reps; i++)
            {
                foreach (PeptideSpectralMatch psm in nonNullPsms)
                {
                    moreNonNullPSMs.Add(psm);
                }
            }

            FdrAnalysisResults fdrResultsClassicDelta = (FdrAnalysisResults)(new FdrAnalysisEngine(moreNonNullPSMs.Where(p => p != null).ToList(), 1, CommonParameters, new List <string>()).Run());

            var maxScore = nonNullPsms.Select(n => n.Score).Max();
            PeptideSpectralMatch     maxScorePsm        = nonNullPsms.Where(n => n.Score == maxScore).First();
            Dictionary <string, int> sequenceToPsmCount = new Dictionary <string, int>();
            List <string>            sequences          = new List <string>();

            foreach (PeptideSpectralMatch psm in nonNullPsms)
            {
                var ss = psm.BestMatchingPeptides.Select(b => b.Peptide.FullSequence).ToList();
                sequences.Add(String.Join("|", ss));
            }
            var s = sequences.GroupBy(i => i);

            foreach (var grp in s)
            {
                sequenceToPsmCount.Add(grp.Key, grp.Count());
            }

            Dictionary <string, Dictionary <int, Tuple <double, double> > > fileSpecificRetTimeHI_behavior = new Dictionary <string, Dictionary <int, Tuple <double, double> > >();
            Dictionary <string, Dictionary <int, Tuple <double, double> > > fileSpecificRetTemHI_behaviorModifiedPeptides = new Dictionary <string, Dictionary <int, Tuple <double, double> > >();

            string[] trainingVariables = PsmData.trainingInfos["topDown"];

            int chargeStateMode = 4;

            var(notch, pwsm) = maxScorePsm.BestMatchingPeptides.First();
            var maxPsmData = PEP_Analysis.CreateOnePsmDataEntry(maxScorePsm, sequenceToPsmCount, fileSpecificRetTimeHI_behavior, fileSpecificRetTemHI_behaviorModifiedPeptides, chargeStateMode, pwsm, trainingVariables, notch, !pwsm.Protein.IsDecoy);

            Assert.That(maxScorePsm.PeptidesToMatchingFragments.Count - 1, Is.EqualTo(maxPsmData.Ambiguity));
            Assert.That(maxScorePsm.DeltaScore, Is.EqualTo(maxPsmData.DeltaScore).Within(0.05));
            Assert.That((float)(maxScorePsm.Score - (int)maxScorePsm.Score), Is.EqualTo(maxPsmData.Intensity).Within(0.05));
            Assert.AreEqual(maxPsmData.HydrophobicityZScore, float.NaN);
            Assert.That(maxScorePsm.BestMatchingPeptides.Select(p => p.Peptide).First().MissedCleavages, Is.EqualTo(maxPsmData.MissedCleavagesCount));
            Assert.That(maxScorePsm.BestMatchingPeptides.Select(p => p.Peptide).First().AllModsOneIsNterminus.Values.Count(), Is.EqualTo(maxPsmData.ModsCount));
            Assert.That(maxScorePsm.Notch ?? 0, Is.EqualTo(maxPsmData.Notch));
            Assert.That(maxScorePsm.PsmCount, Is.EqualTo(maxPsmData.PsmCount * reps));
            Assert.That(-Math.Abs(chargeStateMode - maxScorePsm.ScanPrecursorCharge), Is.EqualTo(maxPsmData.PrecursorChargeDiffToMode));
            Assert.AreEqual((float)0, maxPsmData.IsVariantPeptide);
        }
Пример #25
0
 private void toolStripMenuItemEditPaste_Click(object sender, EventArgs e)
 {
     if (fullPathForCopyList.Count > 0)
     {
         foreach (string source in fullPathForCopyList)
         {
             if (Path.GetExtension(source) != String.Empty)
             {
                 string fileName = Path.GetFileName(source);
                 try
                 {
                     if (mustCutItems)
                     {
                         File.Move(source, Path.Combine(fullPathSelected, fileName));
                         this.toolStripStatusLabel1.Text = "Перемещение файла";
                     }
                     else
                     {
                         MyFileManager.CopyFile(source, Path.Combine(fullPathSelected, fileName));
                         this.toolStripStatusLabel1.Text = "Копирование файла";
                     }
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.Message,
                                     "Ошибка при копировании файла " + source,
                                     MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
             else
             {
                 string folderName = Path.GetFileName(source);
                 try
                 {
                     if (mustCutItems)
                     {
                         MyFileManager.MoveDirectory(source, Path.Combine(fullPathSelected, folderName));
                         this.toolStripStatusLabel1.Text = "Перемещение папки";
                     }
                     else
                     {
                         MyFileManager.CopyDirectory(source, Path.Combine(fullPathSelected, folderName));
                         this.toolStripStatusLabel1.Text = "Копирование папки";
                     }
                 }
                 catch (Exception ex)
                 {
                     MessageBox.Show(ex.Message,
                                     "Ошибка при копировании папки " + source,
                                     MessageBoxButtons.OK, MessageBoxIcon.Error);
                 }
             }
         }
         LoadList();
         UpdateTreeNode(Path.GetPathRoot(fullPathForCopyList[0]));
         UpdateTreeNode(fullPathSelected);
         fullPathForCopyList.Clear();
         this.toolStripStatusLabel1.Text = "";
         mustCutItems = false;
     }
 }
Пример #26
0
        private void AddAFile(string draggedFilePath)
        {
            // this line is NOT used because .xml.gz (extensions with two dots) mess up with Path.GetExtension
            //var theExtension = Path.GetExtension(draggedFilePath).ToLowerInvariant();

            // we need to get the filename before parsing out the extension because if we assume that everything after the dot
            // is the extension and there are dots in the file path (i.e. in a folder name), this will mess up
            var filename     = Path.GetFileName(draggedFilePath);
            var theExtension = filename.Substring(filename.IndexOf(".")).ToLowerInvariant();

            switch (theExtension)
            {
            case ".raw":
                var versionCheckerResult = MyFileManager.ValidateThermoMsFileReaderVersion();

                if (versionCheckerResult.Equals(MyFileManager.ThermoMsFileReaderVersionCheck.IncorrectVersion))
                {
                    GuiWarnHandler(null, new StringEventArgs("Warning! Thermo MSFileReader is not version 3.0 SP2; a crash may result from searching this .raw file", null));
                }
                else if (versionCheckerResult.Equals(MyFileManager.ThermoMsFileReaderVersionCheck.DllsNotFound))
                {
                    GuiWarnHandler(null, new StringEventArgs("Warning! Cannot find Thermo MSFileReader (v3.0 SP2 is preferred); a crash may result from searching this .raw file", null));
                }
                goto case ".mzml";

            case ".mzml":
                RawDataForDataGrid zz = new RawDataForDataGrid(draggedFilePath);
                if (!ExistRaw(rawDataObservableCollection, zz))
                {
                    rawDataObservableCollection.Add(zz);
                }
                UpdateFileSpecificParamsDisplayJustAdded(Path.ChangeExtension(draggedFilePath, ".toml"));
                UpdateOutputFolderTextbox();
                break;

            case ".mzml.gz":      // not implemented yet
            case ".fasta.gz":     // not implemented yet
                GuiWarnHandler(null, new StringEventArgs("Cannot read, try uncompressing: " + draggedFilePath, null));
                break;

            case ".xml":
            case ".xml.gz":
            case ".fasta":
            case ".fa":
                ProteinDbForDataGrid uu = new ProteinDbForDataGrid(draggedFilePath);

                if (!ExistDa(proteinDbObservableCollection, uu))
                {
                    proteinDbObservableCollection.Add(uu);
                    if (theExtension.Equals(".xml") || theExtension.Equals(".xml.gz"))
                    {
                        try
                        {
                            GlobalVariables.AddMods(UsefulProteomicsDatabases.ProteinDbLoader.GetPtmListFromProteinXml(draggedFilePath).OfType <ModificationWithLocation>());
                        }
                        catch (Exception ee)
                        {
                            MessageBox.Show(ee.ToString());
                            GuiWarnHandler(null, new StringEventArgs("Cannot read: " + draggedFilePath, null));
                            proteinDbObservableCollection.Remove(uu);
                        }
                    }
                }
                break;

            case ".toml":
                var tomlFile = Toml.ReadFile(draggedFilePath, MetaMorpheusTask.tomlConfig);
                if (tomlFile.Keys.Contains("PrecursorMassTolerance") && tomlFile.Keys.Contains("ProductMassTolerance") && tomlFile.Keys.Count == 2)
                {
                    // do nothing; it's a ppm suggested tolerance toml from calibration, this gets read in elsewhere
                }
                else
                {
                    try
                    {
                        switch (tomlFile.Get <string>("TaskType"))
                        {
                        case "Search":
                            var ye1 = Toml.ReadFile <SearchTask>(draggedFilePath, MetaMorpheusTask.tomlConfig);
                            AddTaskToCollection(ye1);
                            break;

                        case "Calibrate":
                            var ye2 = Toml.ReadFile <CalibrationTask>(draggedFilePath, MetaMorpheusTask.tomlConfig);
                            AddTaskToCollection(ye2);
                            break;

                        case "Gptmd":
                            var ye3 = Toml.ReadFile <GptmdTask>(draggedFilePath, MetaMorpheusTask.tomlConfig);
                            AddTaskToCollection(ye3);
                            break;

                        case "XLSearch":
                            var ye4 = Toml.ReadFile <XLSearchTask>(draggedFilePath, MetaMorpheusTask.tomlConfig);
                            AddTaskToCollection(ye4);
                            break;

                        case "Neo":
                            var ye5 = Toml.ReadFile <NeoSearchTask>(draggedFilePath, MetaMorpheusTask.tomlConfig);
                            foreach (MetaMorpheusTask task in NeoLoadTomls.LoadTomls(ye5))
                            {
                                AddTaskToCollection(task);
                            }
                            break;
                        }
                    }
                    catch (Exception e)
                    {
                        GuiWarnHandler(null, new StringEventArgs("Could not parse .toml: " + e.Message, null));
                    }
                }
                break;

            default:
                GuiWarnHandler(null, new StringEventArgs("Unrecognized file type: " + theExtension, null));
                break;
            }
        }