コード例 #1
0
ファイル: CacheFormat.cs プロジェクト: laeubisoft/pwiz
        public static CacheFormat FromVersion(CacheFormatVersion formatVersion)
        {
            if (formatVersion > CacheFormatVersion.CURRENT)
            {
                throw new NotSupportedException();
            }
            CacheFormatVersion versionRequired;

            if (formatVersion.CompareTo(CacheHeaderStruct.WithStructSizes) >= 0)
            {
                versionRequired = CacheHeaderStruct.WithStructSizes;
            }
            else
            {
                versionRequired = formatVersion;
            }
            return(new CacheFormat
            {
                FormatVersion = formatVersion,
                VersionRequired = versionRequired,
                ChromPeakSize = ChromPeak.GetStructSize(formatVersion),
                ChromTransitionSize = ChromTransition.GetStructSize(formatVersion),
                CachedFileSize = CachedFileHeaderStruct.GetStructSize(formatVersion),
                ChromGroupHeaderSize = ChromGroupHeaderInfo.GetStructSize(formatVersion)
            });
        }
コード例 #2
0
 public void TestChromPeakOffsets()
 {
     Assert.AreEqual((IntPtr)0, Marshal.OffsetOf <ChromPeak>("_retentionTime"));
     Assert.AreEqual((IntPtr)4, Marshal.OffsetOf <ChromPeak>("_startTime"));
     Assert.AreEqual((IntPtr)8, Marshal.OffsetOf <ChromPeak>("_endTime"));
     Assert.AreEqual((IntPtr)12, Marshal.OffsetOf <ChromPeak>("_area"));
     Assert.AreEqual((IntPtr)16, Marshal.OffsetOf <ChromPeak>("_backgroundArea"));
     Assert.AreEqual((IntPtr)20, Marshal.OffsetOf <ChromPeak>("_height"));
     Assert.AreEqual((IntPtr)24, Marshal.OffsetOf <ChromPeak>("_fwhm"));
     Assert.AreEqual((IntPtr)28, Marshal.OffsetOf <ChromPeak>("_flagBits"));
     Assert.AreEqual((IntPtr)32, Marshal.OffsetOf <ChromPeak>("_pointsAcross"));
     Assert.AreEqual(32, ChromPeak.GetStructSize(CacheFormatVersion.Eleven));
     Assert.AreEqual(36, ChromPeak.GetStructSize(CacheFormatVersion.Twelve));
     Assert.AreEqual(Marshal.SizeOf <ChromPeak>(), ChromPeak.GetStructSize(CacheFormatVersion.CURRENT));
 }
コード例 #3
0
        public static long CacheSize(SrmDocument docInitial, long format3Size, int groupCount, int tranCount, int peakCount)
        {
            long cacheSize       = format3Size;
            int  fileCachedCount = docInitial.Settings.MeasuredResults.MSDataFileInfos.Count();

            if (ChromatogramCache.FORMAT_VERSION_CACHE > ChromatogramCache.FORMAT_VERSION_CACHE_3)
            {
                // Cache version 4 stores instrument information, and is bigger in size.
                cacheSize += sizeof(int) * fileCachedCount;
            }
            if (ChromatogramCache.FORMAT_VERSION_CACHE > ChromatogramCache.FORMAT_VERSION_CACHE_4)
            {
                // Cache version 5 adds an int for flags for each file
                // Allow for a difference in sizes due to the extra information.
                int fileFlagsSize = sizeof(int) * fileCachedCount;
                // And SeqIndex, SeqCount, StartScoreIndex and padding
                var deltaSize5 = ChromGroupHeaderInfo.GetStructSize(CacheFormatVersion.Five) -
                                 ChromGroupHeaderInfo.GetStructSize(CacheFormatVersion.Four);
                int groupHeadersSize = deltaSize5 * groupCount;
                // And flags for each transition
                int transitionFlagsSize = ChromTransition5.DeltaSize5 * tranCount;
                // And num seq byte count, seq location, score types, num scores and score location
                const int headerScoreSize = sizeof(int) + sizeof(long) + sizeof(int) + sizeof(int) + sizeof(long);
                cacheSize += groupHeadersSize + fileFlagsSize + transitionFlagsSize + headerScoreSize;
            }
            if (ChromatogramCache.FORMAT_VERSION_CACHE > ChromatogramCache.FORMAT_VERSION_CACHE_5)
            {
                // Cache version 6 adds status graph dimensions for every file
                cacheSize += sizeof(float) * 2 * fileCachedCount;
            }
            if (ChromatogramCache.FORMAT_VERSION_CACHE > ChromatogramCache.FORMAT_VERSION_CACHE_6)
            {
                // Cache version 7 adds ion mobility information
                cacheSize += sizeof(float) * 2 * tranCount;
            }
            if (ChromatogramCache.FORMAT_VERSION_CACHE > ChromatogramCache.FORMAT_VERSION_CACHE_8)
            {
                // Cache version 9 adds scan id values for every file
                cacheSize += (sizeof(int) + sizeof(long)) * fileCachedCount;
                // And scan ids location to global header
                cacheSize += sizeof(long);
            }
            if (ChromatogramCache.FORMAT_VERSION_CACHE >= ChromatogramCache.FORMAT_VERSION_CACHE_11)
            {
                // Version 11 adds uncompressed buffer size for convenience, and some time span metadata
                cacheSize += ChromGroupHeaderInfo.DeltaSize11 * groupCount;
            }
            if (ChromatogramCache.FORMAT_VERSION_CACHE >= CacheFormatVersion.Twelve)
            {
                cacheSize += peakCount * (ChromPeak.GetStructSize(CacheFormatVersion.Twelve) -
                                          ChromPeak.GetStructSize(CacheFormatVersion.Eleven));
                cacheSize += tranCount *
                             (ChromTransition.GetStructSize(CacheFormatVersion.Twelve) -
                              ChromTransition.GetStructSize(CacheFormatVersion.Eleven));
            }
            cacheSize += fileCachedCount *
                         (CachedFileHeaderStruct.GetStructSize(ChromatogramCache.FORMAT_VERSION_CACHE) -
                          CachedFileHeaderStruct.GetStructSize(CacheFormatVersion.Nine));
            cacheSize += CacheHeaderStruct.GetStructSize(ChromatogramCache.FORMAT_VERSION_CACHE) -
                         CacheHeaderStruct.GetStructSize(ChromatogramCache.FORMAT_VERSION_CACHE_11);
            return(cacheSize);
        }