Exemplo n.º 1
0
        public void TestVennDiagram()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            TestUtils.ShowStarting(methodName);

            const string result1Path = @"C:\cygwin\home\kims336\Data\QCShewQE\NoMod_NTT1.tsv";
            const string result2Path = @"C:\cygwin\home\kims336\Data\QCShewQE\Ic_NTT1_Test\QC_Shew_13_04_A_17Feb14_Samwise_13-07-28_IcTda.tsv";

            if (!File.Exists(result1Path))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, result1Path);
            }

            if (!File.Exists(result2Path))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, result2Path);
            }

            const double pepQValueThreshold = 0.01;
            var result1 = new TsvFileParser(result1Path);
            var result2 = new TsvFileParser(result2Path);

            var vennDiagram = new VennDiagram<string>(result1.GetPeptides(pepQValueThreshold),
                                                      result2.GetPeptides(pepQValueThreshold));

            var intersectionPeptides = vennDiagram.Intersection;
            Console.WriteLine(vennDiagram.Set1 + " " + vennDiagram.Set2);
            Console.WriteLine(vennDiagram.Set1 + " " + vennDiagram.Intersection + " " + vennDiagram.Set2Only);
        }
Exemplo n.º 2
0
        public void GenerateVennDiagrams()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            TestUtils.ShowStarting(methodName);

            // DIA
            const string dir = @"H:\Research\EDRN\Ic\DIA_Replicate";

            const string rep1 = dir + @"\EDRN_Serum_07_DIA_1_01_13Nov13_Samwise_13-07-28_IcTda.tsv";
            //const string rep2 = dir + @"\EDRN_Serum_07_DIA_1_02_13Nov13_Samwise_13-07-28_IcTda.tsv";
            //const string rep3 = dir + @"\EDRN_Serum_07_DIA_1_03_13Nov13_Samwise_13-07-28_IcTda.tsv";
            const string rep4 = dir + @"\EDRN_Serum_07_DIA_1_04_13Nov13_Samwise_13-07-28_IcTda.tsv";
            //const string rep5 = dir + @"\EDRN_Serum_07_DIA_1_05_18Nov13_Samwise_13-07-28_IcTda.tsv";

            const string resultPath1 = rep1;
            const string resultPath2 = rep4;

            var result1 = new TsvFileParser(resultPath1);
            var result2 = new TsvFileParser(resultPath2);

            const double pepQValueThreshold = 0.01;
            var          vennDiagram        = new VennDiagram <string>(result1.GetPeptidesAboveQValueThreshold(pepQValueThreshold),
                                                                       result2.GetPeptidesAboveQValueThreshold(pepQValueThreshold));

            Console.WriteLine("{0}\t{1}\t{2}",
                              vennDiagram.Set1Only.Count, // + vennDiagram.Intersection.Count,
                              vennDiagram.Intersection.Count,
                              vennDiagram.Set2Only.Count  //+ vennDiagram.Intersection.Count
                              );
        }
        public static Diff DiffGenericObjects(IEnumerable <object> pastObjects, IEnumerable <object> currentObjects, DiffConfig diffConfig = null, bool useExistingHash = false)
        {
            BH.Engine.Reflection.Compute.RecordNote("This diffing method cannot track modified objects between different revisions." +
                                                    "\nIt will simply return the objects that appear exclusively in the past set, in the following set, and in both." +
                                                    $"\nConsider using '{nameof(DiffWithCustomId)}', '{nameof(DiffWithFragmentId)}' or '{nameof(DiffRevisions)}' if this feature is needed.");

            // Set configurations if diffConfig is null. Clone it for immutability in the UI.
            DiffConfig diffConfigCopy = diffConfig == null ? new DiffConfig() : (DiffConfig)diffConfig.DeepClone();

            // Clone objects for immutability in the UI.
            List <object> pastObjects_cloned    = BH.Engine.Base.Query.DeepClone(pastObjects).ToList();
            List <object> currentObjects_cloned = BH.Engine.Base.Query.DeepClone(currentObjects).ToList();

            if (!useExistingHash)
            {
                // Clean any existing hash fragment.
                // This ensures the hash will be re-computed within this method using the provided DiffConfig.
                pastObjects_cloned.OfType <IBHoMObject>().ToList().ForEach(o => o.Fragments.Remove(typeof(HashFragment)));
                currentObjects_cloned.OfType <IBHoMObject>().ToList().ForEach(o => o.Fragments.Remove(typeof(HashFragment)));
            }

            // Compute the "Diffing" by means of a VennDiagram.
            // Hashes are computed in the DiffingHashComparer, once per each object (the hash is stored in a hashFragment).
            VennDiagram <object> vd = Engine.Data.Create.VennDiagram(pastObjects_cloned, currentObjects_cloned, new DiffingHashComparer <object>(diffConfigCopy, true));

            return(new Diff(vd.OnlySet2, vd.OnlySet1, null, diffConfigCopy, null, vd.Intersection));
        }
Exemplo n.º 4
0
        public void TestVennDiagram()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            Utils.ShowStarting(methodName);

            const string result1Path = @"C:\cygwin\home\kims336\Data\QCShewQE\NoMod_NTT1.tsv";
            const string result2Path = @"C:\cygwin\home\kims336\Data\QCShewQE\Ic_NTT1_Test\QC_Shew_13_04_A_17Feb14_Samwise_13-07-28_IcTda.tsv";

            if (!File.Exists(result1Path))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, result1Path);
            }

            if (!File.Exists(result2Path))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, result2Path);
            }

            const double pepQValueThreshold = 0.01;
            var          result1            = new TsvFileParser(result1Path);
            var          result2            = new TsvFileParser(result2Path);

            var vennDiagram = new VennDiagram <string>(result1.GetPeptides(pepQValueThreshold),
                                                       result2.GetPeptides(pepQValueThreshold));

            var intersectionPeptides = vennDiagram.Intersection;

            Console.WriteLine(vennDiagram.Set1 + " " + vennDiagram.Set2);
            Console.WriteLine(vennDiagram.Set1 + " " + vennDiagram.Intersection + " " + vennDiagram.Set2Only);
        }
Exemplo n.º 5
0
        public void GenerateVennDiagrams()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            TestUtils.ShowStarting(methodName);

            // DIA
            const string dir = @"H:\Research\EDRN\Ic\DIA_Replicate";

            const string rep1 = dir + @"\EDRN_Serum_07_DIA_1_01_13Nov13_Samwise_13-07-28_IcTda.tsv";
            //const string rep2 = dir + @"\EDRN_Serum_07_DIA_1_02_13Nov13_Samwise_13-07-28_IcTda.tsv";
            //const string rep3 = dir + @"\EDRN_Serum_07_DIA_1_03_13Nov13_Samwise_13-07-28_IcTda.tsv";
            const string rep4 = dir + @"\EDRN_Serum_07_DIA_1_04_13Nov13_Samwise_13-07-28_IcTda.tsv";
            //const string rep5 = dir + @"\EDRN_Serum_07_DIA_1_05_18Nov13_Samwise_13-07-28_IcTda.tsv";

            const string resultPath1 = rep1;
            const string resultPath2 = rep4;

            var result1 = new TsvFileParser(resultPath1);
            var result2 = new TsvFileParser(resultPath2);

            const double pepQValueThreshold = 0.01;
            var vennDiagram = new VennDiagram<string>(result1.GetPeptidesAboveQValueThreshold(pepQValueThreshold),
                                                      result2.GetPeptidesAboveQValueThreshold(pepQValueThreshold));
            Console.WriteLine("{0}\t{1}\t{2}",
                              vennDiagram.Set1Only.Count, // + vennDiagram.Intersection.Count,
                              vennDiagram.Intersection.Count,
                              vennDiagram.Set2Only.Count //+ vennDiagram.Intersection.Count
                              );
        }
Exemplo n.º 6
0
        /***************************************************/
        /**** Public Methods                            ****/
        /***************************************************/

        public static VennDiagram <T> VennDiagram <T>(IEnumerable <T> set1, IEnumerable <T> set2, IEqualityComparer <T> comparer) //where T : BH.oM.Base.IBHoMObject
        {
            VennDiagram <T> diagram = new VennDiagram <T>();

            foreach (T a in set1)
            {
                bool found = false;
                foreach (T b in set2)
                {
                    //Check if object exists
                    if (comparer.Equals(a, b))
                    {
                        diagram.Intersection.Add(new Tuple <T, T>(a, b));
                        found = true;
                        break;
                    }
                }
                if (!found)
                {
                    diagram.OnlySet1.Add(a);
                }
            }

            diagram.OnlySet2 = set2.Except(diagram.Intersection.Select(x => x.Item2)).ToList();

            return(diagram);
        }
Exemplo n.º 7
0
        public static string VennDiagramTest()
        {
            int[] data = new int[] { 100, 80, 60, 30, 30, 30, 10 };

            VennDiagram vennDiagram = new VennDiagram(150, 150);

            vennDiagram.SetTitle("Venn Diagram");
            vennDiagram.SetData(data);

            return(vennDiagram.GetUrl());
        }
Exemplo n.º 8
0
        // Note: setAssignedId is currently not exposed as an option
        //  -- waiting for Adapter refactoring LVL 04 to expose a new CRUDconfig input for the Push
        // CRUDconfig will become available to all CRUD methods
        protected bool CreateAnyObject(List <IObject> objects, bool setAssignedId = true)
        {
            /// Create the objects
            List <SpeckleObject> objs_serialized = SpeckleCore.Converter.Serialise(objects);

            SpeckleLayer.ObjectCount += objects.Count();
            SpeckleStream.Objects.AddRange(objs_serialized);

            /// Assign any other property to the objects before sending them
            var objList = objects.ToList();
            int i       = 0;

            foreach (var o in SpeckleStream.Objects)
            {
                IBHoMObject bhomObj = objList[i] as IBHoMObject;
                if (bhomObj != null)
                {
                    SpeckleStream.Objects[i].Name = string.IsNullOrEmpty(bhomObj.Name) ? bhomObj.GetType().ToString() : bhomObj.Name;
                    //SpeckleStream.Objects[i].Type = string.IsNullOrEmpty(bhomObj.Name) ? bhomObj.GetType().ToString() : bhomObj.Name;
                }
                i++;
            }

            /// Send the objects
            var updateResponse = SpeckleClient.StreamUpdateAsync(SpeckleStreamId, SpeckleStream).Result;

            SpeckleClient.BroadcastMessage("stream", SpeckleStreamId, new { eventType = "update-global" });



            /// Read the IBHoMobjects as exported in speckle
            /// so we can assign the Speckle-generated id into the BHoMobjects
            if (setAssignedId)
            {
                ResponseObject response = SpeckleClient.StreamGetObjectsAsync(SpeckleStreamId, "").Result;

                List <IBHoMObject>        bHoMObjects_inSpeckle = new List <IBHoMObject>();
                IEnumerable <IBHoMObject> iBhomObjsInSpeckle    = BH.Engine.Speckle.Convert.ToBHoM(response, true);

                VennDiagram <IBHoMObject> correspondenceDiagram = Engine.Data.Create.VennDiagram(objects.Where(o => o as IBHoMObject != null).Cast <IBHoMObject>(), iBhomObjsInSpeckle, new IBHoMGUIDComparer());

                if (correspondenceDiagram.Intersection.Count != objects.Count())
                {
                    var gna = 0;
                    //Engine.Reflection.Compute.RecordError("Push failed.\nNumber of objects created in Speckle do not correspond to the number of objects pushed.");
                    //return false;
                }

                correspondenceDiagram.Intersection.ForEach(o => o.Item1.CustomData[AdapterId] = o.Item2.CustomData[AdapterId]);
            }

            return(true);
        }
Exemplo n.º 9
0
        public void CompareRtFusion()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            TestUtils.ShowStarting(methodName);

            // Fusion
            const string qeDdaResult = @"D:\Research\Data\UW\Fusion\DDA_Summary.tsv";
            const string qeDiaResult = @"D:\Research\Data\UW\Fusion\DIA_Summary.tsv";

            const string specFileDda = @"D:\Research\Data\UW\Fusion\WT_D_DDA_130412065618.raw";
            var          ddaReader   = new XCaliburReader(specFileDda);

            const string specFileDia = @"D:\Research\Data\UW\Fusion\WT_D_DIA_130412091220.raw";
            var          diaReader   = new XCaliburReader(specFileDia);

            const string resultPath1 = qeDdaResult;
            const string resultPath2 = qeDiaResult;

            var result1 = new TsvFileParser(resultPath1);
            var result2 = new TsvFileParser(resultPath2);

            const double pepQValueThreshold = 0.01;
            var          vennDiagram        = new VennDiagram <string>(result1.GetPeptides(pepQValueThreshold),
                                                                       result2.GetPeptides(pepQValueThreshold));

            var intersectionPeptides = vennDiagram.Intersection;

            var result1Peptides = result1.GetData("Peptide");
            var result1ScanNums = result1.GetData("ScanNum");

            var result2Peptides = result2.GetData("Peptide");
            var result2ScanNums = result2.GetData("ScanNum");

            Console.WriteLine("Peptide\tScanNum1\tScanNum2\tRt1\tRt2");
            foreach (var peptide in intersectionPeptides)
            {
                var index1 = result1Peptides.IndexOf(peptide);
                var index2 = result2Peptides.IndexOf(peptide);

                var scanNum1 = Convert.ToInt32(result1ScanNums[index1]);
                var scanNum2 = Convert.ToInt32(result2ScanNums[index2]);

                var reader1 = ddaReader;
                var reader2 = diaReader;

                Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", peptide.Replace("C+57.021", "C"), scanNum1, scanNum2, reader1.RtFromScanNum(scanNum1), reader2.RtFromScanNum(scanNum2));
            }
        }
Exemplo n.º 10
0
        public static Output <List <IBHoMObject>, List <IBHoMObject>, List <IBHoMObject>, List <IBHoMObject> > Diffing(IEnumerable <IBHoMObject> setA, IEnumerable <IBHoMObject> setB, DiffConfig diffConfig = null)
        {
            Stream streamA = BH.Engine.Diffing.Create.Stream(setA, diffConfig, "");
            Stream streamB = BH.Engine.Diffing.Create.Stream(setB, diffConfig, "");

            VennDiagram <IBHoMObject> diagram = Engine.Data.Create.VennDiagram(streamA.Objects, streamB.Objects, new HashFragmComparer <IBHoMObject>());

            return(new Output <List <IBHoMObject>, List <IBHoMObject>, List <IBHoMObject>, List <IBHoMObject> >
            {
                Item1 = diagram.OnlySet1,
                Item2 = diagram.Intersection.Select(tuple => tuple.Item1).ToList(),
                Item3 = diagram.Intersection.Select(tuple => tuple.Item2).ToList(),
                Item4 = diagram.OnlySet2,
            });
        }
Exemplo n.º 11
0
        public static Output <List <IBHoMObject>, List <IBHoMObject>, List <IBHoMObject>, List <IBHoMObject> > Diffing(IEnumerable <IBHoMObject> setA, IEnumerable <IBHoMObject> setB, List <string> exceptions = null, bool useDefaultExceptions = true)
        {
            Stream streamA = BH.Engine.Diffing.Create.Stream(setA, null);
            Stream streamB = BH.Engine.Diffing.Create.Stream(setB, null);

            VennDiagram <IBHoMObject> diagram = Engine.Data.Create.VennDiagram(streamA.Objects, streamB.Objects, new HashFragmComparer <IBHoMObject>());

            return(new Output <List <IBHoMObject>, List <IBHoMObject>, List <IBHoMObject>, List <IBHoMObject> >
            {
                Item1 = diagram.OnlySet1,
                Item2 = diagram.Intersection.Select(tuple => tuple.Item1).ToList(),
                Item3 = diagram.Intersection.Select(tuple => tuple.Item2).ToList(),
                Item4 = diagram.OnlySet2,
            });
        }
Exemplo n.º 12
0
        public void GenerateVennDiagramsPeMmr()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            TestUtils.ShowStarting(methodName);

            // No PE-MMR
            //const string noPeMmr = @"D:\Research\Data\PEMMR\iTRAQ_N33T34_10ug_100cm_300min_C2_061213.tsv";

            // PE-MMR Scan based FDR
            //const string scanBasedPeMmr = @"D:\Research\Data\PEMMR\NewSpectra\iTRAQ_N33T34_10ug_100cm_300min_C2_061213_MX_PEMMR_UMCID_ScanFDR.tsv";

            // UMC based FDR
            const string umcBasedPeMmr = @"D:\Research\Data\PEMMR\NewSpectra\iTRAQ_N33T34_10ug_100cm_300min_C2_061213_MX_PEMMR_UMCID_UMCFDR.tsv";

            // IPA
            const string ipa = @"D:\Research\Data\PEMMR\Ox\IPA_Summary_TargetOnly.tsv";

            const string resultPath1 = umcBasedPeMmr;
            const string resultPath2 = ipa;

            var result1 = new TsvFileParser(resultPath1);
            var result2 = new TsvFileParser(resultPath2);

            const double pepQValueThreshold = 0.01;
            var          vennDiagram        = new VennDiagram <string>(result1.GetPeptides(pepQValueThreshold),
                                                                       result2.GetPeptides(pepQValueThreshold));

            Console.WriteLine("{0}\t{1}\t{2}",
                              vennDiagram.Set1Only.Count + vennDiagram.Intersection.Count,
                              vennDiagram.Intersection.Count,
                              vennDiagram.Set2Only.Count + vennDiagram.Intersection.Count);
            Console.WriteLine("{0}\t{1}\t{2}",
                              vennDiagram.Set1Only.Count,
                              vennDiagram.Intersection.Count,
                              vennDiagram.Set2Only.Count);

            foreach (var peptide in vennDiagram.Set2Only)
            {
                Console.WriteLine(peptide);
                var peptides = result2.GetData("Peptide");
            }
        }
Exemplo n.º 13
0
        // Computes the diffing for IEnumerable<object>.
        // For BHoMObjects, it assumes that they all have a HashFragment assigned (like when they have been passed through a Revision).
        // For non-BHoMObjects, it performs the VennDiagram comparision with a HashComparer.
        // Results for BHoMObjects and non are concatenated.
        private static Diff DiffRevisionObjects(IEnumerable <object> pastRevisionObjs, IEnumerable <object> followingRevisionObjs, DiffConfig diffConfig = null)
        {
            // Set configurations if diffConfig is null. Clone it for immutability in the UI.
            DiffConfig diffConfigCopy = diffConfig == null ? new DiffConfig() : diffConfig.DeepClone() as DiffConfig;

            // Dispatch the objects in BHoMObjects and generic objects.
            IEnumerable <IBHoMObject> prevObjs_BHoM = pastRevisionObjs.OfType <IBHoMObject>();
            IEnumerable <IBHoMObject> currObjs_BHoM = followingRevisionObjs.OfType <IBHoMObject>();

            // If all objects are bhomobjects, just call the appropriate method
            if (pastRevisionObjs.Count() != 0 && pastRevisionObjs.Count() == prevObjs_BHoM.Count() && followingRevisionObjs.Count() == currObjs_BHoM.Count())
            {
                return(DiffRevisionObjects(prevObjs_BHoM, currObjs_BHoM, diffConfigCopy));
            }

            IEnumerable <object> prevObjs_nonBHoM = pastRevisionObjs.Where(o => !(o is IBHoMObject));
            IEnumerable <object> currObjs_nonBHoM = followingRevisionObjs.Where(o => !(o is IBHoMObject));

            // Compute the specific Diffing for the BHoMObjects.
            Diff diff = Compute.DiffRevisionObjects(prevObjs_BHoM, currObjs_BHoM, diffConfigCopy);

            // Compute the generic Diffing for the other objects.
            // This is left to the VennDiagram with a HashComparer.
            VennDiagram <object> vd = Engine.Data.Create.VennDiagram(prevObjs_nonBHoM, currObjs_nonBHoM, new DiffingHashComparer <object>(diffConfig));

            // Concatenate the results of the two diffing operations.
            List <object> allPrevObjs      = new List <object>();
            List <object> allCurrObjs      = new List <object>();
            List <object> allUnchangedObjs = new List <object>();

            allCurrObjs.AddRange(diff.AddedObjects);
            allCurrObjs.AddRange(vd.OnlySet1);

            allPrevObjs.AddRange(diff.RemovedObjects);
            allPrevObjs.AddRange(vd.OnlySet2);

            // Create the final, actual diff.
            Diff finalDiff = new Diff(allCurrObjs, allPrevObjs, diff.ModifiedObjects, diffConfigCopy, diff.ModifiedPropsPerObject, diff.UnchangedObjects);

            return(finalDiff);
        }
Exemplo n.º 14
0
        public void GenerateVennDiagrams()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            Utils.ShowStarting(methodName);

            // DIA
            const string dir = @"H:\Research\DDAPlus\NTT2";

            //const string dda1 = dir + @"\20140701_yeast_DDA_01_IcTda.tsv";
            //const string dda2 = dir + @"\20140701_yeast_DDA_02_2_IcTda.tsv";
            const string ddaPlus1 = dir + @"\20140701_yeast_DDAp_binCharge_01_IcTda.tsv";
            const string ddaPlus2 = dir + @"\20140701_yeast_DDAp_binCharge_02_IcTda.tsv";

            const string resultPath1 = ddaPlus1;
            const string resultPath2 = ddaPlus2;

            if (!File.Exists(resultPath1))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, resultPath1);
            }

            if (!File.Exists(resultPath2))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, resultPath2);
            }

            var result1 = new TsvFileParser(resultPath1);
            var result2 = new TsvFileParser(resultPath2);

            const double pepQValueThreshold = 0.01;
            var          vennDiagram        = new VennDiagram <string>(result1.GetPeptidesAboveQValueThreshold(pepQValueThreshold),
                                                                       result2.GetPeptidesAboveQValueThreshold(pepQValueThreshold));

            Console.WriteLine("{0}\t{1}\t{2}",
                              vennDiagram.Set1Only.Count, // + vennDiagram.Intersection.Count,
                              vennDiagram.Intersection.Count,
                              vennDiagram.Set2Only.Count  //+ vennDiagram.Intersection.Count
                              );
        }
Exemplo n.º 15
0
        private static void VennDiagramExamples()
        {
            Console.WriteLine("**Venn Diagram Examples**");

            // Generate some random data of integers
            Console.WriteLine("Generating Random Values");
            int    numberofsets = 5;
            int    maxvalue     = 100;
            int    maxitems     = 50;
            Random ran          = new Random(135121321);

            VennSet <int>[] sets = new VennSet <int> [numberofsets];
            for (int i = 0; i < numberofsets; i++)
            {
                sets[i] = new VennSet <int>(string.Format("Set {0}", i));
                for (int j = 0; j < maxitems; j++)
                {
                    sets[i].Add(ran.Next(maxvalue));
                }
            }

            // Create diagram
            VennDiagram <int> diagram = VennDiagram <int> .CreateDiagram(sets);
        }
Exemplo n.º 16
0
        public void GenerateVennDiagrams()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            TestUtils.ShowStarting(methodName);

            // Fusion
            //const string fusionMsgfResult = @"D:\Research\Data\UW\Fusion\MSGFPlusResults\TI2.tsv";
            const string fusionDdaResult = @"D:\Research\Data\UW\Fusion\DDA_Summary.tsv";
            //const string fusionDiaResult = @"D:\Research\Data\UW\Fusion\DIA_Summary.tsv";

            // Q-Exactive
            //const string qeDdaMsGfResult = @"D:\Research\Data\UW\QExactive\82593_lv_mcx_DDA.tsv";
            //const string qeDdaResult = @"D:\Research\Data\UW\QExactive\DDA_All_Summary.tsv";
            //const string qeDiaResult = @"D:\Research\Data\UW\QExactive\DIA_All_Summary.tsv";

            // PE-MMR
            //const string pemmrQeDia = @"D:\Research\Data\UW\PEMMR\QE\allFDR.tsv";
            const string pemmrFusionDda = @"D:\Research\Data\UW\PEMMR\Fusion\WT_D_DDA_130412065618_MX_PEMMR.tsv";
            //const string pemmrFusionDia = @"D:\Research\Data\UW\PEMMR\Fusion\WT_D_DIA_130412091220_MX_PEMMR.tsv";

            const string resultPath1 = pemmrFusionDda;
            const string resultPath2 = fusionDdaResult;

            var result1 = new TsvFileParser(resultPath1);
            var result2 = new TsvFileParser(resultPath2);

            const double pepQValueThreshold = 0.01;
            var          vennDiagram        = new VennDiagram <string>(result1.GetPeptides(pepQValueThreshold),
                                                                       result2.GetPeptides(pepQValueThreshold));

            Console.WriteLine("{0}\t{1}\t{2}",
                              vennDiagram.Set1Only.Count + vennDiagram.Intersection.Count,
                              vennDiagram.Intersection.Count,
                              vennDiagram.Set2Only.Count + vennDiagram.Intersection.Count);
        }
Exemplo n.º 17
0
        /***************************************************/
        /**** Private Methods                           ****/
        /***************************************************/

        private static TestResult RunOneSet(IBHoMAdapter adapter, string setName, List <IBHoMObject> objects, IRequest request, IEqualityComparer <IBHoMObject> comparer, bool resetModelBetweenRuns)
        {
            if (adapter == null)
            {
                return(new TestResult {
                    Description = "PushPullCompare", Message = "Adapter is null, could not preform test", Status = oM.Test.TestStatus.Error
                });
            }

            TestResult setResult = new TestResult {
                Description = $"PushPullCompare: Adapter: {adapter.GetType().Name}, test set: {setName}.", ID = adapter.GetType().Name + ":" + setName
            };

            bool success = true;

            //CalculateObjectHashes
            objects = objects.SetHashFragment();

            //Start up an empty model
            if (resetModelBetweenRuns)
            {
                adapter.Execute(new NewModel());
            }

            List <IBHoMObject> pushedObjects = new List <IBHoMObject>();
            List <IBHoMObject> pulledObjects = new List <IBHoMObject>();

            BH.oM.Base.ComparisonConfig config = Engine.Test.Create.DefaultTestComparisonConfig();
            config.PropertyExceptions.Add("CustomData");
            config.TypeExceptions.Add(typeof(HashFragment));

            //Push objects
            try
            {
                Engine.Base.Compute.ClearCurrentEvents();
                pushedObjects = adapter.Push(objects).Cast <IBHoMObject>().ToList();
                success      &= pushedObjects.Count == objects.Count;
            }
            catch (Exception e)
            {
                Engine.Base.Compute.RecordError(e.Message);
                setResult.Message = "The adapter crashed trying to push the objects.";
                setResult.Status  = oM.Test.TestStatus.Error;
                return(setResult);
            }
            finally
            {
                setResult.Information.AddRange(Engine.Base.Query.CurrentEvents().Select(x => x.ToEventMessage()));
            }

            if (pushedObjects.Count != objects.Count)
            {
                setResult.Information.AddRange(objects.Where(x => !pushedObjects.Any(y => x.Name == y.Name)).Select(x => TestFailedResult(x, "Object could not be pushed.")));
            }

            //Pull objects
            try
            {
                Engine.Base.Compute.ClearCurrentEvents();
                pulledObjects = adapter.Pull(request).Cast <IBHoMObject>().ToList();
                success      &= pulledObjects.Count == pushedObjects.Count;
            }
            catch (Exception e)
            {
                Engine.Base.Compute.RecordError(e.Message);
                setResult.Message = "The adapter crashed trying to pull the objects.";
                setResult.Status  = oM.Test.TestStatus.Error;
                return(setResult);
            }
            finally
            {
                setResult.Information.AddRange(Engine.Base.Query.CurrentEvents().Select(x => x.ToEventMessage()));
            }

            //Compare pushed and pulled objects
            VennDiagram <IBHoMObject> diagram = Engine.Data.Create.VennDiagram(pushedObjects, pulledObjects, comparer);


            foreach (Tuple <IBHoMObject, IBHoMObject> pair in diagram.Intersection)
            {
                setResult.Information.Add(ComparePushedAndPulledObject(pair.Item1, pair.Item2, config));
            }

            setResult.Information.AddRange(diagram.OnlySet1.Select(x => TestFailedResult(x, "Unable to compare the object.")));

            //Close the model
            if (resetModelBetweenRuns)
            {
                adapter.Execute(new Close {
                    SaveBeforeClose = false
                });
            }

            //Clear events
            Engine.Base.Compute.ClearCurrentEvents();

            setResult.Status = setResult.Information.OfType <TestResult>().MostSevereStatus();

            if (setResult.Status == oM.Test.TestStatus.Error)
            {
                setResult.Message = "Errors where raised trying to run the test";
            }
            else if (setResult.Status == oM.Test.TestStatus.Pass)
            {
                setResult.Message = "All objects were successfully pushed, pulled and compared without any differences.";
            }
            else
            {
                setResult.Message = "All objects were successfully pushed and pulled, but some differences were found.";
            }

            return(setResult);
        }
Exemplo n.º 18
0
        public void GenerateVennDiagrams()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            TestUtils.ShowStarting(methodName);

            // DIA
            const string dir = @"H:\Research\DDAPlus\NTT2";

            //const string dda1 = dir + @"\20140701_yeast_DDA_01_IcTda.tsv";
            //const string dda2 = dir + @"\20140701_yeast_DDA_02_2_IcTda.tsv";
            const string ddaPlus1 = dir + @"\20140701_yeast_DDAp_binCharge_01_IcTda.tsv";
            const string ddaPlus2 = dir + @"\20140701_yeast_DDAp_binCharge_02_IcTda.tsv";

            const string resultPath1 = ddaPlus1;
            const string resultPath2 = ddaPlus2;

            if (!File.Exists(resultPath1))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, resultPath1);
            }

            if (!File.Exists(resultPath2))
            {
                Assert.Ignore(@"Skipping test {0} since file not found: {1}", methodName, resultPath2);
            }

            var result1 = new TsvFileParser(resultPath1);
            var result2 = new TsvFileParser(resultPath2);

            const double pepQValueThreshold = 0.01;
            var vennDiagram = new VennDiagram<string>(result1.GetPeptidesAboveQValueThreshold(pepQValueThreshold),
                                                      result2.GetPeptidesAboveQValueThreshold(pepQValueThreshold));
            Console.WriteLine("{0}\t{1}\t{2}",
                              vennDiagram.Set1Only.Count, // + vennDiagram.Intersection.Count,
                              vennDiagram.Intersection.Count,
                              vennDiagram.Set2Only.Count //+ vennDiagram.Intersection.Count
                              );
        }
Exemplo n.º 19
0
        public void CompareRt()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;

            TestUtils.ShowStarting(methodName);

            // Q-Exactive
            //const string qeDdaResult = @"D:\Research\Data\UW\QExactive\DDA_All_Summary.tsv";
            //const string qeDiaResult = @"D:\Research\Data\UW\QExactive\DIA_All_Summary.tsv";

            // Fusion
            const string qeDdaResult = @"D:\Research\Data\UW\Fusion\DDA_Summary.tsv";
            const string qeDiaResult = @"D:\Research\Data\UW\Fusion\DIA_Summary.tsv";

            const string specFileDda = @"D:\Research\Data\UW\QExactive\82593_lv_mcx_DDA.raw";
            var          ddaReader   = new XCaliburReader(specFileDda);

            var specFileToReader = new Dictionary <string, XCaliburReader>();
            var specFilesDia     = Directory.GetFiles(@"D:\Research\Data\UW\QExactive\", "*_DIA_*.raw");

            foreach (var specFile in specFilesDia)
            {
                var specFileNoExt = Path.GetFileNameWithoutExtension(specFile);
                if (specFileNoExt == null)
                {
                    continue;
                }
                var reader = new XCaliburReader(specFile);
                specFileToReader.Add(specFileNoExt, reader);
            }

            const string resultPath1 = qeDdaResult;
            const string resultPath2 = qeDiaResult;

            var result1 = new TsvFileParser(resultPath1);
            var result2 = new TsvFileParser(resultPath2);

            const double pepQValueThreshold = 0.01;
            var          vennDiagram        = new VennDiagram <string>(result1.GetPeptides(pepQValueThreshold),
                                                                       result2.GetPeptides(pepQValueThreshold));

            var intersectionPeptides = vennDiagram.Intersection;

            var result1Peptides = result1.GetData("Peptide");
            var result1ScanNums = result1.GetData("ScanNum");

            var result2Peptides = result2.GetData("Peptide");
            var result2ScanNums = result2.GetData("ScanNum");
            var result2SpecFile = result2.GetData("#SpecFile");

            Console.WriteLine("Peptide\tScanNum1\tScanNum2\tRt1\tRt2");
            foreach (var peptide in intersectionPeptides)
            {
                var index1 = result1Peptides.IndexOf(peptide);
                var index2 = result2Peptides.IndexOf(peptide);

                var scanNum1 = Convert.ToInt32(result1ScanNums[index1]);
                var scanNum2 = Convert.ToInt32(result2ScanNums[index2]);

                var diaFile = Path.GetFileNameWithoutExtension(result2SpecFile[index2]);

                var reader1 = ddaReader;
                var reader2 = specFileToReader[diaFile];

                Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", peptide.Replace("C+57.021", "C"), scanNum1, scanNum2, reader1.RtFromScanNum(scanNum1), reader2.RtFromScanNum(scanNum2));
            }
        }
Exemplo n.º 20
0
        public void GenerateVennDiagrams()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            TestUtils.ShowStarting(methodName);

            // Fusion
            //const string fusionMsgfResult = @"D:\Research\Data\UW\Fusion\MSGFPlusResults\TI2.tsv";
            const string fusionDdaResult = @"D:\Research\Data\UW\Fusion\DDA_Summary.tsv";
            //const string fusionDiaResult = @"D:\Research\Data\UW\Fusion\DIA_Summary.tsv";

            // Q-Exactive
            //const string qeDdaMsGfResult = @"D:\Research\Data\UW\QExactive\82593_lv_mcx_DDA.tsv";
            //const string qeDdaResult = @"D:\Research\Data\UW\QExactive\DDA_All_Summary.tsv";
            //const string qeDiaResult = @"D:\Research\Data\UW\QExactive\DIA_All_Summary.tsv";

            // PE-MMR
            //const string pemmrQeDia = @"D:\Research\Data\UW\PEMMR\QE\allFDR.tsv";
            const string pemmrFusionDda = @"D:\Research\Data\UW\PEMMR\Fusion\WT_D_DDA_130412065618_MX_PEMMR.tsv";
            //const string pemmrFusionDia = @"D:\Research\Data\UW\PEMMR\Fusion\WT_D_DIA_130412091220_MX_PEMMR.tsv";

            const string resultPath1 = pemmrFusionDda;
            const string resultPath2 = fusionDdaResult;

            var result1 = new TsvFileParser(resultPath1);
            var result2 = new TsvFileParser(resultPath2);

            const double pepQValueThreshold = 0.01;
            var vennDiagram = new VennDiagram<string>(result1.GetPeptides(pepQValueThreshold),
                                                      result2.GetPeptides(pepQValueThreshold));
            Console.WriteLine("{0}\t{1}\t{2}",
                              vennDiagram.Set1Only.Count + vennDiagram.Intersection.Count,
                              vennDiagram.Intersection.Count,
                              vennDiagram.Set2Only.Count + vennDiagram.Intersection.Count);
        }
Exemplo n.º 21
0
        /***************************************************/

        public static int Count <T>(this VennDiagram <T> diagram)
        {
            return(diagram.Intersection.Count + diagram.OnlySet1.Count + diagram.OnlySet2.Count);
        }
Exemplo n.º 22
0
        public void GenerateVennDiagramsPeMmr()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            TestUtils.ShowStarting(methodName);

            // No PE-MMR
            //const string noPeMmr = @"D:\Research\Data\PEMMR\iTRAQ_N33T34_10ug_100cm_300min_C2_061213.tsv";

            // PE-MMR Scan based FDR
            //const string scanBasedPeMmr = @"D:\Research\Data\PEMMR\NewSpectra\iTRAQ_N33T34_10ug_100cm_300min_C2_061213_MX_PEMMR_UMCID_ScanFDR.tsv";

            // UMC based FDR
            const string umcBasedPeMmr = @"D:\Research\Data\PEMMR\NewSpectra\iTRAQ_N33T34_10ug_100cm_300min_C2_061213_MX_PEMMR_UMCID_UMCFDR.tsv";

            // IPA
            const string ipa = @"D:\Research\Data\PEMMR\Ox\IPA_Summary_TargetOnly.tsv";

            const string resultPath1 = umcBasedPeMmr;
            const string resultPath2 = ipa;

            var result1 = new TsvFileParser(resultPath1);
            var result2 = new TsvFileParser(resultPath2);

            const double pepQValueThreshold = 0.01;
            var vennDiagram = new VennDiagram<string>(result1.GetPeptides(pepQValueThreshold),
                                                      result2.GetPeptides(pepQValueThreshold));
            Console.WriteLine("{0}\t{1}\t{2}",
                              vennDiagram.Set1Only.Count + vennDiagram.Intersection.Count,
                              vennDiagram.Intersection.Count,
                              vennDiagram.Set2Only.Count + vennDiagram.Intersection.Count);
            Console.WriteLine("{0}\t{1}\t{2}",
                              vennDiagram.Set1Only.Count,
                              vennDiagram.Intersection.Count,
                              vennDiagram.Set2Only.Count);

            foreach (var peptide in vennDiagram.Set2Only)
            {
                Console.WriteLine(peptide);
                var peptides = result2.GetData("Peptide");
            }
        }
Exemplo n.º 23
0
        public void CompareRtFusion()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            TestUtils.ShowStarting(methodName);

            // Fusion
            const string qeDdaResult = @"D:\Research\Data\UW\Fusion\DDA_Summary.tsv";
            const string qeDiaResult = @"D:\Research\Data\UW\Fusion\DIA_Summary.tsv";

            const string specFileDda = @"D:\Research\Data\UW\Fusion\WT_D_DDA_130412065618.raw";
            var ddaReader = new XCaliburReader(specFileDda);

            const string specFileDia = @"D:\Research\Data\UW\Fusion\WT_D_DIA_130412091220.raw";
            var diaReader = new XCaliburReader(specFileDia);

            const string resultPath1 = qeDdaResult;
            const string resultPath2 = qeDiaResult;

            var result1 = new TsvFileParser(resultPath1);
            var result2 = new TsvFileParser(resultPath2);

            const double pepQValueThreshold = 0.01;
            var vennDiagram = new VennDiagram<string>(result1.GetPeptides(pepQValueThreshold),
                                                      result2.GetPeptides(pepQValueThreshold));

            var intersectionPeptides = vennDiagram.Intersection;

            var result1Peptides = result1.GetData("Peptide");
            var result1ScanNums = result1.GetData("ScanNum");

            var result2Peptides = result2.GetData("Peptide");
            var result2ScanNums = result2.GetData("ScanNum");

            Console.WriteLine("Peptide\tScanNum1\tScanNum2\tRt1\tRt2");
            foreach (var peptide in intersectionPeptides)
            {
                var index1 = result1Peptides.IndexOf(peptide);
                var index2 = result2Peptides.IndexOf(peptide);

                var scanNum1 = Convert.ToInt32(result1ScanNums[index1]);
                var scanNum2 = Convert.ToInt32(result2ScanNums[index2]);

                var reader1 = ddaReader;
                var reader2 = diaReader;

                Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", peptide.Replace("C+57.021", "C"), scanNum1, scanNum2, reader1.RtFromScanNum(scanNum1), reader2.RtFromScanNum(scanNum2));
            }
        }
Exemplo n.º 24
0
        public void CompareRt()
        {
            var methodName = MethodBase.GetCurrentMethod().Name;
            TestUtils.ShowStarting(methodName);

            // Q-Exactive
            //const string qeDdaResult = @"D:\Research\Data\UW\QExactive\DDA_All_Summary.tsv";
            //const string qeDiaResult = @"D:\Research\Data\UW\QExactive\DIA_All_Summary.tsv";

            // Fusion
            const string qeDdaResult = @"D:\Research\Data\UW\Fusion\DDA_Summary.tsv";
            const string qeDiaResult = @"D:\Research\Data\UW\Fusion\DIA_Summary.tsv";

            const string specFileDda = @"D:\Research\Data\UW\QExactive\82593_lv_mcx_DDA.raw";
            var ddaReader = new XCaliburReader(specFileDda);

            var specFileToReader = new Dictionary<string, XCaliburReader>();
            var specFilesDia = Directory.GetFiles(@"D:\Research\Data\UW\QExactive\", "*_DIA_*.raw");
            foreach (var specFile in specFilesDia)
            {
                var specFileNoExt = Path.GetFileNameWithoutExtension(specFile);
                if (specFileNoExt == null) continue;
                var reader = new XCaliburReader(specFile);
                specFileToReader.Add(specFileNoExt, reader);
            }

            const string resultPath1 = qeDdaResult;
            const string resultPath2 = qeDiaResult;

            var result1 = new TsvFileParser(resultPath1);
            var result2 = new TsvFileParser(resultPath2);

            const double pepQValueThreshold = 0.01;
            var vennDiagram = new VennDiagram<string>(result1.GetPeptides(pepQValueThreshold),
                                                      result2.GetPeptides(pepQValueThreshold));

            var intersectionPeptides = vennDiagram.Intersection;

            var result1Peptides = result1.GetData("Peptide");
            var result1ScanNums = result1.GetData("ScanNum");

            var result2Peptides = result2.GetData("Peptide");
            var result2ScanNums = result2.GetData("ScanNum");
            var result2SpecFile = result2.GetData("#SpecFile");

            Console.WriteLine("Peptide\tScanNum1\tScanNum2\tRt1\tRt2");
            foreach (var peptide in intersectionPeptides)
            {
                var index1 = result1Peptides.IndexOf(peptide);
                var index2 = result2Peptides.IndexOf(peptide);

                var scanNum1 = Convert.ToInt32(result1ScanNums[index1]);
                var scanNum2 = Convert.ToInt32(result2ScanNums[index2]);

                var diaFile = Path.GetFileNameWithoutExtension(result2SpecFile[index2]);

                var reader1 = ddaReader;
                var reader2 = specFileToReader[diaFile];

                Console.WriteLine("{0}\t{1}\t{2}\t{3}\t{4}", peptide.Replace("C+57.021", "C"), scanNum1, scanNum2, reader1.RtFromScanNum(scanNum1), reader2.RtFromScanNum(scanNum2));
            }
        }
Exemplo n.º 25
0
        /// This method is actually useless --
        /// written assuming IBHoMObjects had static GUID (instead they are re-instantiated at any modification).
        private bool DiffingByBHoMGuid(List <IObject> objectsToBePushed, out List <IObject> objectsCreated)
        {
            objectsCreated = new List <IObject>();
            List <IObject> objectsToBeCreated = new List <IObject>();

            // Dispatch objects to be pushed
            List <IBHoMObject> bhomObjectsToBePushed = null;
            List <IObject>     iObjectsToBePushed    = null;

            BH.Engine.Speckle.Query.DispatchBHoMObjects(objectsToBePushed, out bhomObjectsToBePushed, out iObjectsToBePushed);

            // Receive and dispatch objects already in speckle
            ResponseObject response = SpeckleClient.StreamGetObjectsAsync(SpeckleStreamId, "").Result;

            List <IBHoMObject> bhomObjectsInSpeckle     = null;
            List <IObject>     iObjectsInSpeckle        = null;
            List <object>      reminderObjectsInSpeckle = null;

            BH.Engine.Speckle.Convert.ToBHoM(response, out bhomObjectsInSpeckle, out iObjectsInSpeckle, out reminderObjectsInSpeckle, false);

            // If speckle doesn't contain anything, push everything
            if (response.Resources.Count == 0)
            {
                objectsToBeCreated = bhomObjectsToBePushed.Concat(iObjectsToBePushed).ToList();
                if (CreateAnyObject(objectsToBeCreated))
                {
                    objectsCreated = objectsToBeCreated;
                }

                return(true);
            }

            // Diffing for IBHoMObjects
            VennDiagram <IBHoMObject> guidDiagram = Engine.Data.Create.VennDiagram(objectsToBePushed.Where(o => o as IBHoMObject != null).Cast <IBHoMObject>(), bhomObjectsInSpeckle, new IBHoMGUIDComparer());

            List <IBHoMObject> newObjects           = guidDiagram.OnlySet1.ToList();                          // Not having a counterpart in the Speckle Server
            List <IBHoMObject> toBeDeleted          = guidDiagram.OnlySet2.ToList();                          // Objects in the Speckle server that do not exist anymore locally. Just not push them.
            List <IBHoMObject> toBeDiffedByProperty = guidDiagram.Intersection.Select(o => o.Item1).ToList(); // Objects that already exist on the Speckle Server, based on their BHoM GUID.


            // // - Insert code here for toBeDiffedByProperty to use custom comparers to diff by property.

            // At the moment, not having any custom comparer, the toBeDiffedByProperty are all just re-created (like assuming they've all changed, even if they didn't).
            objectsToBeCreated = newObjects.Concat(toBeDiffedByProperty).Concat(objectsToBePushed.Where(o => o as IBHoMObject == null)).ToList();

            if (objectsToBeCreated.Count == 0)
            {
                BH.Engine.Reflection.Compute.RecordNote("Speckle already contains every BHoM currently being pushed. They have not been pushed.");
            }

            // IObjects always have to be recreated as they have no GUID
            List <int> objectsToPushHashes = new List <int>();

            objectsToPushHashes = objectsToBePushed.Select(o => o.ToString().GetHashCode()).ToList();

            foreach (var o in iObjectsToBePushed) //.Concat(reminderObjectsInSpeckle)
            {
                if (!objectsToPushHashes.Any(hash => hash == o.ToString().GetHashCode()))
                {
                    objectsToBeCreated.Add(o);
                }
            }


            if (CreateAnyObject(objectsToBeCreated))
            {
                objectsCreated = objectsToBeCreated;
            }

            return(true);
        }