コード例 #1
0
ファイル: IQExecutor.cs プロジェクト: trishorts/DeconTools
        public void SetupMassAndNetAlignment(string alignmentFolder = "")
        {
            WorkflowExecutorBaseParameters massNetAlignerParameters = new BasicTargetedWorkflowExecutorParameters();


            IqMassAndNetAligner = new IqMassAndNetAligner(massNetAlignerParameters, Run);
            IqMassAndNetAligner.LoessBandwidthNetAlignment = 0.1;

            //check if alignment info exists already

            SetupAlignmentFolder(alignmentFolder);

            var expectedAlignmentFilename = Path.Combine(_alignmentFolder, Run.DatasetName + "_iqAlignmentResults.txt");
            var alignmentResultsExist     = (File.Exists(expectedAlignmentFilename));

            if (alignmentResultsExist)
            {
                IqLogger.Log.Info("Using the IQ alignment results from here: " + expectedAlignmentFilename);
                IqMassAndNetAligner.LoadPreviousIqResults(expectedAlignmentFilename);

                SetMassTagReferencesForNetAlignment();
                return;
            }

            //Get a suitable targets file for alignment. These are grabbed from the ..\AlignmentInfo folder.
            var targetFileForAlignment = GetTargetFilePathForIqAlignment();


            if (string.IsNullOrEmpty(targetFileForAlignment))
            {
                IqLogger.Log.Info("Alignment not performed - No suitable target file found for use in alignment.");
                return;
            }

            if (!File.Exists(targetFileForAlignment))
            {
                IqLogger.Log.Info("Alignment not performed - Target file for alignment has been specified but a FILE NOT FOUND error has occured.");
                return;
            }

            var isFirstHitsFile = targetFileForAlignment.EndsWith("_fht.txt");

            if (!isFirstHitsFile)
            {
                IqLogger.Log.Info("Alignment not performed - target file for alignment must be a first hits file (_fht.txt)");
                return;
            }

            IqMassAndNetAligner.LoadAndInitializeTargets(targetFileForAlignment);

            SetMassTagReferencesForNetAlignment();
        }
コード例 #2
0
        public void JoinTargetsTest1()
        {
            var targetsFileName =
                @"\\proto-7\VOrbi05\2013_2\mhp_plat_test_1_14April13_Frodo_12-12-04\MSG201305011339_Auto939903\mhp_plat_test_1_14April13_Frodo_12-12-04_msgfdb_fht.txt";

            var massTagFilename =
                @"\\protoapps\DataPkgs\Public\2013\795_Iq_analysis_of_mouse_O16O18\Targets\MT_Mouse_MHP_O18_Set1_P890_targets.txt";

            var rawFile = @"D:\Data\O16O18\Vlad_Mouse\mhp_plat_test_1_14April13_Frodo_12-12-04.raw";



            IqTargetImporter massTagImporter = new BasicIqTargetImporter(massTagFilename);
            var massTagRefs = massTagImporter.Import().OrderBy(p => p.Code).ToList();

            WorkflowExecutorBaseParameters parameters = new BasicTargetedWorkflowExecutorParameters();

            parameters.TargetsFilePath = targetsFileName;

            var run = new RunFactory().CreateRun(rawFile);

            var massAndNetAligner = new IqMassAndNetAligner(parameters, run);

            massAndNetAligner.LoadAndInitializeTargets();

            var testNET = massAndNetAligner.Targets.First().ElutionTimeTheor;

            var query = (from massTag in massTagRefs
                         join target in massAndNetAligner.Targets on massTag.Code equals target.Code
                         select new
            {
                MassTag = massTag,
                MSGFTarget = target
            }).ToList();


            foreach (var thing in query)
            {
                thing.MSGFTarget.ID = thing.MassTag.ID;
                thing.MSGFTarget.ElutionTimeTheor = thing.MassTag.ElutionTimeTheor;
            }

            var targets = query.Select(p => p.MSGFTarget).ToList();

            var testNETAfter = massAndNetAligner.Targets.First().ElutionTimeTheor;

            Console.WriteLine("NET before= " + testNET);
            Console.WriteLine("NET before= " + testNETAfter);
        }
コード例 #3
0
        public void Test1()
        {
            var targetsFileName =
                @"\\proto-7\VOrbi05\2013_2\mhp_plat_test_1_14April13_Frodo_12-12-04\MSG201305011339_Auto939903\mhp_plat_test_1_14April13_Frodo_12-12-04_msgfdb_fht.txt";


            var massTagFilename =
                @"\\protoapps\DataPkgs\Public\2013\795_Iq_analysis_of_mouse_O16O18\Targets\MT_Mouse_MHP_O18_Set1_P890_targets.txt";

            var rawFile = @"D:\Data\O16O18\Vlad_Mouse\mhp_plat_test_1_14April13_Frodo_12-12-04.raw";

            WorkflowExecutorBaseParameters parameters = new BasicTargetedWorkflowExecutorParameters();

            parameters.TargetsFilePath = targetsFileName;

            var run = new RunFactory().CreateRun(rawFile);

            var massAndNetAligner = new IqMassAndNetAligner(parameters, run);


            massAndNetAligner.LoadAndInitializeTargets();

            IqTargetImporter massTagImporter = new BasicIqTargetImporter(massTagFilename);
            var massTagRefs = massTagImporter.Import();

            massAndNetAligner.SetMassTagReferences(massTagRefs);

            //massAligner.Targets = massAligner.Targets.Take(1).ToList();

            massAndNetAligner.ExecuteAlignment();

            var sb = new StringBuilder();

            var usefulResults = new List <IqResult>();

            foreach (var iqResult in massAndNetAligner.Results)
            {
                var childresults = iqResult.ChildResults();
                foreach (var childresult in childresults)
                {
                    if (childresult.ObservedIsotopicProfile == null)
                    {
                        continue;
                    }



                    sb.Append(childresult.Target.ID);
                    sb.Append("\t");


                    if (childresult.ObservedIsotopicProfile == null)
                    {
                        sb.Append("[null]");
                        sb.Append(Environment.NewLine);
                    }
                    else
                    {
                        usefulResults.Add(childresult);

                        sb.Append(childresult.ChromPeakSelected.XValue);
                        sb.Append("\t");
                        sb.Append(childresult.ElutionTimeObs);
                        sb.Append("\t");
                        sb.Append(childresult.ParentResult.Target.ElutionTimeTheor);
                        sb.Append("\t");
                        sb.Append(childresult.MZObs.ToString("0.00000"));
                        sb.Append("\t");
                        sb.Append(childresult.MonoMassObs.ToString("0.00000"));
                        sb.Append("\t");
                        sb.Append(childresult.MassErrorBefore.ToString("0.00000"));
                        sb.Append("\t");
                        sb.Append(childresult.FitScore.ToString("0.000"));

                        sb.Append(Environment.NewLine);
                    }
                }
            }


            var averageMassError = usefulResults.Average(p => p.MassErrorBefore);

            var stdev = MathUtils.GetStDev(usefulResults.Select(p => p.MassErrorBefore).ToList());

            //Console.WriteLine(sb.ToString());

            Console.WriteLine("avg mass error= " + averageMassError);
            Console.WriteLine("stdev= " + stdev);

            Console.WriteLine("----------- mass alignment ------------");
            TestUtilities.DisplayXYValues(massAndNetAligner.MassAlignmentInfo.ScanAndPpmShiftVals);


            Console.WriteLine("------------NET alignment --------------");

            DisplayNetAlignmentInfo(massAndNetAligner.NetAlignmentInfo);
        }
コード例 #4
0
        public void AlignUsingMsgfOutputFullProcessingTest1()
        {
            var targetsFileName =
                @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\Unlabelled\AlignmentInfo\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18_msgfdb_fht.txt";


            var massTagFilename =
                @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\Unlabelled\Targets\QCShew_ProdTest_Formic_P823_PMT3.txt";

            var rawFile =
                @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\Unlabelled\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18.RAW";

            WorkflowExecutorBaseParameters parameters = new BasicTargetedWorkflowExecutorParameters();

            parameters.TargetsFilePath          = targetsFileName;
            parameters.ReferenceTargetsFilePath = massTagFilename;

            var run = new RunFactory().CreateRun(rawFile);

            var massAndNetAligner = new IqMassAndNetAligner(parameters, run);

            massAndNetAligner.LoadAndInitializeTargets();

            massAndNetAligner.Targets = massAndNetAligner.Targets.Take(2000).ToList();

            var exportedAlignmentResultsFile =
                @"\\protoapps\UserData\Slysz\Standard_Testing\Targeted_FeatureFinding\Unlabelled\AlignmentInfo\QC_Shew_08_04-pt5-2_11Jan09_Sphinx_08-11-18_iqAlignmentResults.txt";

            if (!File.Exists(exportedAlignmentResultsFile))
            {
                File.Delete(exportedAlignmentResultsFile);
            }



            IqTargetImporter massTagImporter = new BasicIqTargetImporter(massTagFilename);
            var massTagRefs = massTagImporter.Import();

            massAndNetAligner.SetMassTagReferences(massTagRefs);

            //massAligner.Targets = massAligner.Targets.Take(1).ToList();

            massAndNetAligner.ExecuteAlignment();

            var sb = new StringBuilder();

            var usefulResults = new List <IqResult>();

            massAndNetAligner.ExportResults(exportedAlignmentResultsFile);


            foreach (var iqResult in massAndNetAligner.Results)
            {
                var childresults = iqResult.ChildResults();
                foreach (var childresult in childresults)
                {
                    if (childresult.ObservedIsotopicProfile == null)
                    {
                        continue;
                    }



                    sb.Append(childresult.Target.ID);
                    sb.Append("\t");


                    if (childresult.ObservedIsotopicProfile == null)
                    {
                        sb.Append("[null]");
                        sb.Append(Environment.NewLine);
                    }
                    else
                    {
                        usefulResults.Add(childresult);

                        sb.Append(childresult.ChromPeakSelected.XValue);
                        sb.Append("\t");
                        sb.Append(childresult.ElutionTimeObs);
                        sb.Append("\t");
                        sb.Append(childresult.ParentResult.Target.ElutionTimeTheor);
                        sb.Append("\t");
                        sb.Append(childresult.MZObs.ToString("0.00000"));
                        sb.Append("\t");
                        sb.Append(childresult.MonoMassObs.ToString("0.00000"));
                        sb.Append("\t");
                        sb.Append(childresult.MassErrorBefore.ToString("0.00000"));
                        sb.Append("\t");
                        sb.Append(childresult.FitScore.ToString("0.000"));

                        sb.Append(Environment.NewLine);
                    }
                }
            }

            var averageMassError = usefulResults.Average(p => p.MassErrorBefore);

            var stdev = MathUtils.GetStDev(usefulResults.Select(p => p.MassErrorBefore).ToList());

            Console.WriteLine(sb.ToString());

            Console.WriteLine("avg mass error= " + averageMassError);
            Console.WriteLine("stdev= " + stdev);

            Console.WriteLine("----------- mass alignment ------------");
            TestUtilities.DisplayXYValues(massAndNetAligner.MassAlignmentInfo.ScanAndPpmShiftVals);


            Console.WriteLine("------------NET alignment --------------");
            DisplayNetAlignmentInfo(massAndNetAligner.NetAlignmentInfo);
        }