Esempio n. 1
0
        private SourceInfo getSourceInfo(DirectoryInfo dirInfo)
        {
            string     type       = DataSourceUtil.GetSourceType(dirInfo);
            SourceInfo sourceInfo = new SourceInfo(new MsDataFilePath(dirInfo.FullName))
            {
                type         = type,
                imageIndex   = (DataSourceUtil.IsFolderType(type) ? ImageIndex.Folder : ImageIndex.MassSpecFile),
                name         = dirInfo.Name,
                dateModified = GetSafeDateModified(dirInfo)
            };

            if (listView.View != View.Details ||
                (sourceTypeComboBox.SelectedIndex > 0 &&
                 sourceTypeComboBox.SelectedItem.ToString() != sourceInfo.type))
            {
                return(sourceInfo);
            }

            if (sourceInfo.isFolder)
            {
                return(sourceInfo);
            }
            if (!sourceInfo.isUnknown)
            {
                sourceInfo.size = 0;
                foreach (FileInfo fileInfo in dirInfo.GetFiles())
                {
                    sourceInfo.size += (UInt64)fileInfo.Length;
                }
                return(sourceInfo);
            }
            return(null);
        }
Esempio n. 2
0
        private SourceInfo getSourceInfo(FileInfo fileInfo)
        {
            string     type       = DataSourceUtil.GetSourceType(fileInfo);
            SourceInfo sourceInfo = new SourceInfo(new MsDataFilePath(fileInfo.FullName))
            {
                type       = type,
                imageIndex = (DataSourceUtil.IsUnknownType(type) ? ImageIndex.UnknownFile : ImageIndex.MassSpecFile),
                name       = fileInfo.Name
            };

            if (!sourceInfo.isUnknown)
            {
                if (listView.View != View.Details ||
                    (sourceTypeComboBox.SelectedIndex > 0 &&
                     sourceTypeComboBox.SelectedItem.ToString() != sourceInfo.type))
                {
                    return(sourceInfo);
                }
                sourceInfo.size         = (UInt64)fileInfo.Length;
                sourceInfo.dateModified = GetSafeDateModified(fileInfo);
                return(sourceInfo);
            }
            return(null);
        }
Esempio n. 3
0
        private IsolationRange[] ReadIsolationRanges(MsDataFileUri dataSource, IsolationRange[] isolationRanges)
        {
            var    dictRangeCounts = isolationRanges.ToDictionary(r => r, r => 0);
            var    listRanges = new List <IsolationRange>(isolationRanges);
            double minStart = double.MaxValue, maxStart = double.MinValue;

            string path    = dataSource.GetFilePath();
            bool   isPasef = Equals(DataSourceUtil.GetSourceType(new DirectoryInfo(path)), DataSourceUtil.TYPE_BRUKER);

            using (var dataFile = new MsDataFileImpl(path, simAsSpectra: true))
            {
                int lookAheadCount = Math.Min(MAX_MULTI_CYCLE, dataFile.SpectrumCount);
                for (int i = 0; i < lookAheadCount; i++)
                {
                    if (dataFile.GetMsLevel(i) != 2)
                    {
                        continue;
                    }

                    var spectrum = dataFile.GetSpectrum(i);
                    isPasef = isPasef && spectrum.IonMobilities != null;
                    foreach (var precursor in spectrum.Precursors)
                    {
                        if (!precursor.IsolationWindowLower.HasValue || !precursor.IsolationWindowUpper.HasValue)
                        {
                            throw new IOException(string.Format(Resources.EditIsolationSchemeDlg_ReadIsolationRanges_Missing_isolation_range_for_the_isolation_target__0__m_z_in_the_file__1_, precursor.IsolationWindowTargetMz, dataSource));
                        }
                        double start = precursor.IsolationWindowTargetMz.Value - precursor.IsolationWindowLower.Value;
                        double end   = precursor.IsolationWindowTargetMz.Value + precursor.IsolationWindowUpper.Value;
                        var    range = new IsolationRange(start, end);
                        int    count;
                        if (!dictRangeCounts.TryGetValue(range, out count))
                        {
                            count = 0;
                            dictRangeCounts.Add(range, count);
                            listRanges.Add(range);
                        }
                        if (count == 2)
                        {
                            // Repeating for the third time
                            i = lookAheadCount;
                            break;
                        }
                        dictRangeCounts[range] = count + 1;
                        minStart = Math.Min(minStart, range.Start);
                        maxStart = Math.Max(maxStart, range.Start);
                    }
                }
            }
            if (dictRangeCounts.Values.Any(c => c == 1))
            {
                if (dictRangeCounts.Count > 2)
                {
                    // Sometime demux of overlapping schemes leaves wings that repeat only every other cycle
                    RemoveRangeSingleton(minStart, dictRangeCounts, listRanges);
                    RemoveRangeSingleton(maxStart, dictRangeCounts, listRanges);
                }

                if (dictRangeCounts.Values.Any(c => c == 1))
                {
                    throw new IOException(string.Format(Resources.EditIsolationSchemeDlg_ReadIsolationRanges_No_repeating_isolation_scheme_found_in__0_, dataSource));
                }
            }
            // diaPASEF comes in out of order and will be misinterpreted unless ordered
            // Multiplexing, however, requires that the acquired order by maintained
            if (isPasef)
            {
                listRanges.Sort((r1, r2) => r1.Start.CompareTo(r2.Start));
            }
            return(listRanges.ToArray());
        }