Beispiel #1
0
        public void MsDataFileUriEncodingTest()
        {
            var fname               = "test.mzML";
            var pathSample          = SampleHelp.EncodePath(fname, null, -1, null, true, false);
            var lockmassParametersA = new LockMassParameters(1.23, 3.45, 4.56);
            var lockmassParametersB = new LockMassParameters(1.23, null, 4.56);

            Assert.IsTrue(lockmassParametersA.CompareTo(LockMassParameters.EMPTY) > 0);
            Assert.IsTrue(lockmassParametersA.CompareTo(null) < 0);
            Assert.IsTrue(lockmassParametersB.CompareTo(lockmassParametersA) < 0);
            Assert.IsTrue(lockmassParametersA.CompareTo(new LockMassParameters(1.23, 3.45, 4.56)) == 0);


            var c = new ChromatogramSet("test", new[] { MsDataFileUri.Parse(pathSample) });

            Assert.AreEqual(fname, c.MSDataFilePaths.First().GetFilePath());
            Assert.IsTrue(c.MSDataFilePaths.First().GetCentroidMs1());
            Assert.IsFalse(c.MSDataFilePaths.First().GetCentroidMs2());

            pathSample = SampleHelp.EncodePath(fname, null, -1, lockmassParametersA, false, true);
            c          = new ChromatogramSet("test", new[] { MsDataFileUri.Parse(pathSample) });
            Assert.AreEqual(lockmassParametersA, c.MSDataFilePaths.First().GetLockMassParameters());
            Assert.IsTrue(c.MSDataFilePaths.First().GetCentroidMs2());
            Assert.IsFalse(c.MSDataFilePaths.First().GetCentroidMs1());

            pathSample = SampleHelp.EncodePath(fname, "test_0", 1, lockmassParametersB, false, false);
            c          = new ChromatogramSet("test", new[] { MsDataFileUri.Parse(pathSample) });
            Assert.AreEqual(lockmassParametersB, c.MSDataFilePaths.First().GetLockMassParameters());
            Assert.AreEqual("test_0", c.MSDataFilePaths.First().GetSampleName());
            Assert.AreEqual(1, c.MSDataFilePaths.First().GetSampleIndex());
            Assert.IsFalse(c.MSDataFilePaths.First().GetCentroidMs1());
            Assert.IsFalse(c.MSDataFilePaths.First().GetCentroidMs2());
        }
        protected int CompareTo(MsDataFilePath other)
        {
            // Culture specific sorting desirable in file paths
// ReSharper disable StringCompareToIsCultureSpecific
            int result = FilePath.CompareTo(other.FilePath);

            if (result != 0)
            {
                return(result);
            }
            result = SampleName.CompareTo(other.SampleName);
            if (result != 0)
            {
                return(result);
            }
            result = SampleIndex.CompareTo(other.SampleIndex);
            if (result != 0)
            {
                return(result);
            }
            result = CentroidMs1.CompareTo(other.CentroidMs1);
            if (result != 0)
            {
                return(result);
            }
            result = CentroidMs2.CompareTo(other.CentroidMs2);
            if (result != 0)
            {
                return(result);
            }
            return(LockMassParameters.CompareTo(other.LockMassParameters));
// ReSharper restore StringCompareToIsCultureSpecific
        }